Ghassany
Ghassany

Reputation: 65

modify order of questions in nops

Let us say we have 20 questions with different number of answers and we want that the questions are not is the same order in the generated nops, how can we do it? I tried :

myexam <- dput(dir("exercises/"))
exams2nops(file = myexam, 
           n = 180,
           nsamp = length(myexam),
           dir = "nops",
           edir = getwd(),
           encoding = "UTF-8", 
           blank = 1, 
           reglength = 8,
           samepage = TRUE)

But it gives the error about only 45 exercices in an exam are supported.

Ps, if the exercices are in a list and I use nsamp I have the error about group of exercices not having the same length.

Thanks for your help.

Upvotes: 3

Views: 146

Answers (1)

Achim Zeileis
Achim Zeileis

Reputation: 17183

Your setup is almost correct but file and nsamp have to be specified slightly differently. For an exam with 20 shuffled exercises:

  • file = list(c("ex1.Rmd", ..., "ex20.Rmd")) should be a list with a single vector of length 20.
  • nsamp = 20.

So in your case probably:

myexam <- list(dir("exercises/"))
exams2nops(myexam, nsamp = length(unlist(myexam)), ...)

The reason behind this is the following:

  • When myexam is a list, then the exams2xyz() interfaces first draw nsamp elements from each element of the list.
  • Thus, if myexam is a list with only a single vector, then nsamp elements from that vector are sampled.
  • If nsamp is equal to the length of that one vector, then the vector is permuted/shuffled.

Upvotes: 1

Related Questions