为选择题或选择题生成 html 或 docx 答案键

Generate html or docx answer key for schoice or mchoice questions

出于校对目的,为了将草稿分发给助教,我想生成一个答案键。我使用 exams2html()exams2pandoc() 生成草稿考试,但这些没有密钥。我查看了这两个函数的参数,但没有看到任何与在输出中显示答案明显相关的内容。我能找到的最接近的是 solution 参数,它似乎改变了问题的呈现方式而不是显示答案。

exams2pandoc(e, solution = "Answer"):这会将输出问题格式更改为列出“答案”而不是默认的“解决方案”。

exams2html(e, solution = "Answer"):这没有显示“答案”,但默认似乎没有显示“解决方案”,所以我想这并不奇怪。

我在 R/exams 文档、R-Forge 和此处的 Whosebug 上进行了搜索。但是,我无法找到这方面的说明或指南。非常感谢为草稿考试生成密钥的任何帮助。如果我错过了一些明显的东西,请提前道歉。

由于 R/exams 的主要目的是生成大量随机问题,因此经典答案键通常用途有限(因为您不想经历数十或数百个随机变体答案键)。这就是为什么 R/exams.

中没有那么强调答案的原因

但是,您可以使用一些工具。命令行上有exams_metainfo(),例如:

exm <- c("capitals.Rmd", "swisscapital.Rmd", "switzerland.Rmd")
set.seed(0)
res <- exams2html(exm)
exams_metainfo(res)
## exam1
##     1. Capitals: 1, 5
##     2. Swiss Capital: 1
##     3. About Switzerland: 1, 2

meta-information 的 print() 方法也可以稍微调整一下,请参阅 http://www.R-exams.org/general/tamiu_finance/ 了解一些实际示例。

如果你想用复选框显示答案键,那么包附带了一个合适的模板 exams2pdf():

set.seed(0)
exams2pdf(exm, template = "solution.tex")

这包括扉页上的以下内容:

当然,您还可以进一步调整 "solution.tex" 模板以使其适应您的特定需求。要开始查看

制作的 demo-pdf.R
exams_skeleton(writer = "exams2pdf")

最后,关于 exams2pandoc()exams2html() 中的 solution 参数的快速说明,摘自相应的帮助页面。

question: character or logical. Should the question be included in the output? If 'question' is a character it will be used as a header for resulting questions.

solution: character or logical, see argument 'question'.