2021-2022/tools/style/myXsim.sty

133 lines
3.7 KiB
TeX

\NeedsTeXFormat{LaTeX2e}
% extensions
\RequirePackage{colorscheme}
\RequirePackage{base}
\RequirePackage{myhdr}
\RequirePackage{notbeamer}
\RequirePackage{xsim}
\DeclareExerciseTagging{step}
\DeclareExerciseTagging{type}
\DeclareExerciseTagging{tribe}
\DeclareExerciseTagging{difficulty}
\DeclareExerciseTagging{origin}
\DeclareExerciseTagging{mode}
\DeclareExerciseTranslations{total}{
French = total,
}
\DeclareExerciseEnvironmentTemplate{exo}{%
\subsection*
{%
\color{exercise}{\XSIMmixedcase{\GetExerciseName}}\nobreakspace
\GetExerciseProperty{counter}%
\hspace{0.5cm} \GetExercisePropertyT{mode}
{{\PropertyValue}}%
\hspace{0.5cm} \color{line}\hrulefill \hspace{0.5cm}
\color{exercise}
\GetExercisePropertyT{subtitle}
{{\PropertyValue}}%
\GetExercisePropertyT{points}
{{(/\PropertyValue})}%
\noindent
}
}{}
\xsimsetup{exercise/template=exo}
\DeclareExerciseEnvironmentTemplate{sol}{%
\subsection*
{%
\color{exercise}\nobreakspace
Exercice \GetExerciseProperty{counter}%
\hspace{0.5cm} \color{line}\hrulefill \hspace{0.5cm}
\color{exercise}{\XSIMmixedcase{\GetExerciseName}}
\hspace{0.5cm} \color{line}\hrulefill \hspace{0.5cm}
\color{exercise}
\GetExercisePropertyT{subtitle}
{{\PropertyValue}}%
\noindent
}
}{}
\xsimsetup{solution/template=sol}
\DeclareExerciseTableTemplate{DNB}{%
\XSIMputright\ExerciseTableCode{%
\hline
\XSIMifblankTF{\ExerciseType}
{}
{\XSIMmixedcase{\GetExerciseParameter{exercise-name}}}
&
\XSIMmixedcase{\XSIMtranslate{points}} \\
\hline
}%
\ForEachUsedExerciseByType{%
\XSIMifeqTF{#1}{\ExerciseTableType{#1}}
{%
\XSIMifblankTF{\ExerciseType}
{%
\XSIMputright\ExerciseTableCode{%
\XSIMmixedcase{\ExerciseParameterGet{#1}{exercise-name} }%
}%
}
{}%
\XSIMputright\ExerciseTableCode
{#3 & \XSIMifblankTF{#5}{\printgoal{0}}{\printgoal{#5}}\\ }%
}
{}%
}
\XSIMputright\ExerciseTableCode{%
\hline
\XSIMmixedcase{\XSIMtranslate{total}} &
\XSIMifblankTF{\ExerciseType}
{\TotalExerciseGoal{points}{}{}}
{\TotalExerciseTypeGoal{\ExerciseType}{points}{}{}} \\
\hline
}%
\XSIMexpandcode{%
\noexpand\begin{tabular}{|\XSIMifblankTF{\ExerciseType}{l}{c}|c|}
\noexpand\ExerciseTableCode
\noexpand\end{tabular}%
}%
}
\newcommand\printsectionexercises{%
\ForEachUsedExerciseByType{%
\ifnum\ExercisePropertyGet{##1}{##2}{step}=\value{section}
\printexercise{exercise}{##2}
\fi
}%
}
\newcommand\listsectionexercises{%
\begin{itemize}[label={$\square$}]
\ForEachUsedExerciseByType{%
\ifnum\ExercisePropertyGet{##1}{##2}{step}=\value{section}%
\item %
\XSIMmixedcase{\GetExerciseName}\nobreakspace
\GetExerciseProperty{counter}%
{{\PropertyValue}}: %
\GetExerciseProperty{subtitle}%
{{\PropertyValue}}%
\dotfill
%Auto-évaluation
\begin{tikzpicture}
\foreach \k in {0,1,...,4}{
\draw (\k*0.5, 0) node[draw, star, star points=5, star point ratio=0.5]{};
}
\end{tikzpicture}
\fi
}%
\end{itemize}
}
\xsimsetup{
exercise/within = section,
exercise/the-counter = \arabic{exercise},
}