4

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

Sinval
  • 1,315
  • 1
  • 16
  • 25

1 Answers1

2

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.
Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Can you please add an implementation of that to my example? Thank you! – Sinval Dec 04 '20 at 20:59
  • I'm not sure what exactly you mean here. You can set `exshuffle: 5` instead of `4` in the exercise. Then you get 5 random choice alternatives. – Achim Zeileis Dec 04 '20 at 21:03
  • I change the `exshuffle` from `4` to `5` and I changed the number of solutions from 6 to 5, however... I receive this message: `length of exsolution and questionlist does not match in '1_1'5 shuffled answers requested, only 4 available in '1_1'` – Sinval Dec 04 '20 at 21:28
  • 1
    I cannot say for sure for your example because it isn't self-contained. But I just noticed that `exsolution` is misspecified, it should be: `exsolution: 'r mchoice2string(solutions)'`. Or in this case you could also hard-code: `exsolution: 100000`. But once `exsolution` is corrected, setting `exshuffle: 5` should do the trick. – Achim Zeileis Dec 04 '20 at 22:58
  • Yes, I changed the exsolution to `exsolution: 'r mchoice2string(solutions)'`. I have five options appearing... however, only one solution appears. The others are `NA`s (https://i.imgur.com/Ugo3q91.png). – Sinval Dec 05 '20 at 13:30
  • Additionally, this warning appears: `length of exsolution and questionlist does not match in '1_1'` – Sinval Dec 05 '20 at 13:32
  • Please create a new question because this is really not related to `exams2nops` at all. Also make sure that it is self contained. And please accept this answer, I think it is fully answered. – Achim Zeileis Dec 05 '20 at 14:22