3

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.

Ghassany
  • 45
  • 5
  • Can you post a minimal reproducible example, please? Your current code is not reproducible because it isn't clear what is in th `exercises/` folder. Maybe you could use some of the demo exercises from the package, just like on `?exams2nops`? Then I will have s closer look. – Achim Zeileis Oct 24 '22 at 00:29

1 Answers1

1

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.
Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Hi Achim, I already tried this but I have the error : the following groups of exercise do not have the same length: aboutLogReg.Rmd/aboutLogReg2.Rmd/aboutLogReg3.Rmd/ .... etc – Ghassany Oct 12 '22 at 10:59
  • Can you post a minimal reproducible example, please? Maybe using some of the demo exercises from the package. Then I will have s closer look. – Achim Zeileis Oct 15 '22 at 00:27
  • @Ghassany, given that my answer now received an upvote I was wondering whether maybe it already solves the problem described in the question. If not, it would be great if you could add further details so that it can be fully resolved. – Achim Zeileis Nov 22 '22 at 08:49
  • Excuse me Achim for my very late reply. I never was able to find a solution for this problem. – Ghassany Apr 21 '23 at 15:38
  • You need to provide a minimal reproducible example, otherwise I can only guess what is going on. My suspicion is that your `myexam` is somehow incorrectly specified but I don't know how. The following works for me: `myexam <- list(c("capitals.Rmd", "switzerland.Rmd", "deriv2.Rmd"))` and then `exams2nops(myexam, nsamp = 3)`. This results in a PDF with the three questions in random order. – Achim Zeileis Jun 03 '23 at 00:33