%%
%% This is file `exam.cls',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% exam.dtx  (with options: `package')
%% 
%% Copyright (C) 1994 by LaTeX3 project.  All rights reserved.
%% For additional copyright information see further down in this file.
%% 
%% This file is part of the LaTeX2e system (PRELIMINARY TEST RELEASE).
%% -------------------------------------------------------------------
%% 
%%  This system is distributed in the hope that it will be useful,
%%  but WITHOUT ANY WARRANTY; without even the implied warranty of
%%  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
%% 
%% 
%% IMPORTANT NOTICE:
%% 
%% For error reports in case of UNCHANGED versions see readme files.
%% 
%% Please do not request updates from us directly.  Distribution is
%% done through Mail-Servers and TeX organizations.
%% 
%% You are not allowed to change this file.
%% 
%% You are allowed to distribute this file under the condition that
%% it is distributed together with all files mentioned in 00readme.l2e.
%% 
%% If you receive only some of these files from someone, complain!
%% 
%% You are NOT ALLOWED to distribute this file alone.  You are NOT
%% ALLOWED to take money for the distribution or use of either this
%% file or a changed version, except for a nominal charge for copying
%% etc.
\def\fileversion{3.25}
\def\filedate{1995/12/17}
%% File: exam.dtx Copyright (C) 1993-1994 Hans van der Meer
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
\NeedsTeXFormat{LaTeX2e}[1995/06/01]
\ProvidesClass{exam}[\filedate\space vs\fileversion\space Exam package]
\newcommand\examerror[2]{\ClassError{exam}{!!!! #1}{#2}}
\newcommand\examwarning[1]{\ClassWarning{exam}{!!!! #1}}
\newif\ifanswers
\DeclareOption{answers}{\answerstrue\scorestrue}
\newif\ifproblempages
\DeclareOption{pages}{\problempagestrue\problemsepfalse}
\newif\ifreservespace
\reservespacetrue
\DeclareOption{questiononly}{\reservespacefalse}
\newif\ifproblemsep
\problemseptrue
\DeclareOption{nosep}{\problemsepfalse}
\newif\ifscores
\DeclareOption{scores}{\scorestrue}
\newif\ifseries
\DeclareOption{series}{\seriestrue\answerstrue\scorestrue}
\providecommand\parentclass{article}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{\parentclass}}
\PassOptionsToClass{titlepage}{\parentclass}
\ProcessOptions
  \ClassWarningNoLine{exam}{%
    documentclass `exam' version \fileversion, date \filedate.
      \MessageBreak
    available options:
      \MessageBreak
    answers:\space show questions with answers;
      \MessageBreak
    nosep:\space no separators between problems;
      \MessageBreak
    pages:\space each problem on a page;
      \MessageBreak
    questiononly:\space suppress answer space in exams;
      \MessageBreak
    scores:\space typeset score values always;
      \MessageBreak
    series:\space\space typeset catalogue of problems}
\LoadClass{\parentclass}
%\ifanswers\AtEndDocument{\cleardoublepage\tableofcontents}\fi
\newcounter{examnum}
\newenvironment{exam}[2][0]{%
  \stepcounter{examnum}%
  \@ifemptyarg{#2}{}{\date{#2}}%
  \ifanswers
    \pagenumbering{roman}%
    \maketitle%\newpage\mbox{}\newpage
  \fi
  \pagenumbering{arabic}%
  \ifseries\SRset{0}\else
    \SRset{#1}%
    \addtocontents{toc}{\protect\contentsline{section}%
      {\Exam~\theexamnum~\textemdash~\@date~%
      \textemdash~random start #1}{}}%
  \fi
  \setcounter{page}{1}}%
  {\ifseries\else
    \typeout{Total value scores = \thetotalscore}%
    \ifanswers
      \addtocontents{toc}{\protect\contentsline{section}%
        {Total value scores = \thetotalscore}{}}%
    \else\maketitle
    \fi\fi}
\newcounter{problemnum}[examnum]
\newtoks\problemid
\newcommand\question[3][]{%
  \@ifemptyarg{#1}{}{\renewcommand\parameter{#1}}%
  \ifseries
    \uppercase{\def\@namesection{#2}}%
    \ifx\namesection\@namesection
    \else
      \newpage
      \global\let\namesection=\@namesection
      \addcontentsline{toc}{subsection}{\namesection}%
      \setcounter{problemnum}{0}%
    \fi
  \fi
  \problemid={\uppercase{#3}}%
  \ifseries
    \noindent\underbar{\emph{File\,:}~\texttt{\the\problemid}}\par
    \nopagebreak\medskip\nopagebreak
  \fi
  \stepcounter{problemnum}%
  \ifanswers
    \addcontentsline{toc}{subsection}%
      {\hbox to1cm{\theproblemnum:\hss}#3}%
  \fi
  \IfFileExists{\mainfolder#2:#3}{\@@input \mainfolder#2:#3}%
    {\examwarning{File \mainfolder#2:#3 not found}}%
  \ifseries\else
    \addtocounter{totalscore}{\value{scorecounter}}%
    \typeout{\Problem\space\theproblemnum: score=\thescorecounter}%
  \fi
  }
\newcommand\namesection{\Collection}
\newcommand\reset@parameter{\gdef\parameter{}}
\reset@parameter
\newcommand\parameterproblem[2][1 ]{%
  \ifx\parameter\@empty
    \ifseries\else\examwarning{\string\parameter\space undefined,
    value `#1' taken}\fi
    \renewcommand\parameter{#1}%
  \fi
  \remark[Parameter \Problem]{#2}}

\newtoks\everyproblem
\newenvironment{problem}[1][]{%
  \@tagsforbidfalse\compact\the\everyproblem#1\@tagsforbidtrue
  \@boxing\bgroup\noindent\problemstart\ignorespaces}%
  {\par\ifproblemsep
    \nopagebreak\smallskip\nopagebreak
    \hbox to\linewidth{\hrulefill
      \ifseries
        \emph{\footnotesize\thinspace\the\@problemdate}%
      \fi}\fi
  \egroup\par
  \ifproblempages\newpage\else\bigskip\fi
  \reset@problemdate\reset@parameter}
\newcommand\compact{\@chktag\compact\def\@boxing{\noindent\vbox}\fi}
%\newcommand\split{\@chktag\split\def\@boxing{\@empty}\fi}
\newif\if@tagsforbid \@tagsforbidtrue
\providecommand\@chktag[1]{%
  \if@tagsforbid\@warning{tag \string#1\space ignored here}\else}
\newcommand\@problemstart{%
  \textbf{\Problem\,\ifnum\value{problemnum}<10 \phantom{0}\fi
  \theproblemnum}.\enskip}
\newcommand\problemstart{%
  \hangafter-2\settowidth\hangindent{\@problemstart}%
  \noindent\llap{\@problemstart}}
\newtoks\@problemdate
\newcommand\problemdate[1]{\global\@problemdate={#1}\ignorespaces}
\newcommand\reset@problemdate{\global\@problemdate={}}
\reset@problemdate
\newcounter{totalscore}[examnum]
\newcounter{scorecounter}[problemnum]
\newcommand\scoreboxsize{6mm}
\newcommand\scorebox[1]{%
  \fbox{\vbox to\scoreboxsize{\vss\hbox to
    \scoreboxsize{\hss#1\hss}\vss}}}
\newcommand\score[1]{%
  \addtocounter{scorecounter}{#1}%
  \rightnote{\scorebox{\ifscores#1\fi}}%
  \ignorespaces}
\providecommand\leftnote[1][-\baselineskip]{\@rlnote l{#1}}
\providecommand\rightnote[1][-\baselineskip]{\@rlnote r{#1}}
\providecommand\@rlnote[3]{%
  \noindent\vadjust{\vbox to\z@{%
    \vskip#2\leftskip\z@skip\rightskip\z@skip\noindent
    \if#1l\llap{#3\hskip\marginparsep}%
    \else\hfill\rlap{\hskip\marginparsep#3}\fi
    \vss\vskip\z@skip}}}
\newcommand\remark[2][]{%
  \ifseries
    \begin{center}%
    \fbox{\parbox{.9\linewidth}{%
    \sloppy\hangafter\@ne
    \setbox\z@=\hbox{\emph{#1}\@ifemptyarg{#1}{}{:~}}%
    \hangindent=\wd\z@
    \strut\box\z@ #2}}%
    \end{center}\nopagebreak
    \addvspace{5mm}\nopagebreak
  \fi}
\newcommand\longwhite{25mm}
\newcommand\shortwhite{8mm}
\newcommand\answerstart{\noindent\emph{\Answer}:\enspace}

\newcommand\answer[2][]{\altanswer[#1]{}{#2}}
\newcommand\altanswer[3][]{%
  \@ifemptyarg{#1}%
    {\mbox{\ifanswers#3\else#2\fi}}%
    {\makebox[#1]{\ifanswers#3\else#2\fi}}%
  }
\newcommand\shortanswer[2][.75\linewidth]{\par
  \ifanswers
    \addvspace{\smallskipamount}%
    \answerstart\parbox[t]{#1}{\noindent #2}%
    \par\medskip
  \else\ifreservespace
    \addvspace{\shortwhite}%
    \answerstart\makebox[#1]{\dotfill}%
    \par\medskip
   \fi\fi
  }
\newenvironment{longanswer}[1][\longwhite]{
  \par
  \ifanswers
    \addvspace{\medskipamount}\answerstart
    \nopagebreak\par\noindent
  \else\ifreservespace
      \addvspace{\medskipamount}\answerstart
      \nopagebreak\par\noindent
      \hrule\@height#1\@width\z@\par
    \fi
    \setbox\z@\vbox\bgroup\leavevmode
   \fi\ignorespaces}
  {\ifanswers\par\medskip\else\egroup\setbox\z@\hbox{}\fi}
\newcount\loadcounter
\newcommand\resetloadcounter{\global\loadcounter\z@}
\newcommand\incloadcounter{\global\advance\loadcounter\@ne}
\newcommand\decloadcounter{\global\advance\loadcounter\m@ne}
\newcommand\@listk{%
  \settowidth{\leftmargin}{\@problemstart}%
  \topsep\medskipamount
  \partopsep\z@
  \itemsep\smallskipamount
  \parsep\z@}
\newenvironment{choice}[1][]{%
  \@tagsforbidfalse\ifseries\ordered\else\random\fi#1\@tagsforbidtrue
  \resetloadcounter
  \ifnum\@itemdepth>3 \@toodeep \else
  \advance\@itemdepth\@ne
  \expandafter\let
    \csname @list\romannumeral\the\@itemdepth\endcsname=\@listk
  \list{\badmark}{\def\makelabel##1{\hss\llap{##1}}}%
  \fi}%
  {\@dumpitems\endlist}
\newcommand\random{\@chktag\random
    \def\@loaditem{\loaditem}%
    \def\@dumpitems{\shuffle\dumpitems}%
  \fi}
\newcommand\ordered{\@chktag\ordered
    \def\@loaditem{}%
    \def\@dumpitems{}%
  \fi}
\newcommand{\marksize}{\fontsize{12}{\f@baselineskip}\selectfont}
%\newcommand{\badmark}{{\marksize\ensuremath{\square}}}
\newcommand{\goodmark}%
  {\ifanswers{\marksize\ensuremath{\boxtimes}}\else\badmark\fi}
\newcommand{\baditem}[1]{\@loaditem{\item[\badmark]#1}}
\newcommand{\gooditem}[1]{\@loaditem{\item[\goodmark]#1}}
\newtoks\@itemA
\newtoks\@itemB
\newtoks\@itemC
\newtoks\@itemD
\newtoks\@itemE
\newcommand\@itemstore{5}
\newcommand\loaditem[1]{%
  \ifcase\loadcounter
    \@itemA={#1}%
    \or\@itemB={#1}%
    \or\@itemC={#1}%
    \or\@itemD={#1}%
    \or\@itemE={#1}%
  \fi
  \ifnum\loadcounter<\@itemstore \incloadcounter
  \else\examwarning{\string\loaditem\space ignored, too many}\fi}
\newcommand\dumpitemno[1]{%
  \ifnum#1>\loadcounter
    \examwarning{\string\dumpitemno[#1] ignored, out range}%
  \else\ifcase#1\relax
    \or\the\@itemA
    \or\the\@itemB
    \or\the\@itemC
    \or\the\@itemD
    \or\the\@itemE
  \fi\fi}
\newcommand\dumpitem{\dumpitemno{\loadcounter}\decloadcounter}
\newcommand\dumpitems{\@whilenum\loadcounter>\z@\do{\dumpitem}}
\newcommand\shuffle{%
  \ifcase\loadcounter
    \or
    \or\shuffle@ii
    \or\shuffle@\@itemA\@itemC \shuffle@ii \shuffle@\@itemB\@itemC
    \or\shuffle@iv
    \or\shuffle@\@itemD\@itemE \shuffle@iv \shuffle@\@itemD\@itemE
    \fi
  }
\newtoks\@item@
\newcommand\shuffle@[2]{\SRtest{}{\@item@=#1 #1=#2 #2=\@item@}}
\newcommand\shuffle@ii{\shuffle@\@itemA\@itemB}
\newcommand\shuffle@iv{%
  \SRtest{\shuffle@\@itemA\@itemB}{\shuffle@\@itemC\@itemD}%
  \SRtest{\shuffle@\@itemA\@itemC}{\shuffle@\@itemB\@itemD}}
\ifx\@SR\undefined\newcount\@SR\fi
\providecommand\@SRconst{2097152}
\providecommand\SRset[1]{\global\@SR#1 \ignorespaces}
\providecommand\@SRadvance{%
  \begingroup
  \ifnum\@SR<\@SRconst\relax\count@\z@\else\count@\@ne\fi
  \ifodd\@SR\advance\count@\@ne\fi
  \global\divide\@SR\tw@
  \ifodd\count@\global\advance\@SR\@SRconst\relax\fi
  \endgroup}
\providecommand\SRbit{\@SRadvance\ifodd\@SR1\else0\fi}
\providecommand\SRtest[2]{\@SRadvance
  \ifodd\@SR#2\else#1\fi\ignorespaces}
\providecommand\SRvalue{\number\@SR }
\SRset{0}
\newcommand\thehead{%
  \textsl{\@title\enspace:\enspace
  \ifseries\namesection\else\@date\fi}}
\newcommand\ps@examheadings{%
  \let\@oddfoot\@empty
  \let\@evenfoot\@empty
  \renewcommand\@oddhead{%
    \vbox{%
    \hbox to\textwidth{\headerfont\thehead\hfil\upshape\thepage}%
    \vskip1.5\p@
    \hrule\@height.5\p@\@width\textwidth
    }}%
  \let\@evenhead\@oddhead}
\newcommand\target[1]{\gdef\@target{#1}}\def\@target{}
\newcommand\Exam{EXAM}
\newcommand\Collection{COLLECTION OF EXAMS}
\newcommand\Answers{ANSWERS}
\newcommand\Answer{Answer}
\newcommand\Problem{Problem}

\newcommand\onlanguage[4]{% {language}{current}{known}{unknown}
  \expandafter\ifx\csname l@#1\endcsname\relax
  #4\else\ifnum\csname l@#1\endcsname=\language #2\else#3\fi\fi}
\newcommand\englishExamNames{%
  \renewcommand\Answers{ANSWERS}%
  \renewcommand\Answer{Answer}%
  \renewcommand\Exam{EXAM}%
  \renewcommand\Collection{COLLECTION OF EXAMS}%
  \renewcommand\Problem{Problem}%
  }
\AtBeginDocument{\onlanguage{english}{\englishExamNames}{}{}}
\AtBeginDocument{\onlanguage{american}{\englishExamNames}{}{}}
\newcommand\dutchExamNames{%
  \renewcommand\Answers{ANTWOORDEN}%
  \renewcommand\Answer{Antwoord}%
  \renewcommand\Exam{TENTAMEN}%
  \renewcommand\Collection{TENTAMENBUNDEL}%
  \renewcommand\Problem{Opgave}%
  }
\AtBeginDocument{\onlanguage{dutch}{\dutchExamNames}{}{}}
\newcommand\headerfont{\rmfamily\small}
\newcommand\bodyfont{\sffamily}
\newcommand\titlefont{\rmfamily\upshape}
\bodyfont
\newcommand\Mainfolder[1]{\def\mainfolder{#1}}
\newcommand\Commonfolder[1]{\def\commonfolder{#1}}
\newcommand\Figuresfolder[1]{\def\figuresfolder{#1}}
\Mainfolder{\@currdir}
\Commonfolder{\@currdir}
\Figuresfolder{\@currdir}
\InputIfFileExists{exam.cfg}{}{}
\providecommand\@ifemptyarg[1]{% {absence}{presence}
  \ifx\@empty#1\@empty
  \expandafter\@firstoftwo\else\expandafter\@secondoftwo\fi}
%\providecommand\square{\bigcirc}
%\providecommand\boxtimes{\surd}
\endinput
%%
%% End of file `exam.cls'.
