-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Counting points from random exercises #27
Comments
As initially reported here: https://tex.stackexchange.com/questions/419046/xsim-incorrect-number-of-questions-and-total-of-points This is a follow up on https://tex.stackexchange.com/questions/383207, where the How can I get the correct number of points and questions when some questions are declared in the collection but not subsquently inserted in the document? The commands What am I doing wrong? \documentclass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{filecontents} % for self-contained example
\begin{filecontents}{bank.tex}
\begin{question}[ID={Q1}, points={50}, tags={difficult}]
First Question: Select one of the following solutions:
\begin{enumerate}
\item A
\item B
\item C
\item D
\item E
\end{enumerate}
\end{question}
\begin{answer}
Solution to First Question
\end{answer}
\begin{question}[ID={Q2}, points={50}, tags={bonus}]
Second Question: Select one of the following solutions:
\begin{enumerate}
\item A
\item B
\item C
\item D
\item E
\end{enumerate}
\end{question}
\begin{answer}
Solution to Second Question
\end{answer}
\end{filecontents}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{xsim}
\usepackage[most]{tcolorbox}
\newcommand*\includeQuestion[1]{%
\XSIMexpandcode{\printexercise{question}{\GetExerciseIdForProperty{ID}{#1}}}%
}
\newcommand*\includeSolution[1]{%
\XSIMexpandcode{\printsolution{question}{\GetExerciseIdForProperty{ID}{#1}}}%
}
\DeclareExerciseEnvironmentTemplate{tcb}
{%
\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}%
\IfInsideSolutionF{%
\IfExercisePropertySetT{tags}{%
\textbf{~~(\ListExerciseTags{tags}{, })}}%
\IfExercisePropertySetT{points}{%
\hfill[\GetExerciseProperty{points}
\IfExerciseGoalSingularTF{points}
{\XSIMtranslate{point}}
{\XSIMtranslate{points}}]%
}%
}%
]%
}{\endtcolorbox}
\DeclareExerciseType{question}{
exercise-env = question,
solution-env = answer,
exercise-name = question, % used with headings=true
solution-name = solution, % used with headings=true
exercise-template = tcb,
solution-template = tcb
}
\DeclareExerciseCollection{myCollection}
\begin{document}
\collectexercises{myCollection}
\input{bank.tex}
\collectexercisesstop{myCollection}
\section*{Instructions}
\noindent Total number of questions: \numberofquestions. \par
\noindent Total points: \printtotalpoints.
\section*{Questions}
\includeQuestion{Q1}
\includeSolution{Q1}
%\includeQuestion{Q2}
%\includeSolution{Q2}
\end{document} |
The text was updated successfully, but these errors were encountered: