通过"exams2pdf"打印为pdf时,如何显示每个练习的分数? [英] How to display points per exercise when printing to pdf via `exams2pdf`?

查看:148
本文介绍了通过"exams2pdf"打印为pdf时,如何显示每个练习的分数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑使用R中的exams软件包创建考试.

Consider creating exams using the exams package in R.

使用exams2nops时,有一个参数showpoints,当设置为TRUE时,该参数将显示每个练习的要点.但是,对于exams2pdf,此参数不可用.

When using exams2nops there is a parameter showpoints that, when set to TRUE will show the points of each exercise. However, for exams2pdf this parameter is not available.

使用exams2pdf时如何显示每个练习的分数?

How to display the points per exercise when using exams2pdf?

推荐答案

(以下答案摘自R/exams论坛上的

(The answer below is adapted from the R/exams forum at https://R-Forge.R-project.org/forum/forum.php?thread_id=33884&forum_id=4377&group_id=1337.)

当前没有内置解决方案可以自动显示exams2pdf()中的点数. points=参数仅将exams2pdf()创建的R对象中的点数存储(如在其他exams2xyz()接口中一样),而将存储在单个PDF文件中.

There is currently no built-in solution to automatically display the number of points in exams2pdf(). The points= argument only stores the number of points in the R object that exams2pdf() creates (as in other exams2xyz() interfaces) but not in the individual PDF files.

因此,如果要显示点,则需要自己进行某种方式.一个简单的解决方案是将其包含在各个练习中,可能取决于所使用的界面类型,例如,.Rmd练习中类似的内容:

Thus, if you want the points to be displayed you need to do it in some way yourself. A simple solution would be to include it in the individual exercises already, possibly depending on the kind of interface used, e.g., something like this for an .Rmd exercise:

pts <- 17
pts_string <- if(match_exams_call() == "exams2pdf") {
  sprintf("_(%s points)_", pts)
} else {
  ""
}

然后在问题"的开头:

Question
========
`r pts_string` And here starts the question text...

最后是元信息

expoints: `r pts`

这总是在元信息中包含所需的点,但仅在使用exams2pdf(...)时才在问题中显示它们.这非常灵活,可以轻松地进一步自定义.唯一的缺点是它对exams2pdf(..., points = ...)参数没有反应.

This always includes the desired points in the meta-information but only displays them in the question when using exams2pdf(...). This is very flexible and can be easily customized further. The only downside is that it doesn't react to the exams2pdf(..., points = ...) argument.

在.Rnw练习中,必须使用\Sexpr{...}而不是r ... .另外,pts_string应该类似于sprintf("\\emph{(%s points)}", pts).

In .Rnw exercises one would have to use \Sexpr{...} instead of r .... Also the pts_string should be something like sprintf("\\emph{(%s points)}", pts).

最后,一个更详尽的解决方案是在您使用的.tex模板中创建合适的\newcommand.如果所有练习的分数都相同,这并不难.但是,如果所有不同的练习都可以有不同的分数,那么就需要更多地参与其中.

Finally, a more elaborate solution would be to create a suitable \newcommand in the .tex template you use. If all exercises have the same number of points, this is not hard to do. But if all the different exercises could have different numbers of points, it would need to be more involved.

exams2nops()中支持此功能但不支持exams2pdf()的主要原因是前者具有相当严格的格式和词汇.但是,在后一种情况下,重点是给予用户关于布局,语言等的所有自由.因此,我没有看到一种解决方案,该解决方案不够简单,但也没有足够的灵活性来涵盖exams2pdf()的所有用例.

The main reason for supporting this in exams2nops() but not exams2pdf() is that the former has a rather restrictive format and vocabulary. In the latter case, however, the point is to give users all freedom regarding layout, language, etc. Hence, I didn't see a solution that is simple enough but also flexible enough to cover all use-cases of exams2pdf().

这篇关于通过"exams2pdf"打印为pdf时,如何显示每个练习的分数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆