-
Notifications
You must be signed in to change notification settings - Fork 20
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
auto- and subpoints (or \addpoints-extended) #2
Comments
This is non-trivial. Definitely not as easy as it sounds (sum the points and print the sum). The first idea I had caused the points added in the environment to be added in each compilation run. \begin{exercise}
\addpoints{2}
\end{exercise} had 6 points after three compilations… |
That sounds bad. Maybe xsim creates his own aux file like *.xsim with the points distribution with the scheme
Would produces the aux file
|
A separate auxiliary file won't change the real problem. Every property is already written to the aux file. The current setup sets the property in the begin code of the environment before the layout template picks those properties up to be able to print them. I probably need to delay the setting of the goal properties to the end code. And |
Implementing the setup I described is rather easy. The problem is making this work and \begin{exercise}[points=2] The latter directly sets the property. I can (and would need to) unset it until the end of the environment but then the layout template never sees the point property as being set and as a consequence never prints it. |
After a few different approaches and tries I don't see how this can be added to the current implementation of |
Idea (reminder for myself): maybe introduce some kind of “pseudo” goals for each existing goal (goal being the generic term for points). Commands like |
In the schule package we have the following solution with points for "teilaufgaben":
|
I found a similar approach using an additional counter on stackexchange. |
Even worse, the current exercise is set to be the subexercise once the first one is read, but the previous value is not restored after the subexercise is complete. This means that in the post-hook of an exercise that contains nested subexercises, the current exercise will be the last subexercise read, not the parent exercise of which the post-hook is run. This can be seen in the following example: \documentclass[a4paper]{article}
\usepackage{xsim}
\DeclareExerciseEnvironmentTemplate{exercise}{%
\par{\GetExerciseName} \GetExerciseProperty{counter} (ID \GetExerciseProperty{id})
}{%
(/ID \GetExerciseProperty{id})
}
\DeclareExerciseType{subexercise}{
exercise-env = subexercise,
solution-env = subsolution,
exercise-name = subexercise,
solution-name = subsolution,
exercise-template = exercise,
solution-template = exercise
}
\xsimsetup{
exercise/template = exercise,
subexercise/within = exercise,
subexercise/the-counter = \arabic{exercise}.\roman{subexercise}
}
\begin{document}
\begin{exercise}
Erste Aufgabe
\begin{subexercise}
Erste Unteraufgabe
\end{subexercise}
\begin{subexercise}
Zweite Unteraufgabe
\end{subexercise}
\end{exercise}
\end{document} Accessing the number of the parent exercise works correctly when rendering the counter value of the subexercise in This could maybe be solved by keeping track of separate "current exercise" values for different exercise types, which would at least allow nesting different types of exercises and easily accessing parent properties using something like |
I found a fix for the above-mentioned bug and uploaded the code into this repository. % Uncomment to fix the footer-template of outer exercise being executed with a wrong \ExerciseId
% \include{xsim-nested}
% \XSIMNestedSetup{exercise}
% \XSIMNestedSetup{subexercise} The fix adds a pre- and post-hook for each exercise type. The pre-hook notes the parent of the current exercise by setting the Having the nesting now working correctly, I also wrote some code for accumulating the points of children exercises into the parent, effectively propagating the points up the tree. This could also work for the use-case initially described in this issue. You can find an example here. |
I think I've got this sorted out. It will need thorough testing. This MWE \documentclass{article}
\usepackage{xsim}
\begin{document}
\begin{exercise}[points=3]
complete: 3~points
\end{exercise}
\begin{exercise}[points=3]
\addpoints{2} \\
complete: 5~points
\end{exercise}
\begin{exercise}
\addpoints{1} \\
complete: 1~point
\end{exercise}
\begin{exercise}
no points
\end{exercise}
Total: \printtotalpoints
\end{document} prints after two compilations: I'll upload the next version to CTAN in the next few days. |
I created thís issue to clean the discussion. So in #1 i mentioned the function of autopoints. I would specify a little bit.
So
would prints
The text was updated successfully, but these errors were encountered: