cgnieder / xsim

eXercise Sheets IMproved

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Custom grading table template not working

hseliger opened this issue · comments

Hi!
Using version 0.21 (via TeXlive 2021).
When I try to use a custom table format for grading tables, the resulting grading table does not list the exercises anymore. Removing all temporary files does not correct this either. If I change the "defaultcopied" into "default" or "default*", the table works.

Below a little test file. The custom format is a 1:1 copy from the xsim.sty file, just the name changed from "default" to "defaultcopied". The result shows the topline, header ("Points reached"), then 2 midlines, the "total 2" and the bottomline.

BTW, in the xsim.sty file, all identifiers with "_grading_table" have, I assume, a typo in the name: they use "xism" instead of "xsim". I have not digested the whole code yet, so not sure if this has an impliocation for the functionality.

Here the test file:

\documentclass{scrartcl}
\usepackage{xsim}
% ----------------------------------------------------------------------------
\DeclareExerciseTableTemplate {defaultcopied}
{
	\XSIMputright \ExerciseTableCode
	{
		\toprule
		\XSIMifblankF { \ExerciseType }
		{ \XSIMmixedcase { \GetExerciseParameter {exercise-name} } }
		&
		\XSIMmixedcase { \XSIMtranslate {points} } &
		\XSIMtranslate {reached} \\
		\midrule
	}
	\ForEachUsedExerciseByOrder
	{
		\XSIMifeqT {#1} { \ExerciseTableType {#1} }
		{
			\XSIMifblankT { \ExerciseTableType {} }
			{
				\XSIMputright \ExerciseTableCode
				{
					\XSIMmixedcase
					{ \ExerciseParameterGet {#1} {exercise-name} ~ }
				}
			}
			\XSIMputright \ExerciseTableCode
			{ #3 & \XSIMifblankTF {#5} {\printgoal{0}} {\printgoal{#5}} & \\ }
		}
	}
	\XSIMputright \ExerciseTableCode
	{
		\midrule
		\XSIMtranslate {total} &
		\XSIMifblankTF { \ExerciseType }
		{ \TotalExerciseGoal {points} {} {} }
		{ \TotalExerciseTypeGoal { \ExerciseType } {points} {} {} } &
		\\ \bottomrule
	}
	\XSIMexpandcode
	{
		\noexpand \begin {tabular} {\XSIMifblankTF{\ExerciseType}{l}{c}cc}
		\noexpand \ExerciseTableCode
		\noexpand \end {tabular}
	}
}
% ----------------------------------------------------------------------------
\begin{document}

\begin{exercise}[points=2]
	Here is the question.
\end{exercise}
\begin{solution}
	This is the solution.
\end{solution}

\gradingtable[template=defaultcopied]
	
\end{document}

You need to keep in mind that xsim is written in an expl3 environment where spaces are ignored. They are not ignored in a normal LaTeX document. If you remove all spurious spaces from you definition you get:

\DeclareExerciseTableTemplate{defaultcopied}{%
  \XSIMputright\ExerciseTableCode{%
    \toprule
      \XSIMifblankF{\ExerciseType}{\XSIMmixedcase{\GetExerciseParameter{exercise-name}}} &
      \XSIMmixedcase{\XSIMtranslate{points}} &
      \XSIMtranslate{reached} \\
    \midrule
  }%
  \ForEachUsedExerciseByOrder{%
    \XSIMifeqT{#1}{\ExerciseTableType{#1}}{%
      \XSIMifblankT{\ExerciseTableType{}}{%
        \XSIMputright\ExerciseTableCode{%
	  \XSIMmixedcase{\ExerciseParameterGet{#1}{exercise-name} }%
	}%
      }%
      \XSIMputright\ExerciseTableCode{
        #3 & \XSIMifblankTF{#5}{\printgoal{0}}{\printgoal{#5}} & \\
      }%
    }%
  }%
  \XSIMputright\ExerciseTableCode{%
    \midrule
      \XSIMtranslate{total} &
      \XSIMifblankTF{\ExerciseType}
        {\TotalExerciseGoal{points}{}{}}
        {\TotalExerciseTypeGoal{\ExerciseType}{points}{}{}} &
    \\ \bottomrule
  }
  \XSIMexpandcode{%
    \noexpand\begin{tabular}{\XSIMifblankTF{\ExerciseType}{l}{c}cc}
    \noexpand\ExerciseTableCode
    \noexpand\end{tabular}
  }%
}

which gives me in an otherwise unchanged copy from your code:

grafik

BTW, in the xsim.sty file, all identifiers with "_grading_table" have, I assume, a typo in the name: they use "xism" instead of "xsim". I have not digested the whole code yet, so not sure if this has an impliocation for the functionality.

Thanks, fixed for the next release.

Ah...!! Thanks lot! After >30 years of using TeX, the new syntax still gets me. Digesting the 340 pages of "The LaTeX3 Interfaces" is a challenge in itself. Chapeau for you mastering this!!
– Hendrik