R考试:省略考试中的子问题,但包括在解决方案中

问题描述 投票:1回答:1

我目前正在研究r考试以生成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个回答
0
投票

如果子问题在同一个完结问题中,则我不认为如何轻松完成所需的操作。但是,如果将它们放在单独的练习中,则可以通过自定义模板“相对”直接地进行操作。

假设您有两个项目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}环境或类似的东西。

© www.soinside.com 2019 - 2024. All rights reserved.