I am trying to use the xsim
package to sort and order the previously given exams in a course (MAT-1001). For this to be viable I need the following equirements
- I should be able to request exam problems by ID, topic, or year.
- I want to be able to request both questions and subquestions.
I tried to do this with the code below, but I have never encountered such bizzare results in my life. The expected output is so far from what I would expect. The code in its entirety can be found below, but I want to step through it one problem at a time.
The following file is a sample file showing a few common exercises.
exam.tex
\begin{question}[
year=2017,semester=V,exam=O
ID=MAT-1001-2017-V-H-Problem-1-a,
topic = integral
]
Evaluate the following integrals
\begin{tasks}(3)
\task $\displaystyle \int_0^{\sqrt{\pi/2}} (x+1) \e^{x-1} dx$
\task $\displaystyle \int \frac{a}{x^2 + a^2} dx$
\task $\displaystyle \int \log x dx$.
\end{tasks}
\end{question}
\begin{question}[
year=2017,semester=V,exam=O
ID=MAT-1001-2017-V-H-Problem-1-b,
topic = limit
]
Evaluate the following limits
\begin{tasks}(2)
\task $\displaystyle \lim_{x \to 0} \frac{\sin(x^2)}{x^2}$
\task $\displaystyle \lim_{x \to 0} \frac{\sin(x^2)}{1 + x^2}$.
\end{tasks}
\end{question}
\begin{question}[
year=2017,semester=V,exam=O
ID=MAT-1001-2017-V-H-Problem-1-c,
topic = injective
]
State the definition of an injective function and provle
that the function $f \to \mathbb{R} \to \mathbb{R}$ defined by $\int_0^x
e^{-s^2} dx$ is injective.
\end{question}
\begin{exercise}[year=2017,semester=H,topic={integral,limit,injective},exam=K,
ID=MAT-1001-2017-V-H-Problem-1]
\begin{enumerate}
\item \insertexercise{ID=MAT-1001-2017-V-H-Problem-1-a}
\item \insertexercise{ID=MAT-1001-2017-V-H-Problem-1-b}
\item \insertexercise{ID=MAT-1001-2017-V-H-Problem-1-c}
\end{enumerate}
\end{exercise}
This leads me to my first two questions
- I want to tag the questions and use these tags, however the code above does not work. I am not able to filter out say every question with the topic
integral
. - How can I put togheter questions to form an exercise (or exam problem)?
I tried to use the code
\newcommand*\insertexercise[1]{%
\XSIMexpandcode{\printexercise{exercise}{\GetExerciseIdForProperty{ID}{#1}}}%
}
From How can I print exercise with ID in xsim?. To insert the questions into the exercise:
\begin{exercise}[year=2017,semester=H,topic={complex,differential},exam=K,
ID=MAT-1001-2017-V-H-Problem-1]
\begin{enumerate}
\item \insertexercise{ID=MAT-1001-2017-V-H-Problem-1-a}
\item \insertexercise{ID=MAT-1001-2017-V-H-Problem-1-b}
\item \insertexercise{ID=MAT-1001-2017-V-H-Problem-1-c}
\end{enumerate}
\end{exercise}
However that did not work. How can one properly do this? And how would this work when displaying solutions?
In the remainder of this question I post snippets of my MWE, sharing my frustrations over things that does not work as I would expect.
The lines below fails to compile when uncommented, why?
% \collectexercisestype{all} % \input{exam.tex} % \collectexercisesstop{all}
I have already defined the file exam.tex
The following code works however
\collectexercisestype{exercise-pool}{exercise}
\input{exam.tex}
\collectexercisesstop{exercise-pool}
% Random exercise
\begin{exercise}
\begin{enumerate}
\item \printrandomexercises[collection=exercise-pool]{2}
\end{enumerate}
\end{exercise}
- I would expect the code above to print the sole
Exercise
environment fromexam.tex
instead it prints nothing. Why?
The following code does print out subquestions. However, why does it only print out one no matter what number I input?
\collectexercises{subquestions}{subquestion}
\input{exam.tex}
\collectexercisesstop{subquestions}
% Random subquestion
\begin{exercise}
\begin{enumerate}
\item \printrandomexercises[collection=subquestions]{2}
\end{enumerate}
\end{exercise}
The following code I would expect to print out the Exercise
environment from the file, alas it prints nothing
\insertexercise{ID=MAT-1001-2017-V-H-Problem-1}
Similarly the following code prints nothing as well
\insertexercise{ID=MAT-1001-2017-V-H-Problem-1-a}
In addition I can not print any of the collections as this gives me an undefined item
error.
\section{All}
% \printcollection{all}
\section{Exercises}
% \printcollection{exercise-pool}
\section{Subquestions}
% \printcollection{subquestions}
The file exam.tex
is defined at the start of the question
main.tex
\documentclass{article}
\usepackage{amssymb,mathtools}
\usepackage{tasks}
\usepackage{xsim}
% \xsimsetup{
% exercise/name=,
% solution/print=true,
% solution/name=Solution,
% }
\DeclareExerciseTagging{year} % 1992, 2010, etc
\DeclareExerciseTagging{topic}
\DeclareExerciseTagging{semester} % V (Spring), H (Fall)
\DeclareExerciseTagging{exam} % O (ordinary), K (kont / re-sit exam), P (prøveeksamen)
\DeclareExerciseCollection{MAT-1001-Integrals}
\DeclareExerciseType{subquestion}{
exercise-env = question ,
solution-env = answer ,
exercise-name = Question ,
solution-name = Answer ,
exercise-template = item ,
solution-template = item
}
\DeclareExerciseProperty{title}
\DeclareExerciseEnvironmentTemplate{named}
{\subsection*{\GetExercisePropertyTF{title}{#1}{??}}}
{}
\DeclareExerciseEnvironmentTemplate{item}
{\item}
{}
\xsimsetup{
exercise/template = named
}
\DeclareExerciseCollection{all}
\DeclareExerciseCollection{exercise-pool}
\DeclareExerciseCollection{subquestions}
\newcommand{\problemfolder}{exam-problems}
\newcommand*\insertexercise[1]{%
\XSIMexpandcode{\printexercise{exercise}{\GetExerciseIdForProperty{ID}{#1}}}%
}
\begin{document}
% The lines below fails to compile why?
% \collectexercisestype{all}
% \input{exam.tex}
% \collectexercisesstop{all}
% Random subproblem or exercise
% \begin{exercise}[title=Random subproblem or exercise]
% \begin{enumerate}
% \item \printrandomexercises[collection=all]{2}
% \end{enumerate}
% \end{exercise}
% Why does the \printrandomexercises{2} only print 1 instead of two exercises?
% Why does it print the subquestions instead of the exercise?
\collectexercisestype{exercise-pool}{exercise}
\input{exam.tex}
\collectexercisesstop{exercise-pool}
% Random exercise
\begin{exercise}
\begin{enumerate}
\item \printrandomexercises[collection=exercise-pool]{1}
\end{enumerate}
\end{exercise}
% Why does the code below print absolutely nothing?
\collectexercises{subquestions}{subquestion}
\input{exam.tex}
\collectexercisesstop{subquestions}
% Random subquestion
\begin{exercise}
\begin{enumerate}
\item \printrandomexercises[collection=subquestions]{2}
\end{enumerate}
\end{exercise}
% Why does the code below print nothing? Is it possible to nest \insertexercise?
Should print the first problem
\insertexercise{ID=MAT-1001-2017-V-H-Problem-1}
% I can sort of understand why the code above does not work, but why
% can it not print subproblems either?
Should print the first subproblem (problem 1-a)
\insertexercise{ID=MAT-1001-2017-V-H-Problem-1-a}
\section{All}
% \printcollection{all}
\section{Exercises}
% \printcollection{exercise-pool}
\section{Subquestions}
% \printcollection{subquestions}
\end{document}