【问题标题】:R-exams: Omit subquestions in exam, but include in solutionR-exams:在考试中省略子问题,但在解决方案中包含
【发布时间】:2020-05-08 04:12:12
【问题描述】:

我目前正在研究 r-exam 以生成 PDF 考试。 一个问题由几个子问题组成,并用 Rmd 编​​写,如下例所示:

Question
========

Calculate the following:

Answerlist
----------

* 1+1
* 2+2

Solution
========

Answerlist
----------

* 2
* 4

Meta-information
================

extype: cloze
exclozetype: num|num
exsolution:  2|4
exname: test

然后使用exams2pdf(结合了多个 Rmd 文件)生成考试。

有没有办法只在考试中包含第一个子问题 (1+1),但在解决方案中同时包含子问题及其答案?

这可能是一个奇怪的问题,但这次考试将用作口试的准备。第一个子问题是关于准备的(因此它应该包含在考试 PDF 中)。第二个子问题没有准备(在口试期间询问),所以它不应该出现在考试 PDF 中,但是如果我能以某种方式将这些附加问题包含在解决方案 PDF 中会很方便吗?

【问题讨论】:

    标签: r r-exams


    【解决方案1】:

    如果子问题在同一个完形填空问题中,我看不出一个简单的方法来做你想做的事。但是,如果您将它们放入单独的练习中,则通过自定义模板“相对”简单。

    假设您有两个项目item1.Rmd(编号与 1+1 练习)和item2.Rmd(编号与 2+2 练习)。然后您需要三个模板:preparation.texoral.texcombined_solution.tex。前两个通常隐藏解决方案环境,而后者显示它。此外,前两个没有显示所有练习,而后一个显示。更多详细信息在下面和vignette("exams", package = "exams") 的第 3 节中。然后就可以了

    `exams2pdf(c("item1.Rmd", "item2.Rmd"), n = 3,
      template = c("preparation.tex", "oral.tex", "combined_solution.tex"))
    

    combined_solution.tex 模板显示问题和解决方案以及所有练习:

    \documentclass[a4paper]{article}
    
    ...
    
    \newenvironment{question}{\item \textbf{Problem}\newline}{}
    \newenvironment{solution}{\textbf{Solution}\newline}{}
    
    ...
    
    \begin{document}
    \begin{enumerate}
    %% \exinput{exercises}
    \end{enumerate}
    \end{document}
    

    preparation.tex 只显示第一个练习(而不是第二个)并隐藏了求解环境:

    \documentclass[a4paper]{article}
    
    ...
    
    \newenvironment{question}{\item \textbf{Problem}\newline}{}
    \newenvironment{solution}{\comment}{\endcomment}
    
    ...
    
    \begin{document}
    \begin{enumerate}
    \input{exercise1.tex}
    \item \emph{Oral part.}
    \end{enumerate}
    \end{document}
    

    相反,oral.tex 只显示第二个练习(而不是第一个)并隐藏解决方案环境:

    \documentclass[a4paper]{article}
    
    ...
    
    \newenvironment{question}{\item \textbf{Problem}\newline}{}
    \newenvironment{solution}{\comment}{\endcomment}
    
    ...
    
    \begin{document}
    \begin{enumerate}
    \item \emph{Preparation part.}
    \input{exercise2.tex}
    \end{enumerate}
    \end{document}
    

    除了将\item \emph{...} 包含在隐藏练习中,您还可以增加计数器或使用嵌套的{enumerate} 环境或类似的东西。

    【讨论】:

    • 感谢您的建议和示例!
    • 如果这回答了您的问题,请在 StackOverflow 上接受它,以便相应地对其进行标记。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-05-15
    • 1970-01-01
    • 2013-09-05
    • 2016-11-15
    • 2011-12-01
    • 1970-01-01
    相关资源
    最近更新 更多