I do not have complete mastery over R, but I am trying to use the R/Exams package to create different exam versions and I am having trouble creating a cloze style question with multiple single choice questions within it. I am doing this because I have a figure that is needed to be analyzed before answering the 3 subsequent questions.
I thought the syntax might be something like this:
Question
==========
Use the following gel image to answer the following questions:
![]("Image.png")
Question 1
Question 2
Question 3
AnswerList
-----------
* Answer A
* Answer B
* Answer C
* Answer D
* Answer E
* Answer F
* Answer A
* Answer B
* Answer C
* Answer D
* Answer E
* Answer A
* Answer B
* Answer C
* Answer D
* Answer E
Meta-information
===============
extype: cloze
exclozetype: schoice|schoice|schoice
exsolution: 000010|00010|00010
exshuffle: TRUE
I haven't found anything online and I'm getting stuck. If anyone can help I would extremely appreciate it and thanks in advance!
Minimal example:
You are almost done, good job! You just need to tell the system where the dropdown interactions should be placed within the exercises. You can do so with ##ANSWER1##
etc. rather than Question 1
. Thus, when you replace the three lines
Question 1
Question 2
Question 3
with
##ANSWER1##
##ANSWER2##
##ANSWER3##
then the exercise works!
More elaborate example:
A similar but somewhat more elaborate example that uses some more R code for randomization is shipped within the package and you can try it via exams2canvas("vowels.Rmd")
. The source code of the file is:
```{r, include=FALSE}
## Vowels and their quality
vowels <- voweltab <- rbind(
c("i", "close", "front", "unrounded"),
c("e", "close-mid", "front", "unrounded"),
c("ɛ", "open-mid", "front", "unrounded"),
c("a", "open", "front", "unrounded"),
c("ɑ", "open", "back", "unrounded"),
c("ɔ", "open-mid", "back", "rounded"),
c("o", "close-mid", "back", "rounded"),
c("u", "close", "back", "rounded"),
c("y", "close", "front", "rounded"),
c("ø", "close-mid", "front", "rounded"),
c("œ", "open-mid", "front", "rounded"),
c("ɶ", "open", "front", "rounded"),
c("ɒ", "open", "back", "rounded"),
c("ʌ", "open-mid", "back", "unrounded"),
c("ɤ", "close-mid", "back", "unrounded"),
c("ɯ", "close", "back", "unrounded"),
c("ɨ", "close", "central", "unrounded"),
c("ʉ", "close", "central", "rounded")
)
vowels <- cbind(vowels, "", "", "")
## Vowel quality parameters
height <- c("close", "near-close", "close-mid", "mid", "open-mid", "near-open", "open")
front_back <- c("front", "front centralized", "central", "back centralized", "back")
lips <- c("unrounded", "rounded")
## Binary coding of features
match_mchoice <- function(true, options) {
x <- match(true, options)
sapply(x, function(i) paste(append(rep(0, length(options) - 1), 1, after = i - 1), collapse = ""))
}
vowels[, 5] <- match_mchoice(vowels[,2], height)
vowels[, 6] <- match_mchoice(vowels[,3], front_back)
vowels[, 7] <- match_mchoice(vowels[,4], lips)
## Casually selecting two vowels
vowels <- vowels[sample(1:nrow(vowels), 2), ]
## Possible answers and correct solution
ans <- rep(c(height, front_back, lips), 2)
sol <- paste(t(vowels[, 5:7]), collapse = "|")
```
Question
========
Describe the following Cardinal vowels according to the three parameters
vowel height, frontness-backness, and lip rounding:
1. [`r vowels[1,1]`] is the ##ANSWER1## ##ANSWER2## ##ANSWER3## vowel.
2. [`r vowels[2,1]`] is the ##ANSWER4## ##ANSWER5## ##ANSWER6## vowel.
```{r, echo=FALSE, results="asis"}
answerlist(ans, markup = "markdown")
```
Solution
========
For an overview of the 18 Cardinal vowels see <https://en.wikipedia.org/wiki/Cardinal_vowels>.
1. [`r vowels[1,1]`] is the `r vowels[1,2]` `r vowels[1,3]` `r vowels[1,4]` vowel.
2. [`r vowels[2,1]`] is the `r vowels[2,2]` `r vowels[2,3]` `r vowels[2,4]` vowel.
Meta-information
================
exname: Cardinal vowels
extype: cloze
exclozetype: schoice|schoice|schoice|schoice|schoice|schoice
exsolution: `r sol`