diff options
| author | Frank Fuhlbrück | 2022-02-01 17:36:15 +0100 |
|---|---|---|
| committer | Frank Fuhlbrück | 2022-02-01 17:36:15 +0100 |
| commit | 58b6f5a9abadf340a55b83355f9e8485709e1bac (patch) | |
| tree | 76d326f0fe85fba6ad4883e906c73daafd28952c | |
| parent | deada505e9173fcc10c61b211de976af52c3b906 (diff) | |
| download | exercisesheets-58b6f5a9abadf340a55b83355f9e8485709e1bac.tar.gz exercisesheets-58b6f5a9abadf340a55b83355f9e8485709e1bac.tar.bz2 exercisesheets-58b6f5a9abadf340a55b83355f9e8485709e1bac.zip | |
prober skipping of lexercises and subtasks
| -rw-r--r-- | examples/exshexample.tex | 40 | ||||
| -rw-r--r-- | exercisesheets.sty | 68 | ||||
| -rw-r--r-- | exsh_lexercise.lua | 2 |
3 files changed, 84 insertions, 26 deletions
diff --git a/examples/exshexample.tex b/examples/exshexample.tex index 700ada8..60fa782 100644 --- a/examples/exshexample.tex +++ b/examples/exshexample.tex @@ -36,7 +36,7 @@ \exshset{solutions=true, task restate font={\color{black!60}}, -only=4 +only={5} } @@ -83,6 +83,38 @@ only=4 \end{exercise} \end{sheet} +\begin{sheet} + \begin{Lexercise} + task = [[ + This exercise will be skipped. + ]], + \end{Lexercise} + \begin{Lexercise} + task = [[ + \label{ex:skiplex}% + This exercise will be skipped, but it has a reference. + ]], + subexercises = {[[\label{subex:skiplexOne} first]]}, + \end{Lexercise} + \begin{exercise}[points={many, many},savetasks, + main task font={\tiny},subtask font={\itshape} + ] + \begin{maintask} + \label{ex:skipex} This exercise will be skipped + \end{maintask} +% \begin{subtasks} +% \item {first \label{subex:skipexOne}} +% \subtask{second} +% \end{subtasks} + \begin{enumerate} + \subtask {first \label{subex:skipexOne}} + \item {{\label}{subex:skipexTwo}} {12345} + \end{enumerate} + + \end{exercise} +\end{sheet} + + \begin{sheet}[date={Novanuar 21, -2022}] \begin{exercise}[points={many, many}, firstline={Read the manual.}] @@ -158,7 +190,9 @@ only=4 options=[[main task font={\itshape}]], task = [[ This is the main task specified via the Lua - interface. + interface, like subexercise \ref{subex:skiplexOne} in \ref{ex:skiplex}, whereas \ref{subex:skipexOne} + and \ref{subex:skipexTwo} in + \ref{ex:skipex} use the \LaTeX~interface. ]], solution=[[ This is a solution for the main task. @@ -195,9 +229,7 @@ only=4 } \end{Lexercise} - \end{sheet} - \end{document} diff --git a/exercisesheets.sty b/exercisesheets.sty index 3eb8d9f..01b034b 100644 --- a/exercisesheets.sty +++ b/exercisesheets.sty @@ -627,6 +627,7 @@ \listadd{\exsh@enums}{compactenum} \listadd{\exsh@enums}{asparaenum} \listadd{\exsh@enums}{inparaenum} +\listadd{\exsh@enums}{subtasks} \listadd{\exsh@nonenums}{itemize} \listadd{\exsh@nonenums}{compactitem} \listadd{\exsh@nonenums}{asparaitem} @@ -647,16 +648,25 @@ \fi %%%%%%%%%%%%%%% END BEAMER-SPECIFIC %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +\ExplSyntaxOn +\cs_new_eq:NN \exsh@ifsingletoken \tl_if_single_token:nTF +\ExplSyntaxOff \long\def\exsh@skipstuff#1{% - \ifstrequal{#1}{\begin}{\exsh@skipstuff@begin}{% - \ifstrequal{#1}{\end}{\exsh@skipstuff@end}{% - \ifstrequal{#1}{\includeexercise}{\exsh@skipstuff@incex}{% - \ifstrequal{#1}{\label}{\exsh@skipstuff@label}{% - \ifstrequal{#1}{\input}{\exsh@skipstuff@input}{% - \ifstrequal{#1}{\exsh@skipstuff@endfile}{\currfile@pop\exsh@skipstuff}{% - \ifstrequal{#1}{\setcounter}{\expandafter\exsh@skipstuff\setcounter}{% - \ifstrequal{#1}{\item}{\ifdef{\@enumctr}{\exsh@hyper@itemtrue\refstepcounter{\@enumctr}}{}}{}% - \pgfkeysvalueof{/exsh/custom skip macro}{#1}}}}}}}}% + \detokenize{.#1.} + \exsh@ifsingletoken{#1}{% + \ifstrequal{#1}{\begin}{\exsh@skipstuff@begin}{% + \ifstrequal{#1}{\end}{\exsh@skipstuff@end}{% + \ifstrequal{#1}{\includeexercise}{\exsh@skipstuff@incex}{% + \ifstrequal{#1}{\label}{\exsh@skipstuff@label}{% + \ifstrequal{#1}{\subtask}{\exsh@skipstuff@subtask}{% + \ifstrequal{#1}{\input}{\exsh@skipstuff@input}{% + \ifstrequal{#1}{\exsh@skipstuff@endfile}{\currfile@pop\exsh@skipstuff}{% + \ifstrequal{#1}{\setcounter}{\expandafter\exsh@skipstuff\setcounter}{% + \ifstrequal{#1}{\item}{\ifdef{\@enumctr}{\exsh@hyper@itemtrue\refstepcounter{\@enumctr}}{}}{}% + \pgfkeysvalueof{/exsh/custom skip macro}{#1}}}}}}}}}% + }{% + \exsh@skipstuff#1 + } } \let\exshskipcontinue\exsh@skipstuff \long\def\exsh@skipcustomstuff#1{\exshskipcontinue} @@ -670,20 +680,22 @@ } \def\exsh@skipstuff@begin#1{% \begingroup - \ifstrequal{#1}{exercise}{\refstepcounter{section}% - % automatic label for the first exercise in every included file - \ifthenelse{\equal{\jobname}{\currfilebase}}{}{% - \ifcsdef{exsh@autolabel@\currfilebase}{}{% - \csdef{exsh@autolabel@\currfilebase}{}% - \exsh@autolabel{ex:\currfilebase}}}% - }{}% - \ifinlist{#1}{\exsh@enums}{% - \exsh@skipstuff@beginenum - }{% - \ifinlist{#1}{\exsh@nonenums}{% - \undef\@enumctr + \ifstrequal{#1}{Lexercise}{\exsh@skipstuff@Lexercise}{% + \ifstrequal{#1}{exercise}{\refstepcounter{section}% + % automatic label for the first exercise in every included file + \ifthenelse{\equal{\jobname}{\currfilebase}}{}{% + \ifcsdef{exsh@autolabel@\currfilebase}{}{% + \csdef{exsh@autolabel@\currfilebase}{}% + \exsh@autolabel{ex:\currfilebase}}}% }{}% - \exsh@skipstuff + \ifinlist{#1}{\exsh@enums}{% + \exsh@skipstuff@beginenum + }{% + \ifinlist{#1}{\exsh@nonenums}{% + \undef\@enumctr + }{}% + \exsh@skipstuff + }% }% } \def\exsh@skipstuff@beginenum{% @@ -714,6 +726,9 @@ \endgroup \exsh@skipstuff } +\def\exsh@skipstuff@subtask#1{% + \exsh@skipstuff \item #1 +} \def\exsh@skipstuff@input#1{% \CatchFileDef{\exsh@inputfilecontent}{#1}{}% \currfile@push @@ -1545,6 +1560,12 @@ !exsh@dlua<exsh_cur_exercise=exercise({#1})> % !endgroup!end<Lexercise>% > +!global!long!def!exsh@start@skip@Lexercise#1\end{Lexercise}< % + !exsh@dlua<exsh_cur_exercise=exercise({#1})> % + !endgroup!endgroup% + !expandafter!exsh@skipstuff% + !exsh@dlua<exsh_texprintlines(exsh_cur_exercise)>% +> !endgroup \def\exsh@lua@catcodesBG{ @@ -1574,4 +1595,7 @@ \fi } +\def\exsh@skipstuff@Lexercise{\exsh@lua@catcodesBG\exsh@start@skip@Lexercise}% +% \exsh@lua@catcodesBG\exsh@start@skip@Lexercise} + \exsh@dlua{dofile("exsh_lexercise.lua")} diff --git a/exsh_lexercise.lua b/exsh_lexercise.lua index ed793d9..b05d29e 100644 --- a/exsh_lexercise.lua +++ b/exsh_lexercise.lua @@ -53,6 +53,8 @@ subexercise = function(se) se = se .. set.options end se = se .. "]{" .. (set.task or "") .. "}" + else + se = "{" .. se .. "}" end return [[\subtask]]..se .. pts .. sols, p, bp end |
