%
%   
%   $RCSfile: dpwexam-new.cls,v $
%   $Revision: 1.3 $
%   $Date: 2006-11-22 15:04:09 $
%   $Author: dana $
%   $Name:  $
%   $State: Exp $
%%
\NeedsTeXFormat{LaTeX2e}[1995/12/01]
\ProvidesClass{dpwexam-new}
              [1997/10/20 Dana P. Williams's Exam Macros]
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifferpa
\ferpatrue
\newif\ifheadline
\headlinetrue
\newif\iftablepage
\tablepagetrue
\newif\ifhwpagenumbers
\hwpagenumbersfalse
\newif\ifnopagenumbers
      \nopagenumbersfalse
\DeclareOption{notable}{\tablepagefalse}
\DeclareOption{noferpa}{\ferpafalse}
\DeclareOption{noheadline}{\headlinefalse}
\DeclareOption{hw}{\tablepagefalse \headlinefalse \hwpagenumberstrue}
\DeclareOption{nopagenumbers}{\nopagenumberstrue}
\DeclareOption*{%
\PassOptionsToClass{\CurrentOption}{article}%
}
\ProcessOptions\relax
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   This file is based on LaTeX's article style and all options are
%   passed along to article -- such as 12pt!
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\LoadClass{article}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   
%   Next we set the line width to 6.5 inches and put the appropriate
%   crap along the top of each page.  The user must supply the
%   \classname, \pageinstructions is initially set to ``Show Your
%   Work!''.   The page numbering is done automatically with
%   \label/\ref s.  The fancy footwork is done just to make sure the
%   font is set correctly in the headline.
%
%   NOTE: if the exam ends with an \eject, the totalpages with be
%   incorrect. 
%   
\setlength{\textwidth}{6.5in}
\setlength{\evensidemargin}{0pt}
\setlength{\oddsidemargin}{0pt}
%
\renewcommand{\@oddfoot}{\hfil}
\ifheadline
\renewcommand{\@oddhead}{\cl@ssname\hfil
  \p@geinstruct\hfil\p@gecount}\else
\renewcommand{\@oddhead}{\hfil}
\fi
%
\ifhwpagenumbers\ifnopagenumbers\renewcommand{\@oddfoot}{\hfil}\else
\renewcommand{\@oddfoot}{\hfil--\textnormal{\arabic{page}}--\hfil}
\fi\fi
%
\newcommand{\cl@ssname}{\textnormal{\classname}}
\newcommand{\classname}{\Tclassname}
\newcommand{\p@geinstruct}{\textnormal{\pageinstructions}}
\newcommand{\pageinstructions}{\textit{Show Your Work!}}
\newcommand{\p@gecount}{\pagecount}
\newcommand{\pagecount}{Page \arabic{page} of \pageref{last-page}}
\def\Tclassname{\texttt{\string\classname}}
\newcommand{\ex@minstr}{\examinstructions}
\newcommand{\FERP@}{\noindent\ferpainstructions}
\newcommand{\ferpainstructions}{\relax}
\newcommand{\examinstructions}{\relax}
%
%    Labels for parts and such.  For details, see the ``LaTeX
%    Companion'' pages 57-8.
%
%\def\labelenumi{\textnormal{(\@alph\c@enumi)}}
\renewcommand{\theenumi}{\@alph\c@enumi}
\renewcommand{\labelenumi}{(\theenumi)}
%\def\labelenumii{\textnormal{(\@roman\c@enumii)}}
\renewcommand{\theenumii}{\@roman\c@enumii}
\renewcommand{\labelenumii}{(\theenumii)}
\renewcommand{\p@enumii}{(\theenumi)}
%
%   Old stuff.  The LaTeX style was used for quesno so that it could
%   be made accessible to the LaTeX's \label stuff.
%
\newtoks\scores
\newskip\quesskip
\newskip\ansskip
\newcount\partno
\newcount\sumscore
\newcounter{quesno}
\newif\ifshowanswers
\sumscore=0
\setcounter{quesno}{0}

%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Tunables
\quesskip=15pt plus 20pt
%\parskip=5pt plus 1pt
\interlinepenalty=200
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%  NEED A DISPLAY MODE Macro
%
\def\bd{\begin{displaymath}}
\def\ed{\end{displaymath}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%       The basic ques environment is built on the quesnp environment and
%       the \points macro.  
%
\def\points(#1){(#1)\global\advance\sumscore by#1
\global\expandafter\scores\expandafter{\the\scores
&&\the\c@quesno\global\advance\c@quesno by1&&#1&&&\cr\tablerule}}

\newenvironment{quesnp}{%\addtocounter{quesno}{1}
\refstepcounter{quesno}\par\vskip\quesskip\noindent\arabic{quesno}.\enspace
\message{<\arabic{quesno}>}}{\par}

\newenvironment{ques}[1][-1]{\begin{quesnp}\ifnum #1<0
  \else\points(#1)\fi}
{\end{quesnp}}
%
%       The quesparts environment is used for questions which have
%       only parts.
%
\newenvironment{quesparts}[1][-1]{\begingroup\begin{quesnp}%
\def\@listi{\leftmargin\leftmargini
\topsep=\itemsep
\relax}%
\ifnum #1<0
\else\points(#1)\fi\c@enumi=1\labelenumi\ \grabtoitem}
{\end{enumerate}\end{quesnp}\endgroup}

\long\def\grabtoitem#1\item{#1 \begin{enumerate}\c@enumi=1\item}
%
%       The True/False stuff.  Use the tfitemize environment.  This
%       environment works like itemize with \tfitem in place of \item 
%
%
\newcounter{tfpartno}
\newenvironment{tfitemize}{\setcounter{tfpartno}{0}
\bgroup\def\@listi{\leftmargin=1in
\labelsep=0pt
\relax}
\begin{description}}{\end{description}\egroup}

\def\tfitem{\addtocounter{tfpartno}{1}%
\item[\hbox
to1in{\hfil T\hfil
F\hfil\textnormal{(\alph{tfpartno})}\enspace}]\ignorespaces} 
%
%
%
\def\exameject{\ifshowanswers\else\eject\fi}
\def\ansfill{\ifshowanswers\else\vfill\fi} % For backwards
                                           % compatibility 
\def\examfill{\ifshowanswers\else\vfill\fi}
%
%       The table of scores on the cover page
%
\def\tablerule{\noalign{\hrule}}
\def\superstrut{$\vphantom{\biggm|}$}
\def\inserttable{\c@quesno=1\centerline{{\offinterlineskip
\vbox{\halign{\superstrut##&
\vrule##\tabskip=2em&
\hfil##\hfil
&\vrule##&\hfil##\hfil&\vrule##&\hfil##\hfil&\tabskip=0pt\vrule##\cr
\tablerule
&&Problem&&Points&&Score&\cr\tablerule
\the\scores
&&Total&&\the\sumscore&&&\cr\tablerule}}}}}

\def\nameplate{\hbox to 4in{\textsf{NAME : \hrulefill}}}
\def\sectionplate{\hbox to 4in{\textsf{SECTION : \hrulefill}}}
\def\examdate{\texttt{\string\examdate}}
\def\examname{\texttt{\string\examname}}
\AtEndDocument{\label{last-page}\iftablepage\eject\thispagestyle{empty}
\begin{flushright}
\noindent\nameplate \\
\noindent\sectionplate
\end{flushright}
\vfill
\begin{center}
{\Large\textsf{\classname}}
\medbreak
\textsf{\examdate} \\
\textsf{\examname}
\end{center}
\vfill
\ex@minstr
\ifferpa
\vfill
\FERP@
\exameject
\thispagestyle{empty}
\null
\fi
\vfill
\inserttable\vfill\vfill\fi}
%
%       For answers --- for later handout
%
\newbox\trash
\ansskip=5pt plus 10pt
\newenvironment{ans}{\ifshowanswers\par\removelastskip
\penalty300\vskip\ansskip
\begingroup\footnotesize\narrower\noindent{\bf ANS}:\enspace\else
\setbox\trash=\vbox\bgroup\fi}{\ifshowanswers\par\endgroup
\else\egroup\fi}

%\long\gdef\ignoreans#1 \end\bgroup ans\endgroup{\end{ans}}

\endinput





