Skip to content

Commit

Permalink
resolve #85
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Feb 12, 2022
1 parent f711fcd commit 9829f95
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 11 deletions.
4 changes: 4 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -196,3 +196,7 @@ HISTORY:
- implement issue #88
- fix issue #96
- `use!' and `print!' had gone lost. Add them back in.
- add new options `match-all'/`match-any' for the collection
conditions. Resolves issue #94.
- new \ForEachUsedExerciseByOrder, used in the table
templates which resolves issue #85
2 changes: 1 addition & 1 deletion code/xsim.auxfile.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
{ \seq_gremove_all:cV {g__xsim_list_#1_seq} \l__xsim_tmpa_str }
\seq_gput_right:cV {g__xsim_list_#1_seq} \l__xsim_tmpa_str
}
\cs_generate_variant:Nn \xsim_add_to_list:nn {nx}
\cs_generate_variant:Nn \xsim_add_to_list:nn {nx,nV}

% #1: name
% #2: entry
Expand Down
1 change: 1 addition & 0 deletions code/xsim.collections.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
\keys_define:nn {xsim/collection/#1}
{
match-all .bool_set:c = {l__xsim_collection_#1_condition_all_bool} ,
match-all .initial:n = true ,
match-any .bool_set_inverse:c = {l__xsim_collection_#1_condition_all_bool}
}
\xsim_before_begin_document:n
Expand Down
8 changes: 4 additions & 4 deletions code/xsim.definitions.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
{ \XSIMmixedcase { \GetExerciseParameter {exercise-name} } }
&
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{
Expand All @@ -227,7 +227,7 @@
\XSIMtranslate {total} \\
\midrule \XSIMmixedcase { \XSIMtranslate {points} } &
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{
Expand All @@ -243,7 +243,7 @@
\\ \midrule
\XSIMtranslate {reached} &
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{ \XSIMputright \ExerciseTableCode {&} }
Expand Down Expand Up @@ -275,7 +275,7 @@
\XSIMtranslate {reached} \\
\midrule
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{
Expand Down
16 changes: 16 additions & 0 deletions code/xsim.exercises.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@
% ----------------------------------------------------------------------------

\xsim_new_list:n {types}
\xsim_new_list:n {order}
\xsim_at_end_document:n { \xsim_update_list:n {order} }
\xsim_new_list:n {idtypes}

% #1: true|false (fixed parameter)
Expand Down Expand Up @@ -224,6 +226,9 @@
\cs_new_protected:Npn \xsim_foreach_exercise_id:n #1
{ \int_step_inline:nnnn {1} {1} { \g_xsim_max_id_int } {#1} }

\cs_new_protected:Npn \xsim_foreach_exercise_order:n #1
{ \xsim_foreach_new_list_entry:nn {order} {#1} }

% #1: macro name
% #2: 0 to 9 times `n' (= number of arguments of internal item)
% #3: code; may contain a suiting \__xsim_loop_item:<nnn>
Expand Down Expand Up @@ -270,6 +275,16 @@
}
}

\xsim_define_loop_macro:Nnn \xsim_foreach_exercise_type_order:nn
{nnnnnn}
{
\xsim_foreach_exercise_type:n
{
\xsim_foreach_exercise_order:n
{ \__xsim_deliver_exercise_details:nnn {##1} {####1} {#1} }
}
}

\xsim_define_loop_macro:Nnn \xsim_foreach_exercise_id_type:nn
{nnnnnn}
{
Expand Down Expand Up @@ -683,6 +698,7 @@
}
\xsim_exercise_if_use:nVT {#1} \g_xsim_exercise_id_tl
{
\xsim_add_to_list:nV {order} \g_xsim_exercise_id_tl
\xsim_set_property:nVnn {#1} \g_xsim_exercise_id_tl {(used)} {true}
\xsim_set_property:nVnn {#1} \g_xsim_exercise_id_tl {used} {true}
\xsim_update_goals:nV {#1} \g_xsim_exercise_id_tl
Expand Down
8 changes: 8 additions & 0 deletions code/xsim.interface.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,14 @@
\tl_clear:N \XSIMtmp
}

\NewDocumentCommand \ForEachUsedExerciseByOrder {+m}
{
\tl_set_eq:NN \XSIMtmp \ExerciseType
\xsim_foreach_exercise_type_order:nn {used} {#1}
\tl_set_eq:NN \ExerciseType \XSIMtmp
\tl_clear:N \XSIMtmp
}

% ----------------------------------------------------------------------------

\NewDocumentCommand \DeclareExerciseTranslations {mm}
Expand Down
36 changes: 31 additions & 5 deletions code/xsim.sty
Original file line number Diff line number Diff line change
Expand Up @@ -730,7 +730,7 @@
{ \seq_gremove_all:cV {g__xsim_list_#1_seq} \l__xsim_tmpa_str }
\seq_gput_right:cV {g__xsim_list_#1_seq} \l__xsim_tmpa_str
}
\cs_generate_variant:Nn \xsim_add_to_list:nn {nx}
\cs_generate_variant:Nn \xsim_add_to_list:nn {nx,nV}

% #1: name
% #2: entry
Expand Down Expand Up @@ -2568,6 +2568,8 @@
% ----------------------------------------------------------------------------

\xsim_new_list:n {types}
\xsim_new_list:n {order}
\xsim_at_end_document:n { \xsim_update_list:n {order} }
\xsim_new_list:n {idtypes}

% #1: true|false (fixed parameter)
Expand Down Expand Up @@ -2711,6 +2713,9 @@
\cs_new_protected:Npn \xsim_foreach_exercise_id:n #1
{ \int_step_inline:nnnn {1} {1} { \g_xsim_max_id_int } {#1} }

\cs_new_protected:Npn \xsim_foreach_exercise_order:n #1
{ \xsim_foreach_new_list_entry:nn {order} {#1} }

% #1: macro name
% #2: 0 to 9 times `n' (= number of arguments of internal item)
% #3: code; may contain a suiting \__xsim_loop_item:<nnn>
Expand Down Expand Up @@ -2757,6 +2762,16 @@
}
}

\xsim_define_loop_macro:Nnn \xsim_foreach_exercise_type_order:nn
{nnnnnn}
{
\xsim_foreach_exercise_type:n
{
\xsim_foreach_exercise_order:n
{ \__xsim_deliver_exercise_details:nnn {##1} {####1} {#1} }
}
}

\xsim_define_loop_macro:Nnn \xsim_foreach_exercise_id_type:nn
{nnnnnn}
{
Expand Down Expand Up @@ -3168,8 +3183,10 @@
\xsim_set_property:nVnn {#1} \g_xsim_exercise_id_tl {(printed)} {true}
\xsim_set_property:nVnn {#1} \g_xsim_exercise_id_tl {printed} {true}
}
% TODO: add to some type of order list, cf. issue #85
\xsim_exercise_if_use:nVT {#1} \g_xsim_exercise_id_tl
{
\xsim_add_to_list:nV {order} \g_xsim_exercise_id_tl
\xsim_set_property:nVnn {#1} \g_xsim_exercise_id_tl {(used)} {true}
\xsim_set_property:nVnn {#1} \g_xsim_exercise_id_tl {used} {true}
\xsim_update_goals:nV {#1} \g_xsim_exercise_id_tl
Expand Down Expand Up @@ -3672,6 +3689,7 @@
\keys_define:nn {xsim/collection/#1}
{
match-all .bool_set:c = {l__xsim_collection_#1_condition_all_bool} ,
match-all .initial:n = true ,
match-any .bool_set_inverse:c = {l__xsim_collection_#1_condition_all_bool}
}
\xsim_before_begin_document:n
Expand Down Expand Up @@ -5123,6 +5141,14 @@
\tl_clear:N \XSIMtmp
}

\NewDocumentCommand \ForEachUsedExerciseByOrder {+m}
{
\tl_set_eq:NN \XSIMtmp \ExerciseType
\xsim_foreach_exercise_type_order:nn {used} {#1}
\tl_set_eq:NN \ExerciseType \XSIMtmp
\tl_clear:N \XSIMtmp
}

% ----------------------------------------------------------------------------

\NewDocumentCommand \DeclareExerciseTranslations {mm}
Expand Down Expand Up @@ -5524,7 +5550,7 @@
{ \XSIMmixedcase { \GetExerciseParameter {exercise-name} } }
&
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{
Expand All @@ -5544,7 +5570,7 @@
\XSIMtranslate {total} \\
\midrule \XSIMmixedcase { \XSIMtranslate {points} } &
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{
Expand All @@ -5560,7 +5586,7 @@
\\ \midrule
\XSIMtranslate {reached} &
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{ \XSIMputright \ExerciseTableCode {&} }
Expand Down Expand Up @@ -5592,7 +5618,7 @@
\XSIMtranslate {reached} \\
\midrule
}
\ForEachUsedExerciseByType
\ForEachUsedExerciseByOrder
{
\XSIMifeqT {#1} { \ExerciseTableType {#1} }
{
Expand Down
14 changes: 13 additions & 1 deletion doc/xsim-manual.tex
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,8 @@ \subsection{Declaring Own Properties}
\DeclareExerciseTagging{topics}
\xsimsetup{tags/ignore-untagged=false}
\end{sourcecode}
This means that these options are available:
For each new tag new options are defined and available. They are described
for the two predefined tags:
\begin{options}
\keyval{tags}{csv list of tags}
Choose the set of tags whose associated exercises should be printed.
Expand Down Expand Up @@ -987,6 +988,17 @@ \subsubsection{Declaring collections}
exercises which fit the tags are automatically added to the new
collection.
\end{commands}
You\sinceversion{0.21} have a choice whether \emph{any} or \emph{all} of the
tags sould match. So \Oarg{topics=algebra,level=1} should probably match
\emph{all} conditions but the choice is up to you. For each defined collection
an option exists:
\begin{options}
\keybool{match-all}\Module{collection/\meta{name}}\Default{true}
If set to \code{true} \emph{all} conditions must be met.
\keybool{match-any}\Module{collection/\meta{name}}\Default{false}
The inverse option to \option{match-all}. If set to \code{true} \emph{any} of
the conditions must be met.
\end{options}

\subsubsection{Activating collections}
If a collection is not activated per default in can be activated (or
Expand Down

0 comments on commit 9829f95

Please sign in to comment.