Skip to content

Commit

Permalink
counter exercises in a collection
Browse files Browse the repository at this point in the history
  • Loading branch information
cgnieder committed Apr 7, 2021
1 parent 4f4470d commit f002681
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
2 changes: 2 additions & 0 deletions HISTORY
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,5 @@ HISTORY:
solution files
- add option <tag>/use-unmatched
- document option `blank/fill'
- add counter foreach type and collection that holds the
number of exercises of a type in a collection
21 changes: 20 additions & 1 deletion code/xsim.collections.code.tex
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,26 @@
\xsim_attribute_set:nnn {collection:conditions} {#1} {#2}
\seq_gput_right:Nn \g__xsim_collections_seq {#1}
\xsim_new_list:n {collection:#1}
\xsim_before_begin_document:n
{
\xsim_foreach_exercise_type:n
{
\int_new:c {g_xsim_collection_##1_in_#1_int}
\newcounter {total##1in#1}
}
}
\xsim_at_end_document:n
{ \xsim_update_list:n {collection:#1} }
{
\xsim_update_list:n {collection:#1}
\xsim_foreach_exercise_type:n
{
\xsim_write_to_aux:x
{
\token_to_str:N \setcounter {total##1in#1}
{ \int_use:c {g_xsim_collection_##1_in_#1_int} }
}
}
}
}
}

Expand Down Expand Up @@ -247,6 +265,7 @@
{ \clist_put_right:Nn \l__xsim_tmpa_clist {#1} }
\xsim_set_property:nnnV {#2} {#3} {collections} \l__xsim_tmpa_clist
\xsim_add_to_list:nn {collection:#1} {#2-#3}
\int_gincr:c {g_xsim_collection_#2_in_#1_int}
}

% ----------------------------------------------------------------------------
Expand Down
21 changes: 20 additions & 1 deletion code/xsim.sty
Original file line number Diff line number Diff line change
Expand Up @@ -3635,8 +3635,26 @@
\xsim_attribute_set:nnn {collection:conditions} {#1} {#2}
\seq_gput_right:Nn \g__xsim_collections_seq {#1}
\xsim_new_list:n {collection:#1}
\xsim_before_begin_document:n
{
\xsim_foreach_exercise_type:n
{
\int_new:c {g_xsim_collection_##1_in_#1_int}
\newcounter {total##1in#1}
}
}
\xsim_at_end_document:n
{ \xsim_update_list:n {collection:#1} }
{
\xsim_update_list:n {collection:#1}
\xsim_foreach_exercise_type:n
{
\xsim_write_to_aux:x
{
\token_to_str:N \setcounter {total##1in#1}
{ \int_use:c {g_xsim_collection_##1_in_#1_int} }
}
}
}
}
}

Expand Down Expand Up @@ -3828,6 +3846,7 @@
{ \clist_put_right:Nn \l__xsim_tmpa_clist {#1} }
\xsim_set_property:nnnV {#2} {#3} {collections} \l__xsim_tmpa_clist
\xsim_add_to_list:nn {collection:#1} {#2-#3}
\int_gincr:c {g_xsim_collection_#2_in_#1_int}
}

% ----------------------------------------------------------------------------
Expand Down

0 comments on commit f002681

Please sign in to comment.