I need a cloze
question with a general statement and some results (random data and tables of statistical analysis) that includes several schoice
questions each of them with its own statement. But I don't know how I should include that subquestions statements. A simple example cloze0.Rmd is shown below. I need export 30 different versios of this cloze
question to moodle
using the command exams2moodle("cloze0.Rmd", n = 30, name = "Simple_Cloze0", rule = 'none', schoice = list(shuffle = T), verbose = T)
but this command includes the fist subquestion statement as a response option and misplace the correct answer in all subquestions. Any ideas much appreciated!
cloze0.Rmd ==> (moodle-result) ==> (needed-moodle-result)
```{r data generation, echo = FALSE, results = "hide"}
# sample
dt <- rnorm(30, 100, 5)
# Statistics
ndt <- length(dt)
mdt <- mean(dt)
sdt <- sd(dt)
vdt <- var(dt)
cvdt <- sdt/abs(mdt)
```
Question
========
A sample of **`r ndt`** individuals is draw and a variable $X$ is measured.
```{r, echo = F, comment = NA}
dt
```
Answerlist
----------
Choose the mean of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Choose the standard deviation of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Choose the variance of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Choose the coefficient of variation of $X$.
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
Meta-information
================
exname: simple_cloze
extype: cloze
exsolution: 1000|0100|0010|0001
exclozetype: schoice|schoice|schoice|schoice
extol: 0|0|0|0
exshuffle: TRUE
If you want this kind of control over the formatting of a cloze exercise then it is better to use ##ANSWERi##
syntax or placing the answer interaction fields where you need them. See the boxhist2 exercise for a worked example.
In your case I would put the following questions before the Answerlist
:
a. Choose the mean of $X$: ##ANSWER1##
b. Choose the standard deviation of $X$: ##ANSWER2##
c. Choose the variance of $X$: ##ANSWER3##
d. Choose the coefficient of variation of $X$: ##ANSWER4##
And then the Answerlist
would just look like this:
Answerlist
----------
* `r mdt`.
* `r sdt`.
* `r vdt`.
* `r cvdt`.
* `r mdt`.
* `r sdt`.
...
Note that rather than manually listing all four statistics four times you could also do the following to create the entire Answerlist
:
```{r, echo=FALSE, results="asis"}
answerlist(rep(c(mdt, sdt, vdt, cvdt), 4), markup = "markdown")
```
I would also add some rounding to, say, three digits for the answers. (Well, personally, I would create a cloze with four "num" items rather than "schoice" items.)
By default
exams2moodle("cloze0.Rmw")
will create dropdown menus for each of the four choice list (display "MULTICHOICE"
in Moodle). If you really want radio buttons in a vertical layout instead (display "MULTICHOICE_V"
) you can switch to:
exams2moodle("cloze0.Rmd",
cloze = list(cloze_schoice_display = "MULTICHOICE_V"))
Note that in versions up to 2.3-6 of the package, the argument was called cloze_mchoice_display
rather than cloze_schoice_display
.