6

I'm trying to create an exam with numbered copies in a single file, using the exam package. I've managed to get everything to work, except that the \gradetable contains as many copies of the questions as there are exam copies (NumCopy). Is there any way to reset the grade table?

\documentclass[addpoints]{exam}
\begin{document}
\newcounter{copynum} % copy number, to be printed in the footer 
\newcounter{NumCopy} % how many copies do we want?
\setcounter{NumCopy}{3} % we want 3
\whiledo{\thecopynum<\theNumCopy}{%
  \setcounter{page}{1} % start numbering pages for the current copy at 1
  \addtocounter{copynum}{1} % the number of the current copy
  \setcounter{question}{1} % make questions start at 1 again
  \setcounter{part}{1}  % make parts start at 1 again
  ...
  % exam content goes here 
  ....
  \gradetable[v][questions] % BUG: contains NumCopy*(number of questions) many entries
}
\end{document}

1 Answer 1

7

There are further counters of class exam that need to be reset: numquestions, numpoints, ...

After the first run, \label needs to be disabled to avoid multiply-defined labels. Also exam writes to the .aux file, which can be prevented by redefining \PgInfo@write.

Full example with questions taken from the documentation of class exam:

\documentclass[addpoints]{exam}

\makeatletter
\newcommand*{\ExamResetAfterFirstRun}{%
  \renewcommand*{\PgInfo@write}[1]{}%
  \renewcommand*{\label}[1]{\@bsphack\@esphack}%
}
\makeatother

\begin{document}
\newcounter{copynum} % copy number, to be printed in the footer 
\newcounter{NumCopy} % how many copies do we want?
\setcounter{NumCopy}{3} % we want 3
\whiledo{\thecopynum<\theNumCopy}{%
  \setcounter{page}{1} % start numbering pages for the current copy at 1
  \addtocounter{copynum}{1} % the number of the current copy
  \setcounter{question}{1} % make questions start at 1 again
  \setcounter{part}{1}  % make parts start at 1 again
  \setcounter{numquestions}{0}
  \setcounter{numpoints}{0}
  \setcounter{numbonuspoints}{0}
  \setcounter{numparts}{0}
  \setcounter{numsubparts}{0}
  \setcounter{numsubsubparts}{0}
  \ifnum\value{copynum}>1 %
    \ExamResetAfterFirstRun
  \fi

  \begin{questions}
    \question[10]
    Why is there air?

    \question[15]
    How much wood would a woodchuck chuck if a woodchuck could cuck
    wood?

    \question[10]
    Compute $\displaystyle\int_0^1 x^2 \, dx$.
  \end{questions}

  \gradetable[v][questions]
}
\end{document}

Result

6
  • How can I change the language in Italian? Thanks a lot!
    – ryuk
    Commented Dec 26, 2015 at 11:41
  • @ryuk Commands like \pointpoints{SingularText}{PluralText}, \bonuspointpoints{SingularText}{PluralText} can be used to translate into Italian. Commented Dec 26, 2015 at 11:52
  • @HeikoOberdiek How can I change the order of questions in each version? Commented Sep 9, 2016 at 4:37
  • @toandhsp If the questions are in separate files, then they can be rearranged by moving the \input commands in the master file. Commented Sep 9, 2016 at 5:14
  • @HeikoOberdiek I don't understand. Can you show detaily? I want to change the order of questions in each version and change the order of A, B, C, D in each question. Please help me. Commented Sep 9, 2016 at 5:22

You must log in to answer this question.

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