diff options
Diffstat (limited to 'macros/latex/contrib/stex/source/extensions/problem.dtx')
-rw-r--r-- | macros/latex/contrib/stex/source/extensions/problem.dtx | 167 |
1 files changed, 104 insertions, 63 deletions
diff --git a/macros/latex/contrib/stex/source/extensions/problem.dtx b/macros/latex/contrib/stex/source/extensions/problem.dtx index 75a34eaf8e..3fcc3215ef 100644 --- a/macros/latex/contrib/stex/source/extensions/problem.dtx +++ b/macros/latex/contrib/stex/source/extensions/problem.dtx @@ -10,7 +10,7 @@ % \iffalse % %<*driver> -\def\bibfolder#1{../../lib/bib/#1} +\def\libfolder#1{../../lib/#1} \input{../../doc/stex-docheader} \RequirePackage[hints,solutions,notes]{problem} @@ -32,6 +32,7 @@ % \maketitle % % \ifinfulldoc\else +% \begin{documentation} % \begin{abstract} % This is the documentation for the \pkg{problem} package. % For a more high-level introduction, @@ -44,12 +45,13 @@ % \end{abstract} % % \tableofcontents -% -% \input{../../doc/packages/stex-problem} +% \begin{sfragment}{User Interface} +% \input{../../doc/packages/stex-problem} +% \ednote{MK: the input does not work! it includes the commented stuff as well. } +% \end{sfragment} +% \end{documentation} % \fi % -% \begin{documentation} -% \end{documentation} % \begin{implementation} % % \section{The Implementation}\label{sec:implementation} @@ -63,8 +65,9 @@ % \begin{macrocode} %<*package> %<@@=problems> -\ProvidesExplPackage{problem}{2022/05/24}{3.1.0}{Semantic Markup for Problems} -\RequirePackage{l3keys2e,stex} +\ProvidesExplPackage{problem}{2022/09/14}{3.2.0}{Semantic Markup for Problems} +\RequirePackage{l3keys2e} +\RequirePackage{amssymb}% for \Box \keys_define:nn { problem / pkg }{ notes .default:n = { true }, @@ -81,7 +84,11 @@ min .bool_set:N = \c_@@_min_bool, boxed .default:n = { true }, boxed .bool_set:N = \c_@@_boxed_bool, - unknown .code:n = {} + test .default:n = { true }, + test .bool_set:N = \c_@@_test_bool, + unknown .code:n = { + \PassOptionsToPackage{\CurrentOption}{stex} + } } \newif\ifsolutions @@ -91,6 +98,7 @@ }{ \solutionsfalse } +\RequirePackage{stex} % \end{macrocode} % % Then we make sure that the necessary packages are loaded (in the right versions). @@ -117,6 +125,8 @@ \def\prob@gnote@kw{Grading} \def\prob@pt@kw{pt} \def\prob@min@kw{min} +\def\prob@correct@kw{Correct} +\def\prob@wrong@kw{Wrong} % \end{macrocode} % \end{macro} % @@ -126,16 +136,16 @@ \ltx@ifpackageloaded{babel}{ \makeatletter \clist_set:Nx \l_tmpa_clist {\bbl@loaded} - \clist_if_in:NnT \l_tmpa_clist {ngerman}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{ \input{problem-ngerman.ldf} } - \clist_if_in:NnT \l_tmpa_clist {finnish}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{ \input{problem-finnish.ldf} } - \clist_if_in:NnT \l_tmpa_clist {french}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{ \input{problem-french.ldf} } - \clist_if_in:NnT \l_tmpa_clist {russian}{ + \exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{ \input{problem-russian.ldf} } \makeatother @@ -178,8 +188,10 @@ % Then we set up a counter for problems. % \begin{macro}{\numberproblemsin} % \begin{macrocode} -\newcounter{problem}[section] -\newcommand\numberproblemsin[1]{\@addtoreset{problem}{#1}} +\newcounter{sproblem}[section] +\newcommand\numberproblemsin[1]{\@addtoreset{sproblem}{#1}} +\def\theplainsproblem{\arabic{sproblem}} +\def\thesproblem{\thesection.\theplainsproblem} % \end{macrocode} % \end{macro} % @@ -200,10 +212,11 @@ \int_if_exist:NTF \l_@@_prob_refnum_int { \prob@label{\int_use:N \l_@@_prob_refnum_int } }{ - \prob@label\theproblem + \prob@label\theplainsproblem } } } +\def\sproblemautorefname{\prob@problem@kw} % \end{macrocode} % \end{macro} % @@ -216,10 +229,10 @@ \tl_if_exist:NTF \l_@@_inclprob_title_tl { #2 \l_@@_inclprob_title_tl #3 }{ - \tl_if_exist:NTF \l_@@_prob_title_tl { - #2 \l_@@_prob_title_tl #3 - }{ + \tl_if_empty:NTF \l_@@_prob_title_tl { #1 + }{ + #2 \l_@@_prob_title_tl #3 } } } @@ -248,7 +261,7 @@ \newenvironment{sproblem}[1][]{ \_@@_prob_args:n{#1}%\sref@target% \@in@omtexttrue% we are in a statement (for inline definitions) - \stepcounter{problem}\record@problem + \refstepcounter{sproblem}\record@problem \def\current@section@level{\prob@problem@kw} \str_if_empty:NT \l_@@_prob_name_str { @@ -315,7 +328,7 @@ } } \stex_ref_new_doc_target:n \sproblemid - \stex_smsmode_do: + \stex_if_smsmode:TF \stex_smsmode_do: \ignorespacesandpars }{ \__stex_modules_end_module: \stex_if_smsmode:F{ @@ -408,35 +421,18 @@ % \begin{macrocode} \keys_define:nn { problem / solution }{ id .str_set_x:N = \l_@@_solution_id_str , - for .tl_set:N = \l_@@_solution_for_tl , - height .dim_set:N = \l_@@_solution_height_dim , - creators .clist_set:N = \l_@@_solution_creators_clist , - contributors .clist_set:N = \l_@@_solution_contributors_clist , - srccite .tl_set:N = \l_@@_solution_srccite_tl + for .str_set_x:N = \l_@@_solution_for_str , + type .str_set_x:N = \l_@@_solution_type_str , + title .tl_set:N = \l_@@_solution_title_tl } \cs_new_protected:Nn \_@@_solution_args:n { \str_clear:N \l_@@_solution_id_str - \tl_clear:N \l_@@_solution_for_tl - \tl_clear:N \l_@@_solution_srccite_tl - \clist_clear:N \l_@@_solution_creators_clist - \clist_clear:N \l_@@_solution_contributors_clist - \dim_zero:N \l_@@_solution_height_dim + \str_clear:N \l_@@_solution_type_str + \str_clear:N \l_@@_solution_for_str + \tl_clear:N \l_@@_solution_title_tl \keys_set:nn { problem / solution }{ #1 } } % \end{macrocode} -% the next step is to define a helper macro that does what is needed to start a solution. -% \begin{macrocode} -\newcommand\@startsolution[1][]{ - \_@@_solution_args:n { #1 } - \@in@omtexttrue% we are in a statement. - \bool_if:NF \c_@@_boxed_bool { \hrule } - \smallskip\noindent - {\textbf\prob@solution@kw :\enspace} - \begin{small} - \def\current@section@level{\prob@solution@kw} - \ignorespacesandpars -} -% \end{macrocode} % % \begin{macro}{\startsolutions} % for the |\startsolutions| macro we use the |\specialcomment| macro from the |comment| @@ -445,14 +441,20 @@ % \begin{macrocode} \box_new:N \l_@@_solution_box \newenvironment{solution}[1][]{ + \_@@_solution_args:n{#1} \stex_html_backend:TF{ \stex_if_do_html:T{ \begin{stex_annotate_env}{solution}{} + \str_if_empty:NF \l_@@_solution_type_str { + \par\noindent + \stex_annotate_invisible:nnn{typestrings}{\sexampletype}{} + } + \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~ } }{ \setbox\l_@@_solution_box\vbox\bgroup \par\smallskip\hrule\smallskip - \noindent\textbf{Solution:}~ + \noindent\textbf{Solution\tl_if_empty:NF\l_@@_solution_title_tl{~(\l_@@_solution_title_tl)}: }~ } }{ \stex_html_backend:TF{ @@ -463,6 +465,7 @@ \smallskip\hrule \egroup \bool_if:NT \c_@@_solutions_bool { + \strut\par\noindent \box\l_@@_solution_box } } @@ -470,6 +473,7 @@ \newcommand\startsolutions{ \bool_set_true:N \c_@@_solutions_bool + \solutionstrue % \specialcomment{solution}{\@startsolution}{ % \bool_if:NF \c_@@_boxed_bool { % \hrule\medskip @@ -485,19 +489,10 @@ % % \begin{macro}{\stopsolutions} % \begin{macrocode} -\newcommand\stopsolutions{\bool_set_false:N \c_@@_solutions_bool}%\excludecomment{solution}} +\newcommand\stopsolutions{\bool_set_false:N \c_@@_solutions_bool \solutionsfalse}%\excludecomment{solution}} % \end{macrocode} % \end{macro} -% -% so it only remains to start/stop solutions depending on what option was specified. % -% \begin{macrocode} -\ifsolutions - \startsolutions -\else - \stopsolutions -\fi -% \end{macrocode} % % \begin{environment}{exnote} % \begin{macrocode} @@ -550,8 +545,10 @@ } % \end{macrocode} % \end{environment} +% +% \subsection{Markup for Added Value Services}\label{sec:impl:avs} % -% \subsection{Multiple Choice Blocks}\label{sec:impl:mcq} +% \subsubsection{Multiple Choice Blocks}\label{sec:impl:mcq} % % \begin{environment}{mcb} % \ednote{MK: maybe import something better here from a dedicated MC package} @@ -579,8 +576,8 @@ T .bool_set:N = \l_@@_mcc_t_bool , F .default:n = { false } , F .bool_set:N = \l_@@_mcc_f_bool , - Ttext .tl_set:N = \l_@@_mcc_Ttext_str , - Ftext .tl_set:N = \l_@@_mcc_Ftext_str + Ttext .tl_set:N = \l_@@_mcc_Ttext_tl , + Ftext .tl_set:N = \l_@@_mcc_Ftext_tl } \cs_new_protected:Nn \l_@@_mcc_args:n { \str_clear:N \l_@@_mcc_id_str @@ -596,12 +593,12 @@ % % \begin{macro}{\mcc} % \begin{macrocode} -\def\mccTrueText{\textbf{(true)~}} -\def\mccFalseText{\textbf{(false)~}} +\def\mccTrueText{\textbf{\prob@correct@kw!~}} +\def\mccFalseText{\textbf{\prob@wrong@kw!~}} \newcommand\mcc[2][]{ \l_@@_mcc_args:n{ #1 } \item[$\Box$] #2 - \ifsolutions + \bool_if:NT \c_@@_solutions_bool{ \\ \bool_if:NT \l_@@_mcc_t_bool { \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccTrueText\l_@@_mcc_Ttext_tl @@ -610,13 +607,27 @@ \tl_if_empty:NTF\l_@@_mcc_Ttext_tl\mccFalseText\l_@@_mcc_Ftext_tl } \tl_if_empty:NF \l_@@_mcc_feedback_tl { - \emph{(\l_@@_mcc_feedback_tl)} + \emph{\l_@@_mcc_feedback_tl} } - \fi + } } %solutions % \end{macrocode} % \end{macro} +% +% \subsubsection{Filling in Concrete Solutions} % +% \begin{macro}{\includeproblem} +% This is embarrasingly simple, but can grow over time. +% \begin{macrocode} +\newcommand\fillinsol[2][]{% + \def\@test{#1} + \quad% + \ifsolutions\textcolor{red}{#1!}\else% + \fbox{\ifx\@test\@empty\phantom{\huge{21}}\else\hspace{#1}\fi}% + \fi} +% \end{macrocode} +% \end{macro} +% % \subsection{Including Problems}\label{sec:impl:includeproblem} % % \begin{macro}{\includeproblem} @@ -780,15 +791,45 @@ %</package> % \end{macrocode} % \end{macro} +% +% \subsection{Testing and Spacing} +% +% \begin{macro}{\testspace} +% \begin{macrocode} +\newcommand\testspace[1]{\bool_if:NT \c_@@_boxed_bool {\vspace*{#1}}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testnewpage} +% \begin{macrocode} +\newcommand\testnewpage{\bool_if:NT \c_@@_boxed_bool {\newpage}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\testemptypage} +% \begin{macrocode} +\newcommand\testemptypage[1][]{% +\bool_if:NT \c_@@_boxed_bool {\begin{center}\hwexam@testemptypage@kw\end{center}\vfill\eject\else}} +% \end{macrocode} +% \end{macro} +% +% \begin{macro}{\test*space} +% \begin{macrocode} +\newcommand\testsmallspace{\testspace{1cm}} +\newcommand\testmedspace{\testspace{2cm}} +\newcommand\testbigspace{\testspace{3cm}} +% \end{macrocode} +% \end{macro} +% % \end{implementation} % \ifinfulldoc\else\printbibliography\fi \endinput -% LocalWords: GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse %%% Local Variables: %%% mode: doctex %%% TeX-master: t %%% End: % \fi +% LocalWords: GPL structuresharing STR dtx pts keyval xcomment CPERL DefKeyVal iffalse % LocalWords: RequirePackage Semiverbatim DefEnvironment OptionalKeyVals soln texttt baz % LocalWords: exnote DefConstructor inclprob NeedsTeXFormat omd.sty textbackslash exfig % LocalWords: stopsolution fileversion filedate maketitle setcounter tocdepth newpage |