Skip to content
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

\gradingtable options with \xsimsetup #15

Closed
maphy-psd opened this issue Oct 3, 2017 · 4 comments
Closed

\gradingtable options with \xsimsetup #15

maphy-psd opened this issue Oct 3, 2017 · 4 comments
Assignees
Labels
suggestion suggestions and feature requests

Comments

@maphy-psd
Copy link

maphy-psd commented Oct 3, 2017

It has no effect when you set the \gradingtable options with \xsimsetup.

\documentclass{article}
\usepackage{xsim}

\xsimsetup{
	grading-table/template = default*,
}

\begin{document}

\begin{exercise}[points=4]
\end{exercise}

\begin{exercise}[points=4,bonus-points=10]
\end{exercise}

\gradingtable[type = exercise]

\end{document}

The grading table uses the default template and not the default*

BTW: grading-table/type = exercise has no effect, too.

Greets

@cgnieder
Copy link
Owner

cgnieder commented Oct 3, 2017

Yes, it does have an effect, just not for the two options you mention. This is due to the definition of \gradingtable:

\NewDocumentCommand \gradingtable {O{}}
  {
    \group_begin:
      \keys_set:nn {xsim/grading-table} { template = default , type = , #1}
      \xsim_setup_template:nnV {table} \l_xism_grading_table_template_tl
        {
          \providecommand* \ExerciseTableCode {}
          \providecommand* \ExerciseTableType [1] {}
          \providecommand* \ExerciseType {}
          \tl_set_eq:NN \ExerciseType \l_xism_grading_table_exercise_type_tl
          \renewcommand* \ExerciseTableCode {}
          \renewcommand* \ExerciseTableType [1]
            { \XSIMifblankTF { \ExerciseType } {##1} { \ExerciseType } }
        }
      \xsim_use_template:nV {table} \l_xism_grading_table_template_tl
    \group_end:
  }

The line \keys_set:nn {xsim/grading-table} { template = default , type = , #1} sets both options again. This behavior can be argued about but meanwhile you can just renew the command to do what you want:

\ExplSyntaxOn
\cs_generate_variant:Nn \xsim_setup_template:nnn {nVn}
\RenewDocumentCommand \gradingtable {O{}}
  {
    \group_begin:
      \keys_set:nn {xsim/grading-table} {#1} % <<<<<
      \xsim_setup_template:nVn {table} \l_xism_grading_table_template_tl
        {
          \providecommand* \ExerciseTableCode {}
          \providecommand* \ExerciseTableType [1] {}
          \providecommand* \ExerciseType {}
          \tl_set_eq:NN \ExerciseType \l_xism_grading_table_exercise_type_tl
          \renewcommand* \ExerciseTableCode {}
          \renewcommand* \ExerciseTableType [1]
            { \XSIMifblankTF { \ExerciseType } {##1} { \ExerciseType } }
        }
      \xsim_use_template:nV {table} \l_xism_grading_table_template_tl
    \group_end:
  }
\ExplSyntaxOff

@cgnieder
Copy link
Owner

cgnieder commented Oct 3, 2017

I found a real bug, though: \xsim_setup_template:nnV should really be \xsim_setup_template:nVn

@cgnieder cgnieder self-assigned this Oct 3, 2017
@cgnieder cgnieder added the suggestion suggestions and feature requests label Oct 3, 2017
cgnieder added a commit that referenced this issue Oct 4, 2017
@cgnieder cgnieder closed this as completed Oct 4, 2017
@maphy-psd
Copy link
Author

maphy-psd commented Oct 4, 2017

Thx for the answer. I asked because in the docs, chapter 12. Grading Tables (p.26) describes to set the option by \xsimsetup as one way.

@cgnieder
Copy link
Owner

cgnieder commented Oct 4, 2017

I know. This is why I changed the behavior in commit 21b5c4a to match the one described in the manual.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
suggestion suggestions and feature requests
Projects
None yet
Development

No branches or pull requests

2 participants