The following template worked with xsim
v.0.19
, but no longer works with v.0.20
. The problem seems to be that \GetExerciseProperty{counter}
is unable to retrieve the counter.
Package info:
Package: xsim 2021/02/03 v0.20c eXercise Sheets IMproved
pdfTeX 3.141592653-2.6-1.40.23 (TeX Live 2022/dev)
Broken Template:
\documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{filecontents} % for self-contained example
\begin{filecontents}{QuestionBank.tex}
\begin{mc}[ID=Q001]
First Question: Select one of the following solutions:
\begin{enumerate}
\item A
\item B
\end{enumerate}
\end{mc}
\begin{hint}
Solution to First Question
\end{hint}
\begin{mc}[ID=Q002]
Second Question: Select one of the following solutions:
\begin{enumerate}
\item C
\item D
\end{enumerate}
\end{mc}
\begin{hint}
Solution to Second Question
\end{hint}
\end{filecontents}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage[verbose,clear-aux]{xsim}
\usepackage[most]{tcolorbox}
\newcommand*\includeQuestion[1]{%
\XSIMexpandcode{\printexercise{mc}{\GetExerciseIdForProperty{ID}{#1}}}%
}
\newcommand*\includeSolution[1]{%
\XSIMexpandcode{\printsolution{mc}{\GetExerciseIdForProperty{ID}{#1}}}%
}
\DeclareExerciseEnvironmentTemplate{mctemplate}
{%
\tcolorbox[breakable,
drop shadow,
beforeafter skip=1\baselineskip,
fonttitle=\bfseries,
fontupper=\normalsize,
valign=top,
colframe=\IfInsideSolutionF{green!20!white}%
\IfInsideSolutionT{blue!20!white},
colback=\IfInsideSolutionF{green!3!white}%
\IfInsideSolutionT{blue!3!white},
coltext=black,
coltitle=black,
boxrule=1pt,
width=\linewidth,
left=2mm,
title=\IfInsideSolutionT{%
\XSIMmixedcase{\XSIMtranslate{solution}}~to~}%
\XSIMmixedcase{\XSIMtranslate{question}}~\GetExerciseProperty{counter}%
]%
}{\endtcolorbox}
\DeclareExerciseType{mc}{
exercise-env = mc,
solution-env = hint,
exercise-name = question,% used with headings=true
solution-name = answer,% used with headings=true
exercise-template = mctemplate,
solution-template = mctemplate,
counter = mc
}
\DeclareExerciseCollection{myCollection}
\begin{document}
\collectexercises{myCollection}
\input{QuestionBank.tex}
\collectexercisesstop{myCollection}
\section*{Multiple Choice Questions with XSIM}
Total number of questions: \numberofmcs
\noindent
The counter above should be 2, not 0.
\noindent
The following should print \textbf{Question 1} and \textbf{Solution to Question 1}. And likewise \textbf{Question 2} and \textbf{Solution to Question 2}.
\includeQuestion{Q001}
\includeSolution{Q001}
\includeQuestion{Q002}
\includeSolution{Q002}
\end{document}
xsim 2020/04/04 v0.19b eXercise Sheets IMproved
withVersion 3.14159265-2.6-1.40.21 (TeX Live 2020)
whereas I'm usingxsim 2021/02/03 v0.20c eXercise Sheets IMproved
withVersion 3.141592653-2.6-1.40.23 (TeX Live 2022/dev) (preloaded format=pdflatex 2021.9.28)
. Is it a bug/feature with the latest version ofxsim
?xsim
. I'm hoping to find a workaround within a week or so, so I'm leaving the question open here just in case someone can suggest a workaround. Thanks! github.com/cgnieder/xsim/issues/91xsim
solution is not forthcoming, I will create my own counter, which should not be too hard. :-)