Skip to content

Commit

Permalink
fis issue #99
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Feb 14, 2022
1 parent b298281 commit 99d8b80
Show file tree
Hide file tree
Showing 12 changed files with 89 additions and 49 deletions.
4 changes: 4 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -200,3 +200,7 @@ HISTORY:
conditions. Resolves issue #94.
- new \ForEachUsedExerciseByOrder, used in the table
templates which resolves issue #85
v0.?? 2022/??/?? - add warning if an exercise tries to set a non-existing
property
- new \ForEachPrintedExerciseByOrder
- fix bug in \ForEachPrintedExerciseByID
2 changes: 1 addition & 1 deletion README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
--------------------------------------------------------------------------
XSIM 2022/02/12 v0.21
XSIM 2022/02/12 v0.21a
XSIMVERB 2022/02/12 v0.4

eXercise Sheets IMproved
Expand Down
2 changes: 0 additions & 2 deletions TODO
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
- check \printsolutions and \printsolutions*, also with all possible options
- reimplement headings options for \printcollection and \printrandomexercises ?
- check grading tables

2 changes: 1 addition & 1 deletion code/xsim.environments.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
% #3: exercise|solution
\prg_new_conditional:Npnn \xsim_if_exchange:nnn #1#2#3 {T,F,TF}
{
\str_if_eq:nnTF {#3} {solution}
\str_if_eq:nnTF {#3} {exercise}
{
\xsim_if_boolean_property:nnnTF {#1} {#2} {solution}
{ \prg_return_true: }
Expand Down
10 changes: 9 additions & 1 deletion code/xsim.interface.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,15 @@
\NewDocumentCommand \ForEachPrintedExerciseByID {+m}
{
\tl_set_eq:NN \XSIMtmp \ExerciseType
\xsim_foreach_exercise_id_type:nn {print} {#1}
\xsim_foreach_exercise_id_type:nn {printed} {#1}
\tl_set_eq:NN \ExerciseType \XSIMtmp
\tl_clear:N \XSIMtmp
}

\NewDocumentCommand \ForEachPrintedExerciseByOrder {+m}
{
\tl_set_eq:NN \XSIMtmp \ExerciseType
\xsim_foreach_exercise_type_order:nn {printed} {#1}
\tl_set_eq:NN \ExerciseType \XSIMtmp
\tl_clear:N \XSIMtmp
}
Expand Down
22 changes: 13 additions & 9 deletions code/xsim.properties.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -230,17 +230,21 @@
% #4: value
\cs_new_protected:Npn \__xsim_set_property:nnnn #1#2#3#4
{
\xsim_verbose:n
{
Setting~ property~ `#3'~ of~ exercise~ type~ `#1'~ id~ `#2'~ to~
value~ `#4'.
}
\xsim_if_property_noupdate:nF {#3}
\xsim_if_property_exist:nTF {#3}
{
\__xsim_remove_property_from_list:nnn {#1} {#2} {#3}
\xsim_add_to_list:nn {#3} {#1-#2=={#4}}
\xsim_verbose:n
{
Setting~ property~ `#3'~ of~ exercise~ type~ `#1'~ id~ `#2'~ to~
value~ `#4'.
}
\xsim_if_property_noupdate:nF {#3}
{
\__xsim_remove_property_from_list:nnn {#1} {#2} {#3}
\xsim_add_to_list:nn {#3} {#1-#2=={#4}}
}
\xsim_attribute_set:nnn {#1!#2} {#3} {#4}
}
\xsim_attribute_set:nnn {#1!#2} {#3} {#4}
{ \msg_error:nnn {xsim} {unknown-property} {#3} }
}
\cs_generate_variant:Nn \__xsim_set_property:nnnn {VVnV}

Expand Down
4 changes: 2 additions & 2 deletions code/xsim.start.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

\ExplSyntaxOn

\tl_const:Nn \c_xsim_date_tl {2022/02/12}
\tl_const:Nn \c_xsim_date_tl {2022/02/13}
\tl_const:Nn \c_xsim_version_major_number_tl {0}
\tl_const:Nn \c_xsim_version_minor_number_tl {21}
\tl_const:Nn \c_xsim_version_subrelease_tl {}
\tl_const:Nn \c_xsim_version_subrelease_tl {a}
\tl_const:Nx \c_xsim_version_number_tl
{
\c_xsim_version_major_number_tl .
Expand Down
38 changes: 25 additions & 13 deletions code/xsim.sty
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@

\ExplSyntaxOn

\tl_const:Nn \c_xsim_date_tl {2022/02/12}
\tl_const:Nn \c_xsim_date_tl {2022/02/13}
\tl_const:Nn \c_xsim_version_major_number_tl {0}
\tl_const:Nn \c_xsim_version_minor_number_tl {21}
\tl_const:Nn \c_xsim_version_subrelease_tl {}
\tl_const:Nn \c_xsim_version_subrelease_tl {a}
\tl_const:Nx \c_xsim_version_number_tl
{
\c_xsim_version_major_number_tl .
Expand Down Expand Up @@ -1035,17 +1035,21 @@
% #4: value
\cs_new_protected:Npn \__xsim_set_property:nnnn #1#2#3#4
{
\xsim_verbose:n
{
Setting~ property~ `#3'~ of~ exercise~ type~ `#1'~ id~ `#2'~ to~
value~ `#4'.
}
\xsim_if_property_noupdate:nF {#3}
\xsim_if_property_exist:nTF {#3}
{
\__xsim_remove_property_from_list:nnn {#1} {#2} {#3}
\xsim_add_to_list:nn {#3} {#1-#2=={#4}}
\xsim_verbose:n
{
Setting~ property~ `#3'~ of~ exercise~ type~ `#1'~ id~ `#2'~ to~
value~ `#4'.
}
\xsim_if_property_noupdate:nF {#3}
{
\__xsim_remove_property_from_list:nnn {#1} {#2} {#3}
\xsim_add_to_list:nn {#3} {#1-#2=={#4}}
}
\xsim_attribute_set:nnn {#1!#2} {#3} {#4}
}
\xsim_attribute_set:nnn {#1!#2} {#3} {#4}
{ \msg_error:nnn {xsim} {unknown-property} {#3} }
}
\cs_generate_variant:Nn \__xsim_set_property:nnnn {VVnV}

Expand Down Expand Up @@ -1613,7 +1617,7 @@
% #3: exercise|solution
\prg_new_conditional:Npnn \xsim_if_exchange:nnn #1#2#3 {T,F,TF}
{
\str_if_eq:nnTF {#3} {solution}
\str_if_eq:nnTF {#3} {exercise}
{
\xsim_if_boolean_property:nnnTF {#1} {#2} {solution}
{ \prg_return_true: }
Expand Down Expand Up @@ -5119,7 +5123,15 @@
\NewDocumentCommand \ForEachPrintedExerciseByID {+m}
{
\tl_set_eq:NN \XSIMtmp \ExerciseType
\xsim_foreach_exercise_id_type:nn {print} {#1}
\xsim_foreach_exercise_id_type:nn {printed} {#1}
\tl_set_eq:NN \ExerciseType \XSIMtmp
\tl_clear:N \XSIMtmp
}

\NewDocumentCommand \ForEachPrintedExerciseByOrder {+m}
{
\tl_set_eq:NN \XSIMtmp \ExerciseType
\xsim_foreach_exercise_type_order:nn {printed} {#1}
\tl_set_eq:NN \ExerciseType \XSIMtmp
\tl_clear:N \XSIMtmp
}
Expand Down
17 changes: 9 additions & 8 deletions doc/xsim-manual.cls
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
% please ignore the contents of this file -- it is not a good example for
% coding...
%
\ProvidesClass{xsim-manual}[2021/01/31]
\ProvidesClass{xsim-manual}[2022/02/13]

\LoadClass[load-preamble,add-index]{cnltx-doc}
\RequirePackage{imakeidx}
Expand Down Expand Up @@ -100,10 +100,12 @@
ExerciseType ,
ForeachExerciseTag ,
ForEachExerciseTranslation ,
ForEachPrintedExerciseByType ,
ForEachPrintedExerciseByID ,
ForEachUsedExerciseByType ,
ForEachPrintedExerciseByOrder ,
ForEachPrintedExerciseByType ,
ForEachUsedExerciseByID ,
ForEachUsedExerciseByOrder ,
ForEachUsedExerciseByType ,
GetExerciseAliasProperty ,
GetExerciseHeadingF ,
GetExerciseIdForProperty ,
Expand Down Expand Up @@ -250,11 +252,9 @@
xsim
} ,
pre-output = { \let\marginpar\marginnote } ,
add-listings-options = {
numberstyle = \tiny\noncopy
} ,
index-setup = { level = \section } ,
makeindex-setup = { columns = 2 , columnsep = 1em } ,
add-listings-options = { numberstyle = \tiny\noncopy } ,
index-setup = { level = \section , othercode = \footnotesize } ,
makeindex-setup = { columns = 3 , columnsep = 1em } ,
module-sep = {\texttt{/}}%
}

Expand Down Expand Up @@ -1004,6 +1004,7 @@
\xsim@add@version{0.20b} {2021-02-02}
\xsim@add@version{0.20c} {2021-02-03}
\xsim@add@version{0.21} {2022-02-12}
\xsim@add@version{0.21a} {2022-02-13}

% ----------------------------------------------------------------------------
\newrobustcmd*\xsimauxfileinfo{%
Expand Down
Binary file modified doc/xsim-manual.pdf
Binary file not shown.
35 changes: 24 additions & 11 deletions doc/xsim-manual.tex
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
% arara: pdflatex: { interaction: nonstopmode }
% arara: biber
% !arara: biber
% arara: pdflatex: { interaction: nonstopmode }
% arara: pdflatex: { interaction: nonstopmode }
% !arara: pdflatex: { interaction: nonstopmode }
Expand Down Expand Up @@ -1342,13 +1342,12 @@ \subsection{Background}
Those commands are explained in the next section. Their usage will hopefully
become clear in the examples in section~\vref{sec:template-examples}. Having
full control over the layout comes at a price: you need to be able to program
yourself in order to achieve certain layouts\footnote{I plan to incorporate
the most common layouts -- and maybe some fancy ones, too -- in the examples
section~\vref{sec:template-examples} but at the time of writing this is still
up in the air.}.
yourself in order to achieve certain layouts.

\subsection{Templates Provided by the Package}
\xsim\ comes with a few predefined layouts:
\xsim\ comes with a few predefined layouts. Most of them are available
through the style file \code{layouts} which is loaded by
\cs{loadxsimstyle}\Marg{layouts}.
\begin{description}
\item[\code{default}] The template activated per default and the only one
available without further action.
Expand All @@ -1368,7 +1367,8 @@ \subsection{Templates Provided by the Package}
\item[\code{centered}] A\sinceversion{0.18} layout with a centered heading.
Available through the style file \code{layouts}.
\end{description}


\xsimsetup{collect}
\collectexercises{layouts}
\begin{exercise}[subtitle=The Subtitle,points=2.5,ID=showlayout]
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Ut purus elit,
Expand Down Expand Up @@ -1582,6 +1582,19 @@ \subsubsection{Further Commands for Usage in Template Definitions}
\item \code{\#5}: the \property{points} property of the exercise
\item \code{\#6}: the \property{bonus-points} property of the exercise
\end{itemize}
\command{ForEachPrintedExerciseByOrder}[\marg{code}]
Loops\sinceversion{0.21a} over each \emph{printed} exercise ordered by the
exercise types and within each type by order of appearance. Inside
\meta{code} you can refer to several properties of the corresponding
exercise:
\begin{itemize}
\item \code{\#1}: the type of the exercise
\item \code{\#2}: the id of the exercise
\item \code{\#3}: the \property{counter} property of the exercise
\item \code{\#4}: the \property{subtitle} property of the exercise
\item \code{\#5}: the \property{points} property of the exercise
\item \code{\#6}: the \property{bonus-points} property of the exercise
\end{itemize}
\command{ForEachUsedExerciseByType}[\marg{code}]
Loops over each \emph{used} exercise ordered by the exercise types and
within each type by id. Inside \meta{code} you can refer to several
Expand Down Expand Up @@ -1984,7 +1997,7 @@ \subsubsection{The \code{default} Table Template}\label{sec:table-templ-default}
\XSIMtranslate{reached} \\
\midrule
}%
\ForEachUsedExerciseByType{%
\ForEachUsedExerciseByOrder{%
\XSIMifeqT{#1}{\ExerciseTableType{#1}}
{%
\XSIMifblankT{\ExerciseTableType{}}
Expand Down Expand Up @@ -2039,7 +2052,7 @@ \subsubsection{The \code{default*} Table Template}\label{sec:table-templ-default
{\XSIMmixedcase{\GetExerciseParameter{exercise-name}}}
&%
}%
\ForEachUsedExerciseByType{%
\ForEachUsedExerciseByOrder{%
\XSIMifeqT{#1}{\ExerciseTableType{#1}}
{
\XSIMifblankT{\ExerciseTableType{}}
Expand All @@ -2056,7 +2069,7 @@ \subsubsection{The \code{default*} Table Template}\label{sec:table-templ-default
\midrule
\XSIMmixedcase{\XSIMtranslate{points}} &
}%
\ForEachUsedExerciseByType{%
\ForEachUsedExerciseByOrder{%
\XSIMifeqT{#1}{\ExerciseTableType{#1}}
{%
\XSIMputright\ExerciseTableCode{%
Expand All @@ -2070,7 +2083,7 @@ \subsubsection{The \code{default*} Table Template}\label{sec:table-templ-default
\\ \midrule
\XSIMtranslate{reached} &%
}%
\ForEachUsedExerciseByType{%
\ForEachUsedExerciseByOrder{%
\XSIMifeqT{#1}{\ExerciseTableType{#1}}
{\XSIMputright\ExerciseTableCode{&}}%
}%
Expand Down
2 changes: 1 addition & 1 deletion xsim.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ moduleext="code.tex"
styname="${pkgname}.sty"
verbname="${pkgname}verb.sty"
layoutsname="${pkgname}.style.layouts.code.tex"
program="arara --verbose"
program="arara"
manualfile="${pkgname}-manual"
zipname="$pkgname"

Expand Down

0 comments on commit 99d8b80

Please sign in to comment.