2

I am using the great xsim-package to create a new exam-template at work.

So far, I have the following setting:

I created two exercise-types, one for the first part of the exam (question) and one for the rest of the exam (exercise). The structure looks like this:

\documentclass[chapterprefix]{scrreprt}
\usepackage{scrlayer-scrpage}
\usepackage[]{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[ngerman]{babel}
\usepackage{lmodern}
\usepackage[verbose]{xsim}


% Chapter-Format
\setkomafont{chapterprefix}{\Huge\sffamily\bfseries}
\setkomafont{chapter}{\LARGE\sffamily\mdseries}
\renewcommand*\chapterformat{
    Aufgabe~\thechapter
}

\xsimsetup{
    solution/print=true
}

\DeclareExerciseType{question}{
    exercise-env = question,
    solution-env = answer,
    exercise-name = Frage,
    solution-name =  \XSIMtranslate{solution},
    exercise-template = default,
    solution-template = default
}

\SetExerciseParameters{exercise}{
    exercise-name = Aufgabe,
    exercise-template = default,
    counter = section
}

\begin{document}



\part*{Exam 2017}

    \section*{Question Section}
    \gradingtable[template=default,type=question]

    \section*{Calculations}
    \gradingtable[template=default,type=exercise]

    \chapter{Question Section}

    \begin{question}
        Die Frage lautet so
    \end{question}

    \begin{solution}
        \blank{Die Lösung ist 3}
    \end{solution}

    \begin{question}
        Die Frage lautet so
    \end{question}

    \begin{solution}
        \blank{Die Lösung ist 3}
    \end{solution}

    \begin{question}
        Die Frage lautet so
    \end{question}

    \begin{solution}
        \blank{Die Lösung ist 3}
    \end{solution}


    \chapter{First Big Exercise}

    Description.

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \chapter{Second Main Exercise}

    Decription.

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \chapter{Third Big Exercise}

    Description.

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

    \begin{exercise}
        Wir befinden uns im Jahre 50 v.Chr. Ganz Gallien ist von den Römern besetzt... Ganz Gallien?
    \end{exercise}

\end{document}

The exercise-environments use the section-counter in order to group all questions in one chapter.

Question: Is it possible to create a gradingtable for each chapter containing the included questions? So far, I can only create two gradingtables for each exercise-type (questions and exercises).

Basically, I just need to split up the table for the type "exercise" in multiple tables, because a single table is simply too long resp. wide.

Any ideas?

1

Maybe something like along the following lines. The template defined below called per-chapter relies on

  • \chapternumber defined to the value of the chapter for which you want the grading table printed and
  • the option type given to \gradingtable

That is a usage like this:

\def\chapternumber{2}
\gradingtable[type=exercise,template=per-chapter]

The code:

\documentclass{report}
\usepackage{xsim}

\SetExerciseParameter{exercise}{counter-within}{chapter}

\newcommand\chapternumber{1}

\DeclareExerciseTableTemplate{per-chapter}{%
  \def\numberofcolumns{0}%
  % build top row:
  \XSIMputright\ExerciseTableCode{%
    \toprule
    \XSIMmixedcase{\GetExerciseParameter{exercise-name}}%
  }
  \ForEachUsedExerciseByType{%
    \XSIMifeqTF{#1}{\ExerciseTableType{#1}}{%
      \def\ExerciseID{#2}%
      \XSIMifeqTF{\GetExerciseProperty{chapter-value}}{\chapternumber}{%
        \XSIMputright\ExerciseTableCode{&#3}%
        \edef\numberofcolumns{\numexpr\numberofcolumns+1\relax}%
      }{}%
    }{}%
  }%
  % finish row and build row of points:
  \XSIMputright\ExerciseTableCode{%
     \\ \midrule \XSIMmixedcase{\XSIMtranslate{points}}%
  }%
  \ForEachUsedExerciseByType{%
    \XSIMifeqTF{#1}{\ExerciseTableType{#1}}{%
      \def\ExerciseID{#2}%
      \XSIMifeqTF{\GetExerciseProperty{chapter-value}}{\chapternumber}{%
        \XSIMputright\ExerciseTableCode{& \XSIMifblankTF{#5}{\printgoal{0}}{\printgoal{#5}}}%
      }{}%
    }{}%
  }%
  % finish row and build empty row:
  \XSIMputright\ExerciseTableCode{%
    \\ \midrule \XSIMtranslate{reached}%
  }%
  \ForEachUsedExerciseByType{%
    \XSIMifeqTF{#1}{\ExerciseTableType{#1}}{%
      \def\ExerciseID{#2}%
      \XSIMifeqTF{\GetExerciseProperty{chapter-value}}{\chapternumber}{%
        \XSIMputright\ExerciseTableCode{&}%
      }{}%
    }{}%
  }%
  % finish up table:
  \XSIMputright\ExerciseTableCode{\\\bottomrule}
  % print table:
  \begin{tabular}{l*{\numberofcolumns}{c}}
     \ExerciseTableCode
  \end{tabular}%
}

\begin{document}

\chapter{Exercises}

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

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

\chapter{Questions}

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

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

\chapter{Grading Tables}

\section{Grading Table of Chapter 1}
\def\chapternumber{1}
\gradingtable[type=exercise,template=per-chapter]

\section{Grading Table of Chapter 2}
\def\chapternumber{2}
\gradingtable[type=exercise,template=per-chapter]

\end{document}

enter image description here

|improve this answer|||||
  • Great solution, thanks for your effort! I edited your template for the gradingtable so that each table has an extra column containing the pointsum of each chapter. Is it possible to count the points of the chapter inside the ForEach-Loop and make it useable in the template? – mspee Sep 21 '17 at 11:21
  • I already solved it :) Solution: Define new variable in the template header \def\chapterpoints{0}% In the ForEach-Loop: \edef\chapterpoints{\the\numexpr \chapterpoints+\XSIMifblankTF{#5}{0}{#5}} – mspee Sep 21 '17 at 11:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for?Browse other questions tagged or ask your own question.