cgnieder / xsim

eXercise Sheets IMproved
67 stars 23 forks source link

\DeclareExerciseCollection works not as expected #94

Closed mschneiderwng closed 2 years ago

mschneiderwng commented 2 years ago

From the example in the manual, I would expect that

\DeclareExerciseCollection[topics=algebra,level=1]{easy-algebra}

selects all exercises which have the topic algebra and are level 1 questions. However, it seems that algebra or are level 1 questions are selected. Is there a way to make the former work such that one the first question is printed in the example below?

\documentclass[a4paper]{article}
\usepackage{xsim}

\begin{filecontents}{exercises.tex}
\begin{exercise}[topics=algebra, level=1]
    algebra question 1 level=1
\end{exercise}
\begin{exercise}[topics=calculus, level=1]
    calculus question 1 level=1
\end{exercise}
\begin{exercise}[topics=algebra, level=2]
    algebra question 2 level=2
\end{exercise}
\end{filecontents}

\xsimsetup{collect}
\DeclareExerciseTagging{level}
\DeclareExerciseCollection[topics=algebra,level=1]{easy-algebra}

\begin{document}
\section{Exercises}
\input{exercises.tex}

\printcollection{easy-algebra}

\end{document}
cgnieder commented 2 years ago

This is probably the same bug as #95

cgnieder commented 2 years ago

Currently, the optional argument filters exercises with or. This means an exercise is added if any of the tags match.

I admit that this behaviour is not intuitive and not clearly documented. Also, I think a user should have a choice whether any or all conditions should match.

cgnieder commented 2 years ago

In the next release the following code:

\documentclass[a4paper]{article}
\usepackage[use-aux]{xsim}

\DeclareExerciseTagging{level}
\DeclareExerciseCollection[topics=algebra,level=1]{easy-algebra}

\xsimsetup{
  collection/easy-algebra/match-all ,
  collect
}

\begin{document}

\section{Exercises}

\collectexercises{easy-algebra}
\begin{exercise}[topics=algebra, level=1]
  algebra question 1 level=1
\end{exercise}
\begin{exercise}[topics=calculus, level=1]
  calculus question 1 level=1
\end{exercise}
\begin{exercise}[topics=algebra, level=2]
  algebra question 2 level=2
\end{exercise}
\collectexercisesstop{easy-algebra}

\printcollection{easy-algebra}

\end{document}

will give

grafik

cgnieder commented 2 years ago

BTW: match-all will be the default behaviour