Search code examples
rr-exams

Is it possible to add more than four answer options to exams2nops exams?


Is it possible to have more than 4 answer options on exams2nops exams? I tried to set the option nchoice = 6 but it did not produce any effect. I have 6 answer options in the correspondent *.rmd exercise.

One example:

exams2nops(questions, n = 1, nsamp = 1, encoding = "UTF-8",  blank = 0,  nchoice = 6, duplex = T, reglength = 5L, points = 4, replacement = T,schoice = list(eval = ee))

And the exercise *.rmd:

```{r}
df <- readRDS(file = "some.rds")

variable <- names(df[,4:7]) %>% sample(1)

measCT<- ifelse(variable==names(df)[4],"Mean",
        ifelse(variable==names(df)[5],"Mean",
           ifelse(variable==names(df)[6],"Median",
              ifelse(variable==names(df)[7],"Median",NaN))))


measuresTC <- c("Mode", "Percentile 25", "Percentile 75", "Median", "Mean", "Geometric mean")

options_answers <- paste0(c(measCT,measuresTC[!measuresTC %in% measCT]))
solutions <- c(T,F,F,F,F,F)
```


Question
========

`r paste0("Some question about the ", variable)`


```{r questionlist, echo = FALSE, results = "asis"}
exams::answerlist(unlist(options_answers), markup = "markdown")
```


Meta-information
================
exname: 1_1
extype: schoice
exsolution: `r paste(solutions, collapse = "|")`
exshuffle: 4

The produced pdf always presents four options...

enter image description here


Solution

  • Answer

    Currently, exams2nops() only supports up to five choice alternatives.

    Further comments

    Optionally supporting more choice alternatives is on the wishlist for NOPS exercises but it's not very likely to be implemented in the near(er) future. (Changes in NOPS exercises require quite a bit of work because generation, scanning, and evaluation all have to be in sync and thoroughly tested etc.)

    In your example, there are always exactly four choice alternatives because you set exshuffle to 4. Thus, always four alternatives are randomly selected. If you want five alternatives, you can set it to exshuffle: 5. And if you specify a number > 5 then you get a warning from exams2nops():

    Error in exams2nops(questions) :
    the following exercises have length < 2 or > 5: ...

    Setting the nchoice argument has no effect because it is not an argument that you can set in exams2nops() but an argument for make_nops_template(). When you call exams2nops() internally the following steps happen:

    1. Determine how many choice alternatives there are per exercise.
    2. Set up a LaTeX template with the correct number of choices via make_nops_template().
    3. Call exams2nops(..., template = ...) with the template created in the previous step.