Historique des modifications [retour]
cliquez ici pour masquer/afficher la révision 2

17 Fév '23, 14:50

touhami's gravatar image

touhami
9.9k410

Voici une solution. Il faut modifier la définition de la commande `\answer` pour quelle puisse collecter les différentes réponses. !TEX none \newcommand*\answer[1]{% \xdef\multichoicehook{\ifx\multichoicehook\empty\else\multichoicehook, \fi\noexpand{\Alph{task}}} \XSIMexpandcode{% \SetExerciseProperty{solution-body}{\multichoicehook}}% #1} Il faut aussi ajouter le réglage suivant pour réinitialiser la commande `\multichoicehook`: !TEX none \xsimsetup{ exercise/template = item , solution/template = space , exercise/name = Q. , exercise/the-counter = \arabic{exercise}. , exercise/collect , random/sort = false, exercise/begin-hook ={\let\multichoicehook\empty} } **ECM**. \documentclass[12pt,a4paper]{article} \usepackage{xsim} \usepackage{tasks} \NewTasksEnvironment[ label = \textbf{\Alph*.}, label-width = 15pt ]{choice}[\choice](4) \DeclareExerciseEnvironmentTemplate{item} {\description\item[\GetExerciseName~\GetExerciseProperty{counter}]} {\enddescription} \DeclareExerciseEnvironmentTemplate{space} {\textbf{\GetExerciseProperty{counter}} } {\quad} \newcommand*\answer[1]{% \xdef\multichoicehook{\ifx\multichoicehook\empty\else\multichoicehook, \fi\noexpand{\Alph{task}}} \XSIMexpandcode{% \SetExerciseProperty{solution-body}{\multichoicehook}}% #1} \DeclareExerciseCollection{Section1} \xsimsetup{ exercise/template = item , solution/template = space , exercise/name = Q. , exercise/the-counter = \arabic{exercise}. , exercise/collect , random/sort = false, exercise/begin-hook ={\let\multichoicehook\empty} } \begin{document} \section{Section 1} \collectexercises{Section1} Il y a 2 réponses vraies par question, mais c'est toujours la dernière qui est reprise dans la liste des réponses! \begin{exercise} Lesquels donnent un résultat égale à $-6$? \begin{choice}(2) \choice \answer $-6 \times 1$ \choice $-3 \times -2$ \choice $-6 \times -1$ \choice \answer $3 \times -2$ \end{choice} % Here the only fourth choice's answer key (the second correct one here "D") is diplayed in answers section \end{exercise} \begin{exercise} Lesquels sont des pays africains? \begin{choice}(4) \choice \answer Nigeria \choice \answer South africa \choice Canada \choice Germany \end{choice} % Here the only second choice's answer key (the second correct one here "B") is diplayed in answers section \end{exercise} \begin{exercise} Lesquels sont exacts? \begin{choice}(2) \choice \answer $-2\times-3=6$ \choice $-2-3=-6$ \choice \answer $2+3=5$ \choice $-2+3=-5$ \end{choice} % Here the only tirth choice's answer key (the second correct one here "C") is diplayed in answers section \end{exercise} \collectexercisesstop{Section1} \subsection{Questions} \printrandomexercises[collection=Section1]{5} \subsection{Réponses} \printsolutions[headings=false] \end{document}
cliquez ici pour masquer/afficher la révision 1

17 Fév '23, 14:48

touhami's gravatar image

touhami
9.9k410

Voici une solution. Il faut modifier la définition de la commande `\answer` pour quelle puisse collecter les différentes réponses. \newcommand*\answer[1]{% \xdef\multichoicehook{\ifx\multichoicehook\empty\else\multichoicehook, \fi\noexpand{\Alph{task}}} \XSIMexpandcode{% \SetExerciseProperty{solution-body}{\multichoicehook}}% #1} Il faut aussi ajouter le réglage suivant pour réinitialiser la commande `\multichoicehook`: \xsimsetup{ exercise/template = item , solution/template = space , exercise/name = Q. , exercise/the-counter = \arabic{exercise}. , exercise/collect , random/sort = false, exercise/begin-hook ={\let\multichoicehook\empty} } **ECM**. \documentclass[12pt,a4paper]{article} \usepackage{xsim} \usepackage{tasks} \NewTasksEnvironment[ label = \textbf{\Alph*.}, label-width = 15pt ]{choice}[\choice](4) \DeclareExerciseEnvironmentTemplate{item} {\description\item[\GetExerciseName~\GetExerciseProperty{counter}]} {\enddescription} \DeclareExerciseEnvironmentTemplate{space} {\textbf{\GetExerciseProperty{counter}} } {\quad} \newcommand*\answer[1]{% \xdef\multichoicehook{\ifx\multichoicehook\empty\else\multichoicehook, \fi\noexpand{\Alph{task}}} \XSIMexpandcode{% \SetExerciseProperty{solution-body}{\multichoicehook}}% #1} \DeclareExerciseCollection{Section1} \xsimsetup{ exercise/template = item , solution/template = space , exercise/name = Q. , exercise/the-counter = \arabic{exercise}. , exercise/collect , random/sort = false, exercise/begin-hook ={\let\multichoicehook\empty} } \begin{document} \section{Section 1} \collectexercises{Section1} Il y a 2 réponses vraies par question, mais c'est toujours la dernière qui est reprise dans la liste des réponses! \begin{exercise} Lesquels donnent un résultat égale à $-6$? \begin{choice}(2) \choice \answer $-6 \times 1$ \choice $-3 \times -2$ \choice $-6 \times -1$ \choice \answer $3 \times -2$ \end{choice} % Here the only fourth choice's answer key (the second correct one here "D") is diplayed in answers section \end{exercise} \begin{exercise} Lesquels sont des pays africains? \begin{choice}(4) \choice \answer Nigeria \choice \answer South africa \choice Canada \choice Germany \end{choice} % Here the only second choice's answer key (the second correct one here "B") is diplayed in answers section \end{exercise} \begin{exercise} Lesquels sont exacts? \begin{choice}(2) \choice \answer $-2\times-3=6$ \choice $-2-3=-6$ \choice \answer $2+3=5$ \choice $-2+3=-5$ \end{choice} % Here the only tirth choice's answer key (the second correct one here "C") is diplayed in answers section \end{exercise} \collectexercisesstop{Section1} \subsection{Questions} \printrandomexercises[collection=Section1]{5} \subsection{Réponses} \printsolutions[headings=false] \end{document}

C'est votre première visite ici ? Consultez la FAQ !

×