Search code examples
r-exams

exams2canvas inline schoice has "a.1", "a.2",... prefixes. Is this a bug?


Okay, I did my best to make a minimal example. Let's say this is "q2.Rmd":

```{r data generation, echo = FALSE, results = "hide"}
mu = runif(1,200,800)
sig = runif(1,10,70)
n = sample(8:12,1)
x = round(rnorm(n,mu,sig),1)
correct_val_1 = round(mean(x),1)
correct_val_2 = round(sd(x),1)
num_under_1 = sample(0:3,1)
num_under_2 = sample(0:3,1)
mults_1 = c(0,sample(-1:-5,num_under_1),sample(1:5,3-num_under_1))
mults_2 = c(0,sample(-1:-5,num_under_2),sample(1:5,3-num_under_2))
choices_1 = sort(correct_val_1+0.2*mults_1)
choices_2 = sort(correct_val_2+0.2*mults_2)
ans1 = paste0((choices_1==correct_val_1)*1,collapse="")
ans2 = paste0((choices_2==correct_val_2)*1,collapse="")
```


Question
========

<style type="text/css" rel="stylesheet">
.bordered-table {
    border-collapse: collapse;
    border-spacing: 0;
    border:2px solid #000000;
}
.bordered-table th {
    border:2px solid #000000;
    padding: 4px;
}
.bordered-table td{
    border:2px solid #000000;
    padding: 4px;
}
</style>

A biologist investigated a population of turtles. They weighed turtles from a simple-random sample; those weights are shown below in grams.

```{r tab_data, echo=FALSE, results="asis"}
opts <- options(knitr.kable.NA = "")
mydf = data.frame(x)
colnames(mydf) = c("Turtle weights (g)")
knitr::kable(mydf,format="html", align = "c",row.names=F,table.attr='class="bordered-table"')
```
\

Find the sample mean, $\bar{x}$, and the sample standard deviation, $s$ (using Bessel's correction).

$\bar{x} =$ ##ANSWER1##

$s =$ ##ANSWER2##

Answerlist
--------
* `r choices_1[1]`
* `r choices_1[2]`
* `r choices_1[3]`
* `r choices_1[4]`
* `r choices_2[1]`
* `r choices_2[2]`
* `r choices_2[3]`
* `r choices_2[4]`

Solution
========

The correct answers were $\bar{x} = `r correct_val_1`$ and $s = `r correct_val_2`$

`r sd(x)`

Meta-information
================
extype: cloze
exclozetype: schoice|schoice
exsolution: `r ans1`|`r ans2`
exname: find sample mean and sample standard deviation
exshuffle: FALSE

If I run exams2canvas("q2.Rmd"), it produces a ZIP file, which I upload by clicking Import Existing Content with the default settings (old style quiz). When I preview the quiz I get the following dropdowns on the schoices.

enter image description here

If I then edit the settings, to turn off answer shuffling, I can at least get the choices in order (a.1., a.2., a.3., a.4.) and students are able to ignore them. But is there a good reason for these to be here? Notice, having them makes answer-choice shuffling pointless.

I have not tried to alter the source code yet. I don't think exams2canvas has a setting I'm messing up.


Solution

  • TL;DR This behavior can be controlled with the enumerate argument for the different exercise types. In order to suppress enumeration for cloze exercises you can do

    exams2canvas(..., cloze = list(enumerate = FALSE))
    

    Starting from version 2.4-1 (the current development version on R-Forge at the time of writing), this will be the default.

    Background: Up to version 2.4-0 (the current CRAN version at the time of writing), the default was for exams to add items within exercises (especially single-choice and multiple-choice items) into enumerated lists, i.e., with a., b., c., etc. For schoice/mchoice within cloze letters and numbers were also combined, i.e., a.1, a.2, a.3, etc. The original idea for this was to make it easier to match the full solution feedback (if any) to the items from the question. However, given that this adds clutter to the question, which is particularly confusing when the learning management system adds its own shuffling, I have decided to change the default behavior. If you install R/exams 2.4-1 (from R-Forge) then you don't need to change the argument yourself.