Reputation: 734
I used the template fourfold.Rmd
to create an exercise of type cloze using a table to be filled by the student. This is my exercise:
```{r data generation, echo = FALSE, results = "hide"}
rm(list=ls())
p_load("tidyverse")
categs<-LETTERS[1:3]
ncat<-length(categs)
varname<-"Tr"
categ_ref<-sample(1:ncat,1)
if(categ_ref==1){
sol<-c(0,1,0,
0,0,1)
}else if(categ_ref==2){
sol<-c(1,0,0,
0,0,1)
}else if(categ_ref==3){
sol<-c(1,0,0,
0,1,0)
}
questions<-rep("",length(sol))
type<-rep("num",length(sol))
```
Question
========
Considere la variable tratamiento ($`r varname `$) con posibles valores $`r paste0(categs,collapse = ",")`$. Sean $I_{`r categs[1]`},I_{`r categs[2]`}$ e $I_{`r categs[3]`}$ variables indicadoras de los respectivos tratamientos. Llene la tabla para establecer un sistema de codificación para la variable tratamiento, en donde la categoría de referencia es el tratamiento $`r categs[categ_ref]`$
| $`r varname `$| $I_{`r categs[-categ_ref][1]`}$|$I_{`r categs[-categ_ref][2]`}$ |
|:-------------:|:-----------------:|:-----------------:|
|$A$ | \#\#ANSWER1\#\# |\#\#ANSWER4\#\# |
|$B$ | \#\#ANSWER2\#\# | \#\#ANSWER5\#\# |
|$C$ | \#\#ANSWER3\#\# | \#\#ANSWER6\#\# |
```{r questionlist, echo = FALSE, results = "asis"}
answerlist(questions, markup = "markdown")
```
Solution
========
| $`r varname `$| $I_{`r categs[-categ_ref][1]`}$|$I_{`r categs[-categ_ref][2]`}$|
|:-------------:|:-----------------:|:-----------------:|
|$A$ | `r sol[1]` |`r sol[4]` |
|$B$ | `r sol[2]` | `r sol[5]` |
|$C$ | `r sol[3]` | `r sol[6]` |
Meta-information
================
extype: cloze
exsolution: `r paste(sol, collapse = "|")`
exclozetype: `r paste(type, collapse = "|")`
exname: catreg
extol: 0.05
exextra[numwidth,logical]: TRUE
rendering using exams2html
or exams2moodle
produces the following warning:
Warning in split.default(exm[[j]]$questionlist, g) : data length is not a multiple of split variable
I just can’t understand why is this appearing. I have similar version of this exercise and they don’t produce any warning.
Upvotes: 1
Views: 111
Reputation: 17203
You need to include a blank line after the answer list code chunk and before the start of the solution section. Otherwise the length of the answer list is not detected correctly.
Upvotes: 1