% The UMIST maths dept. exam class for LaTeX.
% rfbooth, 2001.
%
% You may copy, modify, use and so on this freely.  I would appreciate
% it if you (a) tell me about any interesting mods, and that you found
% it useful, and (b) preserve a reference to my homepage, but I do not
% insist.  Bug reports to me too: richard.booth@umist.ac.uk
%
% The freshest version of this should be at
%   http://www.ma.umist.ac.uk/tech/exam/
%---------------------------------------------------------------------
% Identifications
%---------------------------------------------------------------------
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{umaexam}[2001/03/02 UMIST Maths Exam v0.1, by rfbooth]
%---------------------------------------------------------------------
% Initial Code
%---------------------------------------------------------------------
% (none)
%---------------------------------------------------------------------
% Option declaration
%---------------------------------------------------------------------
\newcommand{\@examptsize}{12pt}
\DeclareOption{10pt}{\renewcommand{\@examptsize}{10pt}}
\DeclareOption{11pt}{\renewcommand{\@examptsize}{11pt}}
\DeclareOption{12pt}{}
%---------------------------------------------------------------------
% Option execution
%---------------------------------------------------------------------
\ProcessOptions
%---------------------------------------------------------------------
% Package Loading
%---------------------------------------------------------------------
\LoadClass[a4paper,\@examptsize]{article}
\RequirePackage{ifthen}
\RequirePackage{fancyheadings}
\RequirePackage{graphicx}
%---------------------------------------------------------------------
% Main Code
%---------------------------------------------------------------------
% Commands for use in the preamble:
\newcommand{\papernumber}[1]{\renewcommand{\@papernumber}{#1}}
\newcommand{\numberofpages}[1]{\renewcommand{\@numberofpages}{#1}}
\newcommand{\firstpage}[1]{\renewcommand{\@firstpage}{#1}}
\newcommand{\firstsection}[1]{\setcounter{section}{#1}%
                               \addtocounter{section}{-1}}
\newcommand{\firstquestion}[1]{\setcounter{examquestion}{#1}%
                               \addtocounter{examquestion}{-1}}
\newcommand{\donotendpaper}{\setboolean{donotneedendofpaper}{true}}
\newcommand{\semesternumber}[1]{\renewcommand{\@semesternumber}{#1}}
\newcommand{\session}[1]{\renewcommand{\@session}{#1}}
\newcommand{\dateofpaper}[1]{\renewcommand{\@dateofpaper}{#1}}
\newcommand{\timeofpaper}[1]{\renewcommand{\@timeofpaper}{#1}}
\newcommand{\instructions}[1]{\renewcommand{\@instructions}{#1}}
\newcommand{\papertitle}[1]{\renewcommand{\@papertitle}{#1}}
\newcommand{\timelimit}[1]{\renewcommand{\@timelimit}{#1}}
\newcommand{\whotakes}[1]{\renewcommand{\@whotakes}{#1}}
%---------------------------------------------------------------------
% Define the question command.  On the first running, this begins a
% special list environment, and starts a new question.  Each question
% starts a new page unless it is the first in its section, or unless
% the previous question was given the optional argument below.
%
% Use \question[false] to avoid the post-question page break
\newcommand{\question}[1][true]{%
     \ifthenelse{\boolean{startedquestionsyet}}{}{%
         \setboolean{startedquestionsyet}{true}%
         \begin{list}%
            {\fbox{You have an extra $\backslash$item.  Use
             $\backslash$question.}}{}%
            }
     \ifthenelse{\boolean{needquestionpagebreak}}{\pagebreak}{}%
     \stepcounter{examquestion}%
     \item[\arabic{examquestion}]%
     \setboolean{needquestionpagebreak}{#1}}
% We add commands to close the question list to the document end.
\AtEndDocument{%
    \ifthenelse{\boolean{startedquestionsyet}}%
       {\end{list}}{\textbf{There seem to be no questions.  Why?}}%
    \ifthenelse{\boolean{donotneedendofpaper}}%
       {}{\vfill\begin{center}\textbf{END OF PAPER}\end{center}}%
    }
%---------------------------------------------------------------------
% This extremely lengthy definition provides the front-page-making
% command, \maketitle:
\renewcommand{\maketitle}{%
    \thispagestyle{empty}
    \addtocounter{page}{-1}
    \hfill Exam Code: \@papernumber\linebreak
%    \textbf{\large{UMIST}}
    \includegraphics[scale=0.6]{bwcrest}
%    \hfill Exam Code: \@papernumber

    \bigskip\bigskip

    \textbf{Calculators: \textit{Only single line display calculators
    are allowed}}
    \hrule

    \medskip

    \begin{center}\@timelimit\end{center}

    \bigskip

    \begin{center}UNIVERSITY OF MANCHESTER INSTITUTE\\
                  OF SCIENCE AND TECHNOLOGY\end{center}

    \bigskip

    \begin{center}\textbf{\@papertitle}\end{center}

    \bigskip

    \begin{center}\textbf{SESSION \@session\\
                          \@semesternumber\ SEMESTER}
    \end{center}

    \bigskip
    
    \noindent For candidates taking:\\
    \noindent \@whotakes

    \bigskip

    \begin{center}\textbf{DATE: \@dateofpaper\\
                          TIME: \@timeofpaper}
    \end{center}

    \vfill


    \hrule\medskip\begin{center}
           \@instructions
		  \end{center}\medskip\hrule
    \pagebreak}
%---------------------------------------------------------------------
% The following defines commands, counters and options used only
% internally, and redefines some standard commands.
\newcounter{examquestion}
\newcommand{\@papernumber}{\textbf{PAPER CODE - FIX ME!}}
\newcommand{\@numberofpages}{\textbf{NUMBER OF PAGES - FIX ME!}}
\newcommand{\@firstpage}{2}
\newcommand{\@semesternumber}{\fbox{SEMESTER NUMBER?}}
\newcommand{\@dateofpaper}{\fbox{DATE OF PAPER?}}
\newcommand{\@timeofpaper}{\fbox{TIME OF PAPER?}}
\newcommand{\@instructions}{\fbox{INSTRUCTIONS (like ``ANSWER THREE OF
                                  FOUR QUESTIONS''?}}
\newcommand{\@papertitle}{\fbox{TITLE OF PAPER (like ``OBSCURE THEORY'')?}}
\newcommand{\@timelimit}{\fbox{TIME LIMIT (like ``TWO HOURS''?}}
\newcommand{\@whotakes}{\fbox{LIST OF COURSES THAT TAKE THE EXAM, PLEASE?}}
\newcommand{\@session}{\fbox{SESSION (like 2000/2001)?}}
\newboolean{needquestionpagebreak}
\newboolean{startedquestionsyet}
\newboolean{donotneedendofpaper}
%---------------------------------------------------------------------
% Set up the page layout:
\pagestyle{fancy}
\headrulewidth 0pt
\headheight 14pt
\lhead{}\chead{}\rhead{}
\AtBeginDocument{\setcounter{page}{\@firstpage}}
\lfoot{\@papernumber}\cfoot{}\rfoot{Page \thepage{} of \@numberofpages}
%---------------------------------------------------------------------
% Redefine enumerates to look like 1 (a) (i) etc.
\renewcommand{\labelenumi}{(\alph{enumi})}
\renewcommand{\labelenumii}{(\roman{enumii})}
%---------------------------------------------------------------------
% Redefine section command:
\renewcommand{\section}{%
     \ifthenelse{\boolean{needquestionpagebreak}}{\pagebreak}{}%
     \stepcounter{section}%
     \begin{center}\textbf{SECTION \Alph{section}}\end{center}%
     \setboolean{needquestionpagebreak}{false}}
%---------------------------------------------------------------------
% This is the end of the file.
%---------------------------------------------------------------------