texlive[42299] Master/texmf-dist: bangorexam (18oct16)

commits+karl at tug.org commits+karl at tug.org
Tue Oct 18 23:23:06 CEST 2016


Revision: 42299
          http://tug.org/svn/texlive?view=revision&revision=42299
Author:   karl
Date:     2016-10-18 23:23:06 +0200 (Tue, 18 Oct 2016)
Log Message:
-----------
bangorexam (18oct16)

Modified Paths:
--------------
    trunk/Master/texmf-dist/doc/latex/bangorexam/bangorexam.pdf
    trunk/Master/texmf-dist/source/latex/bangorexam/bangorexam.dtx
    trunk/Master/texmf-dist/tex/latex/bangorexam/bangorexam.cls

Modified: trunk/Master/texmf-dist/doc/latex/bangorexam/bangorexam.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/source/latex/bangorexam/bangorexam.dtx
===================================================================
--- trunk/Master/texmf-dist/source/latex/bangorexam/bangorexam.dtx	2016-10-18 01:16:50 UTC (rev 42298)
+++ trunk/Master/texmf-dist/source/latex/bangorexam/bangorexam.dtx	2016-10-18 21:23:06 UTC (rev 42299)
@@ -40,9 +40,10 @@
 \end{document}
 %</driver>
 %\fi
-%\CheckSum{432}
+%\CheckSum{501}
 %\RecordChanges
 %\changes{v1.0}{2016/09/26}{Initial version.}
+%\changes{v1.1}{2016/10/17}{Added two from four exam mode.}
 %\pagestyle{fancy}
 %\title{Bangor University Computer Science Department\\ Exam Document Class}
 %\author{Cameron Gray \texttt{<c.gray at bangor.ac.uk>}}
@@ -247,7 +248,7 @@
 %
 %\ \\
 %
-%\DescribeMacro{\choice Choice Text} Typesets a single choice according to
+%\DescribeMacro{\choice\ Choice Text} Typesets a single choice according to
 %which environment it is placed in.
 %
 %Solutions to multiple choice questions are handled somewhat differently.
@@ -256,7 +257,7 @@
 %
 %\ \\
 %
-%\DescribeMacro{\correctchoice Choice Text} Typeset the correct choice based
+%\DescribeMacro{\correctchoice\ Choice Text} Typeset the correct choice based
 %on where the macro is placed.  When |answers| is in effect, the output of
 %this macro will either highlight the option in boldface, or replace the
 %checkbox with a tick.
@@ -272,11 +273,11 @@
 %\end{macrocode}
 %\fi
 %\begin{macrocode}
-\def\version{1.0.0}
+\def\version{1.1.0}
 
 \NeedsTeXFormat{LaTeX2e}
 
-\ProvidesClass{bangorexam}[2016/10/03 \version C. Gray]
+\ProvidesClass{bangorexam}[2016/10/17 \version{}C. Gray]
 
 % Based on the Exam document class by Philip S. Hirschhorn
 % Developed/Adapted for Bangor University by C. Gray
@@ -291,7 +292,6 @@
 \RequirePackage{color}
 \RequirePackage{etoolbox}
 \RequirePackage{graphicx}
-\RequirePackage{ifthen}
 \RequirePackage{letltxmacro}
 \RequirePackage{newpxtext,newpxmath}
 \RequirePackage{totcount}
@@ -300,6 +300,17 @@
 \RequirePackage{courier}
 
 % *******************************************************************
+% Strings
+% *******************************************************************
+
+\newcommand{\engATypeText}{Answer {\bf Section A} (compulsory) and {\bf any two} questions from {\bf Section B}.}%
+\newcommand{\welATypeText}{Atebwch {\bf Adran A} (gorfodol) ac {\bf unrhyw ddau} gwestiwn o {\bf Adran B}.}%
+\newcommand{\engBTypeText}{Answer \textbf{two} out of four questions.}%
+\newcommand{\welBTypeText}{Atebwch \textbf{ddau} o'r pedwar cwestiwn.}%
+\newcommand{\sectionAHeader}{\textbf{SECTION A} --- Answer \textbf{ALL} questions (Total marks \total{sectiona})}%
+\newcommand{\sectionBHeader}{\textbf{SECTION B} --- Answer any \textbf{TWO} questions (\total{sectionb} marks each)}%
+
+% *******************************************************************
 % Class Level Options
 % *******************************************************************
 
@@ -306,27 +317,23 @@
 % Enable Welsh headings, etc.  Does not affect the cover sheet.
 % -------------------------------------------------------------------
 \DeclareOption{welsh}{%
-\newcommand{\welsh}{true}%
+	\newcommand{\welsh}{true}%
+	\renewcommand{\sectionAHeader}{\textbf{ADRAN A} --- Atebwch BOB cwestiwn (Cyfanswm marciau \total{sectiona})}%
+	\renewcommand{\sectionBHeader}{\textbf{ADRAN B} --- Atebwch unrhyw DDAU chwestiwn (\total{sectionb} marc yr un)}%
 }%
 % Exam Type
 % -------------------------------------------------------------------
+\newcommand{\engTypeText}{}
+\newcommand{\welTypeText}{}
 \DeclareOption{ab}{%
-\newtotcounter{sectiona}%
-\newtotcounter{sectionb}
-\newcommand{\examtype}{ab}%
-\newcommand{\engTypeText}{Answer {\bf Section A} (compulsory) and {\bf any two} questions from {\bf Section B}.}%
-\newcommand{\welTypeText}{Atebwch {\bf Adran A} (gorfodol) ac {\bf unrhyw ddau} gwestiwn o {\bf Adran B}.}%
-\newcommand{\sectionAHeader}{\textbf{ADRAN A} --- Atebwch BOB cwestiwn (Cyfanswm marciau \total{sectiona})}%
-\newcommand{\sectionBHeader}{\textbf{ADRAN B} --- Atebwch unrhyw DDAU chwestiwn (\total{sectionb} marc yr un)}%
-\ifx\welsh\undefined%
-\renewcommand{\sectionAHeader}{\textbf{SECTION A} --- Answer \textbf{ALL} questions (Total marks \total{sectiona})}%
-\renewcommand{\sectionBHeader}{\textbf{SECTION B} --- Answer any \textbf{TWO} questions (\total{sectionb} marks each)}%
-\fi%
+	\newcommand{\examtype}{ab}%
+	\renewcommand{\engTypeText}{\engATypeText}
+	\renewcommand{\welTypeText}{\welATypeText}
 }%
 \DeclareOption{twofour}{%
-\newcommand{\examtype}{twofour}%
-\newcommand{\engTypeText}{Answer \textbf{two} out of four questions.}%
-\newcommand{\welTypeTest}{Atebwch \textbf{ddau} o'r pedwar cwestiwn.}%
+	\newcommand{\examtype}{twofour}%
+	\renewcommand{\engTypeText}{\engBTypeText}
+	\renewcommand{\welTypeText}{\welBTypeText}
 }%
 \DeclareOption{answers}{\PassOptionsToClass{\CurrentOption}{exam}}%
 \DeclareOption{draft}{\PassOptionsToClass{\CurrentOption}{exam}}%
@@ -333,7 +340,7 @@
 \ProcessOptions\relax%
 
 \ifx\examtype\undefined%
-\ClassError{bangorexam}{An exam type option has not been defined; use ab or twofour in the class options.}%
+	\ClassError{bangorexam}{An exam type option has not been defined; use ab or twofour in the class options}%
 \fi%
 
 \LoadClass[a4paper,twoside,11pt,addpoints]{exam}%
@@ -348,12 +355,13 @@
 % Footer
 \pagestyle{headandfoot}%
 \coverfooter{}{}{\iflastpage{}{/ troi drosodd\\/ turn over}{}}%
-\footer{}{}{\oddeven{}{\iflastpage{}{/ troi drosodd / turn over}}}%
+\footer{}{}{\oddeven{}{\iflastpage{}{/ troi drosodd\\/ turn over}}}%
 
 % Cover Column Definition
 \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
 
 \SolutionEmphasis{\color{red}}
+\CorrectChoiceEmphasis{\bfseries\color{red}}
 
 % *******************************************************************
 % Configuration Macros
@@ -360,61 +368,64 @@
 % *******************************************************************
 \newcounter{tmp}
 \newtotcounter{all}
+\newtotcounter{tf}
+\newtotcounter{sectiona}
+\newtotcounter{sectionb}
 
 \newcommand{\school}[2] {%
-\def \engSchool {\expandafter\MakeUppercase\expandafter{#1}}%
-\def \welSchool {\expandafter\MakeUppercase\expandafter{#2}}%
+	\def \engSchool {\expandafter\MakeUppercase\expandafter{#1}}%
+	\def \welSchool {\expandafter\MakeUppercase\expandafter{#2}}%
 }%
 \newcommand{\module}[2]{%
-\StrSubstitute{#1}{-}{}[\mTmp]%
-\def \moduleCode {\expandafter\MakeUppercase\expandafter{\mTmp}}%
-\def \moduleName {#2}%
+	\StrSubstitute{#1}{-}{}[\mTmp]%
+	\def \moduleCode {\expandafter\MakeUppercase\expandafter{\mTmp}}%
+	\def \moduleName {#2}%
 }%
 \newcommand{\examperiod}[1]{%
-\setcounter{tmp}{\the\year}%
-\ifnum \the\month>8%
-\stepcounter{tmp}%
-\newcommand{\examYear}{\arabic{tmp}}%
-\else%
-\newcommand{\examYear}{\arabic{tmp}}%
-\fi%
-\newcommand{\welSemesterText}{Arholiadau Diwedd Semester\ \welSemester}%
-\newcommand{\engSemesterText}{End of Semester \engSemester\ Examinations}%
-\ifthenelse{\equal{#1}{s1}}{%
-\def \welSemester {Un}%
-\def \engSemester {One}%
-\def \welExamMonth {IONAWR}%
-\def \engExamMonth {JANUARY}%
-}{}%
-\ifthenelse{\equal{#1}{s2}}{%
-\def \welSemester {Dau}%
-\def \engSemester {Two}%
-\def \welExamMonth {MAI}%
-\def \engExamMonth {MAY}%
-}{}%
-\ifthenelse{\equal{#1}{resit}}{%
-\renewcommand{\welSemesterText}{Arholiadau Atodol}%
-\renewcommand{\engSemesterText}{Supplementary Examination}%
-\def \welExamMonth {AWST}%
-\def \engExamMonth {AUGUST}%
-}{}%
+	\setcounter{tmp}{\the\year}%
+	\ifnum \the\month>8%
+		\stepcounter{tmp}%
+		\newcommand{\examYear}{\arabic{tmp}}%
+	\else%
+		\newcommand{\examYear}{\arabic{tmp}}%
+	\fi%
+	\newcommand{\welSemesterText}{Arholiadau Diwedd Semester\ \welSemester}%
+	\newcommand{\engSemesterText}{End of Semester \engSemester\ Examinations}%
+	\ifthenelse{\equal{#1}{s1}}{%
+		\def \welSemester {Un}%
+		\def \engSemester {One}%
+		\def \welExamMonth {IONAWR}%
+		\def \engExamMonth {JANUARY}%
+	}{}%
+	\ifthenelse{\equal{#1}{s2}}{%
+		\def \welSemester {Dau}%
+		\def \engSemester {Two}%
+		\def \welExamMonth {MAI}%
+		\def \engExamMonth {MAY}%
+	}{}%
+	\ifthenelse{\equal{#1}{resit}}{%
+		\renewcommand{\welSemesterText}{Arholiadau Atodol}%
+		\renewcommand{\engSemesterText}{Supplementary Examination}%
+		\def \welExamMonth {AWST}%
+		\def \engExamMonth {AUGUST}%
+	}{}%
 }
 
 \newcommand{\timeallowed}[1]{%
-\def \timeAllowed {#1}%
+	\def \timeAllowed {#1}%
 }
 
 \newcommand{\guidance}[1]{%
-\def \guidance at a {#1}%
-\def \guidance at b {#1}%
+	\def \guidance at a {#1}%
+	\def \guidance at b {#1}%
 }
 
 \newcommand{\guidancea}[1]{%
-\def \guidance at a {#1}%
+	\def \guidance at a {#1}%
 }
 
 \newcommand{\guidanceb}[1]{%
-\def \guidance at b {#1}%
+	\def \guidance at b {#1}%
 }
 
 % *******************************************************************
@@ -422,99 +433,122 @@
 % *******************************************************************
 
 \renewcommand{\maketitle}{%
-\ifx\timeAllowed\undefined%
-\ClassError{bangorexam}{The time allowed for this exam has not been defined (missing \backslash timealllowed?).}%
-\fi%
-\ifx\engExamMonth\undefined%
-\ClassError{bangorexam}{The exam period for this exam has not been set (missing \backslash examperiod?).}%
-\fi%
-\ifx\moduleCode\undefined%
-\ClassError{bangorexam}{The module details for this exam have not been specified (missing \backslash module?).}%
-\fi%
-\ifx\welSchool\undefined%
-\ClassError{bangorexam}{The academic school setting this exam has not been defined (missing \backslash school?).}%
-\fi%
+	\ifx\timeAllowed\undefined%
+		\ClassError{bangorexam}{The time allowed for this exam has not been defined (missing timealllowed?)}%
+	\fi%
+	\ifx\engExamMonth\undefined%
+		\ClassError{bangorexam}{The exam period for this exam has not been set (missing examperiod?)}%
+	\fi%
+	\ifx\moduleCode\undefined%
+		\ClassError{bangorexam}{The module details for this exam have not been specified (missing module?)}%
+	\fi%
+	\ifx\welSchool\undefined%
+		\ClassError{bangorexam}{The academic school setting this exam has not been defined (missing school?)}%
+	\fi%
 
-\begin{center}
-\bfseries
-\huge
-PRIFYSGOL\\
-\large\mbox{}\\
-\huge
-BANGOR\\
-\large\mbox{}\\
-\huge
-UNIVERSITY
+	\begin{center}
+		\bfseries
+		\huge
+		PRIFYSGOL\\
+		\large\mbox{}\\
+		\huge
+		BANGOR\\
+		\large\mbox{}\\
+		\huge
+		UNIVERSITY
 
-\vfill
-\Large
-\welSchool \\
-\engSchool
-\end{center}
-\medskip
-\large
-\begin{tabular}{C{0.5\textwidth}C{0.5\textwidth}}
-{\bf \welSemesterText\par\welExamMonth\ \examYear}\par\vspace*{\bigskipamount}
-Amser a ganiateir:~\timeAllowed~awr &%
-{\bf \engSemesterText\par\engExamMonth\ \examYear}\par\vspace*{\bigskipamount}
-Time allowed:~\timeAllowed~hours
-\end{tabular}
+		\vfill
+		\Large
+		\welSchool \\
+		\engSchool
+	\end{center}
+	\medskip
+	\large
+	\begin{tabular}{C{0.5\textwidth}C{0.5\textwidth}}
+		{\bf \welSemesterText\par\welExamMonth\ \examYear}\par\vspace*{\bigskipamount}
+		Amser a ganiateir:~\timeAllowed~awr &%
+		{\bf \engSemesterText\par\engExamMonth\ \examYear}\par\vspace*{\bigskipamount}
+		Time allowed:~\timeAllowed~hours
+	\end{tabular}
 
-\vspace*{20mm}
-\LARGE
-\begin{center}
-{\bf \moduleCode\\
-\mbox{}\\
-\moduleName}
+	\vspace*{20mm}
+	\LARGE
+	\begin{center}
+		{\bf \moduleCode\\
+		\mbox{}\\
+		\moduleName}
 
-\vfill
-\large
-{\welTypeText} \\
-{\engTypeText} \\
-\ 
+		\vfill
+		\large
+		{\welTypeText} \\
+		{\engTypeText} \\
+		\ 
 
-\medskip
-{\bf Total marks \total{all}}
-\vfill
-\end{center}
+		\medskip
+		{\bf Total marks \total{all}\\
+		     Cyfanswm Marciau \total{all}}
+		\vfill
+	\end{center}
 }
 \AtBeginDocument{
-\begin{coverpages}
-\setlength{\hoffset}{0mm}
-\setlength{\marginparwidth}{0pt}
-\maketitle
-\end{coverpages}
-\pointsinrightmargin
+	\begin{coverpages}
+		\setlength{\hoffset}{0mm}
+		\setlength{\marginparwidth}{0pt}
+		\maketitle
+	\end{coverpages}
+	\pointsinrightmargin
+	\ifthenelse{\equal{\examtype}{twofour}}{
+		\clearpage
+		{%
+			\LARGE
+			\textbf{\moduleCode: \quad \moduleName}
+
+			\vspace*{8mm}
+			\large
+			\ifcsdef{guidance at a}{\normalsize\par\guidance at a}{}%
+		}
+		\vspace*{8mm}
+	}{}%
 }
 
 % *******************************************************************
 % Section Commands
 % *******************************************************************
-\newcommand{\hassectiona}{false}%
-\newcommand{\hassectionb}{false}%
+\newcounter{seca}
+\newcounter{secb}
 \newcommand{\inDoc}{none}%
 \newcommand{\sectiona} {%
-\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{\\sectiona used in a 'two from four' exam.}}{}%
-\ifthenelse{\equal{\hassectiona}{true}}{\ClassError{bangorexam}{There is already a \\sectiona in this exam.}}{}%
-\renewcommand{\hassectiona}{true}%
-\renewcommand{\inDoc}{secA}%
-\clearpage
-{%
-\LARGE
-\textbf{\moduleCode: \quad \moduleName}
+	\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{Section A defined in a 'two from four' exam}\relax}{}%
+	\ifnumcomp{\value{seca}}{>}{0}
+		{
+			\ClassError{bangorexam}{There is already a Section A in this exam}\relax%
+		}
+		{
+			\stepcounter{seca}\relax%
+		}
+	\renewcommand{\inDoc}{secA}%
+	\clearpage
+	{%
+	\LARGE
+	\textbf{\moduleCode: \quad \moduleName}
 
-\vspace*{8mm}
-\large
-\sectionAHeader
-\ifcsdef{guidance at a}{\normalsize\par\guidance at a}{}%
+	\vspace*{8mm}
+	\large
+	\sectionAHeader
+	\ifcsdef{guidance at a}{\normalsize\par\guidance at a}{}%
+	}
+	\vspace*{8mm}
 }
-\vspace*{8mm}
-}
 
 \newcommand{\sectionb}{%
-\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{\\sectionb used in a 'two from four' exam.}}{}
-\ifthenelse{\equal{\hassectionb}{true}}{\ClassError{bangorexam}{There is already a \\sectionb in this exam.}}{}
-\renewcommand{\hassectionb}{true}
+\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{Section B defined in a 'two from four' exam}\relax}{}
+	\ifnumcomp{\value{secb}}{>}{0}
+		{
+			\ClassError{bangorexam}{There is already a Section B in this exam}\relax%
+		}
+		{
+			\stepcounter{secb}\relax%
+		}
 \renewcommand{\inDoc}{secB}
 \clearpage
 {%
@@ -559,10 +593,26 @@
             \ifnumcomp{\value{sectionb}}{=}{#1}%
                 {}%
                 {%
-                    \ClassError{bangorexam}{Section B question \arabic{question} does not have an equal number of points (Existing Section B question worth \arabic{sectionb})}%
+                    \ClassError{bangorexam}{Section B question \arabic{question} does not have an equal number of points (Existing Section B question worth \arabic{sectionb})}\relax%
                 }%
         }%
         {}%
+   	 \edef\mytemp{{\examtype}}%
+     \expandafter\ifstrequal\mytemp{twofour}%
+		{%
+            \ifnumcomp{\value{tf}}{=}{0}%
+                {%
+                    \addtocounter{tf}{#1}%
+                    \addtocounter{all}{#1}%
+                    \addtocounter{all}{#1}}%
+                {}%
+            \ifnumcomp{\value{tf}}{=}{#1}%
+                {}%
+                {%
+                    \ClassError{bangorexam}{Question \arabic{question} does not have an equal number of points (Existing question(s) worth \arabic{tf})}\relax%
+                }%
+        }%
+        {}%
 }
 
 \newcommand{\patchqnumaddpoints}{%
@@ -573,6 +623,35 @@
 \newcommand{\pointsdec}[1]{%
 \pointname{#1}\patchqnumaddpoints
 }
+
+% *******************************************************************
+% End of document validation
+% *******************************************************************
+
+\AtEndDocument{%
+	\edef\mytemp{{\examtype}}%
+    \expandafter\ifstrequal\mytemp{twofour}%
+    {%
+        \edef\mytmp{\numquestions}%
+		\expandafter\ifstrequal\mytmp{4}%
+			{\relax}%
+			{%
+				\ClassError{bangorexam}{There is/are only (\numquestions) question(s) defined, there should be four}\relax%
+			}%
+    }{%
+        \ifnumcomp{\value{seca}}{=}{0}%
+            {%
+				\ClassError{bangorexam}{There is no Section A defined in this exam}\relax%
+			}%
+            {\relax}%
+        \ifnumcomp{\value{secb}}{=}{0}%
+            {%
+				\ClassError{bangorexam}{There is no Section B defined in this exam}\relax%
+			}%
+            {\relax}%
+    }%
+}
+
 %    \end{macrocode}%\iffalse
 %    \begin{macrocode}
 %</bangorexam.cls>

Modified: trunk/Master/texmf-dist/tex/latex/bangorexam/bangorexam.cls
===================================================================
--- trunk/Master/texmf-dist/tex/latex/bangorexam/bangorexam.cls	2016-10-18 01:16:50 UTC (rev 42298)
+++ trunk/Master/texmf-dist/tex/latex/bangorexam/bangorexam.cls	2016-10-18 21:23:06 UTC (rev 42299)
@@ -39,11 +39,11 @@
 %%   Right bracket \] Circumflex\^ Underscore\_
 %%   Grave accent  \` Left brace\{ Vertical bar  \|
 %%   Right brace   \} Tilde \~}
-\def\version{1.0.0}
+\def\version{1.1.0}
 
 \NeedsTeXFormat{LaTeX2e}
 
-\ProvidesClass{bangorexam}[2016/10/03 \version C. Gray]
+\ProvidesClass{bangorexam}[2016/10/17 \version{}C. Gray]
 
 
 \RequirePackage[dvipsnames]{xcolor}
@@ -56,7 +56,6 @@
 \RequirePackage{color}
 \RequirePackage{etoolbox}
 \RequirePackage{graphicx}
-\RequirePackage{ifthen}
 \RequirePackage{letltxmacro}
 \RequirePackage{newpxtext,newpxmath}
 \RequirePackage{totcount}
@@ -65,26 +64,30 @@
 \RequirePackage{courier}
 
 
+\newcommand{\engATypeText}{Answer {\bf Section A} (compulsory) and {\bf any two} questions from {\bf Section B}.}%
+\newcommand{\welATypeText}{Atebwch {\bf Adran A} (gorfodol) ac {\bf unrhyw ddau} gwestiwn o {\bf Adran B}.}%
+\newcommand{\engBTypeText}{Answer \textbf{two} out of four questions.}%
+\newcommand{\welBTypeText}{Atebwch \textbf{ddau} o'r pedwar cwestiwn.}%
+\newcommand{\sectionAHeader}{\textbf{SECTION A} --- Answer \textbf{ALL} questions (Total marks \total{sectiona})}%
+\newcommand{\sectionBHeader}{\textbf{SECTION B} --- Answer any \textbf{TWO} questions (\total{sectionb} marks each)}%
+
+
 \DeclareOption{welsh}{%
 \newcommand{\welsh}{true}%
+\renewcommand{\sectionAHeader}{\textbf{ADRAN A} --- Atebwch BOB cwestiwn (Cyfanswm marciau \total{sectiona})}%
+\renewcommand{\sectionBHeader}{\textbf{ADRAN B} --- Atebwch unrhyw DDAU chwestiwn (\total{sectionb} marc yr un)}%
 }%
+\newcommand{\engTypeText}{}
+\newcommand{\welTypeText}{}
 \DeclareOption{ab}{%
-\newtotcounter{sectiona}%
-\newtotcounter{sectionb}
 \newcommand{\examtype}{ab}%
-\newcommand{\engTypeText}{Answer {\bf Section A} (compulsory) and {\bf any two} questions from {\bf Section B}.}%
-\newcommand{\welTypeText}{Atebwch {\bf Adran A} (gorfodol) ac {\bf unrhyw ddau} gwestiwn o {\bf Adran B}.}%
-\newcommand{\sectionAHeader}{\textbf{ADRAN A} --- Atebwch BOB cwestiwn (Cyfanswm marciau \total{sectiona})}%
-\newcommand{\sectionBHeader}{\textbf{ADRAN B} --- Atebwch unrhyw DDAU chwestiwn (\total{sectionb} marc yr un)}%
-\ifx\welsh\undefined%
-\renewcommand{\sectionAHeader}{\textbf{SECTION A} --- Answer \textbf{ALL} questions (Total marks \total{sectiona})}%
-\renewcommand{\sectionBHeader}{\textbf{SECTION B} --- Answer any \textbf{TWO} questions (\total{sectionb} marks each)}%
-\fi%
+\renewcommand{\engTypeText}{\engATypeText}
+\renewcommand{\welTypeText}{\welATypeText}
 }%
 \DeclareOption{twofour}{%
 \newcommand{\examtype}{twofour}%
-\newcommand{\engTypeText}{Answer \textbf{two} out of four questions.}%
-\newcommand{\welTypeTest}{Atebwch \textbf{ddau} o'r pedwar cwestiwn.}%
+\renewcommand{\engTypeText}{\engBTypeText}
+\renewcommand{\welTypeText}{\welBTypeText}
 }%
 \DeclareOption{answers}{\PassOptionsToClass{\CurrentOption}{exam}}%
 \DeclareOption{draft}{\PassOptionsToClass{\CurrentOption}{exam}}%
@@ -91,7 +94,7 @@
 \ProcessOptions\relax%
 
 \ifx\examtype\undefined%
-\ClassError{bangorexam}{An exam type option has not been defined; use ab or twofour in the class options.}%
+\ClassError{bangorexam}{An exam type option has not been defined; use ab or twofour in the class options}%
 \fi%
 
 \LoadClass[a4paper,twoside,11pt,addpoints]{exam}%
@@ -101,14 +104,18 @@
 
 \pagestyle{headandfoot}%
 \coverfooter{}{}{\iflastpage{}{/ troi drosodd\\/ turn over}{}}%
-\footer{}{}{\oddeven{}{\iflastpage{}{/ troi drosodd / turn over}}}%
+\footer{}{}{\oddeven{}{\iflastpage{}{/ troi drosodd\\/ turn over}}}%
 
 \newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}
 
 \SolutionEmphasis{\color{red}}
+\CorrectChoiceEmphasis{\bfseries\color{red}}
 
 \newcounter{tmp}
 \newtotcounter{all}
+\newtotcounter{tf}
+\newtotcounter{sectiona}
+\newtotcounter{sectionb}
 
 \newcommand{\school}[2] {%
 \def \engSchool {\expandafter\MakeUppercase\expandafter{#1}}%
@@ -169,16 +176,16 @@
 
 \renewcommand{\maketitle}{%
 \ifx\timeAllowed\undefined%
-\ClassError{bangorexam}{The time allowed for this exam has not been defined (missing \backslash timealllowed?).}%
+\ClassError{bangorexam}{The time allowed for this exam has not been defined (missing timealllowed?)}%
 \fi%
 \ifx\engExamMonth\undefined%
-\ClassError{bangorexam}{The exam period for this exam has not been set (missing \backslash examperiod?).}%
+\ClassError{bangorexam}{The exam period for this exam has not been set (missing examperiod?)}%
 \fi%
 \ifx\moduleCode\undefined%
-\ClassError{bangorexam}{The module details for this exam have not been specified (missing \backslash module?).}%
+\ClassError{bangorexam}{The module details for this exam have not been specified (missing module?)}%
 \fi%
 \ifx\welSchool\undefined%
-\ClassError{bangorexam}{The academic school setting this exam has not been defined (missing \backslash school?).}%
+\ClassError{bangorexam}{The academic school setting this exam has not been defined (missing school?)}%
 \fi%
 
 \begin{center}
@@ -220,7 +227,8 @@
 \
 
 \medskip
-{\bf Total marks \total{all}}
+{\bf Total marks \total{all}\\
+     Cyfanswm Marciau \total{all}}
 \vfill
 \end{center}
 }
@@ -231,15 +239,32 @@
 \maketitle
 \end{coverpages}
 \pointsinrightmargin
+\ifthenelse{\equal{\examtype}{twofour}}{
+\clearpage
+{%
+\LARGE
+\textbf{\moduleCode: \quad \moduleName}
+
+\vspace*{8mm}
+\large
+\ifcsdef{guidance at a}{\normalsize\par\guidance at a}{}%
 }
+\vspace*{8mm}
+}{}%
+}
 
-\newcommand{\hassectiona}{false}%
-\newcommand{\hassectionb}{false}%
+\newcounter{seca}
+\newcounter{secb}
 \newcommand{\inDoc}{none}%
 \newcommand{\sectiona} {%
-\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{\\sectiona used in a 'two from four' exam.}}{}%
-\ifthenelse{\equal{\hassectiona}{true}}{\ClassError{bangorexam}{There is already a \\sectiona in this exam.}}{}%
-\renewcommand{\hassectiona}{true}%
+\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{Section A defined in a 'two from four' exam}\relax}{}%
+\ifnumcomp{\value{seca}}{>}{0}
+{
+\ClassError{bangorexam}{There is already a Section A in this exam}\relax%
+}
+{
+\stepcounter{seca}\relax%
+}
 \renewcommand{\inDoc}{secA}%
 \clearpage
 {%
@@ -255,9 +280,14 @@
 }
 
 \newcommand{\sectionb}{%
-\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{\\sectionb used in a 'two from four' exam.}}{}
-\ifthenelse{\equal{\hassectionb}{true}}{\ClassError{bangorexam}{There is already a \\sectionb in this exam.}}{}
-\renewcommand{\hassectionb}{true}
+\ifthenelse{\equal{\examtype}{twofour}}{\ClassError{bangorexam}{Section B defined in a 'two from four' exam}\relax}{}
+\ifnumcomp{\value{secb}}{>}{0}
+{
+\ClassError{bangorexam}{There is already a Section B in this exam}\relax%
+}
+{
+\stepcounter{secb}\relax%
+}
 \renewcommand{\inDoc}{secB}
 \clearpage
 {%
@@ -299,10 +329,26 @@
             \ifnumcomp{\value{sectionb}}{=}{#1}%
                 {}%
                 {%
-                    \ClassError{bangorexam}{Section B question \arabic{question} does not have an equal number of points (Existing Section B question worth \arabic{sectionb})}%
+                    \ClassError{bangorexam}{Section B question \arabic{question} does not have an equal number of points (Existing Section B question worth \arabic{sectionb})}\relax%
                 }%
         }%
         {}%
+     \edef\mytemp{{\examtype}}%
+     \expandafter\ifstrequal\mytemp{twofour}%
+{%
+            \ifnumcomp{\value{tf}}{=}{0}%
+                {%
+                    \addtocounter{tf}{#1}%
+                    \addtocounter{all}{#1}%
+                    \addtocounter{all}{#1}}%
+                {}%
+            \ifnumcomp{\value{tf}}{=}{#1}%
+                {}%
+                {%
+                    \ClassError{bangorexam}{Question \arabic{question} does not have an equal number of points (Existing question(s) worth \arabic{tf})}\relax%
+                }%
+        }%
+        {}%
 }
 
 \newcommand{\patchqnumaddpoints}{%
@@ -313,6 +359,32 @@
 \newcommand{\pointsdec}[1]{%
 \pointname{#1}\patchqnumaddpoints
 }
+
+
+\AtEndDocument{%
+\edef\mytemp{{\examtype}}%
+    \expandafter\ifstrequal\mytemp{twofour}%
+    {%
+        \edef\mytmp{\numquestions}%
+\expandafter\ifstrequal\mytmp{4}%
+{\relax}%
+{%
+\ClassError{bangorexam}{There is/are only (\numquestions) question(s) defined, there should be four}\relax%
+}%
+    }{%
+        \ifnumcomp{\value{seca}}{=}{0}%
+            {%
+\ClassError{bangorexam}{There is no Section A defined in this exam}\relax%
+}%
+            {\relax}%
+        \ifnumcomp{\value{secb}}{=}{0}%
+            {%
+\ClassError{bangorexam}{There is no Section B defined in this exam}\relax%
+}%
+            {\relax}%
+    }%
+}
+
 \endinput
 %%
 %% End of file `bangorexam.cls'.



More information about the tex-live-commits mailing list