I am new to R so thank you in advance for your patience.
I would like to create a multiple choice quiz in R using the learnr package (the quiz content is not about r code). I have all of the questions, response options, and correct answers in a spreadsheet. Since my item bank has over 100 items, I will give a simpler example
Stem<-c("stem1", "stem2", "stem3")
OptionA <- c("a1", "a2", "a3")
OptionB<- c("b1", "b2", "b3")
OptionC<- c("c1", "c2", "c3")
Correct<- c("c1", "b2", "a3")
items<-cbind(Stem, OptionA, OptionB, OptionC, Correct)
Currently, the only way I know how to pull in the data from the spreadsheet is like this:
learnr::question(items$Stem[1],
answer(items$OptionA[1]),
answer(items$OptionB[1]),
answer(items$OptonC[1], correct = TRUE),
answer(items$OptionD[1])
)
however this still requires me to write that chunk of code for each item and manually assign the correct answers. Does anyone know an easier way of doing this, either with learnr or another package?