2022-2023/tools/style/myXsim.sty

193 lines
5.1 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}%
}%
}
% Annexes
\DeclareExerciseProperty{annexe}
\NewDocumentEnvironment{annexe}{+b}
{%
\edef\ExerciseType{\csname g_xsim_exercise_type_tl\endcsname}%
\edef\ExerciseID{\csname g_xsim_exercise_id_tl\endcsname}%
\SetExerciseProperty{annexe}{#1}%
}
{}
\newcommand\printannexes{%
\ForEachUsedExerciseByType{%
\GetExercisePropertyT{annexe}
{\subsection*{Annexe de l'exercice ##3}
####1
}%
}%
}
% Coup de pouces
\DeclareExerciseProperty{hint}
\NewDocumentEnvironment{hint}{+b}
{%
\edef\ExerciseType{\csname g_xsim_exercise_type_tl\endcsname}%
\edef\ExerciseID{\csname g_xsim_exercise_id_tl\endcsname}%
\SetExerciseProperty{hint}{#1}%
}
{}
\newcommand\printhints{%
\ForEachUsedExerciseByType{%
\GetExercisePropertyT{hint}
{\subsection*{Coup de pouce pour Ex:##3}
####1
}%
}%
}
\newcommand\printsectionexercises{%
\ForEachUsedExerciseByType{%
\ifnum\ExercisePropertyGet{##1}{##2}{step}=\value{section}
\printexercise{exercise}{##2}
\fi
}%
}
\newcommand\selfevaluation{%
\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}
}
\newcommand\listsectionexercises{%
\begin{itemize}[label={$\square$}]
\ForEachUsedExerciseByType{%
\ifnum\ExercisePropertyGet{##1}{##2}{step}=\value{section}%
\item %
\GetExerciseProperty{mode}%
{{\PropertyValue}}\;%
\XSIMmixedcase{\GetExerciseName}\nobreakspace
\GetExerciseProperty{counter}%
{{\PropertyValue}}%
: %
\GetExerciseProperty{subtitle}%
{{\PropertyValue}}%
\dotfill
\selfevaluation
\fi
}%
\end{itemize}
}
\xsimsetup{
exercise/within = section,
exercise/the-counter = \arabic{exercise},
}
\newcommand\searchMode{\faIcon{search}}
\newcommand\groupMode{\faIcon{users}}
\newcommand\trainMode{\faIcon{tools}}
\newcommand\projectMode{\faIcon{sitemap}}
\newcommand\infoMode{\faIcon{desktop}}
\newcommand\computerMode{\faIcon{desktop}}
\newcommand\paperMode{\faIcon{leanpub}}
\newcommand\legendMode{%
\textbf{Légende:} \hfill
\searchMode: pour découvrir quelque chose
\hfill
\groupMode: à faire en groupe
\hfill
\trainMode: pour s'entrainer
}