# Numbered copies with exam class

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}


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}


• @ryuk Commands like \pointpoints{SingularText}{PluralText}, \bonuspointpoints{SingularText}{PluralText} can be used to translate into Italian. – Heiko Oberdiek Dec 26 '15 at 11:52
• @toandhsp If the questions are in separate files, then they can be rearranged by moving the \input commands in the master file. – Heiko Oberdiek Sep 9 '16 at 5:14