summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/exsheets
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-09-08 21:58:30 +0000
committerKarl Berry <karl@freefriends.org>2016-09-08 21:58:30 +0000
commit7c9bd99e29ba8005ab0135a0738cda1317e7d084 (patch)
tree249f66004e13117b5721119c2e8928558c01a294 /Master/texmf-dist/tex/latex/exsheets
parenteb5d69057bb902b9ffd821190480336e56c2e081 (diff)
exsheets (8sep16)
git-svn-id: svn://tug.org/texlive/trunk@42020 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/exsheets')
-rw-r--r--Master/texmf-dist/tex/latex/exsheets/exsheets.sty161
1 files changed, 77 insertions, 84 deletions
diff --git a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
index 9509f543385..09df4ddcab7 100644
--- a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
+++ b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
@@ -28,8 +28,8 @@
\RequirePackage { expl3 , xparse }
\ExplSyntaxOn
-\tl_const:Nn \c_exsheets_date_tl {2016/08/14}
-\tl_const:Nn \c_exsheets_version_tl {0.21d}
+\tl_const:Nn \c_exsheets_date_tl {2016/09/07}
+\tl_const:Nn \c_exsheets_version_tl {0.21e}
\tl_const:Nn \c_exsheets_info_tl
{Yet~ another~ package~ for~ the~ creation~ of~ exercise~ sheets~ and~ exams.}
@@ -228,11 +228,10 @@
\bool_new:N \l__exsheets_include_random_bool
\bool_new:N \l__exsheets_include_by_id_bool
\bool_set_true:N \l__exsheets_include_all_bool
+\bool_new:N \l__exsheets_include_questions_no_duplicates_bool
\bool_new:N \l__exsheets_use_selection_bool
\bool_new:N \l__exsheets_solutions_print_bool
\bool_set_false:N \l__exsheets_solutions_print_bool
-\bool_new:N \l__exsheets_solutions_print_here_bool
-\bool_set_false:N \l__exsheets_solutions_print_here_bool
\bool_new:N \l__exsheets_solutions_print_section_bool
\bool_set_false:N \l__exsheets_solutions_print_section_bool
\bool_new:N \l__exsheets_solutions_print_chapter_bool
@@ -1138,40 +1137,43 @@
!\l__exsheets_questions_deactivate_bool
}
{
- % label:
- \tl_if_blank:VTF \l__exsheets_questions_label_tl
+ \exsheets_if_current_question_is_used:T
{
- \bool_if:NT \l__exsheets_auto_label_bool
+ % label:
+ \tl_if_blank:VTF \l__exsheets_questions_label_tl
{
- \exsheets_label:V \g__exsheets_questions_current_id_tl
- \exsheets_set_ref_properties:V \CurrentQuestionID
+ \bool_if:NT \l__exsheets_auto_label_bool
+ {
+ \exsheets_label:V \g__exsheets_questions_current_id_tl
+ \exsheets_set_ref_properties:V \CurrentQuestionID
+ }
}
- }
- {
- \exsheets_label:V \l__exsheets_questions_label_tl
- \exsheets_set_ref_properties:V \l__exsheets_questions_label_tl
- }
- \__exsheets_save_number_in:N \g_exsheets_question_identification_prop
- % TODO: don't print, only save if \l__exsheets_questions_print_bool is false
- \__exsheets_save_and_print_question_body:VVV
- \BODY
- \l__exsheets_questions_pre_body_hook_tl
- \l__exsheets_questions_post_body_hook_tl
- \exsheets_set_question_properties:x
- {
- \tl_if_blank:VF \l__exsheets_questions_subtitle_tl
- { subtitle = { \exp_not:V \l__exsheets_questions_subtitle_tl } , }
- counter = \l__exsheets_qu_counter_interpretation_tl ,
- % number = \int_to_arabic:V \g__exsheets_questions_id_int ,
- \bool_if:NF \l__exsheets_points_questions_default_bool
{
- \fp_compare:nT { \g__exsheets_this_question_points_fp > 0 }
- { points = \fp_to_decimal:N \g__exsheets_this_question_points_fp , }
- \fp_compare:nT { \g__exsheets_this_question_bonus_fp > 0 }
- { bonus-points = \fp_to_decimal:N \g__exsheets_this_question_bonus_fp }
+ \exsheets_label:V \l__exsheets_questions_label_tl
+ \exsheets_set_ref_properties:V \l__exsheets_questions_label_tl
}
+ \__exsheets_save_number_in:N \g_exsheets_question_identification_prop
+ % TODO: don't print, only save if \l__exsheets_questions_print_bool is false
+ \__exsheets_save_and_print_question_body:VVV
+ \BODY
+ \l__exsheets_questions_pre_body_hook_tl
+ \l__exsheets_questions_post_body_hook_tl
+ \exsheets_set_question_properties:x
+ {
+ \tl_if_blank:VF \l__exsheets_questions_subtitle_tl
+ { subtitle = { \exp_not:V \l__exsheets_questions_subtitle_tl } , }
+ counter = \l__exsheets_qu_counter_interpretation_tl ,
+ % number = \int_to_arabic:V \g__exsheets_questions_id_int ,
+ \bool_if:NF \l__exsheets_points_questions_default_bool
+ {
+ \fp_compare:nT { \g__exsheets_this_question_points_fp > 0 }
+ { points = \fp_to_decimal:N \g__exsheets_this_question_points_fp , }
+ \fp_compare:nT { \g__exsheets_this_question_bonus_fp > 0 }
+ { bonus-points = \fp_to_decimal:N \g__exsheets_this_question_bonus_fp }
+ }
+ }
+ \bool_if:NT \l__exsheets_questions_print_bool {#2}
}
- \bool_if:NT \l__exsheets_questions_print_bool {#2}
}
}
@@ -1308,6 +1310,7 @@
% Optionen:
\tl_if_blank:nF {#1} { \keys_set:nn { exsheets / question } {#1} }
% ID:
+ \__exsheets_determine_question_usage:
\bool_if:nT
{
(\l__exsheets_questions_deactivate_bool && \l__exsheets_select_questions_bool)
@@ -1328,28 +1331,6 @@
}
\tl_use:N \l__exsheets_after_begin_question_tl
\tl_clear:N \l__exsheets_after_begin_question_tl
- \bool_if:nT
- {
- !\l__exsheets_questions_deactivate_bool &&
- !\l__exsheets_select_questions_bool
- }
- {
- \bool_if:NT \l__exsheets_questions_use_bool
- {
- % TODO: write this to the aux file and at this point check if the
- % entry is already present
- % \prop_gput:NVV \g__exsheets_questions_used_prop
- % \g__exsheets_questions_current_id_tl
- % \g__exsheets_questions_id_int
- \int_gincr:N \g__exsheets_questions_used_int
- \__exsheets_mark_as_used_x:nn
- { \int_use:N \g__exsheets_questions_used_int }
- { \tl_use:N \g__exsheets_questions_current_id_tl }
- }
- \prop_gput:NVV \g__exsheets_questions_id_prop
- \g__exsheets_questions_current_id_tl
- \g__exsheets_questions_id_int
- }
}
% #1: points or blank
@@ -1405,7 +1386,6 @@
!\l__exsheets_questions_deactivate_bool
}
{
- \__exsheets_determine_question_usage:
\exsheets_if_current_question_is_used:T
{ \refstepcounter {question} }
\__exsheets_get_sectioning_numbers:
@@ -1421,8 +1401,11 @@
)
}
{
- \exsheets_add_points:V \l__exsheets_question_points_fp
- \exsheets_add_bonus:V \l__exsheets_question_bonus_fp
+ \exsheets_if_current_question_is_used:T
+ {
+ \exsheets_add_points:V \l__exsheets_question_points_fp
+ \exsheets_add_bonus:V \l__exsheets_question_bonus_fp
+ }
}
\tl_if_blank:VTF \l__exsheets_questions_id_tl
{
@@ -1593,11 +1576,14 @@
\cs_new_protected:Npn \exsheets@used@id #1#2
{ \prop_gput:Nnn \g__exsheets_questions_used_prop {#2} {#1} }
-\cs_new_protected:Npn \__exsheets_mark_as_used_x:nn #1#2
+\cs_new_protected:Npn \__exsheets_mark_as_used:n #1
{
- \prop_gput_if_new:Nxx \g__exsheets_questions_used_prop {#2} {#1}
+ \int_gincr:N \g__exsheets_questions_used_int
+ \prop_gput_if_new:Nxx \g__exsheets_questions_used_prop
+ {#1}
+ { \int_use:N \g__exsheets_questions_used_int }
\exsheets_write_to_aux_x:n
- { \exsheets@used@id {#1} {#2} }
+ { \exsheets@used@id {#1} { \int_use:N \g__exsheets_questions_used_int } }
}
% ----------------------------------------------------------------------------
@@ -1885,6 +1871,11 @@
\bool_set_false:N \l__exsheets_questions_deactivate_bool
\int_set_eq:NN \l__exsheets_tmpd_int \g__exsheets_questions_id_int
\int_gset_eq:NN \g__exsheets_questions_id_int \l__exsheets_tmpc_int
+ \bool_if:NT \l__exsheets_include_questions_no_duplicates_bool
+ {
+ \seq_map_inline:Nn \g_exsheets_included_questions_seq
+ { \clist_put_right:Nn \l__exsheets_exclude_id_clist {####1} }
+ }
\__exsheets_select_question_random:n {##1}
\exsheets_file_input_if_exist:n {##1}
\int_gset_eq:NN \g__exsheets_questions_id_int \l__exsheets_tmpd_int
@@ -1892,6 +1883,7 @@
\clist_clear:N \l__exsheets_include_id_clist
\clist_clear:N \l__exsheets_exclude_id_clist
\int_gzero:N \g__exsheets_selection_number_int
+ % \seq_show:N \g_exsheets_included_questions_seq
}
\bool_set_false:N \l__exsheets_select_questions_bool
}
@@ -1917,12 +1909,13 @@
\bool_set_false:N \l__exsheets_include_all_bool
\bool_set_true:N \l__exsheets_include_random_bool
\bool_set_false:N \l__exsheets_include_by_id_bool
- \int_set:Nn \l__exsheets_include_random_int {#1}
+ \int_set:Nn \l__exsheets_include_random_int {#1} ,
+ no-duplicates .bool_set:N = \l__exsheets_include_questions_no_duplicates_bool
}
\cs_new_protected:Npn \__exsheets_select_question:n #1
{
- \bool_if:NT \l__exsheets_select_questions_bool
+ \bool_if:NTF \l__exsheets_select_questions_bool
{
\bool_if:NTF \l__exsheets_questions_deactivate_bool
{
@@ -1957,11 +1950,14 @@
\g__exsheets_questions_id_int
}
\prop_get:NxN \g__exsheets_included_questions_prop
- { \int_use:N \l__exsheets_tmpa_int }
+ { \int_use:N \l__exsheets_tmpa_int }
\l__exsheets_tmpa_tl
\__exsheets_select_question_by_id:V \l__exsheets_tmpa_tl
}
}
+ {
+ \__exsheets_use_question:n {#1}
+ }
}
\cs_generate_variant:Nn \__exsheets_select_question:n { V }
@@ -1977,16 +1973,7 @@
\bool_gset_true:N \g__exsheets_questions_use_bool
\clist_gput_right:Nn \questionsincludedlast {#1}
\seq_gput_right:Nn \g_exsheets_included_questions_seq {#1}
- \int_gincr:N \g__exsheets_questions_used_int
- \__exsheets_mark_as_used_x:nn
- { \int_use:N \g__exsheets_questions_used_int }
- {#1}
- % \prop_gput:NnV \g__exsheets_questions_used_prop
- % {#1}
- % \g__exsheets_questions_id_int
- \prop_gput:NnV \g__exsheets_questions_id_prop
- {#1}
- \g__exsheets_questions_id_int
+ \__exsheets_use_question:n {#1}
}
}
{% parsing list of included IDs
@@ -2002,16 +1989,12 @@
\bool_gset_true:N \g__exsheets_questions_use_bool
\clist_gput_right:Nn \questionsincludedlast {#1}
\seq_gput_right:Nn \g_exsheets_included_questions_seq {#1}
- % \prop_gput:NnV \g__exsheets_questions_used_prop
+ \__exsheets_use_question:n {#1}
+ % \exsheets_if_current_question_is_used:T
+ % { \__exsheets_mark_as_used:n {#1} }
+ % \prop_gput:NnV \g__exsheets_questions_id_prop
% {#1}
% \g__exsheets_questions_id_int
- \int_gincr:N \g__exsheets_questions_used_int
- \__exsheets_mark_as_used_x:nn
- { \int_use:N \g__exsheets_questions_used_int }
- {#1}
- \prop_gput:NnV \g__exsheets_questions_id_prop
- {#1}
- \g__exsheets_questions_id_int
}
}
{ \bool_gset_false:N \g__exsheets_questions_use_bool }
@@ -2019,6 +2002,15 @@
}
\cs_generate_variant:Nn \__exsheets_select_question_by_id:n { V }
+\cs_new_protected:Npn \__exsheets_use_question:n #1
+ {
+ \exsheets_if_current_question_is_used:T
+ { \__exsheets_mark_as_used:n {#1} }
+ \prop_gput:NnV \g__exsheets_questions_id_prop
+ {#1}
+ \g__exsheets_questions_id_int
+ }
+
% TODO: poor efficiency -- there should be no need to map through
% \l__exsheets_class_prop *two* times
\cs_new_protected:Npn \__exsheets_select_question_random:n #1
@@ -2166,7 +2158,7 @@
% print here
\exsheets_if_current_question_is_used:T
{
- \bool_if:NT \l__exsheets_solutions_print_here_bool
+ \bool_if:NT \l__exsheets_solutions_print_bool
{
\int_set:Nn \l_exsheets_counter_qu_int { \arabic {question} }
\__exsheets_get_sectioning_numbers:
@@ -2302,7 +2294,6 @@
{
\group_begin:
\bool_set_true:N \l__exsheets_solutions_print_bool
- \bool_set_true:N \l__exsheets_inside_solution_bool
\cs_set:Npn \S ##1 { \exref { exse:##1 } }
\cs_set:Npn \C ##1 { \exref { exch:##1 } }
\keys_set:nn { exsheets / exsheets_print_solutions } {#1}
@@ -2621,7 +2612,6 @@
print / true .code:n =
{
\bool_set_true:N \l__exsheets_solutions_print_bool
- \bool_set_true:N \l__exsheets_solutions_print_here_bool
\bool_set_false:N \l__exsheets_solutions_print_section_bool
\bool_set_false:N \l__exsheets_solutions_print_chapter_bool
\bool_set_false:N \l__exsheets_solutions_print_all_bool
@@ -3197,6 +3187,9 @@ HISTORY:
should always have the same number pattern as the
corresponding questions
2016/08/14 v0.21d - fix issue #32
+2016/09/07 v0.21e - fix issue #29
+ - fix issue #35
+ - fix issue #36
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO: