I have the following question:
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
```
```{r, include = FALSE}
correct <- c(
"A (correct)
\\vspace{1cm}
$$\\int f\\left(x\\right) dx$$
",
"B (correct)",
"C (correct)"
)
correct <- sample(correct, 2)
incorrect <- c(
"D (incorrect)",
"E (incorrect)",
"F (incorrect)",
"G (incorrect)",
"H (incorrect)",
"I (incorrect)"
)
incorrect <- sample(incorrect, 6)
```
Question
========
Select from the followings items.
\begin{answerlist}
\item `r correct[1]`
\item `r correct[2]`
\item `r incorrect[1]`
\item `r incorrect[2]`
\item `r incorrect[3]`
\item `r incorrect[4]`
\item `r incorrect[5]`
\item `r incorrect[6]`
\end{answerlist}
Meta-information
================
exname: My question
extype: mchoice
exsolution: 11000000
exshuffle: TRUE
And I use the following code to generate the exam:
library(exams)
myexam <- list(
"question.Rmd",
"question.Rmd",
"question.Rmd",
"question.Rmd"
)
exm <- exams2pdf(myexam,dir = "/tmp/", template = "x.tex")
exm[[1]][[1]]$metainfo$solution
where my template is:
\documentclass[a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[portuges]{babel}
\usepackage{graphicx}
\usepackage{fancyhdr}
\usepackage{longtable}
\usepackage{multicol}
\usepackage{enumitem}
\setlength{\parindent}{0em}
\setlength{\parskip}{\bigskipamount}
\pagestyle{fancy}
\setlength\headheight{55pt}
\fancyhf{} % sets both header and footer to nothing
\renewcommand{\headrulewidth}{0pt}
\newenvironment{answerlist}%
{\renewcommand{\labelenumii}{(\alph{enumii})}\begin{multicols}{4}\begin{enumerate}}%
{\end{enumerate}\end{multicols}}
\newenvironment{question}{\item }{}
%\setkeys{Gin}{keepaspectratio}
\begin{document}
This is my exam!
Part 1
\begin{enumerate}
%% \exinput{exercises}
\end{enumerate}
Part 2
\begin{enumerate}[resume]
\input{exercise4}
\end{enumerate}
\end{document}
However, the solution for my question 1 in the exam is not correct (exm[[1]][[1]]$metainfo$solution
). Is this a bug? Or am I doing something wrong?
However, the solution for my question 1 in the exam is not correct (exm[[1]][[1]]$metainfo$solution
). Is this a bug? Or am I doing something wrong?
(Sorry for repeating the last paragraphs, but otherwise Stackoverflow would not allow me to post -- it complains about too much code.)