-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Nested exercises as subexercises #67
Comments
@cgnieder Great idea to collect thoughts on the issue here. The output of your snippet should be here as well After 2 minutes of thinking I agree that being able to nest exercises seems very flexible and powerful. I am unsure if the I would be looking to nest once, like:
I can't imagine I would want to nest any deeper. The following I would try to avoid:
|
The As long as the |
We have already included subexercises as |
Sorry for taking some time to comment here. Here's a summary of what I've been trying to do with the steps mentioned in issue #57.
With the changes I described here, all the above features are working. Two further features which would be nice to have in combination with subexercises (but which I couldn't get to work yet):
|
Very much of this already is possible and it is possible without the need for nesting. Here is a quick example: \documentclass[parskip=half]{scrartcl}
\usepackage{xsim}
\DeclareExerciseProperty{subpoints}
\newcommand*\thesubpoints{}
\newcounter{subexercise}[exercise]
\renewcommand\thesubexercise{\alph{subexercise})}
\NewDocumentCommand\question{O{}}{%
\refstepcounter{subexercise}%
\item[\thesubexercise]%
\XSIMifblankF{#1}{%
\xdef\thesubpoints{\thesubpoints\XSIMifblankF{\thesubpoints}{+}#1}%
(\addpoints{#1})%
}%
}
\DeclareExerciseEnvironmentTemplate{custom}{%
\gdef\thesubpoints{}%
\subsection*{\XSIMmixedcase{\GetExerciseName}~\GetExerciseProperty{counter}%
\IfExercisePropertySetT{subtitle}
{ {\normalfont\itshape\GetExerciseProperty{subtitle}}}%
}
\GetExercisePropertyT{points}{%
\begingroup
\footnotesize\sffamily
Points: \printgoal{\PropertyValue}%
\IfExercisePropertySetT{subpoints}{ (\GetExerciseProperty{subpoints})}%
\endgroup
\par
}
}{
\XSIMifblankF{\thesubpoints}
{\SetExpandedExerciseProperty{subpoints}{\thesubpoints}}%
\par
}
\NewDocumentEnvironment{subexercise}{}
{\begin{enumerate}}
{\end{enumerate}}
\newcommand\answer[1]{\IfSolutionPrintT{\textbf{#1}}}
\xsimsetup{
exercise/template=custom ,
% solution/print
}
\begin{document}
\begin{exercise}[points=3, subtitle=Plain]
Plain exercise. \answer{Plain answer}
\end{exercise}
\begin{exercise}[subtitle=With subexercises]
\begin{subexercise}
\question[2] One \answer{First answer}
\question[3] Two \answer{Second answer}
\end{subexercise}
An exercise with subexercises.
\begin{subexercise}
\question[1] Three \answer{Third answer}
\end{subexercise}
\end{exercise}
\end{document} which gives or |
Yes. This is actually not that different from what I did in my proof of concept here. But instead of defining custom "bare" LaTeX commands for the subexercises, I used a custom xsim exercise environment for the subexercises. Similar to what you did in your code, I used the hook system to collect the subpoints, sum them up, and then report the result to the parent exercise here. The seemingly complicated logic in the post hook is just to ensure that we don't add any dangling pluses when any of the concerned exercises doesn't have points assigned. If we don't care about these we could simply always use the Thanks to your fix from 0f90bd6 and setting most variables locally, nesting is actually no big issue any more. The fixes for restoring the variables I included in previous versions of the POC are mostly no longer required. Now, I'm mostly setting nice-to-have properties related to nesting, i.e. a property for the ID of the parent exercise and its type and a full counter consisting of the concatenation of the parent's counter with the child's. The only thing that still needs to be restored after a nested subexercise is There is really nothing more required than what I just described here for nesting to work flawlessly. I did prefer using a solution via xsim environments instead of custom LaTeX commands because that seemed a lot cleaner, more flexible and extensible. If someone wants to have the subexercises listed individually in the grading table, this would be trivial thanks to the nested exercises. Same goes for using the property, template and hook infrastructure xsim already provides. Also, if xsim were to provide this functionality by default, the custom code a user would need for nesting to work would be minimal. Collecting all the subsolutions and only printing them after the whole body of the exercise would also be easy this way, e.g. by setting Merging the code of my POC into xsim shouldn't be much work. The only thing that would need to be done is to throw out the monkey-patching via hooks and instead find the right places of the xsim code base to insert my additions. If I were to create and open this PR, would you be willing to consider it for merging? |
I am inclined to add a subexercise mechanism to I'm glad that the nested approach works for you but I am hesitating to officially support it. If I do I will always have to keep possible complications in mind whenever I try to add a new feature. That being said I'll still look at your code and will see if I can integrate it in a proper way. |
I see, preventing regressions will probably become a bigger issue the more users and features |
I encountered two further use-cases for nested subexercises:
|
Hello, I find the discussion about exercises with subexercises very interesting, because in my teaching practice I need this all the time. For my learning objective checks I used the package exam by Philip Hirschhorn so far. However, XSIM seems to me potentially much more powerful, I especially appreciate the ability to have solutions output at the end, after the questions, this is very charming especially for practice sheets. Translated with www.DeepL.com/Translator (free version) (Mein Englisch ist leider nicht sehr gut.) |
My feeling didn't deceive me, with this versatile XSIM package you can also realize nice exam tasks with subtasks, however it did take me some time. The code can certainly be optimized, I am not an expert and have read my eyes sore at the manual. `` KA-Vorlage-KOMA-Lua.pdf |
This would be a great feature. I need for final exams to type problems divided in "parts" Part A, Part B, ... This could be implemented using the concept of sub-exercices. |
What should be possible or what would be features when nested exercises are used as subexercises?
I encourage users to give their thoughts here.
The text was updated successfully, but these errors were encountered: