Skip to content

Instantly share code, notes, and snippets.

@N-Coder
Created November 4, 2019 15:36
Show Gist options
  • Save N-Coder/1441aaf7d468045c516723ccacdd8845 to your computer and use it in GitHub Desktop.
Save N-Coder/1441aaf7d468045c516723ccacdd8845 to your computer and use it in GitHub Desktop.
XSIM \printexercise problems
\relax
\providecommand\XSIM[1]{}
\providecommand\numberofexercises{}
\XSIM {goal}{exercise}{points}{0}
\XSIM {totalgoal}{points}{0}
\XSIM {goal}{exercise}{bonus-points}{0}
\XSIM {totalgoal}{bonus-points}{0}
\XSIM {collection:all exercises}{exercise-1||exercise-2||exercise-3||exercise-4||exercise-5||exercise-6}
\XSIM {collection:foo}{exercise-1||exercise-2||exercise-3||exercise-4||exercise-5||exercise-6}
\XSIM {total-number}{6}
\XSIM {exercise}{6}
\XSIM {types}{exercise}
\XSIM {id}{exercise-1=={1}||exercise-2=={2}||exercise-3=={3}||exercise-4=={4}||exercise-5=={5}||exercise-6=={6}}
\XSIM {ID}{exercise-1=={1}||exercise-2=={2}||exercise-3=={3}||exercise-4=={4}||exercise-5=={5}||exercise-6=={6}}
\XSIM {counter}{exercise-\foundid =={1}||exercise-2=={1}}
\XSIM {counter-value}{exercise-\foundid =={1}||exercise-2=={1}}
\XSIM {print}{exercise-1=={false}||exercise-3=={false}||exercise-4=={false}||exercise-5=={false}||exercise-6=={false}||exercise-2=={true}||exercise-\foundid =={true}}
\XSIM {use}{exercise-1=={true}||exercise-2=={true}||exercise-3=={true}||exercise-4=={true}||exercise-5=={true}||exercise-6=={true}}
\XSIM {used}{exercise-1=={false}||exercise-3=={false}||exercise-4=={false}||exercise-5=={false}||exercise-6=={false}||exercise-2=={true}||exercise-\foundid =={true}}
\XSIM {section-value}{exercise-\foundid =={0}||exercise-1=={0}||exercise-3=={0}||exercise-4=={0}||exercise-5=={0}||exercise-6=={0}||exercise-2=={0}}
\XSIM {section}{exercise-\foundid =={0}||exercise-1=={0}||exercise-3=={0}||exercise-4=={0}||exercise-5=={0}||exercise-6=={0}||exercise-2=={0}}
\XSIM {sectioning}{exercise-1=={{0}{0}{0}{0}{0}}||exercise-2=={{0}{0}{0}{0}{0}}||exercise-3=={{0}{0}{0}{0}{0}}||exercise-4=={{0}{0}{0}{0}{0}}||exercise-5=={{0}{0}{0}{0}{0}}||exercise-6=={{0}{0}{0}{0}{0}}}
\XSIM {subtitle}{exercise-2=={Zweite}||exercise-4=={Die Vierte}}
\XSIM {points}{}
\XSIM {bonus-points}{}
\XSIM {page-value}{exercise-\foundid =={1}||exercise-1=={1}||exercise-3=={1}||exercise-4=={1}||exercise-5=={1}||exercise-6=={1}||exercise-2=={1}}
\XSIM {page}{exercise-\foundid =={1}||exercise-1=={1}||exercise-3=={1}||exercise-4=={1}||exercise-5=={1}||exercise-6=={1}||exercise-2=={1}}
\XSIM {tags}{}
\XSIM {topics}{}
\XSIM {title}{exercise-1=={Erste}||exercise-3=={W\"eird ßt$u$ff}||exercise-4=={Vierte}||exercise-5=={Letzte}||exercise-6=={Letzte}}
\documentclass{article}
\usepackage{xsim}
\usepackage{ifthen}
\DeclareExerciseProperty!{title}
\newcommand{\printexercisewithtitle}[1]{%
\edef\foundid{\GetExerciseIdForProperty{title}{#1}}%
\ifthenelse{\equal{\foundid}{}}{%
No exercise with title "#1" found!\\
}{%
\printexercise{exercise}{\foundid}%
}%
}
\DeclareExerciseCollection{foo}
\begin{document}
\collectexercises{foo}
\begin{exercise}[title={Erste}]
The first exercise is added to the collection `foo'.
\end{exercise}
\begin{exercise}[subtitle={Zweite}]
The second exercise is also added to the collection `foo'.
\end{exercise}
\begin{exercise}[title={W\"eird ßt$u$ff}]
So is the third. (W\"eird ßt$u$ff)
\end{exercise}
\begin{exercise}[title={Vierte},subtitle={Die Vierte}]
As is the fourth.
\end{exercise}
\begin{exercise}[title={Letzte}]
As well as the last one.
\end{exercise}
\begin{exercise}[title={Letzte}]
A duplicate!
\end{exercise}
\collectexercisesstop{foo}
Start
\printexercisewithtitle{Erste}
% \printexercisewithtitle{Zweite}
\printexercise{exercise}{2}%
\printexercisewithtitle{W\"eird ßt$u$ff}
\printexercisewithtitle{Vierte}
\printexercisewithtitle{Letzte}
End
\end{document}
\relax
\providecommand\XSIM[1]{}
\providecommand\numberofexercises{}
\XSIM {goal}{exercise}{points}{0}
\XSIM {totalgoal}{points}{0}
\XSIM {goal}{exercise}{bonus-points}{0}
\XSIM {totalgoal}{bonus-points}{0}
\XSIM {collection:all exercises}{exercise-1||exercise-2||exercise-3||exercise-4||exercise-5||exercise-6}
\XSIM {collection:foo}{exercise-1||exercise-2||exercise-3||exercise-4||exercise-5||exercise-6}
\XSIM {total-number}{6}
\XSIM {exercise}{6}
\XSIM {types}{exercise}
\XSIM {id}{exercise-1=={1}||exercise-2=={2}||exercise-3=={3}||exercise-4=={4}||exercise-5=={5}||exercise-6=={6}}
\XSIM {ID}{exercise-1=={1}||exercise-2=={2}||exercise-3=={3}||exercise-4=={4}||exercise-5=={5}||exercise-6=={6}}
\XSIM {counter}{exercise-\GetExerciseIdForProperty {title}{Erste}=={1}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={3}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={4}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={5}||exercise-2=={1}}
\XSIM {counter-value}{exercise-\GetExerciseIdForProperty {title}{Erste}=={1}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={3}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={4}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={5}||exercise-2=={1}}
\XSIM {print}{exercise-1=={false}||exercise-3=={false}||exercise-4=={false}||exercise-5=={false}||exercise-6=={false}||exercise-\GetExerciseIdForProperty {title}{Erste}=={true}||exercise-2=={true}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={true}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={true}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={true}}
\XSIM {use}{exercise-1=={true}||exercise-2=={true}||exercise-3=={true}||exercise-4=={true}||exercise-5=={true}||exercise-6=={true}}
\XSIM {used}{exercise-1=={false}||exercise-3=={false}||exercise-4=={false}||exercise-5=={false}||exercise-6=={false}||exercise-\GetExerciseIdForProperty {title}{Erste}=={true}||exercise-2=={true}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={true}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={true}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={true}}
\XSIM {section-value}{exercise-\GetExerciseIdForProperty {title}{Erste}=={0}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={0}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={0}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={0}||exercise-1=={0}||exercise-3=={0}||exercise-4=={0}||exercise-5=={0}||exercise-6=={0}||exercise-2=={0}}
\XSIM {section}{exercise-\GetExerciseIdForProperty {title}{Erste}=={0}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={0}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={0}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={0}||exercise-1=={0}||exercise-3=={0}||exercise-4=={0}||exercise-5=={0}||exercise-6=={0}||exercise-2=={0}}
\XSIM {sectioning}{exercise-1=={{0}{0}{0}{0}{0}}||exercise-2=={{0}{0}{0}{0}{0}}||exercise-3=={{0}{0}{0}{0}{0}}||exercise-4=={{0}{0}{0}{0}{0}}||exercise-5=={{0}{0}{0}{0}{0}}||exercise-6=={{0}{0}{0}{0}{0}}}
\XSIM {subtitle}{exercise-2=={Zweite}||exercise-4=={Die Vierte}}
\XSIM {points}{}
\XSIM {bonus-points}{}
\XSIM {page-value}{exercise-\GetExerciseIdForProperty {title}{Erste}=={1}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={1}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={1}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={1}||exercise-1=={1}||exercise-3=={1}||exercise-4=={1}||exercise-5=={1}||exercise-6=={1}||exercise-2=={1}}
\XSIM {page}{exercise-\GetExerciseIdForProperty {title}{Erste}=={1}||exercise-\GetExerciseIdForProperty {title}{W\"eird ßt$u$ff}=={1}||exercise-\GetExerciseIdForProperty {title}{Vierte}=={1}||exercise-\GetExerciseIdForProperty {title}{Letzte}=={1}||exercise-1=={1}||exercise-3=={1}||exercise-4=={1}||exercise-5=={1}||exercise-6=={1}||exercise-2=={1}}
\XSIM {tags}{}
\XSIM {topics}{}
\XSIM {title}{exercise-1=={Erste}||exercise-3=={W\"eird ßt$u$ff}||exercise-4=={Vierte}||exercise-5=={Letzte}||exercise-6=={Letzte}}
\documentclass{article}
\usepackage{xsim}
\usepackage{ifthen}
\DeclareExerciseProperty!{title}
% \newcommand{\printexercisewithtitle}[1]{%
% \edef\foundid{\GetExerciseIdForProperty{title}{#1}}%
% \ifthenelse{\equal{\foundid}{}}{%
% No exercise with title "#1" found!\\
% }{%
% \printexercise{exercise}{\foundid}%
% }%
% }
\newcommand{\printexercisewithtitle}[1]{%
\printexercisewithtitleproxy
{#1}
{\GetExerciseIdForProperty{title}{#1}}%
}
\newcommand{\printexercisewithtitleproxy}[2]{%
\ifthenelse{\equal{#2}{}}{%
No exercise with title "#1" found!\\
}{%
\printexercise{exercise}{#2}%
}%
}
\DeclareExerciseCollection{foo}
\begin{document}
\collectexercises{foo}
\begin{exercise}[title={Erste}]
The first exercise is added to the collection `foo'.
\end{exercise}
\begin{exercise}[subtitle={Zweite}]
The second exercise is also added to the collection `foo'.
\end{exercise}
\begin{exercise}[title={W\"eird ßt$u$ff}]
So is the third. (W\"eird ßt$u$ff)
\end{exercise}
\begin{exercise}[title={Vierte},subtitle={Die Vierte}]
As is the fourth.
\end{exercise}
\begin{exercise}[title={Letzte}]
As well as the last one.
\end{exercise}
\begin{exercise}[title={Letzte}]
A duplicate!
\end{exercise}
\collectexercisesstop{foo}
Start
\printexercisewithtitle{Erste}
% \printexercisewithtitle{Zweite}
\printexercise{exercise}{2}%
\printexercisewithtitle{W\"eird ßt$u$ff}
\printexercisewithtitle{Vierte}
\printexercisewithtitle{Letzte}
End
\end{document}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment