summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
diff options
context:
space:
mode:
Diffstat (limited to 'Master/texmf-dist/tex/latex/exsheets/exsheets.sty')
-rw-r--r--Master/texmf-dist/tex/latex/exsheets/exsheets.sty244
1 files changed, 171 insertions, 73 deletions
diff --git a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
index 7e7c5e86aad..4ee87c0109a 100644
--- a/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
+++ b/Master/texmf-dist/tex/latex/exsheets/exsheets.sty
@@ -5,7 +5,7 @@
%
% ----------------------------------------------------------------------------
% Clemens Niederberger
-% Web: https://bitbucket.org/cgnieder/exsheets/
+% Web: http://www.mychemistry.eu/forums/forum/exsheets
% E-Mail: contact@mychemistry.eu
% ----------------------------------------------------------------------------
% Copyright 2011-2015 Clemens Niederberger
@@ -25,8 +25,8 @@
% If you have any ideas, questions, suggestions or bugs to report, please
% feel free to contact me.
% ----------------------------------------------------------------------------
-\def\exsheets@date{2015/07/04}
-\def\exsheets@version{0.19}
+\def\exsheets@date{2015/11/18}
+\def\exsheets@version{0.20}
\RequirePackage { expl3 , xparse }
\ProvidesExplPackage
@@ -37,13 +37,15 @@
% ----------------------------------------------------------------------------
% variants of kernel functions:
-\cs_generate_variant:Nn \prop_get:NnN { Nx , cf }
+\cs_generate_variant:Nn \prop_get:NnN { NV , Nx , cV , cf }
\cs_generate_variant:Nn \prop_get:NnNTF { Nx }
\cs_generate_variant:Nn \prop_gput:Nnn { Nf , Nff , Nfx , Nx , Nxx , NxV , cf , cff }
\cs_generate_variant:Nn \prop_gput_if_new:Nnn { Nxx }
\cs_generate_variant:Nn \tl_if_blank:nTF { x }
\cs_generate_variant:Nn \tl_if_eq:nnF { x }
\cs_generate_variant:Nn \int_to_arabic:n { V }
+\cs_generate_variant:Nn \seq_set_split:Nnn { NnV }
+\cs_generate_variant:Nn \quark_if_no_value:nTF { V }
% ----------------------------------------------------------------------------
% temporary variables
@@ -107,8 +109,7 @@
\msg_new:nnn {exsheets} {deprecated-command}
{
- The~ command~ `~ \token_to_str:N #1 \c_space_tl'~ is~ deprecated.~
- Use~ `~ \token_to_str:N #2 \c_space_tl'~ instead.
+ The~ command~ `#1'~ is~ deprecated.~ Use~ `#2'~ instead.
}
\msg_new:nnn {exsheets} {dropped-option}
@@ -135,10 +136,17 @@
`#2'~ hence~ I'm~ doing~ nothing.
}
-\cs_new_protected:Npn \exsheets_depr_cmd:nn #1#2
+\cs_new_protected:Npn \exsheets_deprecate_cs:Npnn #1#2#
+ { \__exsheets_deprecate_cs:Nnnn #1 {#2} }
+\cs_new_protected:Npn \__exsheets_deprecate_cs:Nnnn #1#2#3#4
{
- \cs_new_protected:Npn #1
- { \msg_warning:nnnn {exsheets} { deprecated-command } {#1} {#2} #2 }
+ \cs_new_protected:Npn #1 #2
+ {
+ \tl_if_blank:nTF {#3}
+ { \msg_warning:nnnn {exsheets} { deprecated-command } {#1} {#4} }
+ { \msg_warning:nnnn {exsheets} { deprecated-command } {#1} {#3} }
+ #4
+ }
}
\cs_new_protected:Npn \exsheets_option_dropped:n #1
@@ -401,7 +409,7 @@
\cs_generate_variant:Nn \exsheets_parse_bonus:n { V }
\cs_new:Npn \exsheets_num:n #1
- { \fp_to_tl:n {#1} }
+ { \fp_to_decimal:n {#1} }
\cs_generate_variant:Nn \exsheets_num:n { V,x }
\cs_new:Npn \__exsheets_print_points_name:nNN #1#2#3
@@ -571,7 +579,7 @@
\group_end:
}
-\exsheets_depr_cmd:nn { \sumpoints } { \totalpoints* }
+\exsheets_deprecate_cs:Npnn \sumpoints {} { \totalpoints* }
\cs_new_protected:Npn \exsheets_totalpoints:
{
@@ -810,7 +818,7 @@
\cs_new:Npn \exsheets_glue:N #1
{ \cleaders \vbox:n {} \skip_vertical:N #1 }
-% Einteilung in Klassen, Themen und andere Gruppierungen:
+% classes, topics and other group concepts:
\prop_new:N \l__exsheets_class_prop
\tl_new:N \g__exsheets_use_current_question_tl
\bool_new:N \l__exsheets_use_this_question_bool
@@ -891,14 +899,17 @@
{
% is the question to this solution an active one?
% get question number from ID
- \prop_get:NoN \g__exsheets_questions_id_prop
- { \g__exsheets_questions_current_id_tl } \l__exsheets_tmpa_tl
+ \prop_get:NVN \g__exsheets_questions_id_prop
+ \g__exsheets_questions_current_id_tl
+ \l__exsheets_tmpa_tl
% get question #1 from number
- \prop_get:coN { g__exsheets_questions_#1_prop }
- { \l__exsheets_tmpa_tl } \l__exsheets_tmpb_tl
+ \prop_get:cVN { g__exsheets_questions_#1_prop }
+ \l__exsheets_tmpa_tl
+ \l__exsheets_tmpb_tl
% test if #1 is active
- \prop_get:coN { g__exsheets_#2_active_prop }
- { \l__exsheets_tmpb_tl } \l__exsheets_tmpc_tl
+ \prop_get:cVN { g__exsheets_#2_active_prop }
+ \l__exsheets_tmpb_tl
+ \l__exsheets_tmpc_tl
\tl_if_eq:NNT \l__exsheets_tmpc_tl \q_no_value
{ \bool_set_false:N \l__exsheets_solutions_use_bool }
}
@@ -916,49 +927,103 @@
{ \exsheets_declare_question_class:nn {#1} {#2} }
\@onlypreamble \DeclareQuestionClass
+% #1: class name
\cs_new:Npn \exsheets_get_question_class:n #1
{
\cs_if_exist:cT { l__exsheets_questions_#1_tl }
{ \tl_use:c { l__exsheets_questions_#1_tl } }
}
+% #1: class name
\DeclareExpandableDocumentCommand \GetQuestionClass { m }
{ \exsheets_get_question_class:n {#1} }
+% #1: class name
+\prg_new_conditional:Npnn \exsheets_if_question_class:n #1 {T,F,TF}
+ {
+ \tl_if_blank:fTF { \exsheets_get_question_class:n {#1} }
+ { \prg_return_false: }
+ { \prg_return_true: }
+ }
+\cs_generate_variant:Nn \tl_if_blank:nTF {f}
+
+% #1: class name
\cs_new_protected:Npn \exsheets_print_question_class:nTF #1#2#3
{
- \group_begin:
- \tl_set:Nx \l__exsheets_tmpa_tl
- { \exsheets_get_question_class:n {#1} }
- \tl_if_blank:VTF \l__exsheets_tmpa_tl
- {#3}
- {
- \cs_set_protected:Npn \__exsheets_print_question_class:n ##1 {#2}
- \__exsheets_print_question_class:n
- { \exsheets_get_question_class:n {#1} }
- }
- \group_end:
+ \exsheets_if_question_class:nTF {#1}
+ {
+ \cs_set_protected:Npn \__exsheets_print_question_class:n ##1 {#2}
+ \__exsheets_print_question_class:n
+ { \exsheets_get_question_class:n {#1} }
+ }
+ {#3}
}
+
\NewDocumentCommand \PrintQuestionClassTF { mmm }
{ \exsheets_print_question_class:nTF {#1} {#2} {#3} }
\NewDocumentCommand \PrintQuestionClassT { mm }
- { \exsheets_print_question_class:nTF {#1} {#2} { } }
+ { \exsheets_print_question_class:nTF {#1} {#2} { } }
\NewDocumentCommand \PrintQuestionClassF { mm }
- { \exsheets_print_question_class:nTF {#1} { } {#2} }
+ { \exsheets_print_question_class:nTF {#1} { } {#2} }
+
+% ----------------------------------------------------------------------------
+% question tags:
+\prop_new:N \g__exsheets_tags_prop
+\seq_new:N \l__exsheets_use_tags_seq
+
+% #1: ID
+% #2: tags
+\cs_new_protected:Npn \exsheets_set_question_tags:nn #1#2
+ { \prop_gput:Nnn \g__exsheets_tags_prop {#1} {#2} }
+\cs_generate_variant:Nn \exsheets_set_question_tags:nn {V}
+
+\cs_new_protected:Npn \exsheets_set_this_question_tags:n #1
+ { \exsheets_set_question_tags:Vn \g__exsheets_questions_current_id_tl {#1} }
+
+\keys_define:nn {exsheets}
+ {
+ use-tags .code:n = \seq_set_split:Nnn \l__exsheets_use_tags_seq {,} {#1} ,
+ question / tags .code:n =
+ \exsheets_after_begin_question:n { \exsheets_set_this_question_tags:n {#1} }
+ }
+
+% #1: ID
+\prg_new_protected_conditional:Npnn \exsheets_check_question_tags:n #1 {T,F,TF}
+ {
+ \bool_set_false:N \l__exsheets_tmpa_bool
+ \seq_if_empty:NTF \l__exsheets_use_tags_seq
+ { \bool_set_true:N \l__exsheets_tmpa_bool }
+ {
+ \prop_get:NnN \g__exsheets_tags_prop {#1} \l__exsheets_tmpa_tl
+ \seq_map_inline:Nn \l__exsheets_use_tags_seq
+ {
+ \tl_if_in:NnT \l__exsheets_tmpa_tl {##1}
+ {
+ \bool_set_true:N \l__exsheets_tmpa_bool
+ \seq_map_break:
+ }
+ }
+ }
+ \bool_if:NTF \l__exsheets_tmpa_bool
+ { \prg_return_true: }
+ { \prg_return_false: }
+ }
+\cs_generate_variant:Nn \exsheets_check_question_tags:nF {V}
% ----------------------------------------------------------------------------
% die 'question' Umgebung
-\tl_new:N \l__exsheets_questions_name_tl
-\tl_set:Nn \l__exsheets_questions_name_tl { Question }
-\tl_new:N \l__exsheets_exercise_name_tl
-\tl_set:Nn \l__exsheets_exercise_name_tl { Exercise }
+\tl_new:N \l__exsheets_questions_name_tl
+\tl_set:Nn \l__exsheets_questions_name_tl {Question}
+\tl_new:N \l__exsheets_exercise_name_tl
+\tl_set:Nn \l__exsheets_exercise_name_tl {Exercise}
-\tl_new:N \l__exsheets_questions_pre_hook_tl
-\tl_new:N \l__exsheets_questions_post_hook_tl
-\tl_new:N \l__exsheets_questions_pre_body_hook_tl
-\tl_new:N \l__exsheets_questions_post_body_hook_tl
+\tl_new:N \l__exsheets_questions_pre_hook_tl
+\tl_new:N \l__exsheets_questions_post_hook_tl
+\tl_new:N \l__exsheets_questions_pre_body_hook_tl
+\tl_new:N \l__exsheets_questions_post_body_hook_tl
+\tl_new:N \l__exsheets_after_begin_question_tl
-\tl_new:N \CurrentQuestionID
+\tl_new:N \CurrentQuestionID
\bool_new:N \l__exsheets_questions_print_bool
\bool_set_true:N \l__exsheets_questions_print_bool
@@ -976,15 +1041,17 @@
\cs_new_eq:NN \exsheets_par: \par
-\cs_new:Npn \exsheets_h_or_vspace:N #1
+\cs_new_protected:Npn \exsheets_after_begin_question:n #1
+ { \tl_put_right:Nn \l__exsheets_after_begin_question_tl {#1} }
+
+\cs_new_protected:Npn \exsheets_add_space:N #1
{
- \bool_if:nTF
+ \bool_if:nF
{
- \l__exsheets_heading_runin_bool ||
+ % \l__exsheets_heading_runin_bool ||
\l__exsheets_heading_inline_bool ||
\l__exsheets_no_skip_after_bool
}
- { } % { \c_space_tl }
{
\exsheets_par:
\dim_compare:nNnT { \parskip } = { 0pt }
@@ -1031,9 +1098,9 @@
\bool_if:NF \l__exsheets_points_questions_default_bool
{
\fp_compare:nT { \g__exsheets_this_question_points_fp > 0 }
- { points = \fp_to_tl:N \g__exsheets_this_question_points_fp , }
+ { 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_tl:N \g__exsheets_this_question_bonus_fp }
+ { bonus-points = \fp_to_decimal:N \g__exsheets_this_question_bonus_fp }
}
}
#2
@@ -1053,7 +1120,7 @@
#2
{ #1 }
#3
- \exsheets_h_or_vspace:N \l__exsheets_questions_skip_below_dim
+ \exsheets_add_space:N \l__exsheets_questions_skip_below_dim
}
\cs_generate_variant:Nn \__exsheets_save_and_print_question_body:nnn { VVV }
@@ -1207,6 +1274,8 @@
{ \tl_use:N \l__exsheets_questions_id_tl }
}
}
+ \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 &&
@@ -1276,6 +1345,8 @@
\__exsheets_select_question:V \g__exsheets_questions_current_id_tl
\prop_map_inline:Nn \l__exsheets_class_prop
{ \use:c { __exsheets_questions_use_##1: } }
+ \exsheets_check_question_tags:VF \g__exsheets_questions_current_id_tl
+ { \bool_gset_false:N \g__exsheets_questions_use_bool }
\bool_if:nT
{
\g__exsheets_questions_use_bool &&
@@ -1655,6 +1726,11 @@
\colorlet { exsheetsdebugcolor } { yellow }
+\keys_define:nn {exsheets}
+ {
+ debug .bool_set:N = \l__exsheets_questions_debug_bool
+ }
+
\cs_new_protected:Npn \exsheets_debug_box:nn #1#2
{
\par
@@ -1669,39 +1745,41 @@
\cs_new:Npn \__exsheets_list_comma: {}
-\cs_new_protected:Npn \exsheets_questions_debug:
+\cs_new_protected:Npn \exsheets_questions_debug:n #1
{
\bool_if:nT
{ \l__exsheets_questions_debug_bool && \l__exsheets_inside_question_bool }
{
\exsheets_debug_box:nn { \linewidth }
{
- \fbox
- {
- ID:~
- \textit
- {
- \tl_if_blank:VTF \l__exsheets_questions_id_tl
- { \int_use:N \g__exsheets_questions_id_int }
- { \tl_use:N \l__exsheets_questions_id_tl }
- }
- }
- \cs_set_protected:Npn \__exsheets_list_comma:
- { ~ \cs_set:Npn \__exsheets_list_comma: { ,~ } }
+ \textbf {ID} :~ \textit {#1}
\prop_map_inline:Nn \l__exsheets_class_prop
{
\bool_if:cT { l__exsheets_questions_##2_bool }
{
- \__exsheets_list_comma: ##2:~
+ ;~ \textbf {##2} :~
\textit { \tl_use:c { l__exsheets_questions_##2_tl } }
}
}
+ \prop_get:NnN \g__exsheets_tags_prop
+ {#1}
+ \l__exsheets_tmpa_tl
+ \quark_if_no_value:VTF \l__exsheets_tmpa_tl
+ { ;~ \textbf {not~tagged} }
+ {
+ ;~ \textbf {tags} : ~
+ \seq_set_split:NnV \l__exsheets_tmpa_seq
+ {,}
+ \l__exsheets_tmpa_tl
+ \textit { \seq_use:Nn \l__exsheets_tmpa_seq {,~} }
+ }
}
}
}
-\NewDocumentCommand \DebugExSheets { G{true} }
- { \use:c { bool_set_#1:N } \l__exsheets_questions_debug_bool }
+\exsheets_deprecate_cs:Npnn \DebugExSheets #1
+ {the~ option~ debug}
+ { \keys_set:nn {exsheets} { debug = #1 } }
% ----------------------------------------------------------------------------
% include random/selected questions from a file:
@@ -1716,6 +1794,8 @@
\clist_new:N \l__exsheets_exclude_id_clist
\clist_new:N \questionsincludedlast
+\seq_new:N \g_exsheets_included_questions_seq
+
\int_new:N \l__exsheets_include_random_int
\int_zero:N \l__exsheets_include_random_int
@@ -1876,6 +1956,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 }
@@ -1900,6 +1981,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}
% \prop_gput:NnV \g__exsheets_questions_used_prop
% {#1}
% \g__exsheets_questions_id_int
@@ -1996,27 +2078,43 @@
{
\prop_if_in:cVTF { g__exsheets_##1_active_prop }
\l__exsheets_tmpc_tl
- { \tl_put_right:Nn \l__exsheets_include_id_tl { y } }
- { \tl_put_right:Nn \l__exsheets_include_id_tl { n } }
+ { \tl_put_right:Nn \l__exsheets_include_id_tl {y} }
+ { \tl_put_right:Nn \l__exsheets_include_id_tl {n} }
}
}
}
- \tl_if_in:NnF \l__exsheets_include_id_tl { n }
- {
- \clist_if_in:NVF \l__exsheets_exclude_id_clist \l__exsheets_tmpb_tl
+ \bool_set_true:N \l__exsheets_tmpa_bool
+ \clist_if_in:NVT
+ \l__exsheets_exclude_id_clist
+ \l__exsheets_tmpb_tl
+ { \bool_set_false:N \l__exsheets_tmpa_bool }
+ \seq_if_in:NnT
+ \g_exsheets_included_questions_seq
+ \l__exsheets_tmpb_tl
+ { \bool_set_false:N \l__exsheets_tmpa_bool }
+ \tl_if_in:NnT \l__exsheets_include_id_tl {n}
+ { \bool_set_false:N \l__exsheets_tmpa_bool }
+ \bool_if:NT \l__exsheets_tmpa_bool
+ % \tl_if_in:NnF \l__exsheets_include_id_tl { n }
+ % {
+ % \clist_if_in:NVF
+ % \l__exsheets_exclude_id_clist
+ % \l__exsheets_tmpb_tl
{
\clist_put_right:NV
\l__exsheets_include_id_clist
\l__exsheets_tmpb_tl
\int_incr:N \l__exsheets_tmpb_int
}
- }
+ % }
}
}
}
}
}
}
+% \cs_generate_variant:Nn \clist_if_in_p:Nn {NV}
+% \cs_generate_variant:Nn \seq_if_in_p:Nn {NV}
\NewDocumentCommand \PrintIfIncludeActiveTF { mm }
{ \bool_if:NTF \l__exsheets_questions_deactivate_bool {#2} {#1} }
@@ -2594,7 +2692,7 @@
}
\l__exsheets_solutions_pre_hook_tl
\l__exsheets_solutions_post_hook_tl
- \exsheets_h_or_vspace:N \l__exsheets_solutions_skip_below_dim
+ \exsheets_add_space:N \l__exsheets_solutions_skip_below_dim
\group_end:
}
\cs_generate_variant:Nn \__exsheets_print_solution:nnnn { VVV, VVVV }
@@ -2922,8 +3020,8 @@
\DeclareTranslation { Turkish } { exsheets-solution-name } { \c C\"oz\"um }
\DeclareTranslation { Croatian } { exsheets-solution-name } { Rje\v{s}enje }
\DeclareTranslation { Hungarian } { exsheets-solution-name } { Megold\'{a}s }
-\DeclareTranslation { Danish } { exsheets-solution-name } { L\o{}sning }
-\DeclareTranslation { Norsk } { exsheets-solution-name } { L\o{}sning }
+\DeclareTranslation { Danish } { exsheets-solution-name } { L\o sning }
+\DeclareTranslation { Norsk } { exsheets-solution-name } { L\o sning }
\DeclareTranslation { Portuges } { exsheets-solution-name } { Solu\c c\~ao }
% the actual translating
\tl_set:Nn \l__exsheets_exercise_name_tl
@@ -3191,10 +3289,10 @@ HISTORY:
2015/07/04 v0.19 - add http://tex.stackexchange.com/q/222814
- allow begin and end of pseudo-environments as hooks
to the question an solution environments
+2015/11/18 v0.20 - add tagging feature
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% TODO:
-- add a `tags' concept => major task
- points/decimal-marker, points/frac (?), points/format (?,im interface)
- points: swedish style
- \examspace inside {tasks} => possible? (\pagegoal-\pagetotal) gives wrong