11

I've just started using the exam class to typeset, well, an exam, and when using the \gradetable command to create the final grade table, it only shows me the points at the granularity of a question, but not the parts (or subparts, etc.) of that question, as the following example illustrates:

\documentclass[addpoints]{exam}

\begin{document}

\begin{questions}
\question
What if there were no air?
\begin{parts}
\part[4]
Describe the effect on the balloon industry.
\part[6]
Describe the effect on the aircraft industry.
\end{parts}
\question
\begin{parts}
\part[12]
Define the universe.
Give three examples.
\part[8]
If the universe were to end, how would you know?
\end{parts}
\end{questions}

\gradetable

\end{document}

enter image description here

Is there anyway to make the gradetable split up the points into parts, or should I do it myself?

1
  • I wonder what the answer would be on your question: Define the universe. :-) Dec 4, 2021 at 13:34

2 Answers 2

6

Sorry, but there's no way to have the gradetable list individual parts. You can list the points either by question number or by page number, but those are the only options.

3
  • 4
    Is there any plan on adding this functionality? Many times we prefer explicitly marking how many points they got in each part.
    – fabikw
    Nov 2, 2016 at 19:46
  • 1
    This functionality would be useful indeed ... May 10, 2019 at 14:58
  • 1
    I second that.... Oct 16, 2019 at 12:56
4

Whilst it is true that the exam class does not provide this functionality it is rarely true that it is not possible to do something in LaTeX. The question is more how hard it is to do what you want and in this instance it is not very difficult.

One way to add marks for the \part's to the grade table is to redefine the \part command so that it extracts the points for each part. This is slightly tricky to do as the \part command is actually (re)defined by the parts environment. Once you figure out what to do, however, you can construct the grade table on the fly using the marks for each part so that the MWE above produces:

enter image description here

Note that I have fallen prey to my own preferences and used booktabs to create the new grade table, which is produced by the \GradeTable command. The code below may break some other features of the exam package. For example, I noticed from exam.cls that "bonus marks" are supported in some fashion but I do not know what they are, how they work, or if my code is compatible with them. As far as I can see, however, my code should not break anything. On the other hand, the \GradeTable command does not support the full functionality of the \gradetable command. For example, it is not possible list marks by page numbers etc.

\documentclass[addpoints]{exam}

\usepackage{xparse,booktabs,xpatch}

% redefine \part command to be \mypart
\appto\parts{\let\exampart\part\let\part\mypart}

\makeatletter
\ExplSyntaxOn
\tl_new:N \g_grade_table_tl% this will; become the new grade table

\int_new:N \g_score_int% this will be the exam score
\NewDocumentCommand\mypart{o}{
  \IfNoValueTF{#1}{\exampart}{
    % don't do anything special inside solutions
    \if@insolution\exampart[#1]
    \else\exampart[#1]
      \int_compare:nNnT {\arabic{partno}} = {1} {
        \tl_gput_right:Nn \g_grade_table_tl { \midrule }
      }
      \tl_gput_right:Nx \g_grade_table_tl {
        \arabic{question}\alph{partno}
      }
      \tl_gput_right:No \g_grade_table_tl  {& #1 & \\}
      \int_gadd:Nn \g_score_int {#1}
    \fi
  }
}
\NewDocumentCommand\GradeTable{}{% the new grade table
  \begin{tabular}{ccc}\toprule Question & Points & Score \\
  \tl_use:N \g_grade_table_tl \midrule
  Total & \int_use:N \g_score_int & \\\bottomrule
  \end{tabular}
}
\ExplSyntaxOff
\makeatother

\begin{document}

\begin{questions}
\question
What if there were no air?
\begin{parts}
\part[4]
Describe the effect on the balloon industry.
\part[6]
Describe the effect on the aircraft industry.
\end{parts}
\question
\begin{parts}
\part[12]
Define the universe.
Give three examples.
\part[8]
If the universe were to end, how would you know?
\end{parts}
\end{questions}

\GradeTable

\end{document}
2
  • As far as I can tell, this is not a suitable option if you mix points for questions and parts. It also does not provide the option to put the table at the beginning of the exam. It is still nice though to see someone making an effort to achieve this. Oct 16, 2019 at 12:58
  • @AskingQuestions I don't think that I understand what you mean as the MWE does have different points for questions and parts. In any case, as the post says, this is not an attempt to provide a fully functional new feature for the exam package. Rather, it is providing the particular feature requested by the OP. If you have different requirements then please ask a new question. For example, by storing data in the aux file it would be possible to allow the grade table to be put anywhere. Currently, as you suggest, it must be at the end of the document.
    – user30471
    Oct 16, 2019 at 23:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .