Reputation: 25323
I would like to use the R/exams package to create multiple-choice questions for a Moodle quiz. However, I am not sure whether R/exams can always choose a fixed number of correct items. Suppose we have a question with the following items:
Answerlist
----------
* A (correct)
* B (correct)
* C (correct)
* D (incorrect)
* E (incorrect)
* F (incorrect)
* G (incorrect)
* H (incorrect)
* I (incorrect)
In this example, I would like R/exams to choose exactly 2 correct answers and exactly 6 incorrect answers. Is that possible?
Upvotes: 0
Views: 131
Reputation: 17183
Yes, it is possible but you need to write a little bit of R code for it. If you only set exshuffle
to 8
, then R/exams would sample 8 items and use only the restriction that there is at least one true and at least one false item.
If one wants further restrictions in the sampling, then generally these can be implemented by writing the corresponding R code for it. In this particular case I would do the following:
answerlist()
.exshuffle
to TRUE
so that the 8 selected items are permuted one more time by R.The corresponding Rmd exercise then looks like this:
```{r, include = FALSE}
correct <- c(
"A (correct)",
"B (correct)",
"C (correct)"
)
correct <- sample(correct, 2)
incorrect <- c(
"D (incorrect)",
"E (incorrect)",
"F (incorrect)",
"G (incorrect)",
"H (incorrect)",
"I (incorrect)"
)
incorrect <- sample(incorrect, 6)
```
Question
========
Please select the correct items.
```{r, echo = FALSE, results = "asis"}
answerlist(c(correct, incorrect), markup = "markdown")
```
Meta-information
================
exname: Custom item sampling
extype: mchoice
exsolution: 11000000
exshuffle: TRUE
When set up like this, it is also easily possibly to extend the list of initial correct
and incorrect
items arbitrarily. The rest of the code will always assure that you get 2 out of the correct
and 6 out of the incorrect
items.
Nothing in this is specific to exams2moodle()
, i.e., you can use this exercise with any exams2xyz()
interface (except exams2nops()
which just supports item lists with up to 5 items).
Upvotes: 1