如何将特定答案的反馈添加到 dist3.Rmd?

How to add answer specific feedback to dist3.Rmd?

我正在查看来自此处的 dist3.Rmd 示例模板:http://www.R-exams.org/templates/dist3/。解决方案markdown是提交后提供的一般反馈。我想创建反馈。

Solution
========
The distance $d$ of $p$ and $q$ is given by
$d^2 = (p_1 - q_1)^2 + (p_2 - q_2)^2$ (Pythagorean formula).

Hence $d = \sqrt{(p_1 - q_1)^2 + (p_2 - q_2)^2} =
  \sqrt{(`r p[1]` - `r q[1]`)^2 + (`r p[2]` - `r q[2]`)^2}
   = `r round(sol, digits = 3)`$.
\
```{r distplot, echo = FALSE, results = "hide", fig.path = "", fig.cap = ""}
par(mar = c(4, 4, 1, 1))
plot(0, type = "n", xlim = c(0, 6), ylim = c(0, 6), xlab = "x", ylab = "y")
grid(col = "slategray")
points(rbind(p, q), pch = 19)
text(rbind(p, q), c("p", "q"), pos = c(2, 4))
lines(rbind(p, q))
lines(c(p[1], p[1], q[1]), c(p[2], q[2], q[2]), lty = 2)
```

如果答案选择正确,我希望弹出一般反馈,如果答案错误,我希望显示毕达哥拉斯公式和图像提示,但不显示计算。我怎样才能做到这一点?

根据您关于“一般反馈”的行话,我认为这与 Moodle 和 R/exams 中的 exams2moodle() 界面有关。

我试图找出您描述的功能是否可以使用 Moodle XML format 指定,但没有成功。所以目前这在 R/exams 中肯定是不可能的,我不确定在 Moodle XML 中是否可能。如果有人知道 Moodle XML 中的解决方案,我会感兴趣并可以检查是否可以将其添加到 exams2moodle()

更新: 在与@ArvindMurali 的评论中进行讨论后,我在此简要讨论如何将图像包含在来自“解决方案列表”的特定反馈中。但是,我仍然看不出如何在回答问题的不同迭代之间区分特定反馈和一般反馈。

如果您将 dist3.Rmd 复制为 dist4.Rmd,您只需修改两行。在第 35 行 r distplot 代码块的选项中,添加 fig.show = "hide"。在第 46 行的 r solutionlist 块中,将 answerlist(...) 命令替换为:

answerlist(ifelse(sc$solutions,
  "This is correct!",
  "This is not correct, please consider: <br/> ![](distplot-1.png)"),
  markup = "markdown")

为了为 Moodle 准备这个,您需要使用 pluginfile = FALSE 以便图像真正直接嵌入到特定的反馈中(而不是通过 Moodle 的插件文件声明)。

set.seed(1)
exams2moodle("dist4.Rmd", pluginfile = FALSE)

然后,每个错误项目的具体反馈将显示 r distplot 块中的情节。

格式不是很好,但可以用 - 到目前为止还不错。

问题是除了这个特定的反馈之外,一般的反馈也会显示在最后 - 总是,据我所知。如果有办法在 Moodle 中延迟它,那么我可以检查是否可以在 R/exams.

中连接它