When generating exams using the function exams2nops
we randomly generate data for each of the produced exams (let's say 5 different versions). We would like to use the exact same version of each exam to produce the solutions version (using exams2pdf
). Is it possible to create the solution version right on the go when generating exams with the exams2nops
? By exact same version I mean, the same order of the multiple-choice answers and the same wrong values (using the marvelous num_to_schoice
function). We save the .rds
objects used on each exercise, allowing us to obtain import them when generating solutions, however, the wrong options and order are different since it is random. Should we also save a specific seed in the .rds
object? Inside each exercise, we have several random generated values.
When you set the same random seed prior to calling exams2pdf()
and exams2nops()
you should get the same random versions of the exercises.
Illustration: n = 2
version of an exm
with 3 exercises.
library("exams")
exm <- c("capitals.Rmd", "deriv2.Rmd", "tstat2.Rmd")
set.seed(1)
exm1 <- exams2pdf(exm, n = 2)
set.seed(1)
exm2 <- exams2nops(exm, n = 2)
Compare the question list of all three exercises in the second random version of the exams:
all.equal(exm1[[2]][[1]]$questionlist, exm2[[2]][[1]]$questionlist)
## [1] TRUE
all.equal(exm1[[2]][[2]]$questionlist, exm2[[2]][[2]]$questionlist)
## [1] TRUE
all.equal(exm1[[2]][[3]]$questionlist, exm2[[2]][[3]]$questionlist)
## [1] TRUE
Both have to be called separately, though, there is no option to produce both in one go, currently.