| 1 |
% \iffalse |
| 2 |
% File: examdesign.dtx Copyright (C) 1997-2001 Jason Alexander |
| 3 |
% Copyright (C) 19yy name of author |
| 4 |
% |
| 5 |
% This program is free software; you can redistribute it and/or |
| 6 |
% modify it under the terms of the GNU General Public License |
| 7 |
% as published by the Free Software Foundation; either version 2 |
| 8 |
% of the License, or (at your option) any later version. |
| 9 |
% |
| 10 |
% This program is distributed in the hope that it will be useful, |
| 11 |
% but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
% GNU General Public License for more details. |
| 14 |
% |
| 15 |
% You should have received a copy of the GNU General Public License along with |
| 16 |
% this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
| 17 |
% Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 |
% |
| 19 |
% For error reports, or offers to help improve the 'examdesign' class |
| 20 |
% please contact me at [email protected]. |
| 21 |
% \fi |
| 22 |
% \ProvidesFile{examdesign.dtx} |
| 23 |
% [1997/11/22 v1.02 `examdesign' class (JMA)] |
| 24 |
% \iffalse |
| 25 |
%<*driver> |
| 26 |
\documentclass{ltxdoc} |
| 27 |
\usepackage{tabularx} |
| 28 |
\CodelineIndex |
| 29 |
\EnableCrossrefs |
| 30 |
\RecordChanges |
| 31 |
\begin{document} |
| 32 |
\DocInput{examdesign.dtx}% \PrintIndex |
| 33 |
\end{document} |
| 34 |
%</driver> |
| 35 |
%\fi |
| 36 |
% \MakeShortVerb{\|} |
| 37 |
% \MakeShortVerb{\"} |
| 38 |
% |
| 39 |
% \def\fileversion{v1.1} |
| 40 |
% \def\filedate{2001/3/26} |
| 41 |
% \changes{v1.00}{1997/10/11}{Initial version.} |
| 42 |
% \changes{v1.01}{1997/10/22}{Fixed several bugs, added |
| 43 |
% \texttt{StudentInfoLineSpacing} |
| 44 |
% command, included two example files |
| 45 |
% to better illustrate the class features.} |
| 46 |
% \changes{v1.02}{1997/11/22}{Added the \textsf{block}, \textsf{frontmatter}, |
| 47 |
% \textsf{endmatter}, \textsf{examtop}, \textsf{keytop}, \textsf{exampreface}, |
| 48 |
% \textsf{keypreface}, \textsf{examclosing}, \textsf{keyclosing} environments |
| 49 |
% and the commands \texttt{word}, \texttt{exam}, \texttt{key}, |
| 50 |
% \texttt{examvspace}, \texttt{examvspace*}, \texttt{examhspace}, |
| 51 |
% \texttt{examhspace*}, \texttt{keyvspace}, \texttt{keyvspace*}, |
| 52 |
% \texttt{keyhspace}, and \texttt{keyhspace*}. Fixed a bug that prevented |
| 53 |
% the \textsf{multiplechoice} environment from identifying the answer |
| 54 |
% in the answer key if the correct answer was the last choice. Added |
| 55 |
% the \texttt{onekey} option. Fixed a careless bug that broke the |
| 56 |
% cedilla.} |
| 57 |
% \changes{v1.1}{2001/3/26}{Reworked the internal code, added the |
| 58 |
% \textsf{matching} environment, and changed the input syntax considerably to |
| 59 |
% make it (I hope) more user-friendly. Questions can now be numbered |
| 60 |
% continously across sections, plus more\ldots} |
| 61 |
% \changes{v1.101}{2006/09/05}{Jim Hefferon Changed name of files and class to |
| 62 |
% examdesign to avoid name clashes with another package, after getting OK |
| 63 |
% from author.} |
| 64 |
% |
| 65 |
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 66 |
% |
| 67 |
% \title{The \textsf{examdesign} class\thanks{This file |
| 68 |
% has version number \fileversion, last |
| 69 |
% revised \filedate.}} |
| 70 |
% \author{Jason Alexander} |
| 71 |
% \date{\filedate} |
| 72 |
% \maketitle |
| 73 |
% \hfuzz=72pt |
| 74 |
% \vfuzz=36pt |
| 75 |
% |
| 76 |
% \DoNotIndex{\if,\else,\fi,\expandafter} |
| 77 |
% \DoNotIndex{\csname,\endcsname} |
| 78 |
% \DoNotIndex{\addtocounter,\stepcounter,\advance,\Alph,\alph,\arabic} |
| 79 |
% \DoNotIndex{\begin,\end,\begingroup,\endgroup,\catcode,\centerline,\day,\def} |
| 80 |
% \DoNotIndex{\divide,\do,\edef,\endgroup,\evensidemargin,\fbox,\gdef,\global} |
| 81 |
% \DoNotIndex{\headheight,\headsep,\hfill,\hphantom,\Huge,\ifnum,\ifx,\large} |
| 82 |
% \DoNotIndex{\long,\m@ne,\mbox,\medskip,\message,\month,\multiply} |
| 83 |
% \DoNotIndex{\noindent,\nopagebreak,\normalsize,\oddsidemargin,\pagebreak} |
| 84 |
% \DoNotIndex{\par,\relax,\rightmargin,\roman,\setcounter,\setlength} |
| 85 |
% \DoNotIndex{\smallskipamount,\space,\textheight,\textsf,\textwidth} |
| 86 |
% \DoNotIndex{\the,\topmargin,\undefined,\underline,\value,\vspace} |
| 87 |
% \DoNotIndex{\xdef,\year,\z@,\time,\topsep} |
| 88 |
% |
| 89 |
% \begin{abstract} |
| 90 |
% A new class, \textsf{examdesign}, for \LaTeXe\ is defined. It provides |
| 91 |
% several features useful for designing tests or question sets: (1) it allows |
| 92 |
% for an explicit markup of questions and answers; (2) the class will, at the |
| 93 |
% user's request, automatically generate answer keys; (3) multiple versions of |
| 94 |
% the same test can be generated automatically, with the ordering of questions |
| 95 |
% within each section randomly permuted so as to minimize cheating; (4) the |
| 96 |
% generated answer keys can be constructed either with or without the |
| 97 |
% questions included; and (4) some environments are provided to assist in |
| 98 |
% constructing the most common types of test question: matching, |
| 99 |
% true/false, multiple-choice, fill-in-the-blank, and short answer/essay |
| 100 |
% questions |
| 101 |
% \end{abstract} |
| 102 |
% |
| 103 |
% \section{Description} |
| 104 |
% |
| 105 |
% Teaching is a rewarding and enjoyable profession, designing exams is not. |
| 106 |
% \emph{Grading} exams is even worse, but for help with that last bit you'll |
| 107 |
% need more than a \LaTeX\ class. This class file started out with a |
| 108 |
% relatively simply goal: randomize a collection of questions so that the |
| 109 |
% author wouldn't need to do it by hand. Since then, it has grown |
| 110 |
% in functionality and size and is now (I hope) a reasonably complete |
| 111 |
% general-purpose class for constructing exams and question sets. |
| 112 |
% |
| 113 |
% |
| 114 |
% \section{Usage} |
| 115 |
% |
| 116 |
% To begin, simply create a new \LaTeXe\ document starting with |
| 117 |
% \begin{verbatim} |
| 118 |
% \documentclass{examdesign} |
| 119 |
% \begin{document}\end{verbatim} |
| 120 |
% If you want to create an exam in 12pt type, use |
| 121 |
% "\documentclass[12pt]{examdesign}" instead. If you need to load |
| 122 |
% additional packages, they may be loaded via the command "\usepackage" as |
| 123 |
% always. The class includes a number of packages included with a standard \LaTeX\ |
| 124 |
% distribution: \textsf{keyval}, \textsf{multicol}, and \textsf{enumerate}. |
| 125 |
% If you don't have these packages, your \LaTeX\ distribution is nonstandard |
| 126 |
% (or incomplete), and you'll have to grab these packages from the nearest |
| 127 |
% CTAN site in order to use \textsf{examdesign}. |
| 128 |
% |
| 129 |
% Most exams/questions sets are split into sections according to the type of |
| 130 |
% question asked, and \textsf{examdesign} follows this practice. There are five |
| 131 |
% environments defined, one environment for each type of question: \textsf{matching}, |
| 132 |
% \textsf{shortanswer}, \textsf{truefalse}, \textsf{multiplechoice}, and |
| 133 |
% \textsf{fillin}. \textbf{N.B.} Previous versions of \textsf{examdesign} had |
| 134 |
% starred forms of these environments of well. The starred forms (as well as |
| 135 |
% the \textsf{fixed} environment, have been eliminated in this new release. |
| 136 |
% Their functionality has been incorporated into the standard environments. |
| 137 |
% |
| 138 |
% All the environments are designed to make binding answers to questions |
| 139 |
% easier. This not only makes the job of writing the exam easier, |
| 140 |
% but it allows the automated generation of answer keys. |
| 141 |
% |
| 142 |
% \subsection{Switches} |
| 143 |
% There are two ways to customize the output of the \textsf{exam} |
| 144 |
% class: switches and special formatting environments. |
| 145 |
% Descriptions of the special formatting environments (such as |
| 146 |
% \textsf{frontmatter}, \textsf{endmatter}, etc.) can be found in section |
| 147 |
% \ref{SFE}. |
| 148 |
% |
| 149 |
% A switch is a single command that changes an internal parameter |
| 150 |
% influencing the overall formatting of the exam. Switches should be included |
| 151 |
% in the preamble because doing so will guarantee that they will apply to the |
| 152 |
% entire exam. Putting |
| 153 |
% switches elsewhere may result in odd results because \textsf{examdesign} shuffles |
| 154 |
% around what you write quite a lot, and you won't always know when a |
| 155 |
% switch will be executed. |
| 156 |
% |
| 157 |
% One change between this release and previous releases is that all of the |
| 158 |
% class options unique to \textsf{examdesign} have been converted to switches for |
| 159 |
% sake of consistency. |
| 160 |
% |
| 161 |
% \DescribeMacro{\NoRearrange} |
| 162 |
% Although the original reason behind writing \textsf{examdesign} was to automate |
| 163 |
% the random rearranging of questions, people have pointed out that it would |
| 164 |
% be nice to turn off the feature (say, when writing the exam). The |
| 165 |
% "\NoRearrange" switch suppresses the rearrangement of questions. You can |
| 166 |
% override this setting on a section-by-section basis, though, by setting the |
| 167 |
% correct environment option (see the discussion of the options in |
| 168 |
% section~\ref{env} for more details). In addition, see the discussion of the |
| 169 |
% "\setrandomseed" macro below for how to generate ``randomly rearranged'' |
| 170 |
% question sets in the \emph{same} order across runs. |
| 171 |
% |
| 172 |
% \DescribeMacro{\NoKey} |
| 173 |
% \DescribeMacro{\OneKey} |
| 174 |
% The switch "\NoKey" suppresses the generation of all answer keys, whereas |
| 175 |
% "\OneKey" generates an answer key for the first exam only. |
| 176 |
% |
| 177 |
% \DescribeMacro{\BoldfaceCorrectMultipleChoiceAnswer} |
| 178 |
% \DescribeMacro{\UnderlineCorrectMultipleChoiceAnswer} |
| 179 |
% The switch "\BoldfaceCorrectMultipleChoiceAnswer" identifies the correct |
| 180 |
% answer in multiple choice questions by using boldface text instead of |
| 181 |
% placing a box around the correct letter. The switch |
| 182 |
% "\UnderlineCorrectMultipleChoiceAnswer" identifies the correct answer in |
| 183 |
% multiple |
| 184 |
% choice questions by underlining. These two switches are cumulative: |
| 185 |
% including both in your exam will |
| 186 |
% give you boldface underlined answers (the order doesn't matter). If neither |
| 187 |
% one is specified, |
| 188 |
% \textsf{examdesign} will default to boxing the letter of the correct answer. This |
| 189 |
% is shown in the examples below. |
| 190 |
% |
| 191 |
% Technical note: The ordinary \LaTeXe\ "\underline" command does not work |
| 192 |
% well when the underlined text spans several lines. Consequently, |
| 193 |
% I've incorporated the \textsf{ulem} package, written |
| 194 |
% by Donald Arseneau, for underlining. Since this package is embedded |
| 195 |
% in this class, you do not need to load it again if you should need it. |
| 196 |
% |
| 197 |
% \DescribeMacro{\NumberOfVersions} |
| 198 |
% The "\NumberOfVersions" macro takes a single numerical argument---the number of |
| 199 |
% different versions of the test to generate. Under the default |
| 200 |
% settings, if you request more than 26 versions of the test you will |
| 201 |
% get an error. This is because the forms are labelled according to letters of |
| 202 |
% the alphabet, and \LaTeXe\ doesn't like it when you try to ask |
| 203 |
% for the 27th letter of the alphabet. If you \emph{really} need more than 27 |
| 204 |
% copies of an exam, you will need to use one of the |
| 205 |
% special formatting environments redefine the material inserted at the top of |
| 206 |
% each exam and key. |
| 207 |
% |
| 208 |
% \DescribeMacro{\class} |
| 209 |
% The "\class" macro takes one argument: the name of the class to appear on |
| 210 |
% the exam. For example, "\class{Math 205A: Set Theory}" will cause the |
| 211 |
% name of the class to appear in the appropriate place (if you are using the |
| 212 |
% default setting). |
| 213 |
% |
| 214 |
% \DescribeMacro{\examname} |
| 215 |
% |\examname| takes one argument, just like |\class|. The argument is used to |
| 216 |
% identify the type of test. For example, |\examname{Final Exam}|, |
| 217 |
% |\examname{Midterm Exam}|, |\examname{Pop Quiz}|,\ldots |
| 218 |
% |
| 219 |
% \DescribeMacro{\ConstantBlanks} |
| 220 |
% |\ConstantBlanks| has one mandatory argument (a length). It tells \TeX\ to |
| 221 |
% typeset the underline in fill-in-the-blank environments using lines of a |
| 222 |
% constant length, regardless of the length of the correct word. |
| 223 |
% |
| 224 |
% \DescribeMacro{\ProportionalBlanks} |
| 225 |
% |\ProportionalBlanks| has one mandatory argument (a real number $r$). It tells \TeX\ |
| 226 |
% to typeset the underline in fill-in-the-blank environments using lines that |
| 227 |
% are exactly $r$ times the length of the correct answer when the correct |
| 228 |
% answer is typeset by \TeX. The default setting is |\ProportionalBlanks{1}|. |
| 229 |
% If you include both "\ConstantBlanks" and "\ProportionalBlanks" in the preamble, |
| 230 |
% the exam will be typeset using whichever switch was last set. |
| 231 |
% |
| 232 |
% \DescribeMacro{\StudentInfoLineSpacing} |
| 233 |
% |\StudentInfoLineSpacing| requires a length as its argument. This value |
| 234 |
% is used to determine the amount of additional spacing between lines in |
| 235 |
% the student data box appearing in the upper right-hand corner of the exam. |
| 236 |
% The default value is 6pt. If you change the definitions these environments |
| 237 |
% using \textsf{examtop} and \textsf{keytop}, this command will have no effect. |
| 238 |
% |
| 239 |
% \DescribeMacro{\SectionFont} |
| 240 |
% This macro takes one argument, which can be any declarative font-changing |
| 241 |
% commands (i.e., "\em" rather than "\emph"). It changes the default font |
| 242 |
% used to typeset the section titles. |
| 243 |
% |
| 244 |
% \DescribeMacro{\ContinuousNumbering} |
| 245 |
% This macro takes no argument. It changes the default numbering behavior. |
| 246 |
% Instead of resetting the numbers at the start of each section, it will |
| 247 |
% continue the numbering from previous sections. (Notice that the |
| 248 |
% \textsf{matching} and \textsf{truefalse} environments are not affected by |
| 249 |
% this, as they don't number their questions.) |
| 250 |
% |
| 251 |
% \DescribeMacro{\ShortKey} |
| 252 |
% This macro takes no argument. It changes the way answer keys are typeset. |
| 253 |
% Basically, it will delete any question text, any instructions at the start |
| 254 |
% of a block of questions (or at the start of a section), and only print the |
| 255 |
% answer. |
| 256 |
% |
| 257 |
% \DescribeMacro{\DefineAnswerWrapper} |
| 258 |
% This macro takes two arguments. For the \textsf{shortanswer} environment, |
| 259 |
% the first argument will always be inserted before the answer, and the second |
| 260 |
% argument will always be inserted after the answer. |
| 261 |
% |
| 262 |
% \DescribeMacro{\SectionPrefix} |
| 263 |
% This macro takes one argument, which specifies the default appearance of the |
| 264 |
% section number preceding each title. Its default setting is\hfil\break |
| 265 |
% "\SectionPrefix{Section \arabic{sectionindex}. \space}" |
| 266 |
% |
| 267 |
% |
| 268 |
% \subsubsection{Summary of Switches} |
| 269 |
% |
| 270 |
% \medskip |
| 271 |
% |
| 272 |
% \begin{tabular}{p{2in}l} |
| 273 |
% {\large Switch Name} \rule[-3pt]{0pt}{15pt} & {\large Function} \\ \hline |
| 274 |
% "\NoKey" & Suppress all answer keys \\ |
| 275 |
% "\OneKey" & Generate only the first answer key, suppressing all others \\ |
| 276 |
% \multicolumn{2}{l}{\texttt \textbackslash BoldfaceCorrectMultipleChoiceAnswer See above}\\ |
| 277 |
% \multicolumn{2}{l}{\texttt \textbackslash UnderlineCorrectMultipleChoiceAnswer See above}\\ |
| 278 |
% "\NumberOfVersions" & specify number of exams to make \\ |
| 279 |
% "\class" & Class data (E.g., ``Philosophy 29'') \\ |
| 280 |
% "\examname" & Exam name (E.g., ``Midterm Exam'') \\ |
| 281 |
% "\ConstantBlanks" & See above \\ |
| 282 |
% "\ProportionalBlanks" & See above \\ |
| 283 |
% "\StudentInfoLineSpacing" & Set spacing in data box \\ |
| 284 |
% "\SectionFont" & Change section font\\ |
| 285 |
% "\ContinuousNumbering" & Change numbering style\\ |
| 286 |
% "\ShortKey" & Change key formatting\\ |
| 287 |
% "\DefineAnswerWrapper" & Change tags surrounding answers\\ |
| 288 |
% "\SectionPrefix" & Change the appearance of the section number\\ |
| 289 |
% \end{tabular} |
| 290 |
% \MakeShortVerb{\|} |
| 291 |
% |
| 292 |
% \subsection{Environments\label{env}} |
| 293 |
% |
| 294 |
% There has been a significant change in the environments between this version |
| 295 |
% of \textsf{examdesign} and earlier versions. In this version, all question |
| 296 |
% environments can take an optional single argument which can be used to set a |
| 297 |
% number of different parameters. (Before, the optional argument was used to |
| 298 |
% set the title for a section.) Exams written for the previous version will |
| 299 |
% have to be updated to work with the new version. Sorry. |
| 300 |
% |
| 301 |
% The options available for each section are: |
| 302 |
% |
| 303 |
% \noindent |
| 304 |
% \begin{tabularx}{\linewidth}{>{\tt}lX} |
| 305 |
% Name & Function\\\hline |
| 306 |
% title & Specifies the title for each section. When no title is specified, |
| 307 |
% no section number is displayed (giving an entirely blank header before the |
| 308 |
% section). However, the section instructions will still be printed. If you |
| 309 |
% would like a section number \emph{without} a title, simply give a blank |
| 310 |
% space for the title, or use "\relax", as in "title={ }" or "title={\relax}".\\ |
| 311 |
% rearrange & This option takes one of two values, either "yes" or "no". If |
| 312 |
% "yes",then the questions in that section are randomly rearranged; if "no", |
| 313 |
% then questions in that section appear in the order in which they are |
| 314 |
% written. This option works for all environments (and hence replaces the old |
| 315 |
% \textsf{fixed} environment).\\ |
| 316 |
% resetcounter & This option takes one of two values, either "yes" or "no". |
| 317 |
% If "yes", then the question numbers for that section start at 1, overriding |
| 318 |
% the "\ContinuousNumbering" switch. If "no", then the question numbers for |
| 319 |
% that section will not be reset. This gives you section-level control over |
| 320 |
% the numbering.\\ |
| 321 |
% keycolumns & This option should be set to a number. It specifies the number |
| 322 |
% of columns that should be used when typesetting the section in the answer |
| 323 |
% key. For example, if you use the "\ShortKey" switch to only include the |
| 324 |
% correct answer for multiple-choice questions, each answer takes up very |
| 325 |
% little space on the line. If you have 40 questions, it would take 40 |
| 326 |
% lines---a waste of paper. Setting "keycolumns=5" would typeset the answer |
| 327 |
% key using 5 columns, requiring only 8 lines for the answers. The section |
| 328 |
% instructions will \emph{not} be typeset in columns, but will span the width |
| 329 |
% of the page, instead. Note that it is very easy to get overfull/underfull |
| 330 |
% box messages with this option (and the next).\\ |
| 331 |
% examcolumns & Same as above, except it affects the exam.\\ |
| 332 |
% suppressprefix & Can be set to either "yes" or "no". If "yes", it |
| 333 |
% suppresses the section prefix for that particular section; if "no", the |
| 334 |
% prefix will appear as always. This option replaces the starred environments |
| 335 |
% in the the previous release.\\ |
| 336 |
%\end{tabularx} |
| 337 |
% |
| 338 |
% \subsubsection{The \textsf{fillin} environment} |
| 339 |
% |
| 340 |
% This environment is for fill-in-the-blank questions. |
| 341 |
% The syntax is: |
| 342 |
% \begin{verbatim} |
| 343 |
% \begin{fillin}[title={Insert title here}] |
| 344 |
% \begin{question} |
| 345 |
% How much \blank{wood} could a \blank{woodchuck} chuck if a woodchuck could |
| 346 |
% \blank{chuck} wood? |
| 347 |
% \end{question} |
| 348 |
% \end{fillin}\end{verbatim} |
| 349 |
% When typeset using "\ProportionalBlanks", the questions will be printed in |
| 350 |
% the exam as: |
| 351 |
% \def\blank#1{$\underline{\mbox{\hphantom{#1}}}$} |
| 352 |
% \begin{enumerate} |
| 353 |
% \item How much \blank{wood} could a \blank{woodchuck} chuck if a woodchuck could |
| 354 |
% \blank{chuck} wood? |
| 355 |
% \end{enumerate} |
| 356 |
% but in the answer key as: |
| 357 |
% \def\blank#1{$\underline{\mbox{#1}}$} |
| 358 |
% \begin{enumerate} |
| 359 |
% \item How much \blank{wood} could a \blank{woodchuck} chuck if a woodchuck could |
| 360 |
% \blank{chuck} wood? |
| 361 |
% \end{enumerate} |
| 362 |
% |
| 363 |
% \subsubsection{The \textsf{shortanswer} environment} |
| 364 |
% |
| 365 |
% The \textsf{shortanswer} environment does not format its questions in any |
| 366 |
% way other than enumerating them. (It is then a catch-all environment for |
| 367 |
% any other type of question.) It does allow the group of |
| 368 |
% answers with questions. Including an answer is not mandatory (but you will get |
| 369 |
% errors if you do not include an answer and ask for a "\ShortKey"). |
| 370 |
% The general syntax is: |
| 371 |
% \begin{verbatim} |
| 372 |
% \begin{shortanswer}[title={Interesting questions...}, |
| 373 |
% rearrange=yes] |
| 374 |
% \begin{question} |
| 375 |
% State Hobbes' definition of the state of nature and the role it plays in |
| 376 |
% his social philosophy. |
| 377 |
% \begin{answer} |
| 378 |
% The state of nature is\ldots |
| 379 |
% \end{answer} |
| 380 |
% \end{question} |
| 381 |
% |
| 382 |
% \begin{question} |
| 383 |
% State several examples that seem to illustrate that Mill's theory of |
| 384 |
% Utilitarianism cannot be followed in practice, and explain why. |
| 385 |
% Afterwards, state Mill's response to the problems you raised. |
| 386 |
% \begin{answer} |
| 387 |
% Often times it appears we need to act on our moral instincts without |
| 388 |
% taking time to deliberate (as in the case of saving a drowning child). |
| 389 |
% According to Mill, though, it seems that before each moral action we |
| 390 |
% ought to deliberate in order to be sure that the action we take is such |
| 391 |
% as to maximize the overall general utility\ldots |
| 392 |
% \end{answer} |
| 393 |
% \end{question} |
| 394 |
% \end{shortanswer} |
| 395 |
% \end{verbatim} |
| 396 |
% \vspace{-\baselineskip} |
| 397 |
% Note that the \textsf{answer} environment appears inside the \textsf{question} |
| 398 |
% environment. |
| 399 |
% |
| 400 |
% In the exam, this will be typeset as: |
| 401 |
% \begin{enumerate}% |
| 402 |
% \item State Hobbes' definition of the state of nature and the role it plays in |
| 403 |
% his social philosophy. |
| 404 |
% \item State several examples that seem to illustrate that Mill's theory of |
| 405 |
% Utilitarianism cannot be followed in practice, and explain why. |
| 406 |
% Afterwards, state Mill's response to the problems you raised. |
| 407 |
% \end{enumerate}% |
| 408 |
% The answer key, in normal form with the default definition of |
| 409 |
% "\DefineAnswerWrapper", will appear as: |
| 410 |
% \begin{enumerate}% |
| 411 |
% \item State Hobbes' definition of the state of nature and the role it plays in |
| 412 |
% his social philosophy. |
| 413 |
% \begin{description}% |
| 414 |
% \item[Answer:] The state of nature is\ldots |
| 415 |
% \end{description}% |
| 416 |
% \item State several examples that seem to illustrate that Mill's theory of |
| 417 |
% Utilitarianism cannot be followed in practice, and explain why. |
| 418 |
% Afterwards, state Mill's response to the problems you raised. |
| 419 |
% \begin{description}% |
| 420 |
% \item[Answer:] Often times it appears we need to act on our moral |
| 421 |
% instincts without taking time to deliberate (as in the case of |
| 422 |
% saving a drowning child). According to Mill, though, it seems that |
| 423 |
% before each moral action we ought to deliberate in order to be sure |
| 424 |
% that the action we take is such as to maximize the overall general |
| 425 |
% utility\ldots |
| 426 |
% \end{description}% |
| 427 |
% \end{enumerate}% |
| 428 |
% If you specify a "\ShortKey", only the answers will be presented: |
| 429 |
% \begin{enumerate}% |
| 430 |
% \item \begin{description} |
| 431 |
% \item[Answer:] The state of nature is\ldots |
| 432 |
% \end{description} |
| 433 |
% \item \begin{description} |
| 434 |
% \item[Answer:] Often times it appears we need to act on our moral |
| 435 |
% instincts without taking time to deliberate (as in the case of |
| 436 |
% saving a drowning child). According to Mill, though, it seems that |
| 437 |
% before each moral action we ought to deliberate in order to be sure |
| 438 |
% that the action we take is such as to maximize the overall general |
| 439 |
% utility\ldots |
| 440 |
% \end{description} |
| 441 |
% \end{enumerate} |
| 442 |
% |
| 443 |
% |
| 444 |
% \subsubsection{The \textsf{truefalse} environment} |
| 445 |
% |
| 446 |
% True/false questions. The general syntax is: |
| 447 |
% \begin{verbatim} |
| 448 |
% \begin{truefalse} |
| 449 |
% \begin{question} |
| 450 |
% \answer{False} Laden swallows fly faster than unladen swallows, |
| 451 |
% especially if they carry coconuts. |
| 452 |
% \end{question} |
| 453 |
% |
| 454 |
% \begin{question} |
| 455 |
% \answer{True} Quantum mechanics was first stated using the |
| 456 |
% mathematical tools of Hilbert spaces by John von~Neumann. |
| 457 |
% \end{question} |
| 458 |
% \end{truefalse}\end{verbatim} |
| 459 |
% |
| 460 |
% Again, note that the \textsf{answer} environment appears within the |
| 461 |
% \textsf{question} environment. The above will be typeset in the exam as: |
| 462 |
% \begin{list}{$\underline{\hskip.5in}$}{\setlength{\rightmargin}{0pt} |
| 463 |
% \setlength{\labelwidth}{.5in} |
| 464 |
% \setlength{\leftmargin}{.6in} |
| 465 |
% \setlength{\labelsep}{.1in} |
| 466 |
% \setlength{\itemindent}{0in} |
| 467 |
% \setlength{\topsep}{4pt} |
| 468 |
% \setlength{\itemsep}{.1in}} |
| 469 |
% \item Laden swallows fly faster than unladen swallows, especially if they |
| 470 |
% carry coconuts. |
| 471 |
% \item Quantum mechanics was first stated using the mathematical tools of Hilbert |
| 472 |
% spaces by John von~Neumann. |
| 473 |
% \end{list} |
| 474 |
% It will be typeset in the answer key as: |
| 475 |
% \begin{list}{$\underline{\hphantom{False}}$}{\setlength{\rightmargin}{0pt} |
| 476 |
% \setlength{\labelwidth}{.5in} |
| 477 |
% \setlength{\leftmargin}{.6in} |
| 478 |
% \setlength{\labelsep}{.1in} |
| 479 |
% \setlength{\itemindent}{0in} |
| 480 |
% \setlength{\topsep}{4pt} |
| 481 |
% \setlength{\itemsep}{.1in}} |
| 482 |
% \item[$\underline{\makebox[.5in][c]{False}}$] Laden swallows fly faster than unladen |
| 483 |
% swallows, especially if they carry coconuts. |
| 484 |
% \item[$\underline{\makebox[.5in][c]{True}}$] Quantum mechanics was first |
| 485 |
% stated using the mathematical tools of Hilbert spaces by John von~Neumann. |
| 486 |
% \end{list} |
| 487 |
% |
| 488 |
% \subsubsection{The \textsf{multiplechoice} Environment} |
| 489 |
% |
| 490 |
% It isn't difficult to format multiple choice questions in ordinary \LaTeX\ with |
| 491 |
% multiply nested \textsf{enumerate}'s, but this environment provides for a |
| 492 |
% simpler entry scheme, and the answer key can indicate the correct answer. |
| 493 |
% The syntax is: |
| 494 |
% \begin{verbatim} |
| 495 |
% \begin{multiplechoice} |
| 496 |
% \begin{question} |
| 497 |
% How much wood could a woodchuck chuck if a woodchuck could chuck wood? |
| 498 |
% \choice{A lot.} |
| 499 |
% \choice{More than most.} |
| 500 |
% \choice{Exactly $\pi$ cords.} |
| 501 |
% \choice[!]{It depends on the nature of the woodchuck.} |
| 502 |
% \end{question} |
| 503 |
% \end{multiplechoice} |
| 504 |
% \end{verbatim} |
| 505 |
% \vspace{-\baselineskip} |
| 506 |
% In the exam, this is typeset as: |
| 507 |
% \begin{enumerate} |
| 508 |
% \item How much wood could a woodchuck chuck if a woodchuck could chuck wood? |
| 509 |
% \begin{list}{$\underline{\hphantom{False}}$}{\setlength{\rightmargin}{0pt} |
| 510 |
% \setlength{\labelwidth}{.4in} |
| 511 |
% \setlength{\leftmargin}{.5in} |
| 512 |
% \setlength{\labelsep}{.1in} |
| 513 |
% \setlength{\itemindent}{0in} |
| 514 |
% \setlength{\topsep}{0pt} |
| 515 |
% \setlength{\itemsep}{0pt}} |
| 516 |
% \item[(a)] A lot. |
| 517 |
% \item[(b)] More than most. |
| 518 |
% \item[(c)] Exactly $\pi$ cords. |
| 519 |
% \item[(d)] It depends on the nature of the woodchuck. |
| 520 |
% \end{list} |
| 521 |
% \end{enumerate} |
| 522 |
% In the answer key, if neither of the options |mcbold| nor |mcunderline| |
| 523 |
% were given, the answer will be typeset as: |
| 524 |
% \begin{enumerate} |
| 525 |
% \item How much wood could a woodchuck chuck if a woodchuck could chuck wood? |
| 526 |
% \begin{list}{$\underline{\hphantom{False}}$}{\setlength{\rightmargin}{0pt} |
| 527 |
% \setlength{\labelwidth}{.4in} |
| 528 |
% \setlength{\leftmargin}{.5in} |
| 529 |
% \setlength{\labelsep}{.1in} |
| 530 |
% \setlength{\itemindent}{0in} |
| 531 |
% \setlength{\topsep}{0pt} |
| 532 |
% \setlength{\itemsep}{0pt}} |
| 533 |
% \item[(a)] A lot. |
| 534 |
% \item[(b)] More than most. |
| 535 |
% \item[(c)] Exactly $\pi$ cords. |
| 536 |
% \item[\fbox{(d)}\hspace{-\fboxsep}] It depends on the nature of the woodchuck. |
| 537 |
% \end{list} |
| 538 |
% \end{enumerate} |
| 539 |
% You can have up to 26 choices. Also, notice that the correct answer was |
| 540 |
% specified by giving the optional argument "[!]" to |\choice|. |
| 541 |
% |
| 542 |
% \subsubsection{The \textsf{matching} environment} |
| 543 |
% |
| 544 |
% This environment is new in this release of \textsf{examdesign}. It provides an |
| 545 |
% environment for the creation of matching tests. The syntax is: |
| 546 |
% \begin{verbatim} |
| 547 |
% \begin{matching}[title={Some matching questions}] |
| 548 |
% \pair{John Steinbeck}{\emph{The Grapes of Wrath}} |
| 549 |
% \pair{Will Self}{\emph{My Kind of Fun}} |
| 550 |
% \pair{Charles Darwin}{\emph{The Origin of Species}} |
| 551 |
% \end{matching}\end{verbatim} |
| 552 |
% In the exam, this will be typeset as: |
| 553 |
% \begin{multicols}{2} |
| 554 |
% \begin{quote} |
| 555 |
% \begin{enumerate} |
| 556 |
% \item[\underline{\hskip .5in}] Will Self |
| 557 |
% \item[\underline{\hskip .5in}] Charles Darwin |
| 558 |
% \item[\underline{\hskip .5in}] John Steinbeck |
| 559 |
% \columnbreak |
| 560 |
% \item[(a)] \emph{The Origin of Species} |
| 561 |
% \item[(b)] \emph{The Grapes of Wrath} |
| 562 |
% \item[(c)] \emph{My Kind of Fun} |
| 563 |
% \end{enumerate} |
| 564 |
% \end{quote} |
| 565 |
% \end{multicols} |
| 566 |
% In the answer key, this will be typeset as: |
| 567 |
% \begin{multicols}{2} |
| 568 |
% \begin{quote} |
| 569 |
% \begin{enumerate} |
| 570 |
% \item[\underline{\makebox[.5in][c]{(c)}}] Will Self |
| 571 |
% \item[\underline{\makebox[.5in][c]{(a)}}] Charles Darwin |
| 572 |
% \item[\underline{\makebox[.5in][c]{(b)}}] John Steinbeck |
| 573 |
% \columnbreak |
| 574 |
% \item[(a)] \emph{The Origin of Species} |
| 575 |
% \item[(b)] \emph{The Grapes of Wrath} |
| 576 |
% \item[(c)] \emph{My Kind of Fun} |
| 577 |
% \end{enumerate} |
| 578 |
% \end{quote} |
| 579 |
% \end{multicols} |
| 580 |
% The "\pair" macro preceeds the \emph{matched} pair of statements. The |
| 581 |
% environment will randomly shuffle the first and second columns in order to |
| 582 |
% create the (hopefully randomized) lists. Because of the way the randomizer |
| 583 |
% is implemented, this environment will produce better results (i.e., more |
| 584 |
% scrambled) results the longer the list of questions is. |
| 585 |
% |
| 586 |
% \textbf{N.B.} The \textsf{block} environment will break badly in this |
| 587 |
% environment, so don't use it. |
| 588 |
% |
| 589 |
% |
| 590 |
% \subsubsection{The \textsf{block} environment} |
| 591 |
% |
| 592 |
% The \textsf{block} environment lets you identify a group of questions, |
| 593 |
% as well as some preceeding text, as a ``block'' that should be kept together |
| 594 |
% even though the rest of the section gets rearranged. (The questions inside |
| 595 |
% the block will not be rearranged. That's on my to-do list, but it will take |
| 596 |
% more time than I have, and it's already been a long time since the last |
| 597 |
% update.) |
| 598 |
% |
| 599 |
% The syntax is straightforward. For example: |
| 600 |
% \begin{verbatim} |
| 601 |
% \begin{block} |
| 602 |
% Here is a spot where you can put some instructions, a graph, or whatever |
| 603 |
% you want to preceed the questions in this block. |
| 604 |
% \begin{question} |
| 605 |
% This is the first question. |
| 606 |
% \begin{answer} |
| 607 |
% This is the answer to the first question. |
| 608 |
% \end{answer} |
| 609 |
% \end{question} |
| 610 |
% |
| 611 |
% \begin{question} |
| 612 |
% This is the second question. |
| 613 |
% \begin{answer} |
| 614 |
% This is the answer to the second question. |
| 615 |
% \end{answer} |
| 616 |
% \end{question} |
| 617 |
% |
| 618 |
% \begin{question} |
| 619 |
% This is the third question. |
| 620 |
% \begin{answer} |
| 621 |
% This is the answer to the third question. |
| 622 |
% \end{answer} |
| 623 |
% \end{question} |
| 624 |
% \end{block}\end{verbatim} |
| 625 |
% Will keep those three questions together when the rearranging happens. |
| 626 |
% |
| 627 |
% The \textsf{block} environment may be used in \emph{any} of the previously |
| 628 |
% described question environments, except for the \textsf{matching} |
| 629 |
% environment. (There were some problems with using blocks inside some of the |
| 630 |
% other environments with earlier versions---I believe those bugs have been |
| 631 |
% fixed.) |
| 632 |
% |
| 633 |
% The \textsf{block} environment can take a special optional argument, |
| 634 |
% "questions", that specifies the number of questions in the block. |
| 635 |
% Specifying this option sets two counters, "first" and "last", so that you |
| 636 |
% can refer to the particular questions that fall within the block in the |
| 637 |
% instructions. So, for example: |
| 638 |
% \begin{verbatim} |
| 639 |
% \begin{block}[questions=3] |
| 640 |
% \noindent For questions \thefirst--\thelast, consider the following data...\end{verbatim} |
| 641 |
% would, if the block appeared after question 13, be typeset as: |
| 642 |
% |
| 643 |
% \bigskip |
| 644 |
% \noindent For questions 14--16, consider the following data...\par\bigskip |
| 645 |
% |
| 646 |
% In previous versions of \textsf{examdesign}, blocks were typeset indented from the |
| 647 |
% left margin. This was undesireable because the block instructions could |
| 648 |
% be misread as belonging to the end of the preceeding question. As of this |
| 649 |
% version, block instructions are typeset using no such indent. |
| 650 |
% |
| 651 |
% |
| 652 |
% \section{Special Formatting Tools} |
| 653 |
% |
| 654 |
% The following environments, macros, and length parameters allow the user to |
| 655 |
% customize virtually every aspect of the exam. As I describe below, the default |
| 656 |
% settings of the \textsf{examdesign} are defined using these environments. |
| 657 |
% |
| 658 |
% \subsection{Special Formatting Environments \label{SFE}} |
| 659 |
% |
| 660 |
% \DescribeEnv{frontmatter} |
| 661 |
% Any material enclosed in the \textsf{frontmatter} environment will be |
| 662 |
% typeset on a page (or pages) by itself before the exam (and the key, too). |
| 663 |
% For example, if one |
| 664 |
% wanted to make a cover sheet for the exam with the class name and a place for |
| 665 |
% the student to write their name, i.d. number, and so forth. |
| 666 |
% |
| 667 |
% \DescribeEnv{endmatter} |
| 668 |
% Any material enclosed in the \textsf{endmatter} environment will be |
| 669 |
% typeset on a page (or pages) by itself after the exam (and the key, too). |
| 670 |
% For example, if one wanted to place a page with several important equations, |
| 671 |
% constants, and tables at the end of the exam for students to reference, if |
| 672 |
% needed. |
| 673 |
% |
| 674 |
% \DescribeEnv{examtop} |
| 675 |
% Any material enclosed in the \textsf{examtop} environment will be |
| 676 |
% typeset on the next page following the \textsf{frontmatter} text, if an exam |
| 677 |
% is being created, and will be omitted if an answer key is being created. The |
| 678 |
% default settings of the \textsf{examdesign} class use this environment to create |
| 679 |
% the area for the class name, student name, etc. as follows: |
| 680 |
% \begin{verbatim} |
| 681 |
% \begin{examtop} |
| 682 |
% \@@line{\parbox{3in}{\classdata \\ |
| 683 |
% \examtype, Form: \fbox{\textsf{\Alph{version}}}} |
| 684 |
% \hfill |
| 685 |
% \parbox{3in}{\normalsize \namedata}} |
| 686 |
% \bigskip |
| 687 |
% \end{examtop}\end{verbatim} |
| 688 |
% Where "\classdata" and "\examtype" are macros that use |
| 689 |
% the current values assigned by the switches "\class" and "\examname". |
| 690 |
% |
| 691 |
% |
| 692 |
% The definition of "\namedata" is: |
| 693 |
% \begin{verbatim} |
| 694 |
% \def\namedata{Name: \hrulefill \\[\namedata@vspace] |
| 695 |
% Student Number: \hrulefill \\[\namedata@vspace] |
| 696 |
% TA: \hrulefill \\[\namedata@vspace] |
| 697 |
% Date: \hrulefill}\end{verbatim} |
| 698 |
% Where "\namedata@vspace" is the length set by the switch |
| 699 |
% "\StudentInfoLineSpacing". |
| 700 |
% |
| 701 |
% For those who don't know, "\@@line" is the \LaTeXe\ equivalent of Plain \TeX's |
| 702 |
% "\line" command. If you wish to use "\@@line" in defining your own \textsf{examtop} |
| 703 |
% or \textsf{keytop}, please be sure to use "\makeatletter" and "\makeatother" |
| 704 |
% in the appropriate places, otherwise you could get errors. |
| 705 |
% |
| 706 |
% \DescribeEnv{keytop} |
| 707 |
% Any material enclosed in the \textsf{keytop} environment will be |
| 708 |
% typeset on the next page following the \textsf{frontmatter} text, if a key |
| 709 |
% is being created, and will be omitted if an exam is being created. The |
| 710 |
% default settings of the \textsf{examdesign} class use this environment to create |
| 711 |
% the top of an answer key as follows: |
| 712 |
% \begin{verbatim} |
| 713 |
% \begin{keytop} |
| 714 |
% \@@line{\hfill \Huge Answer Key |
| 715 |
% for Exam \fbox{\textsf{\Alph{version}}}\fi \hfill} |
| 716 |
% \bigskip |
| 717 |
% \end{keytop}\end{verbatim} |
| 718 |
% |
| 719 |
% \DescribeEnv{exampreface} |
| 720 |
% Any material enclosed in the \textsf{exampreface} environment will be |
| 721 |
% typeset on the same page as the \textsf{examtop} text, right beneath it but |
| 722 |
% before any sections of the exam are included. In case you are wondering what |
| 723 |
% this environment does that cannot be done with \textsf{examtop}, your question |
| 724 |
% is very good. The difference is this: The material enclosed in the |
| 725 |
% \textsf{exampreface} environment is sensitive to whether the \texttt{twocolumn} |
| 726 |
% option was given. If the \texttt{twocolumn} option \emph{was} given, then |
| 727 |
% the material in \textsf{exampreface} will be typeset at the start of the |
| 728 |
% first column. By contrast, the material given in \textsf{examtop} is |
| 729 |
% \emph{always} typeset in a single column spanning the entire textwidth of |
| 730 |
% the page, at the top of the exam. |
| 731 |
% |
| 732 |
% \DescribeEnv{keypreface} |
| 733 |
% Any material enclosed in the \textsf{keypreface} environment will be |
| 734 |
% typeset on the same page as the \textsf{keytop} text, right beneath it but |
| 735 |
% before any sections are included. As described above, if the |
| 736 |
% \texttt{twocolumn} option \emph{was} given, then the material |
| 737 |
% in \textsf{keypreface} will be typeset at the start of the first column. By |
| 738 |
% contrast, the material given in \textsf{keytop} is \emph{always} typeset in a single |
| 739 |
% column spanning the entire textwidth of the page, at the top of the key. |
| 740 |
% |
| 741 |
% \DescribeEnv{examclosing} |
| 742 |
% Essentially the same as the \textsf{exampreface} environment, with the |
| 743 |
% obvious change that the enclosed material is typeset at the end of the exam, |
| 744 |
% on the same page as the rest of the exam (if possible), but before the |
| 745 |
% \textsf{endmatter}. (Any material enclosed in an \textsf{endmatter} |
| 746 |
% environment is typeset on a page by itself after the exam or key.) |
| 747 |
% |
| 748 |
% \DescribeEnv{keyclosing} |
| 749 |
% Essentially the same as the \textsf{keypreface} environment, with the |
| 750 |
% obvious change that the enclosed material is typeset at the end of the key, |
| 751 |
% on the same page as the rest of the key (if possible), but before the |
| 752 |
% \textsf{endmatter}. |
| 753 |
% |
| 754 |
% |
| 755 |
% \subsection{Special Formatting Macros} |
| 756 |
% |
| 757 |
% Due to the special way the \textsf{examdesign} class constructs a document (see the |
| 758 |
% technical notes in section \ref{TN}), several special macros are provided |
| 759 |
% which enable the user to easily take advantage of the way exams are |
| 760 |
% constructed. In addition, there are several lengths which the user can modify |
| 761 |
% to further customize the appearance of the exam. |
| 762 |
% |
| 763 |
% \DescribeMacro{\exam} |
| 764 |
% The "\exam" macro takes one argument, which can be any command or |
| 765 |
% sequence of commands subject to the constraints described in the technical |
| 766 |
% notes. The argument will be included wherever it is if and only if an exam is |
| 767 |
% being made, otherwise the argument will be ignored. |
| 768 |
% |
| 769 |
% \DescribeMacro{\key} |
| 770 |
% The "\key" macro takes one argument, which can be any command or |
| 771 |
% sequence of commands subject to the constraints described in the technical |
| 772 |
% notes. The argument will be included wherever it is if and only if a key is |
| 773 |
% being made, otherwise the argument will be ignored. |
| 774 |
% |
| 775 |
% \DescribeMacro{\examvspace} |
| 776 |
% Just like the ordinary \LaTeX\ command "\vspace", with the exception that the vertical |
| 777 |
% space is included if and only if an exam is being typeset. |
| 778 |
% |
| 779 |
% \DescribeMacro{\examvspace*} |
| 780 |
% Just like the ordinary \LaTeX\ command "\vspace*", with the exception that the vertical |
| 781 |
% space is included if and only if an exam is being typeset. |
| 782 |
% |
| 783 |
% \DescribeMacro{\examhspace} |
| 784 |
% Just like the ordinary \LaTeX\ command "\hspace", with the exception that the |
| 785 |
% horizontal space is included if and only if an exam is being typeset. |
| 786 |
% |
| 787 |
% \DescribeMacro{\examhspace*} |
| 788 |
% Just like the ordinary \LaTeX\ command "\hspace*", with the exception that the |
| 789 |
% horizontal space is included if and only if an exam is being typeset. |
| 790 |
% |
| 791 |
% \DescribeMacro{\keyvspace} |
| 792 |
% Just like the ordinary \LaTeX\ command "\hspace*", with the exception that the |
| 793 |
% horizontal space is included if and only if a key is being typeset. |
| 794 |
% |
| 795 |
% \DescribeMacro{\keyvspace*} |
| 796 |
% Just like the ordinary \LaTeX\ command "\hspace*", with the exception that the |
| 797 |
% horizontal space is included if and only if a key is being typeset. |
| 798 |
% |
| 799 |
% \DescribeMacro{\keyhspace} |
| 800 |
% Just like the ordinary \LaTeX\ command "\hspace*", with the exception that the |
| 801 |
% horizontal space is included if and only if a key is being typeset. |
| 802 |
% |
| 803 |
% \DescribeMacro{\keyhspace*} |
| 804 |
% Just like the ordinary \LaTeX\ command "\hspace*", with the exception that the |
| 805 |
% horizontal space is included if and only if a key is being typeset. |
| 806 |
% |
| 807 |
% \DescribeMacro{\word} |
| 808 |
% The last new command (in version 1.02) is "\word". This command |
| 809 |
% allows the user to insert inessential changes in the wording of a question |
| 810 |
% between various versions of the exam. Thus, not only will the order of the |
| 811 |
% questions be different, but the actual \emph{wording} of the questions will be |
| 812 |
% slightly different as well. For example, if one includes: |
| 813 |
% \begin{verbatim} |
| 814 |
% \begin{question} |
| 815 |
% Is the most well-known \word{{astronomer} {wrestler} {physicist}} in |
| 816 |
% the world \word{{Carl Sagan} {Rowdy Roddy Piper} {Albert Einstein}}? |
| 817 |
% \end{question}\end{verbatim} |
| 818 |
% in an exam, the first version of the exam will include the question |
| 819 |
% \begin{enumerate} |
| 820 |
% \item Is the most well-known astronomer in the world Carl Sagan? |
| 821 |
% \end{enumerate} |
| 822 |
% but the second version of the exam will include |
| 823 |
% \begin{enumerate} |
| 824 |
% \item Is the most well-known wrestler in the world Rowdy Roddy Piper? |
| 825 |
% \end{enumerate} |
| 826 |
% and the third version of the exam will include |
| 827 |
% \begin{enumerate} |
| 828 |
% \item Is the most well-known physicist in the world Albert Einstein? |
| 829 |
% \end{enumerate} |
| 830 |
% |
| 831 |
% Let's call the argument of "\word" an \emph{option-list}. If one requests |
| 832 |
% more versions of an exam than options in an option-list, "\word" will behave |
| 833 |
% as if the option list you gave ``wrapped.'' That is, if one requests five |
| 834 |
% copies of an exam but includes "\word{{A} {B}}" in the input file, "A" will be |
| 835 |
% printed on the fifth version of the exam, because "\word" will act as if the |
| 836 |
% option list was "\word{{A} {B} {A} {B} {A} {B}}", where "A" is the fifth |
| 837 |
% option. |
| 838 |
% |
| 839 |
% If it turns out that your exams are becoming absolutely unreadable through |
| 840 |
% excessive use of "\word", chances are you are not introducing inessential |
| 841 |
% changes in the wording of a question, but are actually trying to write two |
| 842 |
% different exams simultaneously. |
| 843 |
% |
| 844 |
% \subsection{Length Parameters} |
| 845 |
% |
| 846 |
% The following table describes lengths that the user may set to whatever value |
| 847 |
% they wish, and the effect that it has upon the appearance of the exam (or |
| 848 |
% key). |
| 849 |
% |
| 850 |
% \DeleteShortVerb{\|} |
| 851 |
% \begin{center} |
| 852 |
% \begin{tabular}{|l|l|p{1.8in}|} \hline |
| 853 |
% {\large Length} & {\large Initial Value} & {\large Effect} \rule{0pt}{13pt} \\ \hline |
| 854 |
% "\beforesectsep" & "\medskipamount" & Space inserted before the |
| 855 |
% current section heading. \\ |
| 856 |
% "\aftersectsep" & "\medskipamount" & Space inserted after the |
| 857 |
% current section heading. \\ |
| 858 |
% "\beforeinstsep" & "\medskipamount" & Space inserted before any |
| 859 |
% instructions for the current |
| 860 |
% section are typeset. \\ |
| 861 |
% "\afterinstsep" & "\medskipamount-\topsep" & Space inserted after the |
| 862 |
% instructions for the current |
| 863 |
% section but before the |
| 864 |
% questions. \\ \hline |
| 865 |
% \end{tabular} |
| 866 |
% \end{center} |
| 867 |
% \MakeShortVerb{\|} |
| 868 |
% |
| 869 |
% Given the above parameters, there are two rules that determine whether space |
| 870 |
% is inserted. (1) If the section heading is empty (as might happen if someone |
| 871 |
% used a starred environment form and then did not include any optional |
| 872 |
% argument), then \emph{neither} "\beforesectsep" \emph{nor} "\aftersecsep" are |
| 873 |
% used to insert vertical space, and (2) if there are no instructions for a |
| 874 |
% section, then \emph{neither} "\beforeinstsep" \emph{nor} "\afterinstsep" are |
| 875 |
% used to insert vertical space. |
| 876 |
% |
| 877 |
% \section{Miscellaneous Goodies\label{TN}} |
| 878 |
% |
| 879 |
% \DescribeMacro{\setrandomseed} |
| 880 |
% The "\setrandomseed" macro allows you to specify a random seed at the start |
| 881 |
% of an exam. This allows you to have a ``randomized'' exam that keeps |
| 882 |
% questions in the same scrambled order across different runs. |
| 883 |
% If you set the random seed, it becomes possible to have crossreferences in |
| 884 |
% the exam. In this release, the ordinary \LaTeX\ commands "\label" and "\ref" |
| 885 |
% work as expected, even across different forms of the test (with the |
| 886 |
% questions in a different order). |
| 887 |
% |
| 888 |
% Math environments using numbered equations should also work correctly |
| 889 |
% in this version. |
| 890 |
% |
| 891 |
% \DescribeMacro{\pagebreak} |
| 892 |
% Having fixed the order of the questions, you might need to introduce a |
| 893 |
% pagebreaks at certain points. In this release, the "\pagebreak" command |
| 894 |
% works as expected, with one caveat. Putting a "\pagebreak" before a section |
| 895 |
% will introduce a pagebreak before that section, and putting a "\pagebreak" |
| 896 |
% before a question will introduce a pagebreak before that question---no |
| 897 |
% matter where on the page that question may be. |
| 898 |
% |
| 899 |
% \DescribeMacro{\BreakPageOnVersion} |
| 900 |
% If you want to insert pagebreaks before questions or sections conditionally |
| 901 |
% on the exam, you will need to use the "\BreakPageOnVersion{}" macro. This |
| 902 |
% macro, which takes a number as its argument, will conditionally insert a |
| 903 |
% "\pagebreak" depending on whether number of the version currently being |
| 904 |
% typeset equals the version given as an argument to the macro. |
| 905 |
% |
| 906 |
% \DescribeMacro{\IncludeFromFile} |
| 907 |
% \DescribeMacro{\InsertChunk} |
| 908 |
% \DescribeEnv{chunk} |
| 909 |
% If you need to use any environment which changes the catcodes of the input |
| 910 |
% characters (such as the \textsf{verbatim} environment, or XY-pic), you will |
| 911 |
% have to employ the following hack. The reason for this has to do with the |
| 912 |
% way \textsf{examdesign} scrambles the order of the questions. (Basically, each |
| 913 |
% question is saved to a macro for later recall. This assigns each character |
| 914 |
% a catcode when it is saved, so it is not possible to change the catcode at a |
| 915 |
% later time.) |
| 916 |
% |
| 917 |
% The hack is the following: create another file called ``foo.tex'' (you can |
| 918 |
% name it whatever you like) and put "\IncludeFromFile{foo.tex}" in |
| 919 |
% the preamble of your document. For each bit of text that you need contained |
| 920 |
% category code changes (like the \textsf{verbatim} environment) put, in |
| 921 |
% foo.tex, a named chunk containing that code. I.e., |
| 922 |
% \begin{quote} |
| 923 |
% "\begin{chunk}{chunk name}"\\ |
| 924 |
% "\begin{verbatim}"\\ |
| 925 |
% " This is some verbatim text"\\ |
| 926 |
% " This is more verbatim text"\\ |
| 927 |
% "\end{verbatim}"\\ |
| 928 |
% "\end{chunk}" |
| 929 |
% \end{quote} |
| 930 |
% At the appropriate place in your exam, place "\InsertChunk{chunk name}". |
| 931 |
% This macro inserts the named chunk into the exam (or key) at that place. |
| 932 |
% All catcode changing commands, environments, etc., should be capable of |
| 933 |
% being inserted this way. (If you find one that doesn't, let me know.) |
| 934 |
% |
| 935 |
% All of the chunks for a given exam can be stored in the same file---you just |
| 936 |
% need to give each chunk a unique name. Only the |
| 937 |
% chunk you request will be inserted at a particular point. If you have a lot |
| 938 |
% of chunks, this can slow down considerably the overall processing of the exam, |
| 939 |
% but there's no other general solution which will work. |
| 940 |
% |
| 941 |
% The chunk names can be descriptive, but don't try anything too fancy. ``Too |
| 942 |
% fancy'' meaning: if it causes an error, it's too fancy. |
| 943 |
% |
| 944 |
% \subsection{Bugs} |
| 945 |
% |
| 946 |
% No known bugs. |
| 947 |
% |
| 948 |
% \subsection{Changes} |
| 949 |
% |
| 950 |
% The changes between this version and previous versions are indicated in the |
| 951 |
% above sections. Early releases of the \textsf{examdesign} class required that |
| 952 |
% instructions |
| 953 |
% for a given section be specified as such by using the "\instructions" |
| 954 |
% command. The need for using "\instructions" has been lifted as of release |
| 955 |
% 1.02. The rule is this: all material between the start of a section and |
| 956 |
% the first "\begin{question}" or "\begin{block}" will be taken to be the |
| 957 |
% instructions for that section. Old exams created with "\instructions" should |
| 958 |
% still work with the new release (the "\instructions" macro has simply been |
| 959 |
% redefined as "\relax"). |
| 960 |
% |
| 961 |
% Thus, if you are using |
| 962 |
% \textsf{fixed} to format a series of essay questions, you might want to tell |
| 963 |
% students that they only need to write answers to two of the following three |
| 964 |
% questions. The instruction text is always |
| 965 |
% typeset at the beginning of a section, before any questions are typeset. |
| 966 |
% |
| 967 |
% \endinput |
| 968 |
% |
| 969 |
% \section{The Code} |
| 970 |
% |
| 971 |
% The following code is a bit messy, and the comments don't necessarily match |
| 972 |
% up with the code that follows. I thought it was more important to get the |
| 973 |
% new version out than worry about making the source pretty. If you need to |
| 974 |
% figure out how something works, trust the code, not the description! |
| 975 |
% |
| 976 |
% First just some declarations and stuff that says we are building an |
| 977 |
% extension to the ordinary \LaTeX\ class |article|. |
| 978 |
% \begin{macrocode} |
| 979 |
%<*header> |
| 980 |
\ProvidesFile{examdesign.dtx} |
| 981 |
\NeedsTeXFormat{LaTeX2e} |
| 982 |
\ProvidesClass{examdesign} |
| 983 |
\newcounter{passes}\setcounter{passes}{2} |
| 984 |
\newif\ifmcbold \mcboldfalse |
| 985 |
\newif\ifmcunder \mcunderfalse |
| 986 |
\newif\ifulem \ulemfalse |
| 987 |
\newif\ifbox \boxtrue |
| 988 |
\newif\iftwocolumn \twocolumnfalse |
| 989 |
\gdef\@OneKeyHook{\relax} |
| 990 |
%\DeclareOption{mcbold}{\mcboldtrue\boxfalse} |
| 991 |
%\DeclareOption{mcunderline}{\mcundertrue \boxfalse} |
| 992 |
%\DeclareOption{nokey}{\setcounter{passes}{1}} |
| 993 |
%\DeclareOption{onekey}{\setcounter{passes}{2}% |
| 994 |
% \gdef\@OneKeyHook{\setcounter{passes}{1} |
| 995 |
% \gdef\@OneKeyHook{\relax}}} |
| 996 |
\DeclareOption{twocolumn}{\twocolumntrue} |
| 997 |
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}} |
| 998 |
\ProcessOptions |
| 999 |
\LoadClass{article} |
| 1000 |
|
| 1001 |
\def\NoKey{\setcounter{passes}{1}} |
| 1002 |
|
| 1003 |
\def\OneKey{\setcounter{passes}{2}% |
| 1004 |
\gdef\@OneKeyHook{\setcounter{passes}{1} |
| 1005 |
\gdef\@OneKeyHook{\relax}}} |
| 1006 |
|
| 1007 |
\def\BoldfaceCorrectMultipleChoiceAnswer{% |
| 1008 |
\mcboldtrue |
| 1009 |
\boxfalse |
| 1010 |
\exam@SetCorrectChoiceFont} |
| 1011 |
|
| 1012 |
\def\UnderlineCorrectMultipleChoiceAnswer{% |
| 1013 |
\mcundertrue |
| 1014 |
\boxfalse |
| 1015 |
\exam@SetCorrectChoiceFont} |
| 1016 |
|
| 1017 |
\def\exam@SetCorrectChoiceFont{% |
| 1018 |
\ifmcbold |
| 1019 |
\ifmcunder |
| 1020 |
\def\MCfont##1{\textbf{\uline{##1}}}% |
| 1021 |
\else |
| 1022 |
\def\MCfont##1{\textbf{##1}}% |
| 1023 |
\fi |
| 1024 |
\else |
| 1025 |
\ifmcunder |
| 1026 |
\def\MCfont##1{\uline{##1}}% |
| 1027 |
\else |
| 1028 |
\def\MCfont##1{\relax{##1}}% |
| 1029 |
\fi |
| 1030 |
\fi} |
| 1031 |
|
| 1032 |
% \ifmcbold |
| 1033 |
% \ifmcunder |
| 1034 |
% \def\MCfont#1{\textbf{\uline{#1}}} |
| 1035 |
% \else |
| 1036 |
% \def\MCfont#1{\textbf{#1}} |
| 1037 |
% \fi |
| 1038 |
% \else |
| 1039 |
% \ifmcunder |
| 1040 |
% \def\MCfont#1{\uline{#1}} |
| 1041 |
% \else |
| 1042 |
% \def\MCfont#1{\relax{#1}} |
| 1043 |
% \fi |
| 1044 |
% \fi |
| 1045 |
|
| 1046 |
|
| 1047 |
\RequirePackage{enumerate} |
| 1048 |
\RequirePackage{multicol} |
| 1049 |
\RequirePackage{keyval} |
| 1050 |
%</header> |
| 1051 |
% \end{macrocode} |
| 1052 |
% |
| 1053 |
% \subsection{The random number generator} |
| 1054 |
% |
| 1055 |
% RANDOM.TEX v.1 (Donald Arseneau) |
| 1056 |
% Generating "random" numbers in TeX. |
| 1057 |
% |
| 1058 |
% \DescribeMacro{\nextrandom} |
| 1059 |
% Random integers are generated in the range 1 to 2147483646 by the |
| 1060 |
% macro |\nextrandom|. The result is returned in the counter |\randomi|. |
| 1061 |
% Do not change |\randomi| except, perhaps, to initialize it at some |
| 1062 |
% random value. If you do not initialize it, it will be initialized |
| 1063 |
% using the time and date. (This is a sparse initialization, giving |
| 1064 |
% fewer than a million different starting values, but you should use |
| 1065 |
% other sources of numbers if they are available--just remember that |
| 1066 |
% most of the numbers available to \TeX are not at all random.) |
| 1067 |
% |
| 1068 |
% \DescribeMacro{\setrannum} |
| 1069 |
% The |\nextrandom| command is not very useful by itself, unless you |
| 1070 |
% have exactly 2147483646 things to choose from. Much more useful |
| 1071 |
% is the |\setrannum| command which sets a given counter to a random |
| 1072 |
% value within a specified range. There are three parameters: |
| 1073 |
% |\setrannum{|\meta{counter}|}{|\meta{minimum}|}{|\meta{maximum}|}|. |
| 1074 |
% For example, to simulate a die-roll: |\setrannum{\die}{1}{6} \ifcase\die|\ldots |
| 1075 |
% |
| 1076 |
% \DescribeMacro{\setrandimen} |
| 1077 |
% \DescribeMacro{\pointless} |
| 1078 |
% If you need random numbers that are not integers, you will have to |
| 1079 |
% use dimen registers and |\setrandimen|. For example, to set a random |
| 1080 |
% page width: |\setrandimen \hsize{3in}{6.5in}|. The ``|\pointless|'' macro |
| 1081 |
% will remove the ``pt'' that TeX gives so you can use the dimensions |
| 1082 |
% as pure `real' numbers. In that case, specify the range in pt units. |
| 1083 |
% For example, |\setrandimen\answer{2.71828pt}{3.14159pt}| |
| 1084 |
% The answer is |\pointless\answer|. |
| 1085 |
% |
| 1086 |
% The random number generator is the one by Lewis, Goodman, and Miller |
| 1087 |
% (1969) and used as "ran0" in "Numerical Recipies" using Schrage's |
| 1088 |
% method for avoiding overflows. The multiplier is $16807 (7^5)$ the |
| 1089 |
% added constant is 0, and the modulus is $147483647 (2^{31}-1)$ The |
| 1090 |
% range of integers generated is $1 - 2147483646$. A smaller range would |
| 1091 |
% reduce the complexity of the macros a bit, but not much--most of the |
| 1092 |
% code deals with initialization and type-conversion. On the other hand, |
| 1093 |
% the large range may be wasted due to the sparse seed initialization. |
| 1094 |
% |
| 1095 |
% I do not include the code in the documentation. |
| 1096 |
%\iffalse |
| 1097 |
% \begin{macrocode} |
| 1098 |
%<*random> |
| 1099 |
\newcount\randomi % the random number seed (while executing) |
| 1100 |
\global\randomi\catcode`\@ % scratch variable during definitions |
| 1101 |
\catcode`\@=11 |
| 1102 |
% The following macro isn't part of Arseneau's original TeX package, |
| 1103 |
% but it comes in handy when users want to recover a particular run. |
| 1104 |
\def\setrandomseed#1{\global\randomi#1\relax |
| 1105 |
\message{Randomizer initialized to \the\randomi.}% |
| 1106 |
\nextrandom \nextrandom \nextrandom} |
| 1107 |
|
| 1108 |
\def\nextrandom{\begingroup |
| 1109 |
\ifnum\randomi<\@ne % then initialize with time |
| 1110 |
\global\randomi\time |
| 1111 |
\global\multiply\randomi388 \global\advance\randomi\year |
| 1112 |
\global\multiply\randomi31 \global\advance\randomi\day |
| 1113 |
\global\multiply\randomi97 \global\advance\randomi\month |
| 1114 |
\message{Randomizer initialized to \the\randomi.}% |
| 1115 |
\nextrandom \nextrandom \nextrandom |
| 1116 |
\fi |
| 1117 |
\count@ii\randomi |
| 1118 |
\divide\count@ii 127773 % modulus = multiplier * 127773 + 2836 |
| 1119 |
\count@\count@ii |
| 1120 |
\multiply\count@ii 127773 |
| 1121 |
\global\advance\randomi-\count@ii % random mod 127773 |
| 1122 |
\global\multiply\randomi 16807 |
| 1123 |
\multiply\count@ 2836 |
| 1124 |
\global\advance\randomi-\count@ |
| 1125 |
\ifnum\randomi<\z@ \global\advance\randomi 2147483647\relax\fi |
| 1126 |
\endgroup |
| 1127 |
} |
| 1128 |
|
| 1129 |
\countdef\count@ii=2 % use only in boxes! |
| 1130 |
\ifx\@tempcnta\undefined \csname newcount\endcsname \@tempcnta \fi |
| 1131 |
\ifx\@tempcntb\undefined \csname newcount\endcsname \@tempcntb \fi |
| 1132 |
|
| 1133 |
\def\setrannum#1#2#3{% count register, minimum, maximum |
| 1134 |
\@tempcnta#3\advance\@tempcnta-#2\advance\@tempcnta\@ne |
| 1135 |
\@tempcntb 2147483645 % = m - 2 = 2^{31} - 3 |
| 1136 |
\divide\@tempcntb\@tempcnta |
| 1137 |
\getr@nval |
| 1138 |
\advance\ranval#2\relax |
| 1139 |
#1\ranval |
| 1140 |
} |
| 1141 |
|
| 1142 |
\def\setrandim#1#2#3{% dimen register, minimum length, maximum length |
| 1143 |
\dimen@#2\dimen@ii#3\relax |
| 1144 |
\setrannum\ranval\dimen@\dimen@ii |
| 1145 |
#1\ranval sp\relax |
| 1146 |
} |
| 1147 |
|
| 1148 |
\def\getr@nval{% The values in \@tempcnta and \@tempcntb are parameters |
| 1149 |
\nextrandom |
| 1150 |
\ranval\randomi \advance\ranval\m@ne \divide\ranval\@tempcntb |
| 1151 |
\ifnum\ranval<\@tempcnta\else \expandafter\getr@nval \fi |
| 1152 |
} |
| 1153 |
|
| 1154 |
\def\pointless{\expandafter\PoinTless\the} |
| 1155 |
{\catcode`p=12 \catcode`t=12 |
| 1156 |
\gdef\PoinTless#1pt{#1}} |
| 1157 |
|
| 1158 |
\catcode`\@=\randomi |
| 1159 |
\global\randomi=0 |
| 1160 |
\newcount\ranval |
| 1161 |
%</random> |
| 1162 |
% \end{macrocode} |
| 1163 |
%\fi |
| 1164 |
% |
| 1165 |
% \subsection{Incorporating the package \textsf{ulem}} |
| 1166 |
% This code is not listed in the documentation. |
| 1167 |
%\iffalse |
| 1168 |
% \begin{macrocode} |
| 1169 |
%<*ulem> |
| 1170 |
\expandafter \ifx \csname UL@box\endcsname \relax \else |
| 1171 |
\typeout{ulem.sty refuses to load twice. }\endinput \fi |
| 1172 |
\chardef\ULthickness\catcode\string`\@ % hold catcode temporarily |
| 1173 |
\catcode\string`\@=11 |
| 1174 |
\def\uline{\relax \ifmmode\expandafter\underline |
| 1175 |
\else \bgroup\expandafter\ULset\fi} |
| 1176 |
\newbox\UL@box |
| 1177 |
\newbox\UL@hyphenbox |
| 1178 |
\newskip\UL@skip |
| 1179 |
\newcount\UL@pe |
| 1180 |
\let\LA@space\ \let\LA@hskip\hskip |
| 1181 |
\def\UL@end *{\relax\relax}% something harmless unlikely to be found elsewhere |
| 1182 |
\def\ULset{\ifdim\ULdepth=\maxdimen\setbox\UL@box\hbox{(j}\ULdepth\dp\UL@box\fi |
| 1183 |
\def\UL@leadtype{\leaders \hrule \@height\dimen@ \@depth\ULdepth}% |
| 1184 |
\ifmmode \ULdepth-4\p@ \fi |
| 1185 |
\dimen@-\ULdepth \advance\dimen@\ULthickness \ULon} |
| 1186 |
\def\ULon{\ifmmode \expandafter\UL@onmath\else \expandafter\UL@on\fi} |
| 1187 |
\def\UL@on#1{\leavevmode\UL@ender \let\UL@on\UL@onin |
| 1188 |
\everymath{\UL@hrest}\everyvbox{\UL@hrest}\let\hskip\UL@hskip |
| 1189 |
\let\\\UL@cr \let\-\UL@dischyp \let\newline\UL@newline \let\ \UL@space |
| 1190 |
\def\hfil{\hskip\z@ plus1fil\relax}\def\hfill{\hskip\z@ plus1fill\relax}% |
| 1191 |
\def\hss{\hskip\z@ plus1filminus1fil\relax}\let\penalty\UL@penalty |
| 1192 |
\UL@word\@empty#1\xdef\UL@spfactor{\the\spacefactor} \UL@end * } |
| 1193 |
\def\UL@onin#1{\leavevmode\UL@ender % when nested, do multiple underlining |
| 1194 |
\dimen@\ULthickness \advance\ULdepth\thr@@\dimen@ \advance\dimen@-\ULdepth |
| 1195 |
\setbox\UL@box\hbox{{#1}}\let\UL@start\relax\UL@putbox\egroup} |
| 1196 |
\def\UL@onmath#1{\UL@ender\mathord{\UL@hrest\mathop{\kern\z@#1}\limits\sb |
| 1197 |
{\UL@leadtype\LA@hskip\p@ plus1fill}}\egroup} |
| 1198 |
\def\UL@unegroup{} |
| 1199 |
\gdef\UL@ender{} |
| 1200 |
\def\UL@swender{\ifnum`{=\z@\fi\aftergroup}\gdef\UL@ender{}} |
| 1201 |
\def\UL@word#1 {\expandafter\UL@start#1 % |
| 1202 |
\expandafter\ifx\expandafter\UL@end#1\egroup\egroup |
| 1203 |
\unskip \unskip \unskip % remove extra leader at end |
| 1204 |
\spacefactor\UL@spfactor \let\UL@word\egroup |
| 1205 |
\else % not finished |
| 1206 |
\ifmmode\else \ifdim\lastskip=\z@\else % allow syntactical spaces |
| 1207 |
\global\UL@skip\lastskip \unskip |
| 1208 |
\UL@stop \UL@leaders |
| 1209 |
\fi\fi |
| 1210 |
\fi \UL@word\@empty}% \@empty preserves braces in param |
| 1211 |
\def\UL@start{\setbox\UL@box\hbox\bgroup\everyhbox{\UL@hrest}% |
| 1212 |
\let\UL@start\@empty \def\UL@unegroup{\bgroup\bgroup}\let\UL@leadtype\@empty |
| 1213 |
\bgroup \kern-3sp\kern3sp % kerns so I can test for beginning of list |
| 1214 |
\if@ignore \global\@ignorefalse \ignorespaces \fi} |
| 1215 |
\def\UL@stop{\global\UL@pe\lastpenalty \unpenalty % penalty in \UL@pe |
| 1216 |
\ifnum\lastkern=\thr@@ \egroup\egroup % Nothing in hbox...but make sure: |
| 1217 |
\ifdim\wd\UL@box=\z@ \else \UL@putbox \fi % something in box so print it |
| 1218 |
\else \egroup\egroup \UL@putbox % something in box so print it |
| 1219 |
\fi \ifnum\UL@pe=\z@ \else \LA@penalty\UL@pe \fi % use penalty from inside box |
| 1220 |
\UL@unegroup} |
| 1221 |
\def\UL@putbox{\ifx\UL@start\@empty \else % not inner |
| 1222 |
\vrule\@width\z@ \LA@penalty\@M |
| 1223 |
{\UL@skip\wd\UL@box \UL@leaders \kern-\UL@skip}% |
| 1224 |
\box\UL@box \fi} |
| 1225 |
\newdimen\UL@pixel \UL@pixel=1in \divide\UL@pixel 300 |
| 1226 |
\def\UL@leaders{{\LA@hskip-\UL@pixel \advance\UL@skip\tw@\UL@pixel |
| 1227 |
\UL@leadtype\LA@hskip\UL@skip \LA@hskip-\UL@pixel}} |
| 1228 |
\def\UL@hrest{\let\ \LA@space \let\-\@empty \let\penalty\LA@penalty} |
| 1229 |
\def\UL@space{\LA@space \global\UL@skip\lastskip \unskip \UL@reskip}% \ |
| 1230 |
\def\UL@dischyp{\global\setbox\UL@hyphenbox\hbox |
| 1231 |
{\ifnum \hyphenchar\font<\z@ \string-\else \char\hyphenchar\font \fi}% |
| 1232 |
\kern\wd\UL@hyphenbox \LA@penalty\@M \UL@stop \kern-\wd\UL@hyphenbox |
| 1233 |
\discretionary{\box\UL@hyphenbox}{}{}\UL@start} |
| 1234 |
\let\LA@penalty\penalty |
| 1235 |
\def\UL@penalty{\relax\ifhmode \afterassignment\UL@@penalty\count@ |
| 1236 |
\else\LA@penalty\fi} |
| 1237 |
\def\UL@@penalty{\LA@penalty \ifnum\count@=\z@ |
| 1238 |
\@ne \else \count@ \fi % zero penalty => no penalty, so use 1 instead. |
| 1239 |
\UL@stop \UL@start} |
| 1240 |
\def\UL@hskip{\ifx\ \LA@space \LA@hskip \else |
| 1241 |
\afterassignment\UL@reskip \global\UL@skip \fi} |
| 1242 |
\def\UL@reskip{\UL@stop \UL@leaders \UL@start} |
| 1243 |
\def\UL@cr{\unskip \ifx\ \LA@space \let\UL@vad\@gobble |
| 1244 |
\else \UL@stop \unskip\unskip\unskip \let\UL@vad\vadjust \fi |
| 1245 |
\@ifstar{\UL@vad{\LA@penalty\@M}\UL@cra}\UL@cra} |
| 1246 |
\def\UL@cra{\@ifnextchar[\UL@crb\UL@newline} |
| 1247 |
\def\UL@crb[#1]{\UL@vad{\vskip#1}\UL@newline} |
| 1248 |
\def\UL@newline{\ifx\UL@start\@empty % (\UL@cr may have \UL@stop-ed already) |
| 1249 |
\unskip \ifx\ \LA@space \else \UL@stop \unskip\unskip\unskip \fi\fi |
| 1250 |
\LA@hskip \z@\@plus.0001fil\LA@penalty -\@M \UL@start} |
| 1251 |
\newbox\ULC@box |
| 1252 |
\def\markoverwith#1{\setbox\ULC@box\hbox{{#1}}\[email protected]\wd\ULC@box |
| 1253 |
\ifmmode \setbox\ULC@box\hbox{\raise1.4ex\box\ULC@box}% |
| 1254 |
\dp\[email protected]\ht\ULC@box\z@ \def\UL@leadtype{\cleaders\copy\ULC@box}% |
| 1255 |
\else |
| 1256 |
\def\UL@leadtype{\leaders\copy\ULC@box}% |
| 1257 |
\fi} |
| 1258 |
\def\uwave{\bgroup \markoverwith{\lower3.5\p@\hbox{\sixly |
| 1259 |
\kern-.21\p@ \char58 \kern-.21\p@}}\ULon} |
| 1260 |
\font\sixly=lasy6 % does not re-load if already loaded, so no memory problem. |
| 1261 |
\def\uuline{\bgroup \markoverwith{\hbox |
| 1262 |
{\kern-.03em\vtop{\kern.2ex\hrule width.2em\kern1.1\p@ |
| 1263 |
\hrule}\kern-.03em}}\ULon} |
| 1264 |
\def\sout{\bgroup \ULdepth=-.5ex \ULset} |
| 1265 |
\def\xout{\bgroup \markoverwith{\kern-.1em{/}\kern-.1em}\ULon} |
| 1266 |
\def\useunder#1#2#3{\relax |
| 1267 |
\ifx\relax#2\relax\else % declaration command given |
| 1268 |
\def#2{\def\@tempa{#1}\global\let\UL@ender\UL@swender |
| 1269 |
\expandafter\@tempa\expandafter{\ifnum\z@=\string`}\fi}% |
| 1270 |
\MakeRobust{#2}\fi |
| 1271 |
\ifx\relax#3\relax\else % argumentative command |
| 1272 |
\def#3{#1}\MakeRobust{#3}\fi} |
| 1273 |
\expandafter\ifx \csname @ifundefined\endcsname \relax |
| 1274 |
\def\@height{height} |
| 1275 |
\def\@depth{depth} |
| 1276 |
\def\@width{width} |
| 1277 |
\def\@empty{} |
| 1278 |
\def\@gobble#1{} |
| 1279 |
\def\MakeRobust#1{} |
| 1280 |
\csname newif\expandafter\endcsname \csname if@ignore\endcsname |
| 1281 |
\else |
| 1282 |
\def\MakeRobust#1{\expandafter\let |
| 1283 |
\csname \expandafter\@gobble\string#1 \endcsname= #1% |
| 1284 |
\edef#1{\noexpand\protect \expandafter\noexpand |
| 1285 |
\csname\expandafter\@gobble\string#1 \endcsname} |
| 1286 |
} |
| 1287 |
\MakeRobust\uline |
| 1288 |
\MakeRobust\uuline |
| 1289 |
\MakeRobust\uwave |
| 1290 |
\MakeRobust\sout |
| 1291 |
\MakeRobust\xout |
| 1292 |
\let\LA@em\em \let\LA@emph\emph |
| 1293 |
\expandafter\let\expandafter\LA@Pem \csname em \endcsname |
| 1294 |
\expandafter\let\expandafter\LA@Pemph \csname emph \endcsname |
| 1295 |
\def\ULforem{\useunder{\uline}{\em}{\emph}} |
| 1296 |
\def\normalem{\let\em\LA@em \let\emph\LA@emph |
| 1297 |
\expandafter\let\csname em \endcsname\LA@Pem |
| 1298 |
\expandafter\let\csname emph \endcsname\LA@Pemph} |
| 1299 |
\ULforem % default is to use underlining for \em, |
| 1300 |
\fi |
| 1301 |
\catcode`@=\ULthickness % Scratch meaning: restore catcode of @ |
| 1302 |
\def\ULthickness{.4pt}% can change this with \renewcommand |
| 1303 |
\newdimen\ULdepth \ULdepth=\maxdimen |
| 1304 |
|
| 1305 |
\normalem |
| 1306 |
%</ulem> |
| 1307 |
% \end{macrocode} |
| 1308 |
%\fi |
| 1309 |
% |
| 1310 |
% \subsection{The code for the \textsf{examdesign} class} |
| 1311 |
% |
| 1312 |
% We now define an environment \textsf{question} that saves the surrounded text |
| 1313 |
% to a macro |\sec@|\meta{section-number}|@qst|\meta{question-number}, where |
| 1314 |
% \meta{section-number} and \meta{question-number} are expressed as lower case |
| 1315 |
% roman numerals (this way they can be part of the macro name). Note that we |
| 1316 |
% must use lower case roman numerals since, I believe, \LaTeXe\ the |\Roman| |
| 1317 |
% command uses the |\uppercase| command, which is not expanded fully until |
| 1318 |
% further along in \TeX's gullet than we want. |
| 1319 |
% |
| 1320 |
% First, define some new counters and token lists. |
| 1321 |
% \begin{macrocode} |
| 1322 |
%<*othercode> |
| 1323 |
\newcounter{questionnumber} |
| 1324 |
\setcounter{questionnumber}{0} |
| 1325 |
\setcounter{section}{0} |
| 1326 |
\newcounter{extract} |
| 1327 |
\newcounter{question} \setcounter{question}{1} |
| 1328 |
\newcounter{length} \setcounter{length}{0} |
| 1329 |
\newcounter{temp} \setcounter{temp}{1} |
| 1330 |
\newcounter{wordtemp} \setcounter{wordtemp}{1} |
| 1331 |
\newcounter{form} |
| 1332 |
\newcounter{version} |
| 1333 |
\newcounter{current@section} |
| 1334 |
\newcounter{current@question} |
| 1335 |
\newcounter{innerloop} |
| 1336 |
\newcounter{sect} |
| 1337 |
\newcounter{sectionindex} |
| 1338 |
\newcounter{answer} |
| 1339 |
\newcounter{choice} |
| 1340 |
\setcounter{choice}{1} |
| 1341 |
\newcounter{mcquestion} \setcounter{mcquestion}{1} |
| 1342 |
\newcounter{mcchoice} \setcounter{mcchoice}{1} |
| 1343 |
\newcounter{savelistcnt} |
| 1344 |
\newlength{\blank@length} |
| 1345 |
\newlength{\temp@length} |
| 1346 |
\newlength{\temp@@length} |
| 1347 |
\newlength{\namedata@vspace} |
| 1348 |
\newlength{\beforesectsep} |
| 1349 |
\setlength{\beforesectsep}{\medskipamount} |
| 1350 |
\newlength{\aftersectsep} |
| 1351 |
\setlength{\aftersectsep}{\medskipamount} |
| 1352 |
\newlength{\beforeinstsep} |
| 1353 |
\setlength{\beforeinstsep}{\medskipamount} |
| 1354 |
\newlength{\afterinstsep} |
| 1355 |
\setlength{\afterinstsep}{\medskipamount} |
| 1356 |
\addtolength{\afterinstsep}{-\topsep} |
| 1357 |
\newif\ifchoice \choicefalse |
| 1358 |
\newif\ifanswer |
| 1359 |
\newif\ifnotfixed |
| 1360 |
\newif\ifcblanks \cblanksfalse |
| 1361 |
\newif\ifpblanks \pblankstrue |
| 1362 |
\newif\ifidentifier \identifierfalse |
| 1363 |
\newif\ifFirstQuestionInBlock \FirstQuestionInBlocktrue |
| 1364 |
\newif\ifcontinuousnumbering \continuousnumberingtrue |
| 1365 |
\newif\ifresetcounter\resetcounterfalse |
| 1366 |
\global\newtoks\temptoks |
| 1367 |
\global\newtoks\temp@toks |
| 1368 |
% \end{macrocode} |
| 1369 |
% |\setrannum| requires a ``traditional'' counter (i.e., a non-\LaTeX counter (i.e., a |
| 1370 |
% counter whose name doesn't begin with |c@|. |
| 1371 |
% \begin{macrocode} |
| 1372 |
\newcount\exam@c |
| 1373 |
\newcount\exam@n |
| 1374 |
\newcount\exam@m |
| 1375 |
\setrannum{\exam@m}{1}{10} |
| 1376 |
\newtoks\@toklist |
| 1377 |
% \end{macrocode} |
| 1378 |
% |
| 1379 |
% \begin{environment}{section} |
| 1380 |
% Questions naturally occur in blocks which have, more-or-less, the same |
| 1381 |
% general format. For example, one will naturally have a block of true/false |
| 1382 |
% questions together, followed by a block of short answer, and then a |
| 1383 |
% block of essay questions. We don't want to mix questions between blocks (so |
| 1384 |
% that the true/false questions are interspersed between the short answer |
| 1385 |
% questions). Thus we need to index the questions by section type as well as |
| 1386 |
% question number. |
| 1387 |
% |
| 1388 |
% \begin{macrocode} |
| 1389 |
\def\section{\stepcounter{section} |
| 1390 |
\setcounter{question}{1}} |
| 1391 |
% \end{macrocode} |
| 1392 |
% |
| 1393 |
% \begin{macro}{\get@instructions} |
| 1394 |
% This macro collects everything between it and the next |\begin| token. It then |
| 1395 |
% calls the |\find@instructions@end| macro to check whether the |\begin| token |
| 1396 |
% belongs to the \textsf{question} environment or some other environment. |
| 1397 |
% \begin{macrocode} |
| 1398 |
\long\def\get@instructions#1\begin{\@toklist=\expandafter{\the\@toklist#1}% |
| 1399 |
\find@instructions@end} |
| 1400 |
% \end{macrocode} |
| 1401 |
% \end{macro} |
| 1402 |
% |
| 1403 |
% \begin{macro}{\find@instructions@end} |
| 1404 |
% If we are at |\begin{question}| or |\begin{block}| |
| 1405 |
% save everything to the appropriately named |
| 1406 |
% macro. Otherwise, continue collecting tokens |
| 1407 |
% \begin{macrocode} |
| 1408 |
\def\find@instructions@end#1{% |
| 1409 |
\def\@tempa{#1}% |
| 1410 |
\ifx\@tempa\@Q |
| 1411 |
\let\@next=\Qwrap@up@instructions |
| 1412 |
\else |
| 1413 |
\ifx\@tempa\@Block |
| 1414 |
\let\@next=\Bwrap@up@instructions |
| 1415 |
\else |
| 1416 |
\@toklist=\expandafter{\the\@toklist\begin{#1}}% |
| 1417 |
\let\@next=\get@instructions |
| 1418 |
\fi\fi\@next} |
| 1419 |
% \end{macrocode} |
| 1420 |
% \end{macro} |
| 1421 |
% |
| 1422 |
% \begin{macro}{\Qwrap@up@instructions} |
| 1423 |
% Use the counters |section| and |question| to save the collected token list |
| 1424 |
% in a macro named as described earlier. |
| 1425 |
% \begin{macrocode} |
| 1426 |
\def\Qwrap@up@instructions{% |
| 1427 |
\expandafter\xdef\csname inst@sec\thesection\endcsname{\the\@toklist} |
| 1428 |
\begin{question}} |
| 1429 |
% \end{macro} |
| 1430 |
% |
| 1431 |
% \begin{macro}{\Bwrap@up@instructions} |
| 1432 |
% Use the counters |section| and |question| to save the collected token list |
| 1433 |
% in a macro named as described earlier. |
| 1434 |
% \begin{macrocode} |
| 1435 |
\def\Bwrap@up@instructions{% |
| 1436 |
\expandafter\xdef\csname inst@sec\thesection\endcsname{\the\@toklist} |
| 1437 |
\begin{block}} |
| 1438 |
% \end{macro} |
| 1439 |
% |
| 1440 |
% \begin{macro}{\endsection} |
| 1441 |
% At the end of a section, make a list of question indexes. |
| 1442 |
% \begin{macrocode} |
| 1443 |
\def\endsection{\make@qlist} |
| 1444 |
% \end{macrocode} |
| 1445 |
% \end{macro} |
| 1446 |
% \end{environment} |
| 1447 |
% |
| 1448 |
% \begin{macro}{\make@qlist} |
| 1449 |
% As described below, we need to create a token list containing the index |
| 1450 |
% numbers of each question. This is done by a while-loop as follows: |
| 1451 |
% \begin{macrocode} |
| 1452 |
\def\make@qlist{% |
| 1453 |
\setcounter{temp}{1} |
| 1454 |
\edef\@tempa{\thesection}% |
| 1455 |
% \end{macrocode} |
| 1456 |
% We need to create a new token list to hold the question indexes. While |
| 1457 |
% we are at it, might as well create the token list to hold the rearranged |
| 1458 |
% question indexes. This saves us having to include a while-loop later. |
| 1459 |
% \begin{macrocode} |
| 1460 |
\global\expandafter\newtoks\csname qlist@sec\@tempa\endcsname |
| 1461 |
\global\expandafter\newtoks\csname qlist@scr@sec\@tempa\endcsname |
| 1462 |
\global\csname qlist@scr@sec\@tempa\endcsname={} |
| 1463 |
% \end{macrocode} |
| 1464 |
% Now being a while-loop where each pass through the loop appends |
| 1465 |
% an index number to the question list. |
| 1466 |
% \begin{macrocode} |
| 1467 |
\@whilenum \value{question}>1 \do{% |
| 1468 |
\edef\@questionnumber{\arabic{temp}}% |
| 1469 |
\expandafter\append\expandafter{\@questionnumber}% |
| 1470 |
{\csname qlist@sec\@tempa\endcsname} |
| 1471 |
\addtocounter{question}{-1} |
| 1472 |
\addtocounter{temp}{1}}} |
| 1473 |
% \end{macrocode} |
| 1474 |
% \end{macro} |
| 1475 |
% |
| 1476 |
% \subsection{The \textsf{question} environment} |
| 1477 |
% |
| 1478 |
% \begin{macro}{\question} |
| 1479 |
% We define |\question| so that it reads in and saves the surround text |
| 1480 |
% to a macro like in the \textsf{tabularx} environment. |
| 1481 |
% \begin{macrocode} |
| 1482 |
\def\question{% |
| 1483 |
\@toklist={\exam@ExecuteIfDefined{sec\thesection q\thequestion break}}% |
| 1484 |
% \@ifundefined{sec\thesection q\thequestion break} |
| 1485 |
% {\@toklist={}} |
| 1486 |
% {\expandafter\@toklist\expandafter{\csname |
| 1487 |
% sec\thesection q\thequestion break\endcsname}} |
| 1488 |
\get@question@body} |
| 1489 |
% \end{macrocode} |
| 1490 |
% \end{macro} |
| 1491 |
% |
| 1492 |
% \begin{macro}{\endquestion} |
| 1493 |
% Increment the question counter so that the next question will be assigned the |
| 1494 |
% right name |
| 1495 |
% \begin{macrocode} |
| 1496 |
\def\endquestion{\stepcounter{question}} |
| 1497 |
% \end{macrocode} |
| 1498 |
% \end{macro} |
| 1499 |
% |
| 1500 |
% \begin{macro}{\get@question@body} |
| 1501 |
% This macro collects everything between it and the next |\end| token. It then |
| 1502 |
% calls the |\find@question@end| macro to check whether the |\end| token |
| 1503 |
% belongs to the \textsf{question} environment or some other environment. |
| 1504 |
% \begin{macrocode} |
| 1505 |
\long\def\get@question@body#1\end{\@toklist=\expandafter{\the\@toklist#1}% |
| 1506 |
\find@question@end} |
| 1507 |
% \end{macrocode} |
| 1508 |
% \end{macro} |
| 1509 |
% |
| 1510 |
% \begin{macro}{\find@question@end} |
| 1511 |
% If we are at |\end{question}|, save everything to the appropriately named |
| 1512 |
% macro. Otherwise, continue collecting tokens |
| 1513 |
% \begin{macrocode} |
| 1514 |
\def\find@question@end#1{% |
| 1515 |
\def\@tempa{#1}% |
| 1516 |
\ifx\@tempa\@Q\expandafter\wrap@up |
| 1517 |
\else\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 1518 |
\expandafter\get@question@body\fi} |
| 1519 |
% \end{macrocode} |
| 1520 |
% \end{macro} |
| 1521 |
% |
| 1522 |
% \begin{macro}{\wrap@up} |
| 1523 |
% Use the counters |section| and |question| to save the collected token list |
| 1524 |
% in a macro named as described earlier. |
| 1525 |
% \begin{macrocode} |
| 1526 |
\def\exam@ExecuteIfDefined#1{% |
| 1527 |
\@ifundefined{#1}% |
| 1528 |
{}% |
| 1529 |
{\csname #1\endcsname}} |
| 1530 |
|
| 1531 |
\def\wrap@up{% |
| 1532 |
\edef\@tempa{\thesection}% |
| 1533 |
\edef\@tempb{\thequestion}% |
| 1534 |
\ifx\@currentsectionname\@truefalse |
| 1535 |
\expandafter\xdef\csname sec\@tempa @qst\@tempb\endcsname{% |
| 1536 |
\noexpand\exam@ExecuteIfDefined{sec\thesection q\thequestion break}% |
| 1537 |
\noexpand\exam@TFItem |
| 1538 |
\noexpand\@beforequestionhook |
| 1539 |
\noexpand\exam@TFGobbleQuestionHook |
| 1540 |
\the\@toklist |
| 1541 |
\noexpand\@endquestionhook} |
| 1542 |
\else |
| 1543 |
\ifx\@currentsectionname\@MC |
| 1544 |
\expandafter\xdef\csname sec\@tempa @qst\@tempb\endcsname{% |
| 1545 |
\noexpand\exam@ExecuteIfDefined{sec\thesection q\thequestion break}% |
| 1546 |
\noexpand\@mcitem |
| 1547 |
\noexpand\@beforequestionhook |
| 1548 |
\noexpand\exam@MCGobbleQuestionHook |
| 1549 |
\the\@toklist |
| 1550 |
\noexpand\exam@EndChoiceListIfNecessary |
| 1551 |
\noexpand\@mcenditem |
| 1552 |
\noexpand\@endquestionhook} |
| 1553 |
\else |
| 1554 |
\ifx\@currentsectionname\@shortanswer |
| 1555 |
\expandafter\xdef\csname sec\@tempa @qst\@tempb\endcsname{% |
| 1556 |
\noexpand\exam@ExecuteIfDefined{sec\thesection q\thequestion break}% |
| 1557 |
\noexpand\item |
| 1558 |
\noexpand\@beforequestionhook |
| 1559 |
\noexpand\exam@SAGobbleQuestionHook |
| 1560 |
\the\@toklist |
| 1561 |
\noexpand\@endquestionhook} |
| 1562 |
\else |
| 1563 |
\ifx\@currentsectionname\@fillin |
| 1564 |
\expandafter\xdef\csname sec\@tempa @qst\@tempb\endcsname{% |
| 1565 |
\noexpand\exam@ExecuteIfDefined{sec\thesection q\thequestion break}% |
| 1566 |
\noexpand\item |
| 1567 |
\noexpand\@beforequestionhook |
| 1568 |
\noexpand\exam@FillinGobbleQuestionHook |
| 1569 |
\the\@toklist |
| 1570 |
\noexpand\@endquestionhook} |
| 1571 |
\else |
| 1572 |
\expandafter\xdef\csname sec\@tempa @qst\@tempb\endcsname{% |
| 1573 |
\noexpand\exam@ExecuteIfDefined{sec\thesection q\thequestion break}% |
| 1574 |
\noexpand\item |
| 1575 |
\noexpand\@beforequestionhook |
| 1576 |
\the\@toklist |
| 1577 |
\noexpand\@endquestionhook} |
| 1578 |
\fi\fi\fi\fi |
| 1579 |
\end{question}} |
| 1580 |
% \end{macrocode} |
| 1581 |
% \end{macro} |
| 1582 |
% |
| 1583 |
% \begin{macro}{\@Q} |
| 1584 |
% Store the name of the environment for comparison in |\find@question@end| |
| 1585 |
% \begin{macrocode} |
| 1586 |
\def\@Q{question} |
| 1587 |
% \end{macrocode} |
| 1588 |
% \end{macro} |
| 1589 |
% |
| 1590 |
% \subsection{The \textsf{block} environment} |
| 1591 |
% |
| 1592 |
% \begin{macro}{\block} |
| 1593 |
% This macro provides a ``block'' environment that prevents the questions |
| 1594 |
% it surrounds from being rearranged. |
| 1595 |
% |
| 1596 |
% The |\global\@newlistfalse| is required to prevent \LaTeX\ from barfing |
| 1597 |
% if the random rearrangement places the block at the beginning of the |
| 1598 |
% question list, in which case the |\end{enumerate}| would close a |
| 1599 |
% |\begin{enumerate}| without an intervening |\item|. |
| 1600 |
% \begin{macrocode} |
| 1601 |
\newcounter{first} |
| 1602 |
\newcounter{last} |
| 1603 |
\def\exam@GobbleBlockInstructionsHook{\relax} |
| 1604 |
\newcounter{exam@tf}\setcounter{exam@tf}{0} |
| 1605 |
|
| 1606 |
\newcommand{\block}[1][]{% |
| 1607 |
% Break only if a pagebreak preceeded the block |
| 1608 |
\@toklist={\exam@ExecuteIfDefined{sec\current@section q\current@question break}}% |
| 1609 |
\@toklist=\expandafter{\the\@toklist |
| 1610 |
\global\@newlistfalse |
| 1611 |
\setcounter{questionnumber}{\value{enumi}}}% |
| 1612 |
\ifx\@currentsectionname\@truefalse |
| 1613 |
\@toklist=\expandafter{\the\@toklist |
| 1614 |
\end{list}% |
| 1615 |
\setcounter{exam@tf}{0}% |
| 1616 |
\exam@TrueFalseGobbleBlockInstructionsHook}% |
| 1617 |
\else |
| 1618 |
\@toklist=\expandafter{\the\@toklist |
| 1619 |
\end{enumerate}\exam@GobbleBlockInstructionsHook}% |
| 1620 |
\fi |
| 1621 |
\setkeys{block}{#1}% |
| 1622 |
\exam@GetBlockToFirstQuestion} |
| 1623 |
|
| 1624 |
\define@key{block}{questions}[0]{% |
| 1625 |
\@toklist=\expandafter{\the\@toklist |
| 1626 |
\setcounter{first}{\value{enumi}} |
| 1627 |
\stepcounter{first} |
| 1628 |
\setcounter{last}{\value{enumi}} |
| 1629 |
\addtocounter{last}{#1}}} |
| 1630 |
|
| 1631 |
\long\def\exam@GetBlockToFirstQuestion#1\begin{% |
| 1632 |
\@toklist=\expandafter{\the\@toklist #1}% |
| 1633 |
\exam@CheckForQuestion} |
| 1634 |
|
| 1635 |
\def\exam@CheckForQuestion#1{% |
| 1636 |
\def\@tempa{#1}% |
| 1637 |
\ifx\@tempa\@Q |
| 1638 |
\ifx\@currentsectionname\@truefalse |
| 1639 |
\@toklist=\expandafter{\the\@toklist |
| 1640 |
\exam@StartTrueFalseList |
| 1641 |
\begin{question}} |
| 1642 |
\else |
| 1643 |
\@toklist=\expandafter{\the\@toklist |
| 1644 |
\begin{enumerate} |
| 1645 |
\setcounter{enumi}{\value{questionnumber}}% |
| 1646 |
\begin{question}} |
| 1647 |
\fi |
| 1648 |
\expandafter\get@block@body |
| 1649 |
\else |
| 1650 |
\expandafter\exam@GetBlockToFirstQuestion |
| 1651 |
\fi} |
| 1652 |
|
| 1653 |
\long\def\get@block@body#1\end{\@toklist=\expandafter{\the\@toklist #1}% |
| 1654 |
\find@block@end} |
| 1655 |
\def\find@block@end#1{% |
| 1656 |
\def\@tempa{#1}% |
| 1657 |
\ifx\@tempa\@Block\expandafter\block@wrap@up |
| 1658 |
\else\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 1659 |
\expandafter\get@block@body\fi} |
| 1660 |
% \end{macrocode} |
| 1661 |
% \end{macro} |
| 1662 |
% |
| 1663 |
% \begin{macro}{\block@wrap@up} |
| 1664 |
% \begin{macrocode} |
| 1665 |
\def\block@wrap@up{% |
| 1666 |
\edef\@tempa{\thesection}% |
| 1667 |
\edef\@tempb{\thequestion}% |
| 1668 |
\expandafter\xdef\csname sec\@tempa @qst\@tempb\endcsname{% |
| 1669 |
\noexpand\@startofblockhook |
| 1670 |
\the\@toklist |
| 1671 |
\noexpand\@endofblockhook}% |
| 1672 |
\end{block}} |
| 1673 |
% \end{macrocode} |
| 1674 |
% \end{macro} |
| 1675 |
% |
| 1676 |
% \begin{macro}{\@startofblockhook} |
| 1677 |
% \begin{macrocode} |
| 1678 |
\def\@startofblockhook{\relax} |
| 1679 |
% \end{macrocode} |
| 1680 |
% \end{macro} |
| 1681 |
% |
| 1682 |
% |
| 1683 |
% \begin{macro}{\@endofblockhook} |
| 1684 |
% \begin{macrocode} |
| 1685 |
\def\@endofblockhook{\relax} |
| 1686 |
% \end{macrocode} |
| 1687 |
% \end{macro} |
| 1688 |
% |
| 1689 |
% \begin{macro}{\@Block} |
| 1690 |
% \begin{macrocode} |
| 1691 |
\def\@Block{block} |
| 1692 |
% \end{macrocode} |
| 1693 |
% \end{macro} |
| 1694 |
% |
| 1695 |
% \begin{macro}{\endblock} |
| 1696 |
% \begin{macrocode} |
| 1697 |
\def\endblock{\stepcounter{question}} |
| 1698 |
% \end{macrocode} |
| 1699 |
% \end{macro} |
| 1700 |
% |
| 1701 |
% \subsection{The \textsf{frontmatter} environment} |
| 1702 |
% |
| 1703 |
% \begin{macro}{\frontmatter} |
| 1704 |
% We define "\frontmatter" so that it reads in and saves the surround text |
| 1705 |
% to a macro like in the \textsf{tabularx} environment. |
| 1706 |
% \begin{macrocode} |
| 1707 |
\def\frontmatter{\@toklist={} |
| 1708 |
\get@frontmatter@body} |
| 1709 |
% \end{macrocode} |
| 1710 |
% \end{macro} |
| 1711 |
% |
| 1712 |
% \begin{macro}{\endfrontmatter} |
| 1713 |
% This doesn't need to do anything. |
| 1714 |
% \begin{macrocode} |
| 1715 |
\def\endfrontmatter{\relax} |
| 1716 |
% \end{macrocode} |
| 1717 |
% \end{macro} |
| 1718 |
% |
| 1719 |
% \begin{macro}{\get@frontmatter@body} |
| 1720 |
% This macro collects everything between it and the next |\end| token. It then |
| 1721 |
% calls the |\find@frontmatter@end| macro to check whether the |\end| token |
| 1722 |
% belongs to the \textsf{frontmatter} environment or some other environment. |
| 1723 |
% \begin{macrocode} |
| 1724 |
\long\def\get@frontmatter@body#1\end{% |
| 1725 |
\@toklist=\expandafter{\the\@toklist#1}% |
| 1726 |
\find@frontmatter@end} |
| 1727 |
% \end{macrocode} |
| 1728 |
% \end{macro} |
| 1729 |
% |
| 1730 |
% \begin{macro}{\find@frontmatter@end} |
| 1731 |
% If we are at |\end{frontmatter}|, save everything to the appropriately named |
| 1732 |
% macro. Otherwise, continue collecting tokens |
| 1733 |
% \begin{macrocode} |
| 1734 |
\def\find@frontmatter@end#1{% |
| 1735 |
\def\@tempa{#1}% |
| 1736 |
\ifx\@tempa\@Frontmatter |
| 1737 |
\expandafter\frontmatter@wrap@up |
| 1738 |
\else |
| 1739 |
\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 1740 |
\expandafter\get@frontmatter@body |
| 1741 |
\fi} |
| 1742 |
% \end{macrocode} |
| 1743 |
% \end{macro} |
| 1744 |
% |
| 1745 |
% \begin{macro}{\frontmatter@wrap@up} |
| 1746 |
% Save all the scanned text into an appropriately named macro for later |
| 1747 |
% recall. |
| 1748 |
% \begin{macrocode} |
| 1749 |
\def\frontmatter@wrap@up{% |
| 1750 |
\xdef\@frontmattertext{\the\@toklist} |
| 1751 |
\end{frontmatter}} |
| 1752 |
% \end{macrocode} |
| 1753 |
% \end{macro} |
| 1754 |
% |
| 1755 |
% \begin{macro}{\@Frontmatter} |
| 1756 |
% Store the name of the environment for comparison in |\find@frontmatter@end| |
| 1757 |
% \begin{macrocode} |
| 1758 |
\def\@Frontmatter{frontmatter} |
| 1759 |
% \end{macrocode} |
| 1760 |
% \end{macro} |
| 1761 |
% |
| 1762 |
% \subsection{The \textsf{endmatter} environment} |
| 1763 |
% |
| 1764 |
% The \textsf{endmatter} environment behaves just like the \textsf{frontmatter} |
| 1765 |
% environment, except the enclosed text is saved in a differently-named macro. |
| 1766 |
% |
| 1767 |
% \begin{macro}{\endmatter} |
| 1768 |
% We define "\endmatter" so that it reads in and saves the surround text |
| 1769 |
% to a macro like in the \textsf{tabularx} environment. |
| 1770 |
% \begin{macrocode} |
| 1771 |
\def\endmatter{\@toklist={} |
| 1772 |
\get@endmatter@body} |
| 1773 |
% \end{macrocode} |
| 1774 |
% \end{macro} |
| 1775 |
% |
| 1776 |
% \begin{macro}{\endendmatter} |
| 1777 |
% This doesn't need to do anything. |
| 1778 |
% \begin{macrocode} |
| 1779 |
\def\endendmatter{\relax} |
| 1780 |
% \end{macrocode} |
| 1781 |
% \end{macro} |
| 1782 |
% |
| 1783 |
% \begin{macro}{\get@endmatter@body} |
| 1784 |
% This macro collects everything between it and the next |\end| token. It then |
| 1785 |
% calls the |\find@endmatter@end| macro to check whether the |\end| token |
| 1786 |
% belongs to the \textsf{endmatter} environment or some other environment. |
| 1787 |
% \begin{macrocode} |
| 1788 |
\long\def\get@endmatter@body#1\end{% |
| 1789 |
\@toklist=\expandafter{\the\@toklist#1}% |
| 1790 |
\find@endmatter@end} |
| 1791 |
% \end{macrocode} |
| 1792 |
% \end{macro} |
| 1793 |
% |
| 1794 |
% \begin{macro}{\find@endmatter@end} |
| 1795 |
% If we are at |\end{endmatter}|, save everything to the appropriately named |
| 1796 |
% macro. Otherwise, continue collecting tokens |
| 1797 |
% \begin{macrocode} |
| 1798 |
\def\find@endmatter@end#1{% |
| 1799 |
\def\@tempa{#1}% |
| 1800 |
\ifx\@tempa\@Endmatter |
| 1801 |
\expandafter\endmatter@wrap@up |
| 1802 |
\else |
| 1803 |
\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 1804 |
\expandafter\get@endmatter@body |
| 1805 |
\fi} |
| 1806 |
% \end{macrocode} |
| 1807 |
% \end{macro} |
| 1808 |
% |
| 1809 |
% \begin{macro}{\endmatter@wrap@up} |
| 1810 |
% Save the scanned text to an appropriately named macro for later recall. |
| 1811 |
% \begin{macrocode} |
| 1812 |
\def\endmatter@wrap@up{% |
| 1813 |
\xdef\@endmattertext{\the\@toklist} |
| 1814 |
\end{endmatter}} |
| 1815 |
% \end{macrocode} |
| 1816 |
% \end{macro} |
| 1817 |
% |
| 1818 |
% \begin{macro}{\@Endmatter} |
| 1819 |
% Store the name of the environment for comparison in |\find@endmatter@end| |
| 1820 |
% \begin{macrocode} |
| 1821 |
\def\@Endmatter{endmatter} |
| 1822 |
% \end{macrocode} |
| 1823 |
% \end{macro} |
| 1824 |
% |
| 1825 |
% We now initialize "\@frontmattertext" and "\@endmattertext" to a randomly |
| 1826 |
% chosen garbage value that no user will ever use. This enables us to test in |
| 1827 |
% the main loop whether the user has used \textsf{frontmatter} or |
| 1828 |
% \textsf{endmatter} in her document. |
| 1829 |
% |
| 1830 |
% \begin{macrocode} |
| 1831 |
\begin{frontmatter} |
| 1832 |
\relax |
| 1833 |
\end{frontmatter} |
| 1834 |
% \end{macrocode} |
| 1835 |
% |
| 1836 |
% \begin{macrocode} |
| 1837 |
\begin{endmatter} |
| 1838 |
\relax |
| 1839 |
\end{endmatter} |
| 1840 |
% \end{macrocode} |
| 1841 |
% |
| 1842 |
% \subsection{The \textsf{exampreface} environment} |
| 1843 |
% |
| 1844 |
% The \textsf{exampreface} environment behaves just like the \textsf{frontmatter} |
| 1845 |
% environment, except the enclosed text is saved in a differently-named |
| 1846 |
% macro---one that will be printed just beneath any text specified in the |
| 1847 |
% \textsf{examtop} environment. |
| 1848 |
% |
| 1849 |
% \begin{macro}{\exampreface} |
| 1850 |
% We define "\exampreface" so that it reads in and saves the surround text |
| 1851 |
% to a macro like in the \textsf{tabularx} environment. |
| 1852 |
% \begin{macrocode} |
| 1853 |
\def\exampreface{\@toklist={} |
| 1854 |
\get@exampreface@body} |
| 1855 |
% \end{macrocode} |
| 1856 |
% \end{macro} |
| 1857 |
% |
| 1858 |
% \begin{macro}{\endexampreface} |
| 1859 |
% This doesn't need to do anything. |
| 1860 |
% \begin{macrocode} |
| 1861 |
\def\endexampreface{\relax} |
| 1862 |
% \end{macrocode} |
| 1863 |
% \end{macro} |
| 1864 |
% |
| 1865 |
% \begin{macro}{\get@exampreface@body} |
| 1866 |
% This macro collects everything between it and the next |\end| token. It then |
| 1867 |
% calls the |\find@exampreface@end| macro to check whether the |\end| token |
| 1868 |
% belongs to the \textsf{exampreface} environment or some other environment. |
| 1869 |
% \begin{macrocode} |
| 1870 |
\long\def\get@exampreface@body#1\end{% |
| 1871 |
\@toklist=\expandafter{\the\@toklist#1}% |
| 1872 |
\find@exampreface@end} |
| 1873 |
% \end{macrocode} |
| 1874 |
% \end{macro} |
| 1875 |
% |
| 1876 |
% \begin{macro}{\find@exampreface@end} |
| 1877 |
% If we are at |\end{exampreface}|, save everything to the appropriately named |
| 1878 |
% macro. Otherwise, continue collecting tokens |
| 1879 |
% \begin{macrocode} |
| 1880 |
\def\find@exampreface@end#1{% |
| 1881 |
\def\@tempa{#1}% |
| 1882 |
\ifx\@tempa\@Exampreface |
| 1883 |
\expandafter\exampreface@wrap@up |
| 1884 |
\else |
| 1885 |
\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 1886 |
\expandafter\get@exampreface@body |
| 1887 |
\fi} |
| 1888 |
% \end{macrocode} |
| 1889 |
% \end{macro} |
| 1890 |
% |
| 1891 |
% \begin{macro}{\exampreface@wrap@up} |
| 1892 |
% Save the scanned text to an appropriately named macro for later recall. |
| 1893 |
% \begin{macrocode} |
| 1894 |
\def\exampreface@wrap@up{% |
| 1895 |
\xdef\@examprefacetext{\the\@toklist} |
| 1896 |
\end{exampreface}} |
| 1897 |
% \end{macrocode} |
| 1898 |
% \end{macro} |
| 1899 |
% |
| 1900 |
% \begin{macro}{\@Exampreface} |
| 1901 |
% Store the name of the environment for comparison in |\find@exampreface@end| |
| 1902 |
% \begin{macrocode} |
| 1903 |
\def\@Exampreface{exampreface} |
| 1904 |
% \end{macrocode} |
| 1905 |
% \end{macro} |
| 1906 |
% |
| 1907 |
% \subsection{The \textsf{examclosing} environment} |
| 1908 |
% |
| 1909 |
% The \textsf{examclosing} environment behaves just like the \textsf{frontmatter} |
| 1910 |
% environment, except the enclosed text is saved in a differently-named |
| 1911 |
% macro. |
| 1912 |
% |
| 1913 |
% \begin{macro}{\examclosing} |
| 1914 |
% We define "\examclosing" so that it reads in and saves the surround text |
| 1915 |
% to a macro like in the \textsf{tabularx} environment. |
| 1916 |
% \begin{macrocode} |
| 1917 |
\def\examclosing{\@toklist={} |
| 1918 |
\get@examclosing@body} |
| 1919 |
% \end{macrocode} |
| 1920 |
% \end{macro} |
| 1921 |
% |
| 1922 |
% \begin{macro}{\endexamclosing} |
| 1923 |
% This doesn't need to do anything. |
| 1924 |
% \begin{macrocode} |
| 1925 |
\def\endexamclosing{\relax} |
| 1926 |
% \end{macrocode} |
| 1927 |
% \end{macro} |
| 1928 |
% |
| 1929 |
% \begin{macro}{\get@examclosing@body} |
| 1930 |
% This macro collects everything between it and the next |\end| token. It then |
| 1931 |
% calls the |\find@examclosing@end| macro to check whether the |\end| token |
| 1932 |
% belongs to the \textsf{examclosing} environment or some other environment. |
| 1933 |
% \begin{macrocode} |
| 1934 |
\long\def\get@examclosing@body#1\end{% |
| 1935 |
\@toklist=\expandafter{\the\@toklist#1}% |
| 1936 |
\find@examclosing@end} |
| 1937 |
% \end{macrocode} |
| 1938 |
% \end{macro} |
| 1939 |
% |
| 1940 |
% \begin{macro}{\find@examclosing@end} |
| 1941 |
% If we are at |\end{examclosing}|, save everything to the appropriately named |
| 1942 |
% macro. Otherwise, continue collecting tokens |
| 1943 |
% \begin{macrocode} |
| 1944 |
\def\find@examclosing@end#1{% |
| 1945 |
\def\@tempa{#1}% |
| 1946 |
\ifx\@tempa\@Examclosing |
| 1947 |
\expandafter\examclosing@wrap@up |
| 1948 |
\else |
| 1949 |
\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 1950 |
\expandafter\get@examclosing@body |
| 1951 |
\fi} |
| 1952 |
% \end{macrocode} |
| 1953 |
% \end{macro} |
| 1954 |
% |
| 1955 |
% \begin{macro}{\examclosing@wrap@up} |
| 1956 |
% Save the scanned text to an appropriately named macro for later recall. |
| 1957 |
% \begin{macrocode} |
| 1958 |
\def\examclosing@wrap@up{% |
| 1959 |
\xdef\@examclosingtext{\the\@toklist} |
| 1960 |
\end{examclosing}} |
| 1961 |
% \end{macrocode} |
| 1962 |
% \end{macro} |
| 1963 |
% |
| 1964 |
% \begin{macro}{\@Examclosing} |
| 1965 |
% Store the name of the environment for comparison in |\find@examclosing@end| |
| 1966 |
% \begin{macrocode} |
| 1967 |
\def\@Examclosing{examclosing} |
| 1968 |
% \end{macrocode} |
| 1969 |
% \end{macro} |
| 1970 |
% |
| 1971 |
% We now initialize "\@\examprefacetext" and "\@examclosingtext" to "\relax" |
| 1972 |
% so that in case the user doesn't specify any special text, nothing will be |
| 1973 |
% typeset in the actual exam. |
| 1974 |
% |
| 1975 |
% \begin{macrocode} |
| 1976 |
\begin{exampreface} |
| 1977 |
\relax |
| 1978 |
\end{exampreface} |
| 1979 |
% \end{macrocode} |
| 1980 |
% |
| 1981 |
% \begin{macrocode} |
| 1982 |
\begin{examclosing} |
| 1983 |
\relax |
| 1984 |
\end{examclosing} |
| 1985 |
% \end{macrocode} |
| 1986 |
% |
| 1987 |
% \subsection{The \textsf{keypreface} environment} |
| 1988 |
% |
| 1989 |
% The \textsf{keypreface} environment behaves just like the \textsf{frontmatter} |
| 1990 |
% environment, except the enclosed text is saved in a differently-named |
| 1991 |
% macro---one that will be printed just beneath any text specified in the |
| 1992 |
% \textsf{keytop} environment. |
| 1993 |
% |
| 1994 |
% \begin{macro}{\keypreface} |
| 1995 |
% We define "\keypreface" so that it reads in and saves the surround text |
| 1996 |
% to a macro like in the \textsf{tabularx} environment. |
| 1997 |
% \begin{macrocode} |
| 1998 |
\def\keypreface{\@toklist={} |
| 1999 |
\get@keypreface@body} |
| 2000 |
% \end{macrocode} |
| 2001 |
% \end{macro} |
| 2002 |
% |
| 2003 |
% \begin{macro}{\endkeypreface} |
| 2004 |
% This doesn't need to do anything. |
| 2005 |
% \begin{macrocode} |
| 2006 |
\def\endkeypreface{\relax} |
| 2007 |
% \end{macrocode} |
| 2008 |
% \end{macro} |
| 2009 |
% |
| 2010 |
% \begin{macro}{\get@keypreface@body} |
| 2011 |
% This macro collects everything between it and the next |\end| token. It then |
| 2012 |
% calls the |\find@keypreface@end| macro to check whether the |\end| token |
| 2013 |
% belongs to the \textsf{keypreface} environment or some other environment. |
| 2014 |
% \begin{macrocode} |
| 2015 |
\long\def\get@keypreface@body#1\end{% |
| 2016 |
\@toklist=\expandafter{\the\@toklist#1}% |
| 2017 |
\find@keypreface@end} |
| 2018 |
% \end{macrocode} |
| 2019 |
% \end{macro} |
| 2020 |
% |
| 2021 |
% \begin{macro}{\find@keypreface@end} |
| 2022 |
% If we are at "\end{keypreface}", save everything to the appropriately named |
| 2023 |
% macro. Otherwise, continue collecting tokens |
| 2024 |
% \begin{macrocode} |
| 2025 |
\def\find@keypreface@end#1{% |
| 2026 |
\def\@tempa{#1}% |
| 2027 |
\ifx\@tempa\@Keypreface |
| 2028 |
\expandafter\keypreface@wrap@up |
| 2029 |
\else |
| 2030 |
\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 2031 |
\expandafter\get@keypreface@body |
| 2032 |
\fi} |
| 2033 |
% \end{macrocode} |
| 2034 |
% \end{macro} |
| 2035 |
% |
| 2036 |
% \begin{macro}{\keypreface@wrap@up} |
| 2037 |
% Save the scanned text to an appropriately named macro for later recall. |
| 2038 |
% \begin{macrocode} |
| 2039 |
\def\keypreface@wrap@up{% |
| 2040 |
\xdef\@keyprefacetext{\the\@toklist} |
| 2041 |
\end{keypreface}} |
| 2042 |
% \end{macrocode} |
| 2043 |
% \end{macro} |
| 2044 |
% |
| 2045 |
% \begin{macro}{\@Keypreface} |
| 2046 |
% Store the name of the environment for comparison in "\find@keypreface@end" |
| 2047 |
% \begin{macrocode} |
| 2048 |
\def\@Keypreface{keypreface} |
| 2049 |
% \end{macrocode} |
| 2050 |
% \end{macro} |
| 2051 |
% |
| 2052 |
% \subsection{The \textsf{keyclosing} environment} |
| 2053 |
% |
| 2054 |
% The \textsf{keyclosing} environment behaves just like the \textsf{frontmatter} |
| 2055 |
% environment, except the enclosed text is saved in a differently-named |
| 2056 |
% macro. |
| 2057 |
% |
| 2058 |
% \begin{macro}{\keyclosing} |
| 2059 |
% We define "\keyclosing" so that it reads in and saves the surround text |
| 2060 |
% to a macro like in the \textsf{tabularx} environment. |
| 2061 |
% \begin{macrocode} |
| 2062 |
\def\keyclosing{\@toklist={} |
| 2063 |
\get@keyclosing@body} |
| 2064 |
% \end{macrocode} |
| 2065 |
% \end{macro} |
| 2066 |
% |
| 2067 |
% \begin{macro}{\endkeyclosing} |
| 2068 |
% This doesn't need to do anything. |
| 2069 |
% \begin{macrocode} |
| 2070 |
\def\endkeyclosing{\relax} |
| 2071 |
% \end{macrocode} |
| 2072 |
% \end{macro} |
| 2073 |
% |
| 2074 |
% \begin{macro}{\get@keyclosing@body} |
| 2075 |
% This macro collects everything between it and the next "\end" token. It then |
| 2076 |
% calls the "\find@keyclosing@end" macro to check whether the "\end" token |
| 2077 |
% belongs to the \textsf{keyclosing} environment or some other environment. |
| 2078 |
% \begin{macrocode} |
| 2079 |
\long\def\get@keyclosing@body#1\end{% |
| 2080 |
\@toklist=\expandafter{\the\@toklist#1}% |
| 2081 |
\find@keyclosing@end} |
| 2082 |
% \end{macrocode} |
| 2083 |
% \end{macro} |
| 2084 |
% |
| 2085 |
% \begin{macro}{\find@keyclosing@end} |
| 2086 |
% If we are at |\end{keyclosing}|, save everything to the appropriately named |
| 2087 |
% macro. Otherwise, continue collecting tokens |
| 2088 |
% \begin{macrocode} |
| 2089 |
\def\find@keyclosing@end#1{% |
| 2090 |
\def\@tempa{#1}% |
| 2091 |
\ifx\@tempa\@Keyclosing |
| 2092 |
\expandafter\keyclosing@wrap@up |
| 2093 |
\else |
| 2094 |
\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 2095 |
\expandafter\get@keyclosing@body |
| 2096 |
\fi} |
| 2097 |
% \end{macrocode} |
| 2098 |
% \end{macro} |
| 2099 |
% |
| 2100 |
% \begin{macro}{\keyclosing@wrap@up} |
| 2101 |
% Save the scanned text to an appropriately named macro for later recall. |
| 2102 |
% \begin{macrocode} |
| 2103 |
\def\keyclosing@wrap@up{% |
| 2104 |
\xdef\@keyclosingtext{\the\@toklist} |
| 2105 |
\end{keyclosing}} |
| 2106 |
% \end{macrocode} |
| 2107 |
% \end{macro} |
| 2108 |
% |
| 2109 |
% \begin{macro}{\@Keyclosing} |
| 2110 |
% Store the name of the environment for comparison in "\find@keyclosing@end" |
| 2111 |
% \begin{macrocode} |
| 2112 |
\def\@Keyclosing{keyclosing} |
| 2113 |
% \end{macrocode} |
| 2114 |
% \end{macro} |
| 2115 |
% |
| 2116 |
% We now initialize "\@keyprefacetext" and "\@keyclosingtext" to "\relax" |
| 2117 |
% so that in case the user doesn't specify any special text, nothing will be |
| 2118 |
% typeset in the actual exam. |
| 2119 |
% |
| 2120 |
% \begin{macrocode} |
| 2121 |
\begin{keypreface} |
| 2122 |
\relax |
| 2123 |
\end{keypreface} |
| 2124 |
% \end{macrocode} |
| 2125 |
% |
| 2126 |
% \begin{macrocode} |
| 2127 |
\begin{keyclosing} |
| 2128 |
\relax |
| 2129 |
\end{keyclosing} |
| 2130 |
% \end{macrocode} |
| 2131 |
% |
| 2132 |
% \subsection{Macros for manipulating token lists} |
| 2133 |
% In order to make manipulation of token lists easier, (or, really, to just |
| 2134 |
% increase the overall readability of the syntax, we define some macros |
| 2135 |
% to manipulate token lists. |
| 2136 |
% |
| 2137 |
% \begin{macro}{\append} |
| 2138 |
% |\append{|\meta{string}|}{|\meta{token-list}|}| appends \meta{string} |
| 2139 |
% to the rightmost end of \meta{token-list}. |
| 2140 |
% |
| 2141 |
% Note that we use |\@separator| between entries in the list, rather than |
| 2142 |
% |\\| as recommended in the \TeX{}book, since we will later want to redefine |
| 2143 |
% the list separator and \emph{execute} the list. If we used |\\|, we run into |
| 2144 |
% potential conflicts in executing the list, since \LaTeXe, at any given point |
| 2145 |
% during the execution of the list entry, might redefine |\\| in such a way as to |
| 2146 |
% screw things up. |
| 2147 |
% \begin{macrocode} |
| 2148 |
\def\append#1#2{% |
| 2149 |
\global\temp@toks=\expandafter{\the #2\@separator {#1}}% |
| 2150 |
\global#2=\expandafter{\the\temp@toks}} |
| 2151 |
% \end{macrocode} |
| 2152 |
% \end{macro} |
| 2153 |
% |
| 2154 |
% \begin{macro}{\length} |
| 2155 |
% The usage is |\length{|\meta{token-list}|}|. So |\length{\foo}| computes the |
| 2156 |
% length of the token list |\foo|, where it is assumed that the separator |
| 2157 |
% between list elements is |\@separator|. |
| 2158 |
% \begin{macrocode} |
| 2159 |
\def\length#1{% |
| 2160 |
\setcounter{length}{0} |
| 2161 |
\def\@separator##1{\stepcounter{length}}\the#1} |
| 2162 |
% \end{macrocode} |
| 2163 |
% \end{macro} |
| 2164 |
% |
| 2165 |
% \begin{macro}{\remove} |
| 2166 |
% |\remove{|\meta{number}|}{|\meta{token-list}|}| removes the \meta{number}th |
| 2167 |
% element from the token list \meta{token-list}, redefining \meta{token-list} |
| 2168 |
% to be that list. As always, we assume that the list elements are separated |
| 2169 |
% by the token |\@separator|. |
| 2170 |
% \begin{macrocode} |
| 2171 |
\def\remove#1#2{% |
| 2172 |
\exam@c=0 |
| 2173 |
\temptoks={} |
| 2174 |
\def\@separator##1{\advance\exam@c by 1\relax |
| 2175 |
\ifnum\exam@c=#1\relax% |
| 2176 |
\setcounter{extract}{##1}% |
| 2177 |
\else\append{##1}{\temptoks} |
| 2178 |
\fi} |
| 2179 |
\the#2 |
| 2180 |
\global#2=\expandafter{\the\temptoks}} |
| 2181 |
% \end{macrocode} |
| 2182 |
% \end{macro} |
| 2183 |
% |
| 2184 |
% \subsection{Scrambling the order of the questions} |
| 2185 |
% |
| 2186 |
% The general idea is that, for each section, we form a token list named |
| 2187 |
% |\qlist@sec|\meta{c} of the form: |
| 2188 |
% |{\@separator{1}\@separator{2}|\ldots|\@separator{|\meta{n}|}}| |
| 2189 |
% where \meta{c} is the number of the section (in roman numerals), and |
| 2190 |
% \meta{n} is the number of questions in section \meta{c}. We call a while-loop |
| 2191 |
% to loop \meta{n} times, each time removing a randomly |
| 2192 |
% chosen entry from the token list. This entry is appended to the list |
| 2193 |
% |\qlist@scr|\meta{m}@|sec|\meta{c}, where |
| 2194 |
% \meta{m} is the current value (in roman numerals) of the form we are |
| 2195 |
% generating. Once this list is built, we can then typeset the questions by |
| 2196 |
% simply redefining |\@separator| and executing the new scrambled list. |
| 2197 |
% |
| 2198 |
% \begin{macro}{\@enddocumenthook} |
| 2199 |
% Redefine the |\@enddocumenthook| so that the questions are automatically |
| 2200 |
% generated without the user needing to insert a command after all the question |
| 2201 |
% blocks. This has the ironic effect that absolutely nothing the user sees in |
| 2202 |
% the input file causes the text to be created. I haven't been real careful to |
| 2203 |
% prevent collisions occurring with other applications that use |
| 2204 |
% |\@enddocumenthook|, so this could be a source of problems. |
| 2205 |
% |
| 2206 |
% \medskip |
| 2207 |
% |
| 2208 |
% First, save any previously assigned meaning to |
| 2209 |
% |\@enddocumenthook| so that we don't clobber it. |
| 2210 |
% \begin{macrocode} |
| 2211 |
\let\@oldenddocumenthook=\@enddocumenthook |
| 2212 |
\def\@enddocumenthook{% |
| 2213 |
\global\let\pagebreak=\old@pagebreak |
| 2214 |
\global\let\BreakPageOnVersion=\exam@DoneReadingBreakPageOnVersion |
| 2215 |
% \end{macrocode} |
| 2216 |
% We need to create the number of forms specified, so we loop over the |
| 2217 |
% total number of forms. Initialize the counter \texttt{version} to 1 (this |
| 2218 |
% is the value we will loop over) and step the counter \texttt{form} (so that |
| 2219 |
% we actually generate all the forms that the user wants). |
| 2220 |
% \begin{macrocode} |
| 2221 |
\setcounter{version}{1} \stepcounter{form} |
| 2222 |
% \end{macrocode} |
| 2223 |
% Loop until the value of \texttt{version} exceeds \texttt{form}. |
| 2224 |
% \begin{macrocode} |
| 2225 |
\@whilenum \value{version}<\value{form} \do{% |
| 2226 |
% \end{macrocode} |
| 2227 |
% But two passes per exam are needed (once for the exam, once for the answers), |
| 2228 |
% so we create an ``inner-loop'' to take care of this problem. Since we will |
| 2229 |
% want the answer key to have a slightly different format (where the |
| 2230 |
% answers are included!) it pays to make this on the second pass. |
| 2231 |
% \begin{macrocode} |
| 2232 |
\setcounter{innerloop}{0} |
| 2233 |
\@whilenum \value{innerloop}<\value{passes} \do{% |
| 2234 |
% \end{macrocode} |
| 2235 |
% Reset the page counter so that no new exams or answer keys start on page 17 |
| 2236 |
% (for example). |
| 2237 |
% \begin{macrocode} |
| 2238 |
\setcounter{page}{1} |
| 2239 |
\setcounter{questionnumber}{0} |
| 2240 |
\setcounter{enumi}{0} |
| 2241 |
\setcounter{equation}{0} |
| 2242 |
% \end{macrocode} |
| 2243 |
% If |innerloop|=0, we are making an exam. If not, we are making an answer key, |
| 2244 |
% so take the appropriate action for the top of the form. Since we won't want |
| 2245 |
% absent-minded professors to make 200+ copies of the answer key, print the |
| 2246 |
% title of the answer key using |\Huge| to call attention to it. |
| 2247 |
% \begin{macrocode} |
| 2248 |
\ifx\@frontmattertext\relax |
| 2249 |
\relax |
| 2250 |
\else |
| 2251 |
\@frontmattertext \pagebreak |
| 2252 |
\fi |
| 2253 |
\ifnum \value{innerloop}=0 % |
| 2254 |
\@examtopmatter |
| 2255 |
\answerfalse |
| 2256 |
\iftwocolumn \begin{multicols}{2}\fi |
| 2257 |
\@examprefacetext |
| 2258 |
\else% |
| 2259 |
\@keytopmatter |
| 2260 |
\answertrue |
| 2261 |
\iftwocolumn \begin{multicols}{2}\fi |
| 2262 |
\@keyprefacetext |
| 2263 |
\fi |
| 2264 |
\setcounter{sectionindex}{0} |
| 2265 |
% \end{macrocode} |
| 2266 |
% And finally, once we have started making the exam, we need to loop over each |
| 2267 |
% individual section. |
| 2268 |
% \begin{macrocode} |
| 2269 |
\@whilenum \value{sectionindex}<\value{section} \do{% |
| 2270 |
\addtocounter{sectionindex}{1} |
| 2271 |
% \end{macrocode} |
| 2272 |
% Store the value of |sectionindex| in the macro |
| 2273 |
% |\current@section| so we can use it in |\csname|\ldots |\endcsname| pairs. |
| 2274 |
% \begin{macrocode} |
| 2275 |
\edef\current@section{\thesectionindex} |
| 2276 |
% \end{macrocode} |
| 2277 |
% Compute the length of |\qlist@sec|\meta{current@section} |
| 2278 |
% \begin{macrocode} |
| 2279 |
\length{\csname qlist@sec\current@section\endcsname} |
| 2280 |
% \end{macrocode} |
| 2281 |
% Here's the main meat of the code. Pick a random number between 1 and the |
| 2282 |
% length of |\qlist@sec|\meta{current@section}. Store it in the counter |\exam@m|. |
| 2283 |
% Remove the $m$th element from |\qlist@sec|\meta{current@section} and store it |
| 2284 |
% as the first element in |\qlist@scr@sec|\meta{current@section}. Continuing to |
| 2285 |
% do this will rearrange the order of the questions. The only thing we need to |
| 2286 |
% keep in mind is to change the requested range of the random number to keep in |
| 2287 |
% mind the fact that we removed an element from |
| 2288 |
% |\qlist@sec|\meta{current@section}. Although there are faster ways to do |
| 2289 |
% this, I chose to opt for more readable code, since this part of the program is |
| 2290 |
% so complex anyway. |
| 2291 |
% \begin{macrocode} |
| 2292 |
\csname sec\current@section @fixed\endcsname |
| 2293 |
\ifnotfixed |
| 2294 |
\ifanswer \relax |
| 2295 |
\else \typeout{Scrambling section \current@section, question: }\fi |
| 2296 |
\exam@ScrambleQuestionList |
| 2297 |
\else |
| 2298 |
\csname qlist@scr@sec\current@section\endcsname=\expandafter{% |
| 2299 |
\the\csname qlist@sec\current@section\endcsname} |
| 2300 |
\fi |
| 2301 |
% \end{macrocode} |
| 2302 |
% Finally, the code dealing with processing the different types of questions. Each |
| 2303 |
% type of question is processed in the exact same way: we perform an |\ifx| to |
| 2304 |
% test to see what type of question it is, and if it is that type of question, |
| 2305 |
% execute the following code, which redefines |\begin{answer}|\ldots |
| 2306 |
% |\end{answer}| as necessary to achieve the desired effects. |
| 2307 |
% |
| 2308 |
% \medskip |
| 2309 |
% |
| 2310 |
% We now conduct a series of tests to see exactly what type of question the |
| 2311 |
% current section contains. Once a match is made, the appropriate macro |
| 2312 |
% (defined below) is expanded, which typesets all the questions in that section. |
| 2313 |
% \begin{macrocode} |
| 2314 |
\csname RS@sec@\current@section\endcsname |
| 2315 |
\@ifundefined{sec\current@section break} |
| 2316 |
{\relax} |
| 2317 |
{\pagebreak} |
| 2318 |
\ifsection{\@matching}{\@matchingmain} |
| 2319 |
\ifsection{\@shortanswer}{\@shortanswermain} |
| 2320 |
\ifsection{\@fillin}{\@fillinmain} |
| 2321 |
\ifsection{\@MC}{\@multiplechoicemain} |
| 2322 |
\ifsection{\@truefalse}{\@truefalsemain}} |
| 2323 |
\ifnum \value{innerloop}=0 % |
| 2324 |
\@examclosingtext\par |
| 2325 |
\else |
| 2326 |
\@keyclosingtext\par |
| 2327 |
\fi |
| 2328 |
\iftwocolumn \end{multicols} \fi |
| 2329 |
\ifx\@endmattertext\relax |
| 2330 |
\relax |
| 2331 |
\else |
| 2332 |
\pagebreak \@endmattertext \par |
| 2333 |
\fi |
| 2334 |
\pagebreak |
| 2335 |
\addtocounter{innerloop}{1}} |
| 2336 |
\@OneKeyHook |
| 2337 |
% \end{macrocode} |
| 2338 |
% This is the end of the code for the inner while-loop (that generates both |
| 2339 |
% exams and answer sheets. Toggle the value of "\ifanswer" so that |
| 2340 |
% on the second pass we generate answers to the questions. Add one to |
| 2341 |
% "innerloop", too. |
| 2342 |
% \begin{macrocode} |
| 2343 |
\stepcounter{version} |
| 2344 |
\setcounter{sectionindex}{0} |
| 2345 |
% \end{macrocode} |
| 2346 |
% This is the end of the code for the form while-loop. Add -1 to |form| to |
| 2347 |
% keep track of the number of copies we've made, and redefine the |
| 2348 |
% |\qlist@sec|\meta{section} lists, since they were eaten up by |\remove| |
| 2349 |
% during the randomization. (This is what the next loop does.) |
| 2350 |
% \begin{macrocode} |
| 2351 |
\@whilenum \value{sectionindex}<\value{section} \do{% |
| 2352 |
\addtocounter{sectionindex}{1} |
| 2353 |
\edef\current@section{\thesectionindex} |
| 2354 |
\csname sec\current@section @fixed\endcsname |
| 2355 |
\ifnotfixed |
| 2356 |
\exam@RestoreSectionLists |
| 2357 |
\else \notfixedtrue\fi} |
| 2358 |
}} |
| 2359 |
|
| 2360 |
\def\exam@RestoreSectionLists{% |
| 2361 |
\csname qlist@sec\current@section\endcsname=\expandafter{\the\csname |
| 2362 |
qlist@scr@sec\current@section\endcsname} |
| 2363 |
\csname qlist@scr@sec\current@section\endcsname={}} |
| 2364 |
|
| 2365 |
\def\exam@ScrambleQuestionList{% |
| 2366 |
\length{\csname qlist@sec\current@section\endcsname}% |
| 2367 |
\@whilenum \value{length}>0 \do{% |
| 2368 |
\setrannum{\exam@m}{1}{\value{length}}% |
| 2369 |
\remove{\exam@m}{\csname qlist@sec\current@section\endcsname}% |
| 2370 |
\edef\@TEMP{\theextract}% |
| 2371 |
\ifnum \value{length}=1 |
| 2372 |
\message{\@TEMP.}% |
| 2373 |
\else |
| 2374 |
\message{\@TEMP,}% |
| 2375 |
\fi |
| 2376 |
\expandafter\append\expandafter{\@TEMP}{\csname |
| 2377 |
qlist@scr@sec\current@section\endcsname} |
| 2378 |
\length{\csname qlist@sec\current@section\endcsname}}} |
| 2379 |
% \end{macrocode} |
| 2380 |
% \end{macro} |
| 2381 |
% |
| 2382 |
% \section{The layout of the exam} |
| 2383 |
% |
| 2384 |
% \begin{macro}{\NumberOfVersions} |
| 2385 |
% A user-level command to specify the number of version to make. Originally |
| 2386 |
% initialized to 1. |
| 2387 |
% \begin{macrocode} |
| 2388 |
\def\NumberOfVersions#1{\setcounter{form}{#1}} |
| 2389 |
\NumberOfVersions{1} |
| 2390 |
% \end{macrocode} |
| 2391 |
% \end{macro} |
| 2392 |
% |
| 2393 |
% \begin{macro}{\instructions} |
| 2394 |
% Often one wants to preface a block of questions with a series of instructions |
| 2395 |
% for the student. Previous releases had defined "\instructions" to do this, |
| 2396 |
% but that command is obsolete as of version 1.02. Thus, we define |
| 2397 |
% "\instructions" to be "\relax". |
| 2398 |
% \begin{macrocode} |
| 2399 |
\def\instructions{\relax} |
| 2400 |
% \end{macrocode} |
| 2401 |
% \end{macro} |
| 2402 |
% |
| 2403 |
% \begin{macro}{\classdata} |
| 2404 |
% This command saves its argument in the macro |\classdata| (it is intended for |
| 2405 |
% data like the class name and course number. E.g., Phil 29: Critical |
| 2406 |
% Reasoning). Originally initialized to |\relax|. |
| 2407 |
% \begin{macrocode} |
| 2408 |
\def\class#1{\def\classdata{#1}} |
| 2409 |
\def\classdata{\relax} |
| 2410 |
% \end{macrocode} |
| 2411 |
% \end{macro} |
| 2412 |
% |
| 2413 |
% \begin{macro}{\examtype} |
| 2414 |
% Allows one to specify the name of the exam (midterm, final, etc.) |
| 2415 |
% \begin{macrocode} |
| 2416 |
\def\examname#1{\def\examtype{#1}} |
| 2417 |
\examname{Exam} |
| 2418 |
% \end{macrocode} |
| 2419 |
% \end{macro} |
| 2420 |
% |
| 2421 |
% \begin{macro}{\namedata} |
| 2422 |
% Placed in a |\parbox|, |\namedata| contains all the standard fields |
| 2423 |
% ordinarily required in a large university setting. If you should be so lucky as |
| 2424 |
% to teach at a place where student numbers are not required, simply delete the |
| 2425 |
% appropriate line. |
| 2426 |
% \begin{macrocode} |
| 2427 |
\def\namedata{Name: \hrulefill \\[\namedata@vspace] |
| 2428 |
Student Number: \hrulefill \\[\namedata@vspace] |
| 2429 |
TA: \hrulefill \\[\namedata@vspace] |
| 2430 |
Date: \hrulefill} |
| 2431 |
% \end{macrocode} |
| 2432 |
% \end{macro} |
| 2433 |
% |
| 2434 |
% \subsection{Types of questions} |
| 2435 |
% |
| 2436 |
% Five types of questions have special |
| 2437 |
% formats: true/false, fill-in-the-blank, short answer, multiple choice, and |
| 2438 |
% fixed (meaning: don't swap the order of the questions). Since we will want to |
| 2439 |
% distinguish between these types of questions when creating the exam, we need |
| 2440 |
% a way to identify a particular section with a particular type of question. |
| 2441 |
% We do this in the following way: for each section, we define a macro |
| 2442 |
% |\type@sec|\meta{section} consisting of a single string containing the name |
| 2443 |
% of the type of question. That string will later be used to identify the |
| 2444 |
% section as such and take appropriate action. |
| 2445 |
% |
| 2446 |
% First, some necessary definitions. |
| 2447 |
% \begin{macrocode} |
| 2448 |
\define@key{section}{title}[\relax]{% |
| 2449 |
\expandafter\gdef\csname head@sec\thesection\endcsname{#1}} |
| 2450 |
|
| 2451 |
\define@key{section}{resetcounter}[yes]{% |
| 2452 |
\def\exam@arg{#1}% |
| 2453 |
\ifx\exam@arg\exam@c@yes |
| 2454 |
\expandafter |
| 2455 |
\gdef\csname RS@sec@\thesection\endcsname{\resetcountertrue} |
| 2456 |
\else |
| 2457 |
\expandafter |
| 2458 |
\gdef\csname RS@sec@\thesection\endcsname{\resetcounterfalse} |
| 2459 |
\fi} |
| 2460 |
|
| 2461 |
\define@key{section}{suppressprefix}[yes]{% |
| 2462 |
\def\exam@arg{#1}% |
| 2463 |
\ifx\exam@arg\exam@c@yes |
| 2464 |
\expandafter |
| 2465 |
\gdef\csname SP@sec@\thesection\endcsname{\resetcountertrue} |
| 2466 |
\fi} |
| 2467 |
|
| 2468 |
\define@key{section}{rearrange}[yes]{% |
| 2469 |
\def\exam@arg{#1}% |
| 2470 |
\ifx\exam@arg\exam@c@yes |
| 2471 |
\exam@SectionIsNotFixed |
| 2472 |
\else |
| 2473 |
\exam@SectionIsFixed |
| 2474 |
\fi} |
| 2475 |
|
| 2476 |
\define@key{section}{keycolumns}[1]{% |
| 2477 |
\ifnum#1=1\relax\else |
| 2478 |
\ifx\@currentsectionname\@matching |
| 2479 |
\message{Column specification ignored for the `matching' environment.} |
| 2480 |
\else |
| 2481 |
\exam@SetKeyColumns{#1} |
| 2482 |
\fi |
| 2483 |
\fi} |
| 2484 |
\define@key{section}{examcolumns}[1]{% |
| 2485 |
\ifnum#1=1\relax\else |
| 2486 |
\ifx\@currentsectionname\@matching |
| 2487 |
\message{Column specification ignored for the `message' environment.} |
| 2488 |
\else |
| 2489 |
\exam@SetExamColumns{#1} |
| 2490 |
\fi |
| 2491 |
\fi} |
| 2492 |
|
| 2493 |
\def\exam@definesectiontype#1{% |
| 2494 |
\expandafter\gdef\csname type@sec\thesection\endcsname{#1}} |
| 2495 |
% \end{macrocode} |
| 2496 |
% These next three macros just makes some following code easier to read. |
| 2497 |
% \begin{macrocode} |
| 2498 |
\def\exam@SetKeyColumns#1{% |
| 2499 |
\expandafter\gdef\csname sec\thesection @KCol\endcsname{#1}} |
| 2500 |
\def\exam@SetExamColumns#1{% |
| 2501 |
\expandafter\gdef\csname sec\thesection @ECol\endcsname{#1}} |
| 2502 |
\def\exam@SectionIsNotFixed{% |
| 2503 |
\expandafter\gdef\csname sec\thesection @fixed\endcsname{\notfixedtrue}} |
| 2504 |
\def\exam@SectionIsFixed{% |
| 2505 |
\expandafter\gdef\csname sec\thesection @fixed\endcsname{\notfixedfalse}} |
| 2506 |
\def\exam@SetDefaultSectionTitle#1{ |
| 2507 |
\expandafter\gdef\csname head@sec\thesection\endcsname{#1}} |
| 2508 |
\def\exam@SetDefaultRecountState#1{ |
| 2509 |
\expandafter\gdef\csname RS@sec@\thesection\endcsname{#1}} |
| 2510 |
\def\exam@notitle{\exam@notitle} |
| 2511 |
% \end{macrocode} |
| 2512 |
% |
| 2513 |
% \begin{environment}{matching} |
| 2514 |
% The environment for matching questions. |
| 2515 |
% \begin{macrocode} |
| 2516 |
\newenvironment{matching}[1][] |
| 2517 |
{\begin{section} |
| 2518 |
\def\@currentsectionname{matching} |
| 2519 |
\exam@definesectiontype{matching} |
| 2520 |
\exam@SetDefaultRearrangeBehavior |
| 2521 |
\exam@SetDefaultSectionTitle{\exam@notitle} |
| 2522 |
\exam@SetDefaultRecountState{\exam@DefaultNumberingBehavior} |
| 2523 |
\setkeys{section}{#1}% |
| 2524 |
\setcounter{temp}{0}% |
| 2525 |
\exam@GetInstructionsForMatchingSection} |
| 2526 |
{\end{section}} |
| 2527 |
|
| 2528 |
\long\def\exam@GetInstructionsForMatchingSection#1\pair{% |
| 2529 |
\@ifundefined{sec\thesection q\thequestion break} |
| 2530 |
{\@toklist={}} |
| 2531 |
{\@toklist={\old@pagebreak}} |
| 2532 |
\expandafter |
| 2533 |
\xdef\csname inst@sec\thesection\endcsname{\the\@toklist#1}\pair} |
| 2534 |
|
| 2535 |
\def\exam@MatchingLineLength{.5in} |
| 2536 |
\def\exam@MatchingLineAfterSkip{6pt} |
| 2537 |
\def\pair#1#2{% |
| 2538 |
\expandafter |
| 2539 |
\xdef\csname sec\thesection @\thequestion @tag\endcsname{\thetemp} |
| 2540 |
\expandafter |
| 2541 |
\gdef\csname sec\thesection @qst\thequestion\endcsname{% |
| 2542 |
\exam@PairA{\item[]\hskip-\leftmargin |
| 2543 |
\ifanswer |
| 2544 |
\underline{\makebox[\exam@MatchingLineLength][c]{\exam@GetMatchingAnswer}}% |
| 2545 |
\hskip\exam@MatchingLineAfterSkip #1 |
| 2546 |
\else |
| 2547 |
\rule{\exam@MatchingLineLength}{.4pt}% |
| 2548 |
\hskip\exam@MatchingLineAfterSkip #1 |
| 2549 |
\fi}} |
| 2550 |
\stepcounter{question} |
| 2551 |
\expandafter |
| 2552 |
\xdef\csname sec\thesection @\thequestion @tag\endcsname{\thetemp} |
| 2553 |
\expandafter |
| 2554 |
\gdef\csname sec\thesection @qst\thequestion\endcsname{% |
| 2555 |
\exam@PairB{\item\relax\exam@SaveMatchingAnswer #2}} |
| 2556 |
\stepcounter{temp} |
| 2557 |
\stepcounter{question}} |
| 2558 |
|
| 2559 |
\def\exam@GetMatchingAnswer{% |
| 2560 |
\edef\exam@tag{\csname sec\current@section @\current@question |
| 2561 |
@tag\endcsname}% |
| 2562 |
\csname matching@answer@\exam@tag\endcsname} |
| 2563 |
\def\exam@SaveMatchingAnswer{% |
| 2564 |
\edef\exam@tag{\csname sec\current@section @\current@question |
| 2565 |
@tag\endcsname}% |
| 2566 |
\expandafter |
| 2567 |
\xdef\csname matching@answer@\exam@tag\endcsname{(\alph{enumi})}} |
| 2568 |
|
| 2569 |
% \end{macrocode} |
| 2570 |
% \end{environment} |
| 2571 |
% |
| 2572 |
% \begin{environment}{fillin} |
| 2573 |
% The environment for fill-in-the-blank questions. |
| 2574 |
% \begin{macrocode} |
| 2575 |
\newenvironment{fillin}[1][] |
| 2576 |
{\begin{section} |
| 2577 |
\def\@currentsectionname{fillin} |
| 2578 |
\exam@definesectiontype{fillin} |
| 2579 |
\exam@SetDefaultRearrangeBehavior |
| 2580 |
\exam@SetDefaultSectionTitle{\exam@notitle} |
| 2581 |
\exam@SetDefaultRecountState{\exam@DefaultNumberingBehavior} |
| 2582 |
\setkeys{section}{#1}% |
| 2583 |
\get@instructions \relax} |
| 2584 |
{\end{section}} |
| 2585 |
% \end{macrocode} |
| 2586 |
% \end{environment} |
| 2587 |
% |
| 2588 |
% |
| 2589 |
% \begin{environment}{truefalse} |
| 2590 |
% The environment for true/false questions |
| 2591 |
% \begin{macrocode} |
| 2592 |
\newenvironment{truefalse}[1][] |
| 2593 |
{\begin{section} |
| 2594 |
\def\@currentsectionname{truefalse} |
| 2595 |
\exam@definesectiontype{truefalse} |
| 2596 |
\exam@SetDefaultRearrangeBehavior |
| 2597 |
\exam@SetDefaultSectionTitle{\exam@notitle} |
| 2598 |
\exam@SetDefaultRecountState{\exam@DefaultNumberingBehavior} |
| 2599 |
\setkeys{section}{#1}% |
| 2600 |
\get@instructions \relax} |
| 2601 |
{\end{section}} |
| 2602 |
% \end{macrocode} |
| 2603 |
% \end{environment} |
| 2604 |
% |
| 2605 |
% |
| 2606 |
% \begin{environment}{shortanswer} |
| 2607 |
% The environment for short answer questions |
| 2608 |
% \begin{macrocode} |
| 2609 |
\newenvironment{shortanswer}[1][] |
| 2610 |
{\begin{section} |
| 2611 |
\def\@currentsectionname{shortanswer} |
| 2612 |
\exam@definesectiontype{shortanswer} |
| 2613 |
\exam@SetDefaultRearrangeBehavior |
| 2614 |
\exam@SetDefaultSectionTitle{\exam@notitle} |
| 2615 |
\exam@SetDefaultRecountState{\exam@DefaultNumberingBehavior} |
| 2616 |
\setkeys{section}{#1}% |
| 2617 |
\get@instructions \relax} |
| 2618 |
{\end{section}} |
| 2619 |
% \end{macrocode} |
| 2620 |
% \end{environment} |
| 2621 |
% |
| 2622 |
% |
| 2623 |
% \begin{environment}{multiplechoice} |
| 2624 |
% The environment for multiple choice questions |
| 2625 |
% \begin{macrocode} |
| 2626 |
\newenvironment{multiplechoice}[1][] |
| 2627 |
{\begin{section} |
| 2628 |
\def\@currentsectionname{multiplechoice} |
| 2629 |
\exam@definesectiontype{multiplechoice} |
| 2630 |
\exam@SetDefaultRearrangeBehavior |
| 2631 |
\exam@SetDefaultSectionTitle{\exam@notitle} |
| 2632 |
\exam@SetDefaultRecountState{\exam@DefaultNumberingBehavior} |
| 2633 |
\setkeys{section}{#1}% |
| 2634 |
\get@instructions \relax} |
| 2635 |
{\end{section}} |
| 2636 |
% \end{macrocode} |
| 2637 |
% \end{environment} |
| 2638 |
% |
| 2639 |
% |
| 2640 |
% \subsection{Loose Ends} |
| 2641 |
% |
| 2642 |
% The following macros just contain the environment names for identification in |
| 2643 |
% the main loop. |
| 2644 |
% \begin{macrocode} |
| 2645 |
\def\@matching{matching} |
| 2646 |
\def\@fillin{fillin} |
| 2647 |
\def\@shortanswer{shortanswer} |
| 2648 |
\def\@truefalse{truefalse} |
| 2649 |
\def\@MC{multiplechoice} |
| 2650 |
% \end{macrocode} |
| 2651 |
% |
| 2652 |
% \begin{macro}{\choice} |
| 2653 |
% This is one of the complicated macros in the package. From the user's point |
| 2654 |
% of view, it indicates one answer to a multiple choice question. Internally, |
| 2655 |
% |\choice| has to recognize whether it is the first or last question, taking |
| 2656 |
% different action depending on which it is. Moreover, |\choice| has to format |
| 2657 |
% the label differently depending on whether or not we are creating an exam or a |
| 2658 |
% test. Note that, for reasons of sanity, I do not attempt to rearrange the order |
| 2659 |
% of the choices. |
| 2660 |
% \begin{macrocode} |
| 2661 |
\newcommand{\exam@DefaultChoice}[2][]{% |
| 2662 |
\ifchoice \relax |
| 2663 |
\else \@mcstartlist \choicetrue |
| 2664 |
\fi |
| 2665 |
\ifanswer |
| 2666 |
\if#1!% |
| 2667 |
\ifbox \vspace{-\fboxsep}\item[\hfill\fbox{(\alph{choice})}\hfill] #2 |
| 2668 |
\vspace{-\fboxsep}% |
| 2669 |
\else |
| 2670 |
\item[\hfill\MCfont{(\alph{choice})}\hfill] \MCfont{#2}% |
| 2671 |
\fi |
| 2672 |
\else \item[\hfill(\alph{choice})\hfill] #2 |
| 2673 |
\fi |
| 2674 |
\stepcounter{choice}% |
| 2675 |
\else |
| 2676 |
\item[\hfill(\alph{choice})\hfill] #2 |
| 2677 |
\stepcounter{choice}% |
| 2678 |
\fi} |
| 2679 |
\def\exam@EndChoiceListIfNecessary{% |
| 2680 |
\ifchoice\end{list}\choicefalse\fi\setcounter{choice}{1}} |
| 2681 |
\let\choice=\exam@DefaultChoice |
| 2682 |
% \end{macrocode} |
| 2683 |
% \end{macro} |
| 2684 |
% |
| 2685 |
% \begin{macro}{\@mcstartlist} |
| 2686 |
% The parameters used to start the |\begin{list}| environment used in |
| 2687 |
% the |\choice| macro. |
| 2688 |
% \begin{macrocode} |
| 2689 |
\def\@mcstartlist{\begin{list}{}{% |
| 2690 |
\setlength{\topsep}{6pt} |
| 2691 |
\setlength{\rightmargin}{0pt} |
| 2692 |
\setlength{\labelwidth}{.35in} |
| 2693 |
\setlength{\leftmargin}{.5in} |
| 2694 |
\setlength{\labelsep}{.15in} |
| 2695 |
\setlength{\itemindent}{0in} |
| 2696 |
\setlength{\itemsep}{0pt}}} |
| 2697 |
% \end{macrocode} |
| 2698 |
% \end{macro} |
| 2699 |
% |
| 2700 |
% |
| 2701 |
% \subsection{More User-Level Macros} |
| 2702 |
% |
| 2703 |
% \begin{macro}{\Fullpages} |
| 2704 |
% Just a command so that people can automatically set the page margins to |
| 2705 |
% full-sized pages. Only defined for US letter, sorry. |
| 2706 |
% \begin{macrocode} |
| 2707 |
\newcommand{\Fullpages}{\setlength{\topmargin}{0pc} |
| 2708 |
\setlength{\oddsidemargin}{0pc} |
| 2709 |
\setlength{\evensidemargin}{0pc} |
| 2710 |
\setlength{\headheight}{0pc} |
| 2711 |
\setlength{\headsep}{0pc} |
| 2712 |
\setlength{\textwidth}{6.5in} |
| 2713 |
\setlength{\textheight}{9in}} |
| 2714 |
%</othercode> |
| 2715 |
% \end{macrocode} |
| 2716 |
% \end{macro} |
| 2717 |
% |
| 2718 |
% \begin{macro}{\ConstantBlanks} |
| 2719 |
% Sets the blanks in \textsf{fillin} to be of constant width |
| 2720 |
% \begin{macrocode} |
| 2721 |
\def\ConstantBlanks#1{\setlength{\blank@length}{#1}\cblankstrue\pblanksfalse} |
| 2722 |
% \end{macrocode} |
| 2723 |
% \end{macro} |
| 2724 |
% |
| 2725 |
% \begin{macro}{\ProportionalBlanks} |
| 2726 |
% Sets the blanks in \textsf{fillin} to be proportional to the actual typeset |
| 2727 |
% width of the word. |
| 2728 |
% \begin{macrocode} |
| 2729 |
\def\ProportionalBlanks#1{\edef\blank@multiplier{#1}\cblanksfalse\pblankstrue} |
| 2730 |
\ProportionalBlanks{1} |
| 2731 |
% \end{macrocode} |
| 2732 |
% \end{macro} |
| 2733 |
% |
| 2734 |
% \begin{macro}{\StudentInfoLineSpacing} |
| 2735 |
% Sets the amount of spacing between the lines in the |\namedata| macro. |
| 2736 |
% \begin{macrocode} |
| 2737 |
\newcommand{\StudentInfoLineSpacing}[1]{\setlength{\namedata@vspace}{#1}} |
| 2738 |
\StudentInfoLineSpacing{6pt} |
| 2739 |
% \end{macrocode} |
| 2740 |
% \end{macro} |
| 2741 |
% |
| 2742 |
% \begin{macro}{\examtop} |
| 2743 |
% We define "\examtop" so that it reads in and saves the surround text |
| 2744 |
% to a macro like in the \textsf{tabularx} environment. |
| 2745 |
% \begin{macrocode} |
| 2746 |
\def\examtop{\@toklist={} |
| 2747 |
\get@examtop@body} |
| 2748 |
% \end{macrocode} |
| 2749 |
% \end{macro} |
| 2750 |
% |
| 2751 |
% \begin{macro}{\endexamtop} |
| 2752 |
% This doesn't need to do much. |
| 2753 |
% \begin{macrocode} |
| 2754 |
\def\endexamtop{\relax} |
| 2755 |
% \end{macrocode} |
| 2756 |
% \end{macro} |
| 2757 |
% |
| 2758 |
% \begin{macro}{\get@examtop@body} |
| 2759 |
% This macro collects everything between it and the next |\end| token. It then |
| 2760 |
% calls the |\find@examtop@end| macro to check whether the |\end| token |
| 2761 |
% belongs to the \textsf{question} environment or some other environment. |
| 2762 |
% \begin{macrocode} |
| 2763 |
\long\def\get@examtop@body#1\end{% |
| 2764 |
\@toklist=\expandafter{\the\@toklist#1}% |
| 2765 |
\find@examtop@end} |
| 2766 |
% \end{macrocode} |
| 2767 |
% \end{macro} |
| 2768 |
% |
| 2769 |
% \begin{macro}{\find@examtop@end} |
| 2770 |
% If we are at |\end{examtop}|, save everything to the appropriately named |
| 2771 |
% macro. Otherwise, continue collecting tokens |
| 2772 |
% \begin{macrocode} |
| 2773 |
\def\find@examtop@end#1{% |
| 2774 |
\def\@tempa{#1}% |
| 2775 |
\ifx\@tempa\@XMtop\expandafter\XMtop@wrap@up |
| 2776 |
\else\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 2777 |
\expandafter\get@examtop@body\fi} |
| 2778 |
% \end{macrocode} |
| 2779 |
% \end{macro} |
| 2780 |
% |
| 2781 |
% \begin{macro}{\XMtop@wrap@up} |
| 2782 |
% Save the gathered information to a macro for later use. |
| 2783 |
% \begin{macrocode} |
| 2784 |
\def\XMtop@wrap@up{\xdef\@examtopmatter{\the\@toklist}% |
| 2785 |
\end{examtop}} |
| 2786 |
% \end{macrocode} |
| 2787 |
% \end{macro} |
| 2788 |
% |
| 2789 |
% \begin{macro}{\@XMtop} |
| 2790 |
% Store the name of the environment for comparison in |\find@question@end| |
| 2791 |
% \begin{macrocode} |
| 2792 |
\def\@XMtop{examtop} |
| 2793 |
% \end{macrocode} |
| 2794 |
% \end{macro} |
| 2795 |
% |
| 2796 |
% \DescribeEnv{examtop} |
| 2797 |
% This environment is defined via the macros below. It allows the user |
| 2798 |
% to customize the text at the top of the exam. The example here is the |
| 2799 |
% default definition. |
| 2800 |
% \begin{macrocode} |
| 2801 |
\begin{examtop} |
| 2802 |
\@@line{\parbox{3in}{\classdata \\ |
| 2803 |
\examtype, Form:~\fbox{\textsf{\Alph{version}}}} |
| 2804 |
\hfill |
| 2805 |
\parbox{3in}{\normalsize \namedata}} |
| 2806 |
\bigskip |
| 2807 |
\end{examtop} |
| 2808 |
% \end{macrocode} |
| 2809 |
% |
| 2810 |
% \begin{macro}{\keytop} |
| 2811 |
% We define "\keytop" so that it reads in and saves the surround text |
| 2812 |
% to a macro like in the \textsf{tabularx} environment. |
| 2813 |
% \begin{macrocode} |
| 2814 |
\def\keytop{\@toklist={} |
| 2815 |
\get@keytop@body} |
| 2816 |
% \end{macrocode} |
| 2817 |
% \end{macro} |
| 2818 |
% |
| 2819 |
% \begin{macro}{\endkeytop} |
| 2820 |
% This doesn't need to do much. |
| 2821 |
% \begin{macrocode} |
| 2822 |
\def\endkeytop{\relax} |
| 2823 |
% \end{macrocode} |
| 2824 |
% \end{macro} |
| 2825 |
% |
| 2826 |
% \begin{macro}{\get@keytop@body} |
| 2827 |
% This macro collects everything between it and the next |\end| token. It then |
| 2828 |
% calls the |\find@keytop@end| macro to check whether the |\end| token |
| 2829 |
% belongs to the \textsf{question} environment or some other environment. |
| 2830 |
% \begin{macrocode} |
| 2831 |
\long\def\get@keytop@body#1\end{\@toklist=\expandafter{\the\@toklist#1}% |
| 2832 |
\find@keytop@end} |
| 2833 |
% \end{macrocode} |
| 2834 |
% \end{macro} |
| 2835 |
% |
| 2836 |
% \begin{macro}{\find@keytop@end} |
| 2837 |
% If we are at |\end{keytop}|, save everything to the appropriately named |
| 2838 |
% macro. Otherwise, continue collecting tokens |
| 2839 |
% \begin{macrocode} |
| 2840 |
\def\find@keytop@end#1{% |
| 2841 |
\def\@tempa{#1}% |
| 2842 |
\ifx\@tempa\@KYtop\expandafter\KYtop@wrap@up |
| 2843 |
\else\@toklist=\expandafter{\the\@toklist\end{#1}}% |
| 2844 |
\expandafter\get@keytop@body\fi} |
| 2845 |
% \end{macrocode} |
| 2846 |
% \end{macro} |
| 2847 |
% |
| 2848 |
% \begin{macro}{\KYtop@wrap@up} |
| 2849 |
% Save the gathered information to a macro for later use. |
| 2850 |
% \begin{macrocode} |
| 2851 |
\def\KYtop@wrap@up{\xdef\@keytopmatter{\the\@toklist}% |
| 2852 |
\end{keytop}} |
| 2853 |
% \end{macrocode} |
| 2854 |
% \end{macro} |
| 2855 |
% |
| 2856 |
% \begin{macro}{\@KYtop} |
| 2857 |
% Store the name of the environment for comparison in |\find@keytop@end| |
| 2858 |
% \begin{macrocode} |
| 2859 |
\def\@KYtop{keytop} |
| 2860 |
% \end{macrocode} |
| 2861 |
% \end{macro} |
| 2862 |
% |
| 2863 |
% \DescribeEnv{keytop} |
| 2864 |
% This environment is defined via the macros below. It allows the user |
| 2865 |
% to customize the text at the top of the exam. The example here is the |
| 2866 |
% default definition. |
| 2867 |
% \begin{macrocode} |
| 2868 |
\begin{keytop} |
| 2869 |
\@@line{\hfill \Huge Answer Key |
| 2870 |
for Exam \fbox{\textsf{\Alph{version}}}\hfill} |
| 2871 |
\bigskip |
| 2872 |
\end{keytop} |
| 2873 |
% \end{macrocode} |
| 2874 |
% |
| 2875 |
% \MakeShortVerb{\"} |
| 2876 |
% \DeleteShortVerb{\|} |
| 2877 |
% \begin{macro}{\word} |
| 2878 |
% This macro enables one to insert minor (read: inessential) changes in wording |
| 2879 |
% between different versions of the test. For example, including the |
| 2880 |
% command "\word|{Carl Sagan} {Bob Dole}|" in the text will cause the phrase |
| 2881 |
% ``Carl Sagan'' to be printed in that place on every odd-numbered test and ``Bob Dole'' |
| 2882 |
% to be printed in that place on every even-numbered test. In the event that |
| 2883 |
% more versions of the test are requested than options given, "\word" acts as if |
| 2884 |
% the given list of options repeats itself. I.e., in the above case, if we requested |
| 2885 |
% four different versions of the examn, "\word" will behave as if the |
| 2886 |
% command given were "\word|{Carl Sagan} {Bob Dole} {Carl Sagan} {Bob Dole}|". |
| 2887 |
% |
| 2888 |
% \smallskip |
| 2889 |
% |
| 2890 |
% First we define a string to be equal to a space so that we can allow for any |
| 2891 |
% number of spaces to be given in the option list. |
| 2892 |
% \begin{macrocode} |
| 2893 |
\def\@Space{ } |
| 2894 |
% \end{macrocode} |
| 2895 |
% The "\word" macro just saves the option-list in a macro named "\@wordlist" and |
| 2896 |
% invokes the macro "\@wordmain" which most of the work. |
| 2897 |
% \begin{macrocode} |
| 2898 |
\def\word#1{\def\@wordlist{#1}\expandafter\@wordmain\@wordlist \stop} |
| 2899 |
|
| 2900 |
\def\@wordmain#1{% |
| 2901 |
% \end{macrocode} |
| 2902 |
% Check to see if the current argument is a space. If so, ignore it. |
| 2903 |
% \begin{macrocode} |
| 2904 |
\ifx#1\@Space |
| 2905 |
\let\@next=\@wordmain |
| 2906 |
\else |
| 2907 |
% \end{macrocode} |
| 2908 |
% If the current argument is not a space, but is "\stop", this means that |
| 2909 |
% fewer options were given than versions of the test were requested. Thus we |
| 2910 |
% need to start "\@wordmain" again at the beginning of the option list. This |
| 2911 |
% is what the "\@dumpthenstart" macro does. |
| 2912 |
% \begin{macrocode} |
| 2913 |
\ifx#1\stop |
| 2914 |
\let\@next=\@dumpthenstart |
| 2915 |
\else% |
| 2916 |
% \end{macrocode} |
| 2917 |
% If the current argument is none of the above, then it is an actual option. |
| 2918 |
% However, we must check whether it is the option we want. If it is, then |
| 2919 |
% typeset it and gobble everything up to (and including) "\stop". If not, just |
| 2920 |
% throw the current argument away and get the next one. |
| 2921 |
% \begin{macrocode} |
| 2922 |
\ifnum\value{wordtemp}=\value{version}% |
| 2923 |
#1\let\@next=\@gobbletostop |
| 2924 |
\else |
| 2925 |
\stepcounter{wordtemp}% |
| 2926 |
\let\@next=\@wordmain |
| 2927 |
\fi |
| 2928 |
\fi |
| 2929 |
\fi |
| 2930 |
\@next} |
| 2931 |
% \end{macrocode} |
| 2932 |
% \end{macro} |
| 2933 |
% |
| 2934 |
% \begin{macro}{\@dumpthenstart} |
| 2935 |
% \begin{macrocode} |
| 2936 |
\def\@dumpthenstart{\expandafter\@wordmain\@wordlist \stop} |
| 2937 |
% \end{macrocode} |
| 2938 |
% \end{macro} |
| 2939 |
% |
| 2940 |
% \begin{macro}{\@gobbletostop} |
| 2941 |
% \begin{macrocode} |
| 2942 |
\def\@gobbletostop#1\stop{\relax\setcounter{wordtemp}{1}} |
| 2943 |
% \end{macrocode} |
| 2944 |
% \end{macro} |
| 2945 |
% |
| 2946 |
% \section{Macros to format types of questions} |
| 2947 |
% |
| 2948 |
% \begin{macro}{\ifsection} |
| 2949 |
% This macro increases the readability of the code in the definition |
| 2950 |
% of "\@enddocumenthook" when we test to see just which type of questions |
| 2951 |
% the current section consists of. |
| 2952 |
% \begin{macrocode} |
| 2953 |
\def\ifsection#1#2{% |
| 2954 |
\expandafter\ifx\csname type@sec\current@section\endcsname#1#2\fi} |
| 2955 |
% \end{macrocode} |
| 2956 |
% \end{macro} |
| 2957 |
% |
| 2958 |
% \begin{macro}{\exam@AddSectionTitle} |
| 2959 |
% Typeset the section title, if there is one; otherwise, don't do anything. |
| 2960 |
% \begin{macrocode} |
| 2961 |
\def\exam@AddSectionTitle{% |
| 2962 |
\expandafter\ifx\csname head@sec\current@section\endcsname\exam@notitle |
| 2963 |
\relax |
| 2964 |
\else |
| 2965 |
\par\vspace{\beforesectsep} |
| 2966 |
\noindent {\exam@sectionfont \exam@sectionprefix |
| 2967 |
\csname head@sec\current@section\endcsname} |
| 2968 |
\par\vspace{\aftersectsep} |
| 2969 |
\fi} |
| 2970 |
|
| 2971 |
|
| 2972 |
% \end{macrocode} |
| 2973 |
% \end{macro} |
| 2974 |
% |
| 2975 |
% \begin{macro}{\exam@AddSectionInstructions} |
| 2976 |
% Add instructions for the section, if any were give; otherwise, don't |
| 2977 |
% do anything. |
| 2978 |
% \begin{macrocode} |
| 2979 |
\def\exam@AddSectionInstructions{% |
| 2980 |
\ifx\csname inst@sec\current@section\endcsname\relax |
| 2981 |
\relax |
| 2982 |
\else |
| 2983 |
\vspace{\beforeinstsep} |
| 2984 |
\csname inst@sec\current@section\endcsname |
| 2985 |
\par\vspace{\afterinstsep} |
| 2986 |
\fi} |
| 2987 |
\let\exam@AddSectionInstructionsHook=\exam@AddSectionInstructions |
| 2988 |
% \end{macrocode} |
| 2989 |
% \end{macro} |
| 2990 |
% |
| 2991 |
% \begin{macro}{\exam@MakeAnswerEnvironGobble} |
| 2992 |
% This macro redefines the \textsf{answer} environment so that it |
| 2993 |
% ignores (``gobbles'') everything inside it. Used when typesetting |
| 2994 |
% the exam. |
| 2995 |
% \begin{macrocode} |
| 2996 |
\def\exam@MakeAnswerEnvironGobble{% |
| 2997 |
\def\answer{\get@noanswer@body} |
| 2998 |
\def\endanswer{\relax} |
| 2999 |
\def\@S{answer} |
| 3000 |
\long\def\get@noanswer@body##1\end{\find@answer@end} |
| 3001 |
\def\find@answer@end##1{\def\@tempa{##1} |
| 3002 |
\ifx\@tempa\@S\expandafter\finish@up |
| 3003 |
\else\expandafter\get@noanswer@body\fi} |
| 3004 |
\def\finish@up{\end{answer}}} |
| 3005 |
% \end{macrocode} |
| 3006 |
% \end{macro} |
| 3007 |
% |
| 3008 |
% |
| 3009 |
% \begin{macro}{\exam@TypesetQuestions} |
| 3010 |
% With the exception of the \textsf{truefalse} environment, |
| 3011 |
% all of the other kinds of questions are handled in the sam |
| 3012 |
% way. (The \textsf{truefalse} environment is special because of |
| 3013 |
% the wide blanks it places at the left margin.) |
| 3014 |
% \begin{macrocode} |
| 3015 |
\def\exam@PossiblyStartMultipleColumnsInKey{% |
| 3016 |
\ifanswer |
| 3017 |
\@ifundefined{sec\current@section @KCol} |
| 3018 |
\relax |
| 3019 |
{\begin{multicols}{\csname sec\current@section @KCol\endcsname}} |
| 3020 |
\fi} |
| 3021 |
\def\exam@PossiblyEndMultipleColumnsInKey{% |
| 3022 |
\ifanswer |
| 3023 |
\@ifundefined{sec\current@section @KCol} |
| 3024 |
\relax |
| 3025 |
{\end{multicols}} |
| 3026 |
\fi} |
| 3027 |
\def\exam@PossiblyStartMultipleColumnsInExam{% |
| 3028 |
\ifanswer\relax\else |
| 3029 |
\@ifundefined{sec\current@section @ECol} |
| 3030 |
\relax |
| 3031 |
{\begin{multicols}{\csname sec\current@section @ECol\endcsname}} |
| 3032 |
\fi} |
| 3033 |
\def\exam@PossiblyEndMultipleColumnsInExam{% |
| 3034 |
\ifanswer\relax\else |
| 3035 |
\@ifundefined{sec\current@section @ECol} |
| 3036 |
\relax |
| 3037 |
{\end{multicols}} |
| 3038 |
\fi} |
| 3039 |
|
| 3040 |
\def\exam@EnumerateStyle{1.} |
| 3041 |
\def\exam@DefaultEnumerateStyle{1.} |
| 3042 |
|
| 3043 |
\def\enumerate{% |
| 3044 |
\ifnum \@enumdepth >3 \@toodeep\else |
| 3045 |
\advance\@enumdepth \@ne |
| 3046 |
\edef\@enumctr{enum\romannumeral\the\@enumdepth}\fi |
| 3047 |
\@ifnextchar[{\exam@@enum@}{\@enum@}} |
| 3048 |
\def\exam@@enum@[#1]{\expandafter\@@enum@\expandafter[#1]} |
| 3049 |
|
| 3050 |
\def\exam@TypesetQuestions{% |
| 3051 |
\exam@PossiblyStartMultipleColumnsInKey |
| 3052 |
\exam@PossiblyStartMultipleColumnsInExam |
| 3053 |
\ifx\exam@EnumerateStyle\exam@DefaultEnumerateStyle |
| 3054 |
\begin{enumerate} |
| 3055 |
\else |
| 3056 |
\begin{enumerate}[\exam@EnumerateStyle] |
| 3057 |
\fi |
| 3058 |
\ifresetcounter |
| 3059 |
\setcounter{enumi}{0} |
| 3060 |
\else |
| 3061 |
% \message{QuestionNumber: \thequestionnumber}% |
| 3062 |
\setcounter{enumi}{\value{questionnumber}} |
| 3063 |
\fi |
| 3064 |
\the\csname qlist@scr@sec\current@section\endcsname |
| 3065 |
\setcounter{questionnumber}{\value{enumi}} |
| 3066 |
\end{enumerate} |
| 3067 |
\exam@PossiblyEndMultipleColumnsInKey |
| 3068 |
\exam@PossiblyEndMultipleColumnsInExam} |
| 3069 |
% \end{macrocode} |
| 3070 |
% \end{macro} |
| 3071 |
% |
| 3072 |
% \begin{macro}{\@shortanswermain} |
| 3073 |
% |
| 3074 |
% Define |\@separator| in the appropriate fashion for this kind of question. |
| 3075 |
% \begin{macrocode} |
| 3076 |
\def\@shortanswermain{% |
| 3077 |
\def\question{% |
| 3078 |
\item |
| 3079 |
\@beforequestionhook |
| 3080 |
\exam@SAGobbleQuestionHook} |
| 3081 |
\def\endquestion{\@endquestionhook} |
| 3082 |
\def\@separator##1{\setcounter{temp}{##1} |
| 3083 |
\edef\current@question{\thetemp} |
| 3084 |
\csname sec\current@section @qst\current@question\endcsname} |
| 3085 |
% \end{macrocode} |
| 3086 |
% If we are makingf a answer, set up the \textsf{answer} environment so that |
| 3087 |
% it prints the answer along with an identifier. |
| 3088 |
% \begin{macrocode} |
| 3089 |
\ifanswer |
| 3090 |
\exam@DefineAnswerEnvironment |
| 3091 |
\else |
| 3092 |
\exam@MakeAnswerEnvironGobble |
| 3093 |
\fi |
| 3094 |
\exam@AddSectionTitle |
| 3095 |
\exam@AddSectionInstructionsHook |
| 3096 |
\exam@TypesetQuestions} |
| 3097 |
% |
| 3098 |
% \begin{macro}{\@matchingmain} |
| 3099 |
% |
| 3100 |
% Define |\@separator| in the appropriate fashion for this kind of question. |
| 3101 |
% \begin{macrocode} |
| 3102 |
\def\@matchingmain{% |
| 3103 |
\def\@separator##1{\setcounter{temp}{##1} |
| 3104 |
\edef\current@question{\thetemp} |
| 3105 |
\csname sec\current@section @qst\current@question\endcsname} |
| 3106 |
% \end{macrocode} |
| 3107 |
% If we are makingf a answer, set up the \textsf{answer} environment so that |
| 3108 |
% it prints the answer along with an identifier. |
| 3109 |
% \begin{macrocode} |
| 3110 |
\exam@AddSectionTitle |
| 3111 |
\exam@AddSectionInstructionsHook |
| 3112 |
\def\exam@PairA##1{##1} |
| 3113 |
\def\exam@PairB##1{} |
| 3114 |
\edef\exam@questionnumber{\thequestionnumber}% |
| 3115 |
\begin{multicols}{2}\raggedcolumns |
| 3116 |
\exam@TypesetQuestions |
| 3117 |
\def\exam@PairA##1{} |
| 3118 |
\def\exam@PairB##1{##1} |
| 3119 |
\def\exam@EnumerateStyle{(a)} |
| 3120 |
\columnbreak |
| 3121 |
\exam@TypesetQuestions |
| 3122 |
\end{multicols} |
| 3123 |
\setcounter{enumi}{\exam@questionnumber}% |
| 3124 |
\setcounter{questionnumber}{\exam@questionnumber}} |
| 3125 |
% \end{macrocode} |
| 3126 |
% \end{macro} |
| 3127 |
% |
| 3128 |
% \begin{macro}{\@fillinmain} |
| 3129 |
% As with all of the section routines, we need to |
| 3130 |
% define |\@separator| again. |
| 3131 |
% \begin{macrocode} |
| 3132 |
\def\@fillinmain{% |
| 3133 |
\def\question{% |
| 3134 |
\item |
| 3135 |
\@beforequestionhook |
| 3136 |
\exam@FillinBlockGobbleQuestionHook} |
| 3137 |
\def\endquestion{\@endquestionhook} |
| 3138 |
\def\@separator##1{\setcounter{temp}{##1} |
| 3139 |
\edef\current@question{\thetemp} |
| 3140 |
\csname sec\current@section @qst\current@question\endcsname} |
| 3141 |
% \end{macrocode} |
| 3142 |
% Define |\blank| so that it either makes just an underline or an underline |
| 3143 |
% with the word printed over it. |
| 3144 |
% \begin{macrocode} |
| 3145 |
\ifanswer |
| 3146 |
\ifcblanks |
| 3147 |
\def\blank##1{\mbox{\rule[-1pt]{\blank@length}{.4pt}% |
| 3148 |
\hspace{-\blank@length}% |
| 3149 |
\makebox[\blank@length]{##1}}} |
| 3150 |
\fi |
| 3151 |
\ifpblanks |
| 3152 |
\def\blank##1{\settowidth{\temp@length}{##1}% |
| 3153 |
\mbox{\rule[-1pt]{\blank@multiplier\temp@length}{.4pt}% |
| 3154 |
\hspace{-\blank@multiplier\temp@length}% |
| 3155 |
\makebox[\blank@multiplier\temp@length]{##1}}} |
| 3156 |
\fi |
| 3157 |
\else |
| 3158 |
\ifcblanks |
| 3159 |
\def\blank##1{\rule[-1pt]{\blank@length}{.4pt}} |
| 3160 |
\fi |
| 3161 |
\ifpblanks |
| 3162 |
\def\blank##1{\settowidth{\temp@length}{##1}% |
| 3163 |
\rule[-1pt]{\blank@multiplier\temp@length}{.4pt}} |
| 3164 |
\fi |
| 3165 |
\fi |
| 3166 |
\exam@AddSectionTitle |
| 3167 |
\exam@AddSectionInstructionsHook |
| 3168 |
\exam@TypesetQuestions} |
| 3169 |
% \end{macrocode} |
| 3170 |
% \end{macro} |
| 3171 |
% |
| 3172 |
% |
| 3173 |
% \begin{macro}{\@multiplechoicemain} |
| 3174 |
% This contains all the commands to be invoked if the current section in |
| 3175 |
% the main loop is a multiple-choice environment. |
| 3176 |
% \begin{macrocode} |
| 3177 |
\def\@multiplechoicemain{\setcounter{mcchoice}{1} |
| 3178 |
% \end{macrocode} |
| 3179 |
% First, redefine the "\question", "\endquestion" pairs in case someone |
| 3180 |
% used the \textsf{block} environment within multiplechoice. |
| 3181 |
% \begin{macrocode} |
| 3182 |
\def\question{\@mcitem |
| 3183 |
\@beforequestionhook |
| 3184 |
\exam@MCGobbleQuestionHook} |
| 3185 |
\def\endquestion{\@endquestionhook |
| 3186 |
\exam@EndChoiceListIfNecessary\@mcenditem} |
| 3187 |
% \end{macrocode} |
| 3188 |
% Now define "\@separator" so that it calls the appropriate macro. |
| 3189 |
% \begin{macrocode} |
| 3190 |
\def\@separator##1{\setcounter{temp}{##1} |
| 3191 |
\edef\current@question{\thetemp} |
| 3192 |
\csname sec\current@section @qst\current@question\endcsname} |
| 3193 |
\exam@AddSectionTitle |
| 3194 |
\exam@AddSectionInstructionsHook |
| 3195 |
\exam@TypesetQuestions} |
| 3196 |
% \end{macrocode} |
| 3197 |
% \end{macro} |
| 3198 |
% |
| 3199 |
% \begin{macro}{\@truefalsemain} |
| 3200 |
% This contains all the commands to be invoked if the current section in the |
| 3201 |
% main loop is a true/false environment. |
| 3202 |
% \begin{macrocode} |
| 3203 |
\def\@truefalsemain{% |
| 3204 |
% \end{macrocode} |
| 3205 |
% First, define "\@separator" so that it calls the macro where the right |
| 3206 |
% question is saved. |
| 3207 |
% \begin{macrocode} |
| 3208 |
\def\@separator##1{\setcounter{temp}{##1} |
| 3209 |
\edef\current@question{\thetemp} |
| 3210 |
\csname sec\current@section @qst\current@question\endcsname} |
| 3211 |
% \end{macrocode} |
| 3212 |
% Redefine "\question" and "\endquestion" to work properly in case someone |
| 3213 |
% used a \textsf{block} environment to keep a couple of true/false questions |
| 3214 |
% together |
| 3215 |
% \begin{macrocode} |
| 3216 |
\def\question{% |
| 3217 |
\edef\current@question{\thetemp.\theexam@tf}% |
| 3218 |
\exam@TFItem \@beforequestionhook} |
| 3219 |
\def\endquestion{\stepcounter{exam@tf}\@endquestionhook} |
| 3220 |
% \end{macrocode} |
| 3221 |
% Since the appearance of a true/false question depends heavily on whether we |
| 3222 |
% are typesetting an answer key or not, we have to make a number of definitions |
| 3223 |
% (or redefinitions) depending upon whether we are currently making an answer |
| 3224 |
% key. |
| 3225 |
% \begin{macrocode} |
| 3226 |
\ifanswer |
| 3227 |
% \end{macrocode} |
| 3228 |
% If we are typesetting an answer, we don't want the argument given to |
| 3229 |
% "\answer" to do anything, so we define it so that it gobbles its argument. |
| 3230 |
% \begin{macrocode} |
| 3231 |
\def\answer##1{\relax} |
| 3232 |
% \end{macrocode} |
| 3233 |
% If we aren't typesetting an answer, then we are typesetting a test. We |
| 3234 |
% must define "\answer" so that it saves the answer in |
| 3235 |
% a macro so that it can be recalled when the answer key is typeset. |
| 3236 |
% \begin{macrocode} |
| 3237 |
\else |
| 3238 |
\def\answer##1{\expandafter\gdef |
| 3239 |
\csname tf@sol\current@question\endcsname{##1}} |
| 3240 |
\vspace{-\smallskipamount} |
| 3241 |
\fi |
| 3242 |
\exam@AddSectionTitle |
| 3243 |
\exam@AddSectionInstructionsHook |
| 3244 |
\exam@StartTrueFalseList |
| 3245 |
\the\csname qlist@scr@sec\current@section\endcsname |
| 3246 |
\end{list}} |
| 3247 |
|
| 3248 |
\def\exam@StartTrueFalseList{% |
| 3249 |
\ifanswer |
| 3250 |
\begin{list}{} |
| 3251 |
{\setlength{\rightmargin}{0pt} |
| 3252 |
\setlength{\labelwidth}{.4in} |
| 3253 |
\setlength{\leftmargin}{.5in} |
| 3254 |
\setlength{\labelsep}{.1in} |
| 3255 |
\setlength{\itemindent}{0in} |
| 3256 |
\setlength{\itemsep}{3pt}} |
| 3257 |
% \the\csname qlist@scr@sec\current@section\endcsname |
| 3258 |
% \end{list} |
| 3259 |
\else |
| 3260 |
\begin{list}%{$\underline{\mbox{\hphantom{false}}}$} |
| 3261 |
{\setlength{\rightmargin}{0pt} |
| 3262 |
\setlength{\labelwidth}{.35in} |
| 3263 |
\setlength{\leftmargin}{.5in} |
| 3264 |
\setlength{\labelsep}{.15in} |
| 3265 |
\setlength{\itemindent}{0in} |
| 3266 |
\setlength{\itemsep}{3pt}} |
| 3267 |
% \the\csname qlist@scr@sec\current@section\endcsname |
| 3268 |
% \end{list} |
| 3269 |
\fi} |
| 3270 |
% \end{macrocode} |
| 3271 |
% \end{macro} |
| 3272 |
% |
| 3273 |
% \begin{macro}{\@endquestionhook} |
| 3274 |
% This provides a ``hook'' for inserting something (like a place to put points) |
| 3275 |
% at the end of every question. Originally initialized to just "\relax" |
| 3276 |
% \begin{macrocode} |
| 3277 |
\def\@endquestionhook{\relax} |
| 3278 |
% \end{macrocode} |
| 3279 |
% \end{macro} |
| 3280 |
% |
| 3281 |
% \begin{macro}{\@beforequestionhook} |
| 3282 |
% This provides a ``hook'' for inserting something (like a place to put points) |
| 3283 |
% at the start of every question. Originally initialized to just "\relax". |
| 3284 |
% \begin{macrocode} |
| 3285 |
\def\@beforequestionhook{\relax} |
| 3286 |
% \end{macrocode} |
| 3287 |
% \end{macro} |
| 3288 |
% |
| 3289 |
%\def\@endquestionhook{\par\hfill Score: \fbox{\phantom{M}}} |
| 3290 |
% |
| 3291 |
% \begin{macro}{\exam@DefaultTFItem} |
| 3292 |
% This is a fancy version of "\item" that must be used for the true/false |
| 3293 |
% environment because of the way the exams and answers are printed. |
| 3294 |
% \begin{macrocode} |
| 3295 |
\def\exam@DefaultTFItem{% |
| 3296 |
\ifanswer |
| 3297 |
\item[\uline{\makebox[.5in][c]{\csname tf@sol\current@question\endcsname}}] |
| 3298 |
\else |
| 3299 |
\item[\uline{\makebox[.5in][r]{\hss}}] |
| 3300 |
\fi} |
| 3301 |
\let\exam@TFItem=\exam@DefaultTFItem |
| 3302 |
% \end{macrocode} |
| 3303 |
% \end{macro} |
| 3304 |
% |
| 3305 |
% \begin{macro}{\@mcitem} |
| 3306 |
% This is a fancy version of "\item" that must be used for the multiple |
| 3307 |
% choice environment because we want to put the question text inside a |
| 3308 |
% minipage to keep it from being broken across pages. |
| 3309 |
% \begin{macrocode} |
| 3310 |
\def\@mcitem{\item\begin{minipage}[t]{\linewidth}} |
| 3311 |
% \end{macrocode} |
| 3312 |
% \end{macro} |
| 3313 |
% |
| 3314 |
% \begin{macro}{\@mcenditem} |
| 3315 |
% This completes the minipage environment begun above. |
| 3316 |
% \begin{macrocode} |
| 3317 |
\def\@mcenditem{\end{minipage}} |
| 3318 |
% \end{macrocode} |
| 3319 |
% \end{macro} |
| 3320 |
% |
| 3321 |
% \begin{macro}{\answerspace} |
| 3322 |
% Inserts a particular amount of space for an answer to be given only on |
| 3323 |
% the actual exam. The space is suppressed in the answer key. |
| 3324 |
% \begin{macrocode} |
| 3325 |
\def\answerspace#1{\ifanswer \relax \else \vspace*{#1} \fi} |
| 3326 |
% \end{macrocode} |
| 3327 |
% \end{macro} |
| 3328 |
% |
| 3329 |
% \begin{macro}{\exam} |
| 3330 |
% Whatever is given as an argument to this macro will only be included if we |
| 3331 |
% are typesetting an exam. |
| 3332 |
% \begin{macrocode} |
| 3333 |
\def\exam#1{\ifanswer\relax\else #1\fi} |
| 3334 |
% \end{macrocode} |
| 3335 |
% \end{macro} |
| 3336 |
% |
| 3337 |
% \begin{macro}{\key} |
| 3338 |
% Whatever is given as an argument to this macro will only be included if we |
| 3339 |
% are typesetting an answer key. |
| 3340 |
% \begin{macrocode} |
| 3341 |
\def\key#1{\ifanswer#1\fi} |
| 3342 |
% \end{macrocode} |
| 3343 |
% \end{macro} |
| 3344 |
% |
| 3345 |
% \begin{macro}{\examvspace} |
| 3346 |
% Insert the specified amount of vertical space only if we are making an |
| 3347 |
% exam. At the same time, check to see if the command was a starred command or |
| 3348 |
% not. |
| 3349 |
% \begin{macrocode} |
| 3350 |
\def\examvspace{\@ifnextchar*{\@examvspacestar}{\@examvspace}} |
| 3351 |
% \end{macrocode} |
| 3352 |
% \end{macro} |
| 3353 |
% |
| 3354 |
% \begin{macro}{\@examvspacestar} |
| 3355 |
% \begin{macrocode} |
| 3356 |
\def\@examvspacestar*#1{\exam{\vspace*{#1}}} |
| 3357 |
% \end{macrocode} |
| 3358 |
% \end{macro} |
| 3359 |
% |
| 3360 |
% \begin{macro}{\@examvspace} |
| 3361 |
% \begin{macrocode} |
| 3362 |
\def\@examvspace#1{\exam{\vspace{#1}}} |
| 3363 |
% \end{macrocode} |
| 3364 |
% \end{macro} |
| 3365 |
% |
| 3366 |
% \begin{macro}{\examhspace} |
| 3367 |
% Insert the specified amount of horizontal space only if we are making an |
| 3368 |
% exam. At the same time, check to see if the command was a starred command or |
| 3369 |
% not. |
| 3370 |
% \begin{macrocode} |
| 3371 |
\def\examhspace{\@ifnextchar*{\@examhspacestar}{\@examhspace}} |
| 3372 |
% \end{macrocode} |
| 3373 |
% \end{macro} |
| 3374 |
% |
| 3375 |
% \begin{macro}{\@examhspacestar} |
| 3376 |
% \begin{macrocode} |
| 3377 |
\def\@examhspacestar*#1{\exam{\hspace*{#1}}} |
| 3378 |
% \end{macrocode} |
| 3379 |
% \end{macro} |
| 3380 |
% |
| 3381 |
% \begin{macro}{\@examhspace} |
| 3382 |
% \begin{macrocode} |
| 3383 |
\def\@examhspace#1{\exam{\hspace{#1}}} |
| 3384 |
% \end{macrocode} |
| 3385 |
% \end{macro} |
| 3386 |
% |
| 3387 |
% \begin{macro}{\keyvspace} |
| 3388 |
% Insert the specified amount of vertical space only if we are making an |
| 3389 |
% exam. At the same time, check to see if the command was a starred command or |
| 3390 |
% not. |
| 3391 |
% \begin{macrocode} |
| 3392 |
\def\keyvspace{\@ifnextchar*{\@keyvspacestar}{\@keyvspace}} |
| 3393 |
% \end{macrocode} |
| 3394 |
% \end{macro} |
| 3395 |
% |
| 3396 |
% \begin{macro}{\@keyvspacestar} |
| 3397 |
% \begin{macrocode} |
| 3398 |
\def\@keyvspacestar*#1{\key{\vspace*{#1}}} |
| 3399 |
% \end{macrocode} |
| 3400 |
% \end{macro} |
| 3401 |
% |
| 3402 |
% \begin{macro}{\@keyvspace} |
| 3403 |
% \begin{macrocode} |
| 3404 |
\def\@keyvspace#1{\key{\vspace{#1}}} |
| 3405 |
% \end{macrocode} |
| 3406 |
% \end{macro} |
| 3407 |
% |
| 3408 |
% \begin{macro}{\keyhspace} |
| 3409 |
% Insert the specified amount of vertical space only if we are making an |
| 3410 |
% exam. At the same time, check to see if the command was a starred command or |
| 3411 |
% not. |
| 3412 |
% \begin{macrocode} |
| 3413 |
\def\keyhspace{\@ifnextchar*{\@keyhspacestar}{\@keyhspace}} |
| 3414 |
% \end{macrocode} |
| 3415 |
% \end{macro} |
| 3416 |
% |
| 3417 |
% \begin{macro}{\@keyhspacestar} |
| 3418 |
% \begin{macrocode} |
| 3419 |
\def\@keyhspacestar*#1{\key{\hspace*{#1}}} |
| 3420 |
% \end{macrocode} |
| 3421 |
% \end{macro} |
| 3422 |
% |
| 3423 |
% \begin{macro}{\@keyhspace} |
| 3424 |
% \begin{macrocode} |
| 3425 |
\def\@keyhspace#1{\key{\hspace{#1}}} |
| 3426 |
% \end{macrocode} |
| 3427 |
% \end{macro} |
| 3428 |
% |
| 3429 |
% \begin{macro}{\label} |
| 3430 |
% The multiple processing of exams generates error messages if we use |
| 3431 |
% the default definition of |\label|. The following hack lets one |
| 3432 |
% use |\label| inside of exams with the expected effect. |
| 3433 |
% \begin{macrocode} |
| 3434 |
\let\exam@oldlabel=\label |
| 3435 |
\renewcommand{\label}[1]{\exam{\exam@oldlabel{\theversion @#1}}} |
| 3436 |
% \end{macrocode} |
| 3437 |
% \end{macro} |
| 3438 |
% |
| 3439 |
% \begin{macro}{\ref} |
| 3440 |
% And a similar hack to get |\ref| working as well\ldots |
| 3441 |
% \begin{macrocode} |
| 3442 |
\let\exam@oldref=\ref |
| 3443 |
\renewcommand{\ref}[1]{\exam@oldref{\theversion @#1}} |
| 3444 |
% \end{macrocode} |
| 3445 |
% \end{macro} |
| 3446 |
% |
| 3447 |
% \begin{macro}{\problem} |
| 3448 |
% Occasionally one needs to put several different numbered questions |
| 3449 |
% inside of a single block (I didn't first encounter this until I wrote |
| 3450 |
% my first scantron exam). This macro gives a way to do this consistently |
| 3451 |
% with the numbering scheme for the rest of the section. |
| 3452 |
% \begin{macrocode} |
| 3453 |
\def\problem{\stepcounter{enumi}\theenumi} |
| 3454 |
% \end{macrocode} |
| 3455 |
% \end{macro} |
| 3456 |
% |
| 3457 |
% \begin{macro}{\SectionFont} |
| 3458 |
% Here's an easy way to change the font used in section headings. |
| 3459 |
% \begin{macrocode} |
| 3460 |
\def\SectionFont#1{\def\exam@sectionfont{#1}} |
| 3461 |
\SectionFont{\large} % The default value |
| 3462 |
% \end{macrocode} |
| 3463 |
% \end{macro} |
| 3464 |
% |
| 3465 |
% \begin{macro}{\NoRearrange} |
| 3466 |
% The default behavior is to rearrange the questions. This macro changes |
| 3467 |
% it. |
| 3468 |
% \begin{macrocode} |
| 3469 |
\let\exam@SetDefaultRearrangeBehavior=\exam@SectionIsNotFixed |
| 3470 |
\def\NoRearrange{% |
| 3471 |
\let\exam@SetDefaultRearrangeBehavior=\exam@SectionIsFixed} |
| 3472 |
% \end{macrocode} |
| 3473 |
% \end{macro} |
| 3474 |
% |
| 3475 |
% \begin{macrocode} |
| 3476 |
\def\exam@resetcounter{% |
| 3477 |
\ifresetcounter |
| 3478 |
\setcounter{enumi}{0} |
| 3479 |
\global\resetcounterfalse |
| 3480 |
\else |
| 3481 |
\setcounter{enumi}{\value{questionnumber}} |
| 3482 |
\fi} |
| 3483 |
% \end{macrocode} |
| 3484 |
% |
| 3485 |
% \begin{macro}{\SectionPrefix} |
| 3486 |
% This macro let's one change the appearance of the section number |
| 3487 |
% which preceeds the title. |
| 3488 |
% \begin{macrocode} |
| 3489 |
\def\SectionPrefix#1{% |
| 3490 |
\def\exam@sectionprefix{% |
| 3491 |
\@ifundefined{SP@sec@\current@section} |
| 3492 |
{#1} |
| 3493 |
\relax}} |
| 3494 |
\SectionPrefix{Section \arabic{sectionindex}. \space} |
| 3495 |
% \end{macrocode} |
| 3496 |
% \end{macro} |
| 3497 |
% |
| 3498 |
% \begin{macro}{\ContinuousNumbering} |
| 3499 |
% When called, changes the default numbering behavior across sections. |
| 3500 |
% \begin{macrocode} |
| 3501 |
\def\ContinuousNumbering{% |
| 3502 |
\let\exam@DefaultNumberingBehavior=\resetcounterfalse} |
| 3503 |
\let\exam@DefaultNumberingBehavior=\resetcountertrue |
| 3504 |
% \end{macrocode} |
| 3505 |
% \end{macro} |
| 3506 |
% |
| 3507 |
|
| 3508 |
% \begin{macro}{\ShortKey} |
| 3509 |
% This macro only includes the answers in the key. |
| 3510 |
% \begin{macrocode} |
| 3511 |
\def\exam@SAGobbleQuestionHook{\relax}% default values |
| 3512 |
\def\exam@MCGobbleQuestionHook{\relax} |
| 3513 |
\def\exam@TFGobbleQuestionHook{\relax} |
| 3514 |
\def\exam@FillinGobbleQuestionHook{\relax} |
| 3515 |
\def\exam@FillinBlockGobbleQuestionHook{\relax} |
| 3516 |
\def\exam@TrueFalseGobbleBlockInstructionsHook{\relax} |
| 3517 |
\def\exam@answer{answer} |
| 3518 |
\def\exam@enumerate{enumerate} |
| 3519 |
\def\exam@list{list} |
| 3520 |
|
| 3521 |
\long\def\exam@BlockGobbleToBeginEnumerate#1\begin{% |
| 3522 |
\exam@CheckNextTokenForEnumerate} |
| 3523 |
\def\exam@CheckNextTokenForEnumerate#1{% |
| 3524 |
\def\@tempa{#1}% |
| 3525 |
\ifx\@tempa\exam@enumerate |
| 3526 |
\exam@BeginEnumerate |
| 3527 |
\else |
| 3528 |
\expandafter\exam@BlockGobbleToBeginEnumerate |
| 3529 |
\fi} |
| 3530 |
\def\exam@BeginEnumerate{\begin{enumerate}} |
| 3531 |
|
| 3532 |
\long\def\exam@TrueFalseBlockInstructionsGobble#1\exam@StartTrueFalseList{% |
| 3533 |
\exam@StartTrueFalseList} |
| 3534 |
|
| 3535 |
\long\def\exam@GobbleUpToAnswer#1\begin{% |
| 3536 |
\exam@CheckNextTokenForAnswer} |
| 3537 |
\def\exam@CheckNextTokenForAnswer#1{% |
| 3538 |
\def\@tempa{#1}% |
| 3539 |
\ifx\@tempa\exam@answer |
| 3540 |
\let\exam@next=\exam@PrepareToTypesetAnswer |
| 3541 |
\else |
| 3542 |
\ifx\@tempa\@endquestionhook |
| 3543 |
\let\exam@next=\@endquestionhook |
| 3544 |
\else |
| 3545 |
\let\exam@next=\exam@GobbleUpToAnswer |
| 3546 |
\fi\fi\exam@next} |
| 3547 |
\def\exam@PrepareToTypesetAnswer{\begin{answer}} |
| 3548 |
|
| 3549 |
\long\def\exam@GobbleUpToEndQuestionHook#1\@endquestionhook{% |
| 3550 |
\@endquestionhook} |
| 3551 |
|
| 3552 |
\long\def\exam@GobbleUpToChoice#1\choice{\choice} |
| 3553 |
|
| 3554 |
\def\exam@FillinGobbleNext#1{% |
| 3555 |
\ifx #1\blank |
| 3556 |
\let\exam@next=\exam@FillinInsertBlank |
| 3557 |
\else |
| 3558 |
\ifx #1\@endquestionhook |
| 3559 |
\def\exam@insertedblank{no}% |
| 3560 |
.\let\exam@next=\relax |
| 3561 |
\else |
| 3562 |
\let\exam@next=\exam@FillinGobbleNext |
| 3563 |
\fi\fi\exam@next} |
| 3564 |
|
| 3565 |
\def\exam@FillinBlockGobbleNext#1{% |
| 3566 |
\ifx #1\blank |
| 3567 |
\let\exam@next=\exam@FillinBlockInsertBlank |
| 3568 |
\else |
| 3569 |
\ifx #1\end |
| 3570 |
\let\exam@next=\exam@CheckNextTokenForQuestion |
| 3571 |
\else |
| 3572 |
\let\exam@next=\exam@FillinBlockGobbleNext |
| 3573 |
\fi\fi\exam@next} |
| 3574 |
\def\exam@CheckNextTokenForQuestion#1{% |
| 3575 |
\def\@tempa{#1}% |
| 3576 |
\ifx\@tempa\@Q |
| 3577 |
\expandafter\exam@FillinWrapupAndEndQuestion |
| 3578 |
\else |
| 3579 |
\expandafter\exam@FillinBlockGobbleNext |
| 3580 |
\fi} |
| 3581 |
\def\exam@FillinWrapupAndEndQuestion{.\end{question}} |
| 3582 |
|
| 3583 |
\def\exam@insertedblank{no} |
| 3584 |
\def\exam@FillinInsertBlank#1{% |
| 3585 |
\ifx\exam@insertedblank\exam@c@no |
| 3586 |
#1\def\exam@insertedblank{yes}% |
| 3587 |
\else |
| 3588 |
, #1\relax |
| 3589 |
\fi\exam@FillinGobbleNext} |
| 3590 |
\def\exam@FillinBlockInsertBlank#1{% |
| 3591 |
\ifx\exam@insertedblank\exam@c@no |
| 3592 |
#1\def\exam@insertedblank{yes}% |
| 3593 |
\else |
| 3594 |
, #1\relax |
| 3595 |
\fi\exam@FillinBlockGobbleNext} |
| 3596 |
|
| 3597 |
\def\ShortKey{% |
| 3598 |
\def\exam@AddSectionInstructionsHook{% |
| 3599 |
\ifanswer\relax\else\exam@AddSectionInstructions\fi} |
| 3600 |
\def\exam@SAGobbleQuestionHook{% |
| 3601 |
\ifanswer\expandafter\exam@GobbleUpToAnswer\fi} |
| 3602 |
\def\exam@MCGobbleQuestionHook{% |
| 3603 |
\ifanswer\expandafter\exam@GobbleUpToChoice\fi} |
| 3604 |
\def\exam@FillinGobbleQuestionHook{% |
| 3605 |
\ifanswer\expandafter\exam@FillinGobbleNext\fi} |
| 3606 |
\def\exam@FillinBlockGobbleQuestionHook{% |
| 3607 |
\ifanswer\expandafter\exam@FillinBlockGobbleNext\fi} |
| 3608 |
\def\exam@GobbleBlockInstructionsHook{% |
| 3609 |
\ifanswer\expandafter\exam@BlockGobbleToBeginEnumerate\fi} |
| 3610 |
\def\exam@TrueFalseGobbleBlockInstructionsHook{% |
| 3611 |
\ifanswer\expandafter\exam@TrueFalseBlockInstructionsGobble\fi} |
| 3612 |
\let\choice=\exam@ShortChoice} |
| 3613 |
|
| 3614 |
\def\exam@ShortChoice{% |
| 3615 |
\ifanswer |
| 3616 |
\expandafter\exam@ShortKeyChoice |
| 3617 |
\else |
| 3618 |
\expandafter\exam@DefaultChoice |
| 3619 |
\fi} |
| 3620 |
|
| 3621 |
\newif\ifOneCorrectAnswerAlreadyGiven |
| 3622 |
\OneCorrectAnswerAlreadyGivenfalse |
| 3623 |
\def\MultipleChoiceShortKeyPrefix#1{% |
| 3624 |
\def\exam@MultipleChoiceShortKeyPrefix{#1}} |
| 3625 |
\MultipleChoiceShortKeyPrefix{} |
| 3626 |
|
| 3627 |
\newcommand{\exam@ShortKeyChoice}[2][]{% |
| 3628 |
\if#1!% |
| 3629 |
\ifOneCorrectAnswerAlreadyGiven |
| 3630 |
, (\alph{choice}) |
| 3631 |
\else |
| 3632 |
\exam@MultipleChoiceShortKeyPrefix |
| 3633 |
(\alph{choice})% |
| 3634 |
\OneCorrectAnswerAlreadyGiventrue |
| 3635 |
\fi |
| 3636 |
\else |
| 3637 |
\stepcounter{choice}% |
| 3638 |
\fi\ignorespaces} |
| 3639 |
|
| 3640 |
\def\exam@ShortTFItem{% |
| 3641 |
\ifanswer |
| 3642 |
\item[\csname tf@sol\current@question\endcsname] |
| 3643 |
\else |
| 3644 |
\item |
| 3645 |
\fi} |
| 3646 |
|
| 3647 |
\def\exam@c@yes{yes} |
| 3648 |
\def\exam@c@no{no} |
| 3649 |
|
| 3650 |
\def\exam@MCMinipageWrapperBegin{\begin{minipage}[t]{\noexpand\linewidth}} |
| 3651 |
\def\exam@MCMinipageWrapperEnd{\end{minipage}} |
| 3652 |
|
| 3653 |
\def\DefineAnswerWrapper#1#2{% |
| 3654 |
\def\exam@DefineAnswerEnvironment{% |
| 3655 |
\def\answer{#1}\def\endanswer{#2}}} |
| 3656 |
\DefineAnswerWrapper{\begin{description}\item[Answer:]}{\end{description}} |
| 3657 |
|
| 3658 |
\let\old@pagebreak=\pagebreak |
| 3659 |
\def\exam@none{none} |
| 3660 |
\def\pagebreak{% |
| 3661 |
\ifx\@currentsectionname\exam@none |
| 3662 |
\setcounter{temp}{\thesection} |
| 3663 |
\stepcounter{temp} |
| 3664 |
\expandafter\def\csname sec\thetemp break\endcsname{\old@pagebreak} |
| 3665 |
\else |
| 3666 |
\expandafter |
| 3667 |
\gdef\csname sec\thesection q\thequestion break\endcsname{\old@pagebreak} |
| 3668 |
\fi} |
| 3669 |
|
| 3670 |
\def\exam@WhileReadingBreakPageOnVersion#1{% |
| 3671 |
\ifx\@currentsectionname\exam@none |
| 3672 |
\setcounter{temp}{\thesection}% |
| 3673 |
\stepcounter{temp}% |
| 3674 |
\expandafter\def\csname sec\thetemp break\endcsname{% |
| 3675 |
\ifnum\value{version}=#1\relax |
| 3676 |
\old@pagebreak |
| 3677 |
\fi} |
| 3678 |
\else |
| 3679 |
\expandafter |
| 3680 |
\gdef\csname sec\thesection q\thequestion break\endcsname{% |
| 3681 |
\ifnum\c@version=#1 |
| 3682 |
\old@pagebreak |
| 3683 |
\fi} |
| 3684 |
\fi} |
| 3685 |
\def\exam@DoneReadingBreakPageOnVersion#1{% |
| 3686 |
\ifnum\value{version}=#1\relax |
| 3687 |
\old@pagebreak |
| 3688 |
\fi} |
| 3689 |
\let\BreakPageOnVersion=\exam@WhileReadingBreakPageOnVersion |
| 3690 |
|
| 3691 |
\def\@currentsectionname{none} |
| 3692 |
|
| 3693 |
\def\IncludeFromFile#1{\def\exam@includefile{#1}} |
| 3694 |
|
| 3695 |
\def\InsertChunk#1{% |
| 3696 |
\def\exam@chunklookup{#1}% |
| 3697 |
\input{\exam@includefile}} |
| 3698 |
|
| 3699 |
\def\chunk#1{% |
| 3700 |
\def\@tempa{#1}% |
| 3701 |
\ifx\@tempa\exam@chunklookup |
| 3702 |
\relax |
| 3703 |
\else |
| 3704 |
\expandafter\exam@GobbleRestOfChunk |
| 3705 |
\fi} |
| 3706 |
\def\endchunk{\relax} |
| 3707 |
|
| 3708 |
\def\exam@chunk{chunk} |
| 3709 |
\long\def\exam@GobbleRestOfChunk#1\end{% |
| 3710 |
\exam@CheckNextTokenForChunk} |
| 3711 |
\def\exam@CheckNextTokenForChunk#1{% |
| 3712 |
\def\@tempa{#1}% |
| 3713 |
\ifx\@tempa\exam@chunk |
| 3714 |
\end{chunk}% |
| 3715 |
\else |
| 3716 |
\expandafter\exam@GobbleRestOfChunk |
| 3717 |
\fi} |
| 3718 |
|
| 3719 |
|
| 3720 |
% \end{macrocode} |
| 3721 |
% \end{macro} |