From 392ef991c763e22a148b0b8bd344c18c42b94069 Mon Sep 17 00:00:00 2001
From: Frank Fuhlbrück
Date: Wed, 19 Jan 2022 16:29:14 +0100
Subject: task evironments (NOT finished)

---
 exercisesheets.sty | 54 +++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 53 insertions(+), 1 deletion(-)

(limited to 'exercisesheets.sty')

diff --git a/exercisesheets.sty b/exercisesheets.sty
index 2d8298d..9da1f41 100644
--- a/exercisesheets.sty
+++ b/exercisesheets.sty
@@ -18,7 +18,7 @@
 %\NeedsTeXFormat{LaTeX2e}[1994/12/01]
 
 % don't forget to update the version and date in exercisesheets.tex
-\def\exsh@version{0.10}
+\def\exsh@version{0.10+git}
 \def\exsh@date{2022/01/12}
 
 \ProvidesPackage{exercisesheets}[\exsh@date\space\exsh@version\space Typesetting of exercise sheets]
@@ -29,6 +29,7 @@
 
 \RequirePackage{etoolbox}%[2008/06/28]
 \RequirePackage{scrlfile}
+\RequirePackage{environ}
 
 \RequirePackage{pgfkeys}
 \RequirePackage{keyval}
@@ -45,6 +46,7 @@
 % configuration keys
 
 \newif\ifexsh@patchenumerate\exsh@patchenumeratetrue
+\newif\ifexsh@savetasks
 \newif\ifexsh@solutions
 \newif\ifexsh@oralsolutions
 \newif\ifexsh@nonoralsolutions
@@ -68,6 +70,7 @@
   \PackageError{exercisesheets}{
     beamercompatibility used twice}{}%
 \else
+  %TODO:\only<>{A} -> {A} which breaks global effects of A
   \let\pause\relax
   \def\frame{}
   \renewcommand{\frame}[1][]{}
@@ -96,6 +99,8 @@
 \pgfkeys{/exsh/.is family,/exsh,
   patchenumerate/.is if=exsh@patchenumerate,
   patchenumerate/.default=true,
+  savetasks/.is if=exsh@savetasks,
+  savetasks/.default=true,
   solutions/.is choice,
   solutions/true/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionstrue,
   solutions/oral/.code=\exsh@solutionstrue\exsh@oralsolutionstrue\exsh@nonoralsolutionsfalse,
@@ -225,6 +230,7 @@
   optional/.value forbidden,
   exercisemark/.initial={},
   difficult/.style={/exsh/exercisemark=*},difficult/.value forbidden,
+  savetasks/.initial=false,
   %
   % translatable strings
   strings/sheet/.initial={},
@@ -322,6 +328,9 @@
   sheet title font/.initial=\Large\bfseries,
   exercise title font/.initial=\bfseries,
   points font/.initial=\itshape,
+  main task font/.initial={},
+  subtasks font/.initial={},
+  task restate font/.initial=\itshape,
   hint font/.initial={},
   hint title font/.initial=\itshape,
   solution font/.initial={},
@@ -928,6 +937,49 @@
 % reset equation numbering for each exercise
 \@addtoreset{equation}{section}
 
+\long\def\exsh@savemaintask#1{%
+  \global\def\exsh@restatetaskmain{#1}%
+  #1%
+}
+
+\newenvironment{maintask}[1][]{%
+  \pgfkeys{exsh,#1}%
+  \pgfkeysvalueof{/exsh/main task font}%
+  \ifbool{exsh@savetasks}{\Collect@Body\exsh@savemaintask}{}%
+  \ignorespaces
+}{}
+
+%we ignore everything before the frist item
+%and process everything afterwards
+\long\def\exsh@processsubtasks#1\item#2\item{%
+\ifstrequal{#2}{}{}{%
+\item #2%
+\exsh@processsubtasks\item%new "frist" \item to ignore
+}%no whitespace here is crucial for end detecttion
+}
+
+\long\def\exsh@collectedsubtasks#1{
+\begin{enumerate}
+\exsh@processsubtasks#1\item\item
+\end{enumerate}%
+}
+
+\newenvironment{subtasks}[1][]{%
+  \pgfkeys{exsh,#1}%
+  \pgfkeysvalueof{/exsh/subtasks font}%
+  \ifbool{exsh@savetasks}{\Collect@Body\exsh@collectedsubtasks}{
+    \begin{enumerate}
+  }%
+  \ignorespaces
+}{
+  \ifbool{exsh@savetasks}{}{\end{enumerate}}
+}
+
+\newcommand{\restatetask}[1][main]{
+  {\pgfkeysvalueof{/exsh/task restate font}%
+  \csname exsh@restatetask#1\endcsname}
+}
+
 \newenvironment{hint}[1][]{%
   \par
   \pgfkeys{exsh,every hint,#1,hint font}%
-- 
cgit v1.2.3

