I am trying to use exams package to create my Moodle exams. I want to create a cloze question whit 3 numeric and one string sub-types but I am having problems with the exams2moodle(). Here is a simplification of my code:
```{r data generation, echo = FALSE, results = "hide"}
## DATA GENERATION
options(scipen = 999)
#here in my version, I generated the data and solutions, but I simplified the code for a better understanding
cambio_delta <- 20.1
r2 <- 0.97
y0_1 <- 19.56
sol_str<- "Not possible"
```
Question
========
Here goes the question speech
Answerlist
----------
* Question 1 (this is numeric)
* Question 2 (this is numeric)
* Question 3 (this is numeric)
* Question 4 (this is STRING, the answer suppose to be "Not possible")
Meta-information
================
extype: cloze
exclozetype: num|num|num|string
exsolution: `r 100*r2`|`r cambio_delta`|`r y0_1`|`r sol_str`
extol: 0.05|0.05|0.05
exname: regresion
When I knit this in the Rmarkdown, it works well, but not with exams2moodle():
exams2moodle("regresion.Rmd", n = 8, name = "Exam reg")
I get the warning message:
Error in split.default(solutionlist, gr) :
first argument must be a vector
I will appreciate any suggestion! Thank you!
I put the R/Markdown exercise into a file regresion.Rmd
and then ran your code with both exams
2.3-6 (the current CRAN release version at the time of writing) and 2.4-0 (the current R-Forge devel version). Everything worked fine without error and the exercises worked as intended after import into Moodle.
I suggest that you update your version of the exams
package and if necessary of R itself. Then you should be fine.