r - R-exams:在考试中省略子问题,但在解决方案中包含
问题描述
我目前正在研究 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 中会很方便吗?
解决方案
如果子问题在同一个完形填空问题中,我看不出一个简单的如何做你想做的事。但是,如果您将它们放入单独的练习中,则通过自定义模板“相对”简单。
假设您有两个项目item1.Rmd
(num 与 1+1 练习)和item2.Rmd
(num 与 2+2 练习)。然后您需要三个模板:preparation.tex
、oral.tex
和combined_solution.tex
。前两个通常隐藏解决方案环境,而后者显示它。此外,前两个没有显示所有练习,而后一个显示。更多细节在下面和第 3 节中vignette("exams", package = "exams")
。然后你可以做
`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}
环境或类似的东西。
推荐阅读
- reactjs - 使用 onPress 调用函数时使用 Hooks 无效
- java - software.amazon.jsii.JsiiException:找不到模块“@company/cdk-tagsModule”
- javascript - TypeScript 中的函数表达式与函数声明
- c++ - 如何更改窗口句柄类名称或至少将其别名为 windows
- c++ - range::iota_view 的构造函数为什么不将参数移动到成员变量?
- r - 如何将普通条形图转换为百分比条形图
- python - 从 pandas.core.dtypes.cast 导入(ImportError: cannot import name 'doc'
- flutter - 颤振蓝牙 Arduino
- azure - 无法调用 Microsoft Graph API:无法解析租户复制范围模板令牌
- delete-file - 无法在操作控制台中删除项目