How do I put a custom url in a r-exams question that it will be exported to moodle?

169 views Asked by At

The r-exams package offers a possibility to add a url to the question using the macro \url{some link}, however I would like to hide the link and show some text instead, for example: \command{www.r-exams.org}{R/EXAMS}. It's possible?

1

There are 1 answers

0
Achim Zeileis On BEST ANSWER

Answer

In R/LaTeX (Rnw) exercises you can do so with the \href{...}{...} command. In R/Markdown (Rmd) exercises you can use the [...](...) syntax. See below for rexams.Rnw and rexams.Rmd respectively.

Details

To generate the Moodle XML file for import into Moodle, use

exams2moodle("rexams.Rnw")

And to preview more quickly what the HTML code looks like use

exams2html("rexams.Rnw")

In the latter case you can also add the argument converter = "pandoc-mathjax" so that you use the same HTML converter that exams2moodle() uses by default. The same also works for the rexams.Rmd file. Both of the HTML converters (ttm and pandoc) support these syntaxes for the specification of hyperlinks.

Only when converting to PDF the default template will not work but you need to do something like

exams2pdf("rexams.Rnw", template = "mytemplate.tex")

where "mytemplate.tex" needs to be a suitable LaTeX template that includes the {hyperref} package. See Section 3 in vignette("exams", package = "exams") for further details. The reason the {hyperref} is not included in the default template is that (a) {hyperref} is quite "invasive" and changes many aspects of the document formatting and (b) the default PDF configuration is intended for printing and not hyperlinking because HTML-based formats are better for the latter.

Exercise rexams.Rnw

\begin{question}
How many times do you see the logo on the
\href{http://www.R-exams.org/}{R/exams web page}?
\end{question}

\exname{R/exams logo}
\extype{num}
\exsolution{2}

Exercise rexams.Rmd

Question
========
How many times do you see the logo on the
[R/exams web page](http://www.R-exams.org/)?

Meta-information
================
exname: R/exams logo
extype: num
exsolution: 2