Exam (not exam class) with LaTeX

I would like to do an exam with LaTeX. I want to use the srcartcl class and the exam itself is ready. But I like to have a number as a unique identifier for the students. So, for 60 students, I like to have written 01, 02, 03, ... up to 60 at a defined position in the document. The rest of course stays unchanged. Is that somehow achievable?

-

It would probably help to have a better idea of how you're formatting your exam. But I'll give it a go. I teach in an extremely crowded classroom. So, when I administer exams and quizzes, I use multiple versions of the quiz. This can be a pain in the neck to write. But there are ways to streamline the process.

First, I separate the preamble and LaTeX command definitions from the body of the document. So the master file I process through LaTeX is very plain looking:

\documentclass{article}
\input{preamble}
\begin{document}
\input{quizbody}
\end{document}


I can then issue a versioning command and repeated input the quiz as follows:

\documentclass{article}
\input{preamble}
\begin{document}

\setversion{a}
\input{quizbody}
\clearpage

\setversion{b}
\input{quizbody}
\clearpage

\setversion{c}
\input{quizbody}
\clearpage

\end{document}


The mechanics of this are a bit more complicated than you probably need for your document. This is where knowing something a bit more about how you implement your exam could be useful. But here are some basics:

Here's an example:

The preamble: filehandle preamble.tex

This is where I load all packages and where I define all counters and commands that I will use throughout the document.

\usepackage{multido}
\usepackage{lipsum}
%% student specific commands
\newcounter{studentidcounter}
\setcounter{studentidcounter}{1}
\newcommand{\studentid}{\thestudentidcounter}
%% formatting the header and footer
\usepackage{fancyhdr}
\pagestyle{fancy}
\renewcommand{\footrulewidth}{0.4pt}
%% formatting for quiz questions
\newcounter{quizproblemcounter}
\newcommand{\quizproblem}{\vspace{2ex}\par\stepcounter{quizproblemcounter}%
\noindent\textbf{\sffamily QP\thequizproblemcounter.}%
\hspace*{1em}}


The quiz file: filehandle: quizbody.tex

This is the content of the document. No new commands are defined here. No new counters are defined.

\quizproblem \lipsum[1]

\quizproblem \lipsum[2]

\quizproblem \lipsum[3]

\quizproblem \lipsum[4]

\quizproblem \lipsum[5]

\quizproblem \lipsum[6]

\quizproblem \lipsum[7]

\quizproblem \lipsum[8]

\quizproblem \lipsum[9]


Here I just input the various files that I'll need and only execute actions necessary between formatting the next version of the quiz.

\documentclass{article}
\input{preamble}
\begin{document}

\multido{\nx=1+1}{60}{
\input{quizbody}
\clearpage
\stepcounter{studentidcounter}%
\setcounter{page}{1}%
\setcounter{quizproblemcounter}{0}%
}
\end{document}


EDIT

To reformat the student id:

\newcommand{\studentid}{%
\ifnum\thestudentidcounter<10\relax%
0\thestudentidcounter\else%
\thestudentidcounter\fi}

-
Great! Thanks! But two additional questions: Can I somehow force a blank page if the quizbody has an odd number of pages? This would be nice to have when printing two sided. And question two: Can I force the numbers to have the format 01, 02, etc instead of 1, 2, ...? –  DaPhil Feb 11 '13 at 20:46
1) \cleardoublepage{} –  user999007 Feb 11 '13 at 21:23
Your first additional question has been answer in someone else's comment. I've added an edit above to show how to get the numbering of ids as you would like. –  A.Ellett Feb 11 '13 at 21:31