0

I'm building on the deriv2.Rnw question from the r-exams package, which includes num_to_schoice to randomize the answer options of a schoice question:

sc <- NULL
while(is.null(sc)) {
## parameters
a <- sample(2:9, 1)
b <- sample(seq(2, 4, 0.1), 1)
c <- sample(seq(0.6, 0.9, 0.01), 1)
## solution
res <- exp(b * c) * (a * c^(a-1) + b * c^a)
## schoice
err <- c(a * c^(a-1) * exp(b * c), a * c^(a-1) * exp(b * c) + c^a * exp(b * c))
rg <- if(res < 4) c(0.5, 5.5) else res * c(0.5, 1.5)
sc <- num_to_schoice(res, wrong = err, range = rg, delta = 0.1)

My intention is to enter text in the four or five answer options, in such a way that a result similar to the one in the attached image is obtained.

enter image description here

  • (1) It is not fully clear to my why you want to do that with the output from num_to_schoice. The whole point of num_to_schoice is that it generates _random_ numbers and only uses at most two of the provided wrong answers. See: https://stackoverflow.com/questions/66590681/r-exams-numerical-to-single-choice-conversion (2) Please clarify your question either omitting the num_to_schoice aspect or work it out more clearly. (3) Please also follow up on your other questions where you haven't accepted any of the given answers. – Achim Zeileis Apr 21 '21 at 13:58
  • Greetings, Achim. My intention is to take advantage of the randomness of the "range" and the "delta" of the incorrect answers with num_to_schoice, so as not to have to do it manually and, in addition, add COMPLEMENTARY TEXT to each answer option. If there is an option similar to "delta" and "range" without using the num_to_schoice, that would be great. Thank you. I am going to review numeral (3). – Álvaro Ángel Molina Apr 21 '21 at 14:52
  • I don't know if I'm making mistakes while reviewing, but I don't see any pending answers. I have little experience in stackoverflow ... – Álvaro Ángel Molina Apr 21 '21 at 14:58
  • This question has answers that have not yet been accepted: https://stackoverflow.com/questions/67141618/how-to-execute-a-statement-only-if-a-condition-is-met-in-r-exams – Achim Zeileis Apr 21 '21 at 15:49
  • As for the num_to_schoice aspect: The "range" and "delta" only applies to the random wrong answers - not to the ones you define. And if I interpret your setup correctly you want to predefine all of the wrong answers, don't you? – Achim Zeileis Apr 21 '21 at 15:51
  • It is right. Predefined incorrect answers (With text included), but that do not obey a pattern that the student can easily deduce. – Álvaro Ángel Molina Apr 21 '21 at 18:03

1 Answers1

0

You can just insert them into the answerlist() that sets up the choice options:

answerlist(sc$questions,
  c("because Lorem ipsum dolor sit amet.",
    "because fusce et interdum neque.",
    "because suspendisse a bibendum turpis.",
    "because donec sed imperdiet justo.",
    "because duis efficitur mattis."),
  sep = ", "
)

(Note that in Rmd exercises you additionally need to add markup = "markdown".)

However, the main problem with this in practice will be that sc$questions contains random answers and all answers are shuffled randomly. So you would have to match sc$questions to the typical errors you supplied as the wrong argument. Also you probably won't have explanations for the random answer options. So possibly it would be better to do this without num_to_schoice() and write the answer list "by hand". For automatic shuffling you can then set exshuffle to TRUE in the exercise.

Achim Zeileis
  • 15,710
  • 1
  • 39
  • 49
  • Thank you for taking the time to analyze and respond. I have decided on the second option: write the answer options "by hand". I keep learning and moving forward. Again, thank you very much. – Álvaro Ángel Molina Apr 22 '21 at 02:43