diff options
author | Karl Berry <karl@freefriends.org> | 2019-10-13 21:43:03 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2019-10-13 21:43:03 +0000 |
commit | 59e719d7e1969d25917e37c43d81239fa593396a (patch) | |
tree | 6097b5adce2ecaf15fa76068cfdd058cd41c1158 /Master/texmf-dist/tex/latex/xsim | |
parent | e0ce141fcde2bce358ce1f883ceff960742cae4a (diff) |
xsim (13oct19)
git-svn-id: svn://tug.org/texlive/trunk@52371 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/xsim')
8 files changed, 115 insertions, 46 deletions
diff --git a/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls b/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls index 8d289452627..a36d869869f 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls +++ b/Master/texmf-dist/tex/latex/xsim/xsim-manual.cls @@ -80,6 +80,9 @@ ExerciseGoalValuePrint , ExerciseID , ExerciseParameterGet , + ExerciseParameterIfSetF , + ExerciseParameterIfSetT , + ExerciseParameterIfSetTF , ExercisePropertyGet , ExercisePropertyGetAlias , ExercisePropertyGlobalSave , @@ -87,6 +90,8 @@ ExercisePropertyIfSetT , ExercisePropertyIfSetTF , ExercisePropertySave , + ExerciseSetExpandedProperty , + ExerciseSetProperty , ExerciseTableType , ExerciseTableCode , ExerciseType , @@ -97,6 +102,7 @@ ForEachUsedExerciseByType , ForEachUsedExerciseByID , GetExerciseAliasProperty , + GetExerciseHeadingF , GetExerciseName , GetExerciseParameter , GetExerciseProperty , @@ -153,6 +159,8 @@ SaveExerciseProperty , SetExerciseParameter , SetExerciseParameters , + SetExerciseProperty , + SetExpandedExerciseProperty , theexercise , TotalExerciseGoal , TotalExerciseGoals , @@ -693,7 +701,7 @@ \cs_new_protected:Npn \xsim@example@links #1 { \href { \xsim@example@texfile@path {#1} } { \color{white} [\TeX] } ~ - \href { \xsim@example@pdffile@path {#1} } { \color{white} [PDF] } + \href { \xsim@example@pdffile@path.#1.pdf } { \color{white} [PDF] } \tl_if_in:nnT {#1} {texsx} { \tl_set:Nx \l_tmpa_tl { \__xsim_get_texsx_number:w #1 \q_stop: } @@ -765,6 +773,32 @@ \dolistloop\xsim@examplefiles } +% ---------------------------------------------------------------------------- + +\newcommand*\listlayouts{% + \def\do##1{% + \begin{cnltxcode}[{title=Layout \enquote{\texttt{##1}}}] + \ifcsdef{xsim@layout@extra@##1} + {\csuse{xsim@layout@extra@##1}} + {}% + \xsimsetup{exercise/template={##1}} + \let\marginpar\marginnote + \XSIMexpandcode{% + \printexercise{exercise}{\GetExerciseIdForProperty{ID}{showlayout}} + }% + \end{cnltxcode} + }% + \dolistloop\xsim@layouts +} + +\NewDocumentCommand\xsim@add@layout{mo}{% + \listadd\xsim@layouts{#1}% + \IfNoValueF{#2}{\csdef{xsim@layout@extra@#1}{#2}}% +} + +% ---------------------------------------------------------------------------- +% examples: + \xsim@add@example{blanks}{Create blank lines} \xsim@add@example{boxed-headings}{Put headings in a box} \xsim@add@example{code-and-output}{Create code examples} @@ -798,35 +832,20 @@ \xsim@add@example{texsx-395273}{Different aspects of exercises. Highlighted solutions} \xsim@add@example{texwelt-6698}{Custom list of exercises} \xsim@add@example{texwelt-15093}{Indicate difficulty level} +\xsim@add@example{texwelt-23968}{Long and short solutions} \xsim@add@example{golatex-80640}{Different versions for students and teachers} \xsim@add@example{golatex-91339}{Another custom layout with rules} % ---------------------------------------------------------------------------- - -\newcommand*\listlayouts{% - \def\do##1{% - \begin{cnltxcode}[{title=Layout \enquote{\texttt{##1}}}] - \ifcsdef{xsim@layout@extra@##1} - {\csuse{xsim@layout@extra@##1}} - {}% - \xsimsetup{exercise/template={##1}} - \let\marginpar\marginnote - \XSIMexpandcode{% - \printexercise{exercise}{\GetExerciseIdForProperty{ID}{showlayout}} - }% - \end{cnltxcode} - }% - \dolistloop\xsim@layouts -} - -\NewDocumentCommand\xsim@add@layout{mo}{% - \listadd\xsim@layouts{#1}% - \IfNoValueF{#2}{\csdef{xsim@layout@extra@#1}{#2}}% -} +% layouts: \xsim@add@layout{default} \xsim@add@layout{runin}[\renewcommand*\theexercise{\arabic{exercise}.}] \xsim@add@layout{margin}[\renewcommand*\theexercise{\arabic{exercise}.}] +\xsim@add@layout{minimal}[\renewcommand*\theexercise{\arabic{exercise}.}] + +% ---------------------------------------------------------------------------- +% versions: \xsim@add@version{0.8} {2017-05-18} \xsim@add@version{0.8a} {2017-05-19} @@ -837,6 +856,7 @@ \xsim@add@version{0.11} {2018-02-12} \xsim@add@version{0.12} {2019-09-26} \xsim@add@version{0.13} {2019-10-06} +\xsim@add@version{0.14} {2019-10-13} % ---------------------------------------------------------------------------- \endinput diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex index 02fb1444f71..2a7add33de4 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.definitions.code.tex @@ -42,6 +42,11 @@ \DeclareExerciseParameter* {solution-counter} \DeclareExerciseParameter* {number} +% these are additional - but are used in the `default' environment +% template: +\DeclareExerciseParameter {exercise-heading} +\DeclareExerciseParameter {solution-heading} + % ---------------------------------------------------------------------------- % not exactly a user choice, must be present at various places: @@ -63,7 +68,9 @@ \DeclareExerciseProperty {sectioning} % those are additional and wouldn't *need* to be present except for -% pre-defined templates which make use of them: +% pre-defined templates which make use of them (the page and page-value +% property actually needs to be defined for xsim to be able to save the +% corresponding values): \DeclareExerciseProperty {subtitle} \DeclareExerciseProperty {points} \DeclareExerciseProperty {bonus-points} @@ -166,23 +173,25 @@ solution-name = \XSIMtranslate {solution} , solutions-name = \XSIMtranslate {solutions} , exercise-template = default , - solution-template = default + solution-template = default , + exercise-heading = \subsection* , + solution-heading = \subsection* } % ---------------------------------------------------------------------------- \DeclareExerciseEnvironmentTemplate {default} { - \subsection* - { - \XSIMmixedcase { \GetExerciseName } \nobreakspace - \GetExerciseProperty {counter} - \IfInsideSolutionF - { - \IfExercisePropertySetT {subtitle} - { ~ { \normalfont \itshape \GetExerciseProperty {subtitle} } } - } - } + \GetExerciseHeadingF { \subsection* } + { + \XSIMmixedcase { \GetExerciseName } \nobreakspace + \GetExerciseProperty {counter} + \IfInsideSolutionF + { + \IfExercisePropertySetT {subtitle} + { ~ { \normalfont \itshape \GetExerciseProperty {subtitle} } } + } + } \GetExercisePropertyT {points} { \marginpar @@ -195,7 +204,7 @@ } } } - {} + { \par } % ---------------------------------------------------------------------------- diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex index b9235ba555e..2aacf63f51a 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.environments.code.tex @@ -350,9 +350,9 @@ \xsim_step_exercise_counter:nn {#1} {#2} \xsim_set_properties:nnx {#1} {#2} { - page-value = \arabic{page} , + page-value = \the\value{page} , page = \thepage , - section-value = \arabic{section} , + section-value = \the\value{section} , section = \thesection } } @@ -360,7 +360,7 @@ { \xsim_set_properties:nnx {#1} {#2} { - chapter-value = \arabic{chapter} , + chapter-value = \the\value{chapter} , chapter = \thechapter } } diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex index 98cebe3eb34..0de63e04607 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.exercises.code.tex @@ -364,7 +364,11 @@ \xsim_get_parameter:nn {#1} {exercise-env} / name .code:n = \xsim_set_parameter:nnn {#1} {exercise-name} {####1} , \xsim_get_parameter:nn {#1} {solution-env} / name - .code:n = \xsim_set_parameter:nnn {#1} {solution-name} {####1} + .code:n = \xsim_set_parameter:nnn {#1} {solution-name} {####1} , + \xsim_get_parameter:nn {#1} {exercise-env} / heading + .code:n = \xsim_set_parameter:nnn {#1} {exercise-heading} {####1} , + \xsim_get_parameter:nn {#1} {solution-env} / heading + .code:n = \xsim_set_parameter:nnn {#1} {solution-heading} {####1} } \xsim_new_environment:nn {#1} {exercise} \xsim_new_environment:nn {#1} {solution} diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex index b8798e9c47b..3331f6278a6 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.interface.code.tex @@ -256,6 +256,21 @@ { \GetExerciseParameter {exercise-name} } } +\NewExpandableDocumentCommand \GetExerciseHeadingF {m} + { + \IfInsideSolutionTF + { + \IfExerciseParameterSetTF {solution-heading} + { \GetExerciseParameter {solution-heading} } + {#1} + } + { + \IfExerciseParameterSetTF {exercise-heading} + { \GetExerciseParameter {exercise-heading} } + {#1} + } + } + \NewDocumentCommand \GetExerciseBody {m} { \xsim_input:oon { \ExerciseType } { \ExerciseID } {#1} } @@ -632,7 +647,7 @@ % ---------------------------------------------------------------------------- -\NewDocumentCommand \xsimsetup {m} +\NewDocumentCommand \xsimsetup {+m} { \xsim_setup:n {#1} } % ---------------------------------------------------------------------------- diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex index 3d94ca4b616..3b874dbad03 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.modules.code.tex @@ -204,11 +204,17 @@ \IfBooleanT {#1} { \ExplSyntaxOn } } -\cs_new_protected:Npn \xsim_style_options:nn #1#2 - { \keys_define:nn {xsim/#1} {#2} } +% \cs_new_protected:Npn \xsim_style_options:nn #1#2 +% { \keys_define:nn {xsim/#1} {#2} } -\NewDocumentCommand \loadxsimstyle {m} +\cs_new_protected:Npn \xsim_load_style:n #1 { \clist_map_inline:nn {#1} { \xsim_load_module:n {style.##1} } } +\keys_define:nn {xsim} + { load-style .code:n = \xsim_load_style:n {#1} } + +\NewDocumentCommand \loadxsimstyle {m} + { \xsim_load_style:n {#1} } + % -------------------------------------------------------------------------- \file_input_stop: diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.sty b/Master/texmf-dist/tex/latex/xsim/xsim.sty index 01dcbd96b37..59992c37d81 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.sty +++ b/Master/texmf-dist/tex/latex/xsim/xsim.sty @@ -29,9 +29,9 @@ \ExplSyntaxOn -\tl_const:Nn \c_xsim_date_tl {2019/10/06} +\tl_const:Nn \c_xsim_date_tl {2019/10/13} \tl_const:Nn \c_xsim_version_major_number_tl {0} -\tl_const:Nn \c_xsim_version_minor_number_tl {13} +\tl_const:Nn \c_xsim_version_minor_number_tl {14} \tl_const:Nn \c_xsim_version_subrelease_tl {} \tl_const:Nx \c_xsim_version_number_tl { diff --git a/Master/texmf-dist/tex/latex/xsim/xsim.style.layouts.code.tex b/Master/texmf-dist/tex/latex/xsim/xsim.style.layouts.code.tex index 304316eed0e..756a61e838a 100644 --- a/Master/texmf-dist/tex/latex/xsim/xsim.style.layouts.code.tex +++ b/Master/texmf-dist/tex/latex/xsim/xsim.style.layouts.code.tex @@ -25,7 +25,7 @@ % If you have any ideas, questions, suggestions or bugs to report, please % feel free to contact me. % ---------------------------------------------------------------------------- -\xsimstyle{layouts}[2017/09/14] +\xsimstyle{layouts}[2019/10/12] \RequirePackage{needspace} @@ -73,5 +73,20 @@ } {\endtrivlist} +\DeclareExerciseEnvironmentTemplate{minimal} + {% + \textbf{\GetExerciseProperty{counter}}% + \IfInsideSolutionF{% + \GetExercisePropertyT{points}{ % <<< notice the space + (\printgoal{\PropertyValue}% + \GetExercisePropertyT{bonus-points}{+\printgoal{\PropertyValue}}% + \,\IfExerciseGoalSingularTF{points} + {\XSIMtranslate{point}} + {\XSIMtranslate{points}})% + }% + } % <<< notice the space + } + {} + % ---------------------------------------------------------------------------- \endinput |