如何在 num_to_schoice 中插入文本?
How to insert text in num_to_schoice?
我正在构建 r-exams 包中的 deriv2.Rnw 问题,其中包括 num_to_schoice 随机选择问题的答案选项:
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)
我的意图是在四个或五个答案选项中输入文本,以便获得类似于附图中的结果。
您只需将它们插入设置选项的answerlist()
即可:
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 = ", "
)
(注意在Rmd练习中你还需要加上markup = "markdown"
。)
然而,这在实践中的主要问题是 sc$questions
包含随机答案,所有答案都是随机洗牌的。因此,您必须将 sc$questions
与您作为 wrong
参数提供的典型错误相匹配。此外,您可能不会对随机答案选项有任何解释。因此,最好在没有 num_to_schoice()
的情况下执行此操作并“手动”编写答案列表。对于自动洗牌,您可以在练习中将 exshuffle
设置为 TRUE
。
我正在构建 r-exams 包中的 deriv2.Rnw 问题,其中包括 num_to_schoice 随机选择问题的答案选项:
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)
我的意图是在四个或五个答案选项中输入文本,以便获得类似于附图中的结果。
您只需将它们插入设置选项的answerlist()
即可:
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 = ", "
)
(注意在Rmd练习中你还需要加上markup = "markdown"
。)
然而,这在实践中的主要问题是 sc$questions
包含随机答案,所有答案都是随机洗牌的。因此,您必须将 sc$questions
与您作为 wrong
参数提供的典型错误相匹配。此外,您可能不会对随机答案选项有任何解释。因此,最好在没有 num_to_schoice()
的情况下执行此操作并“手动”编写答案列表。对于自动洗牌,您可以在练习中将 exshuffle
设置为 TRUE
。