summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/stex/hwexam/hwexam.dtx
blob: f7abb4011ccf90d72ded17a6ac7b69b69f82330d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
% \iffalse meta-comment
% An Infrastructure for marking up Assignments
% $URL: https://svn.kwarc.info/repos/stex/trunk/sty/hwexam/hwexam.dtx $ 
% $Rev: 1671 $; last modified by $Author: kohlhase $ 
% $Date: 2010-11-06 08:05:15 +0100 (Sat, 06 Nov 2010) $
% Copyright (c) 2007 Michael Kohlhase, all rights reserved
%               this file is released under the
%               LaTeX Project Public License (LPPL)
% \fi
% 
% \iffalse
%<package|cls>\NeedsTeXFormat{LaTeX2e}[1999/12/01]
%<package>\ProvidesPackage{hwexam}[2010/06/25 v0.9b homework assignments and exams]
%<cls>\ProvidesClass{hwexam}[2010/06/25 v0.9b assignment and exam documents]
%
%<*driver>
\documentclass{ltxdoc}
\usepackage{url,float}
\usepackage{hwexam}
\usepackage[show]{ed}
\usepackage[hyperref=auto,style=alphabetic]{biblatex}
\bibliography{kwarc}
\usepackage[eso-foot,today]{svninfo}
\svnInfo $Id: hwexam.dtx 1671 2010-11-06 07:05:15Z kohlhase $
\svnKeyword $HeadURL: https://svn.kwarc.info/repos/stex/trunk/sty/hwexam/hwexam.dtx $
\usepackage{stex-logo}
\usepackage{../ctansvn}
\usepackage{hyperref}
\makeindex
\floatstyle{boxed}
\newfloat{exfig}{thp}{lop}
\floatname{exfig}{Example}
\def\tracissue#1{\cite{sTeX:online}, \hyperlink{http://trac.kwarc.info/sTeX/ticket/#1}{issue #1}}
\begin{document}\DocInput{hwexam.dtx}\end{document}
%</driver>
% \fi
%\iffalse\CheckSum{323}\fi
% 
% \changes{v0.9}{2006/09/18}{First Version with Documentation}
% \changes{v0.9a}{2010/06/25}{more semantic headers for exams}
% \changes{v0.9b}{2010/09/20}{adding \texttt{assignment.cls}}
% \changes{v0.9c}{2010/09/20}{renaming from \texttt{assignment} to \texttt{hwexam} to
% avoid name clashes with existing \texttt{assignment.cls} on CTAN.}
% 
% \GetFileInfo{hwexam.sty}
% 
% \MakeShortVerb{\|}
%\def\scsys#1{{{\sc #1}}\index{#1@{\sc #1}}}
% \def\latexml{\scsys{LaTeXML}}
%
% \title{\texttt{hwexam.sty/cls}: An Infrastructure for formatting Assignments 
%        and Exams\thanks{Version {\fileversion} (last revised {\filedate})}}
%    \author{Michael Kohlhase\\
%            Jacobs University, Bremen\\
%            \url{http://kwarc.info/kohlhase}}
% \maketitle
%
% \begin{abstract}
%   The |hwexam| packge and class allows individual course assignment sheets and
%   compond assignment documents using problem files marked up with the |problem| package.
% \end{abstract}
% \setcounter{tocdepth}{2}\tableofcontents\newpage
%
%\section{Introduction}\label{sec:intro}
%
% The |hwexam| package and class supplies an infrastructure that allows to format
% nice-looking assignment sheets by simply including problems from problem files marked up
% with the |problem| package~\cite{Kohlhase:problem:ctan}.  It is designed to be
% compatible with |problems.sty|, and inherits some of the functionality.
% 
% \section{The User Interface}
% 
% \subsection{Package and Class Options}\label{sec:user:options}
% 
% The |hwexam| package and class take the options |solutions|, |notes|, |hints|, |pts|,
% |min|, and |boxed| that are just passed on to the |problems| package (cf. its
% documentation for a description of the intended behavior).
% 
% If the \DescribeMacro{showmeta}|showmeta| option is set, then the metadata keys are
% shown (see~\cite{Kohlhase:metakeys:ctan} for details and customization options).
% 
% The |hwexam| class additionally accepts the options |report|, |book|, |chapter|, |part|,
% and |showignores|, of the |omdoc| package~\cite{Kohlhase:smomdl:ctan} on which it is
% based and passes them on to that. For the |extrefs| option
% see~\cite{Kohlhase:sref:ctan}.
%
% \subsection{Assignments}
%
% \DescribeEnv{assignment} This package supplies the |assignment| environment that groups
% problems into assignment sheets. It takes an optional KeyVal argument with the keys
% \DescribeMacro{number}|number| (for the assignment number; if none is given, 1 is
% assumed as the default or --- in multi-assignment documents --- the ordinal of the
% |assignment| environment), \DescribeMacro{title}|title| (for the assignment title; this
% is referenced in the title of the assignment sheet), \DescribeMacro{type}|type| (for the
% assignment type; e.g. ``quiz'', or ``homework''), \DescribeMacro{given}|given| (for the
% date the assignment was given), and \DescribeMacro{due}|due| (for the date the
% assignment is due).
% 
% \subsection{Typesetting Exams}
%
% Furthermore, the |hwexam| package takes the option
% \DescribeMacro{multiple}|multiple| that allows to combine multiple assigment sheets into
% a compound document (the assignment sheets are treated as section, there is a table of
% contents, etc.). 
% 
% Finally, there is the option \DescribeMacro{test}|test| that modifies the behavior to
% facilitate formatting tests. Only in |test| mode, the macros |\testspace|,
% |\testnewpage|, and |\testemptypage| have an effect: they generate space for the
% students to solve the given problems. Thus they can be left in the {\LaTeX} source. 
%
% \DescribeMacro{\testspace}|\testspace| takes an argument that expands to a dimension,
% and leaves vertical space accordingly. \DescribeMacro{\testnewpage}|\testnewpage| makes
% a new page in |test| mode, and \DescribeMacro{\testemptypage}|\testemptypage| generates
% an empty page with the cautionary message that this page was intentionally left empty.
%
% Finally, the \DescribeEnv{testheading}|\testheading| takes an optional keyword argument
% where the keys \DescribeMacro{duration}|duration| specifies a string that specifies the
% duration of the test, \DescribeMacro{min}|min| specifies the equivalent in number of
% minutes, and \DescribeMacro{reqpts}|reqpts| the points that are required for a perfect
% grade.
% \begin{exfig}[ht]
% \makeatletter
% \@problem{1.1}{4}{10}
% \@problem{2.1}{4}{8}
% \@problem{2.2}{6}{10}
% \@problem{2.3}{6}{10}
% \@problem{3.1}{4}{8}
% \@problem{3.2}{4}{8}
% \@problem{3.3}{2}{4}
% \makeatother
% \begin{verbatim}
% \title{320101 General Computer Science (Fall 2010)}
% \begin{testheading}[duration=one hour,min=60,reqpts=27]
%   Good luck to all students!
% \end{testheading}
% \end{verbatim}
% \vspace*{-3ex}\hrule\vspace*{.5ex}  formats to\vspace*{1ex}
% \hrule\par\noindent\vspace*{2ex}
% \title{320101 General Computer Science (Fall 2010)}
% \begin{testheading}[duration=one hour,min=60,reqpts=27]
%   good luck
% \end{testheading}
% \caption{A generated test heading.}\label{fig:testheading}
% \end{exfig}
% 
% \subsection{Including Assignments}
%
% The \DescribeMacro{\includeassignment}|\includeassignment| macro can be used to include
% an assignment from another file. It takes an optional KeyVal argument and a second
% argument which is a path to the file containing the problem (the macro assumes that
% there is only one |assignment| environment in the included file).  The keys
% \DescribeMacro{number}|number|, \DescribeMacro{title}|title|,
% \DescribeMacro{type}|type|, \DescribeMacro{given}|given|, and \DescribeMacro{due}|due|
% are just as for the |assignment| environment and (if given) overwrite the ones specified
% in the |assignment| environment in the included file.
% 
%
% \section{Limitations}\label{sec:limitations}
% 
% In this section we document known limitations. If you want to help alleviate them,
% please feel free to contact the package author. Some of them are currently discussed in
% the \sTeX TRAC~\cite{sTeX:online}. 
% \begin{compactenum}
% \item none reported yet
% \end{compactenum}
% 
% \StopEventually{\newpage\PrintIndex\newpage\PrintChanges\printbibliography}\newpage
% \newpage
%
% \section{Implementation: The hwexam Class}\label{sec:impl:cls}
%
% The functionality is spread over the |hwexam| class and package. The class provides
% the |document| environment and pre-loads some convenience packages, whereas the package
% provides the concrete functionality.
% 
% |hwexam.dtx| generates four files: |hwexam.cls| (all the code between
% {\textsf{$\langle$*cls$\rangle$}} and {\textsf{$\langle$/cls$\rangle$}}), |hwexam.sty|
% (between {\textsf{$\langle$*package$\rangle$}} and
% {\textsf{$\langle$/package$\rangle$}}) and their {\latexml} bindings (between
% {\textsf{$\langle$*ltxml.cls$\rangle$}} and {\textsf{$\langle$/ltxml.cls$\rangle$}} and
% {\textsf{$\langle$*ltxml.sty$\rangle$}} and {\textsf{$\langle$/ltxml.sty$\rangle$
% respetively}}). We keep the corresponding code fragments together, since the
% documentation applies to both of them and to prevent them from getting out of sync.
%
% \subsection{Class Options}\label{sec:impl:cls:options}
%
% To initialize the |hwexam| class, we declare and process the necessary options by
% passing them to the respective packages and classes they come from.
% 
%    \begin{macrocode}
%<*cls>
\DeclareOption{test}{\PassOptionsToPackage{\CurrentOption}{hwexam}}
\DeclareOption{multiple}{\PassOptionsToPackage{\CurrentOption}{hwexam}}
\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}}
\DeclareOption{extrefs}{\PassOptionsToPackage{\CurrentOption}{sref}}
\DeclareOption{notes}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption{hints}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption{solutions}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption{pts}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption{min}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption{boxed}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption{extract}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{omdoc}}
\ProcessOptions
%</cls>
%<*ltxml.cls>
# -*- CPERL -*-
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
use LaTeXML::Util::Pathname;
use Cwd qw(cwd abs_path);
DeclareOption('test',,sub {PassOptions('hwexam','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('multiple',sub {PassOptions('hwexam','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('showmeta',sub {PassOptions('metakeys','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('extrefs',sub {PassOptions('sref','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('notes',sub {PassOptions('problem','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('hints',sub {PassOptions('problem','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('solutions',sub {PassOptions('problem','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('pts',sub {PassOptions('problem','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('min',sub {PassOptions('problem','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('boxed',sub {PassOptions('problem','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption('extract',sub {PassOptions('problem','sty',ToString(Digest(T_CS('\CurrentOption')))); }); 
DeclareOption(undef,sub {PassOptions('omdoc','cls',ToString(Digest(T_CS('\CurrentOption')))); });
ProcessOptions();
%</ltxml.cls>
%    \end{macrocode}
%
% We load |article.cls|, and the desired packages. For the {\latexml} bindings, we make
% sure the right packages are loaded.
%
%    \begin{macrocode}
%<*cls>
\LoadClass{omdoc}
\RequirePackage{stex}
\RequirePackage{hwexam}
\RequirePackage{graphicx}
\RequirePackage{a4wide}
\RequirePackage{amssymb}
\RequirePackage{amstext}
\RequirePackage{amsmath}
%</cls>
%<*ltxml.cls>
LoadClass('omdoc');
RequirePackage('stex');
RequirePackage('hwexam');
RequirePackage('graphicx');
RequirePackage('amssymb');
RequirePackage('amstext');
RequirePackage('amsmath');
%</ltxml.cls>
%    \end{macrocode}
%
% \section{Implementation: The hwexam Package} 
%
% \subsection{Package Options}
%
% The first step is to declare (a few) package options that handle whether certain
% information is printed or not. Some come with their own conditionals that are set by the
% options, the rest is just passed on to the |problems| package.
%
%    \begin{macrocode}
%<*package>
\DeclareOption{showmeta}{\PassOptionsToPackage{\CurrentOption}{metakeys}}
\newif\iftest\testfalse
\newif\ifsolutions\solutionsfalse
\DeclareOption{test}{\testtrue\solutionsfalse}
\newif\ifmultiple\multiplefalse
\DeclareOption{multiple}{\multipletrue}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}}
\ProcessOptions
%</package>
%    \end{macrocode}
% Then we make sure that the necessary packages are loaded (in the right versions).
%    \begin{macrocode}
%<*package>
\RequirePackage{keyval}[1997/11/10]
\RequirePackage{problem}
%</package>
%    \end{macrocode}
%
% Here comes the equivalent header information for {\latexml}, we also initialize the
% package inclusions. Since {\latexml} does not handle options yet, we have nothing to
% do. 
%    \begin{macrocode}
%<*ltxml>
# -*- CPERL -*-
package LaTeXML::Package::Pool;
use strict;
use LaTeXML::Package;
RequirePackage('problem');
%</ltxml>
%    \end{macrocode}
%
% Then we register the namespace of the requirements ontology
%    \begin{macrocode}
%<*ltxml>
RegisterNamespace('assig'=>"http://omdoc.org/ontology/assignments#");
RegisterDocumentNamespace('assig'=>"http://omdoc.org/ontology/assignments#");
%</ltxml>
%    \end{macrocode}
%
% \subsection{Assignments}
%
% We will prepare the keyval support for the |assignment| environment.
%
%    \begin{macrocode}
%<*package>
\addmetakey{assig}{number}
\addmetakey*{assig}{title}
\addmetakey{assig}{type}
\addmetakey{assig}{given}
\addmetakey{assig}{due}
%    \end{macrocode}
%
% The next three macros are intermediate functions that handle the case gracefully, where
% the respective token registers are undefined.
% 
% The |\given@due| macro prints information about the given and due status of the
% assignment. Its arguments specify the brackets. 
% 
%    \begin{macrocode}
\def\given@due#1#2{%
\ifx\assig@given\@empty\else\ifx\assig@due\@empty\else{#1}\fi\fi%
\ifx\assig@given\@empty\else{Given {\assig@given}}\fi%
\ifx\assig@given\@empty\else\ifx\assig@due\@empty\else{, }\fi\fi%
\ifx\assig@due\@empty\else{Due {\assig@due}}\fi%
\ifx\assig@given\@empty\else{\ifx\assig@due\@empty\else{#2}\fi}\fi}
%    \end{macrocode}
% 
% With them, we can define the central |assignment| environment. This has two forms
% (separated by |\ifmultiple|) in one we make a title block for an assignment sheet, and
% in the other we make a section heading and add it to the table of
% contents.
% 
% \begin{macro}{assignment@titleblock}
%   This macro prints the title block of a section. If the |multiple| package option is
%   given we make a section heading out of this, and if not, a title block. Note that as
%   |problem|s are numbered by section, we also set the section counter in the latter
%   case.
%    \begin{macrocode}
\ifmultiple
\def\assignment@titleblock{%
\@ifundefined{assig@number}{\stepcounter{section}}{\setcounter{section}{\assig@number}}%
\section*{\document@hwexamtype~\arabic{section}:~\assig@title\given@due{\\(})}%
\addcontentsline{toc}{section}{\document@hwexamtype~{\arabic{section}}:~\assig@title}%
\setcounter{problem}{0}}
\else
\def\assignment@titleblock{%
\setcounter{section}{\assig@number}
\begin{center}\bf
\Large\@title\\
\document@hwexamtype~\assig@number:~\assig@title\strut\\
\large{\given@due()}
\end{center}}
\fi
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{assignment@process@keys}
%   this macro collects the keys from its arugment and corrects them from the outside.
%    \begin{macrocode}
\def\assignment@process@keys#1{\metasetkeys{assig}{#1}
\ifx\inclassig@title\@empty\else\def\assig@title{\inclassig@title}\fi
\ifx\inclassig@type\@empty\else\def\assig@type{\inclassig@type}\fi
\ifx\inclassig@number\@empty\else\def\assig@number{\inclassig@number}\fi
\ifx\inclassig@due\@empty\else\def\assig@due{\inclassig@due}\fi
\ifx\inclassig@given\@empty\else\def\assig@given{\inclassig@given}\fi}
%    \end{macrocode}
% for this to work we need to define the |\inclassig| macros in case no
% |\includeassignment| is ever called. 
%    \begin{macrocode}
\def\inclassig@title{}
\def\inclassig@type{}
\def\inclassig@number{}
\def\inclassig@due{}
\def\inclassig@given{}
%    \end{macrocode}
% \end{macro}
%
% \begin{environment}{assignment}
%    \begin{macrocode}
\newenvironment{assignment}[1][]{\assignment@process@keys{#1}%
\assignment@titleblock}{}
%</package>
%    \end{macrocode}
% 
%    \begin{macrocode}
%<*ltxml>
DefEnvironment('{assignment} OptionalKeyVals:assig',
  "<omdoc:omgroup ?&KeyVal(#1,'id')(xml:id='&KeyVal(#1,'id')')() "
  .  "assig:dummy='for the namespace'"
  . "?#locator(stex:srcref='#locator')()>"
  .  "<omdoc:metadata ?#locator(stex:srcref='#locator')()>"
  .    "<dc:title ?#locator(stex:srcref='#locator')()>"
  .       "Assignment ?&KeyVal(#1,'num')(&KeyVal(#1,'num').)()"
  .       "?&KeyVal(#1,'title')((&KeyVal(#1,'title')))"
  .    "</dc:title>"
  .    "?&KeyVal(#1,'given')(<omdoc:meta property='assig:given'>&KeyVal(#1,'given')</omdoc:meta>)()"
  .    "?&KeyVal(#1,'due')(<omdoc:meta property='assig:due'>&KeyVal(#1,'due')</omdoc:meta>)()"
  .    "?&KeyVal(#1,'pts')(<omdoc:meta property='assig:pts'>&KeyVal(#1,'pts')</omdoc:meta>)()"
  .  "</omdoc:metadata>"
  .  "#body"
  ."</omdoc:omgroup>\n");
%</ltxml>
%    \end{macrocode}
% \end{environment}
% 
%    \begin{macrocode}
%<*package>
\addmetakey[\assig@default@type]{document}{hwexamtype}
%</package>
%    \end{macrocode}
% 
% \subsection{Including Assignments}
%
% The next command is essentially a glorified |\include| statement, it just sets some
% internal macros first that overwrite the local points, \ednote{these keys should be done
% with \texttt{\textbackslash addmetakey}}
% 
%    \begin{macrocode}
%<*package>
\addmetakey{inclassig}{number}
\addmetakey{inclassig}{title}
\addmetakey{inclassig}{type}
\addmetakey{inclassig}{given}
\addmetakey{inclassig}{due}
\newcommand{\includeassignment}[2][]{\metasetkeys{inclassig}{#1}\include{#2}}
\newcommand{\inputassignment}[2][]{\metasetkeys{inclassig}{#1}\input{#2}}
%</package>
%<*ltxml>
DefMacro('\includeassignment [] {}','\input{#2}');
DefMacro('\inputassignment [] {}','\input{#2}');
%</ltxml>
%    \end{macrocode}
%
% \subsection{Typesetting Exams}
%
%    \begin{macrocode}
%<*package>
\addmetakey{quizheading}{tas}
\newcommand\quizheading[1]{\def\@tas{#1}%
\large\noindent NAME: \hspace{8cm}  MAILBOX:\\[2ex]%
\ifx\@tas\@empty\else%
\noindent YOUR TA: \@for\@I:=\@tas\do{$\Box$ \@I\hspace*{1em}}\\[2ex]\fi}
%</package>
%    \end{macrocode}
%    \begin{macrocode}
%<*package>
\addmetakey{testheading}{min}
\addmetakey{testheading}{duration}
\addmetakey{testheading}{reqpts}
\newenvironment{testheading}[1][]{\metasetkeys{testheading}{#1}
{\noindent\large{}Name: \hfill Matriculation Number:\hspace*{2cm}\strut\\[1ex]
\begin{center}\Large\textbf{\@title}\\[1ex]\large\@date\\[3ex]\end{center}  
{\textbf{You have 
\ifx\test@heading@duration\@empty\testheading@min minutes\else\testheading@duration\fi 
(sharp) for the test}};\\ Write the solutions to the sheet.}\par\noindent

\newcount\check@time\check@time=\testheading@min
\advance\check@time by -\theassignment@totalmin
The estimated time for solving this exam is {\theassignment@totalmin} minutes, 
leaving you {\the\check@time} minutes for revising your exam. 

\newcount\bonus@pts\bonus@pts=\theassignment@totalpts
\advance\bonus@pts by -\testheading@reqpts
You can reach {\theassignment@totalpts} points if you solve all problems. You will only need
{\testheading@reqpts} points for a perfect score, i.e.\ {\the\bonus@pts} points are
bonus points. \vfill
\begin{center}
  {\Large\em
%  You have ample time, so take it slow and avoid rushing to mistakes!\\[2ex]
  Different problems test different skills and knowledge, so do not get stuck on
  one problem.}\vfill\par\correction@table \\[3ex]
\end{center}}
{\newpage}
%</package>
%<*ltxml>
DefEnvironment('{testheading}OptionalKeyVals:omdoc','');
%</ltxml>
%    \end{macrocode}
%
%    \begin{macrocode}
%<*package>
\def\testspace#1{\iftest\vspace*{#1}\fi}
\def\testnewpage{\iftest\newpage\fi}
\def\testemptypage{\iftest\begin{center}This page was intentionally left
    blank for extra space\end{center}\vfill\eject\else\fi}
%</package>
%<*ltxml>
DefConstructor('\testspace{}','');
DefConstructor('\testnewpage','');
DefConstructor('\testemptypage','');
%</ltxml>
%    \end{macrocode}
%
% \begin{macro}{\@problem}
%   This macro acts on a problem's record in the |*.aux| file. Here we redefine it to
%   generate the correction table. 
%    \begin{macrocode}
%<*package>
\def\@problem#1#2#3{\stepcounter{assignment@probs}
\def\@test{#2}\ifx\@test\@empty\else\addtocounter{assignment@totalpts}{#2}\fi
\def\@test{#3}\ifx\@test\@empty\else\addtocounter{assignment@totalmin}{#3}\fi
\xdef\correction@probs{\correction@probs & #1}%
\xdef\correction@pts{\correction@pts & #2}
\xdef\correction@reached{\correction@reached &}}
%</package>
%    \end{macrocode}
% \end{macro}
% 
% \begin{macro}{\correction@table}
%   This macro generates the correction table
%    \begin{macrocode}
%<*package>
\newcounter{assignment@probs}
\newcounter{assignment@totalpts}
\newcounter{assignment@totalmin}
\def\correction@probs{prob.}%
\def\correction@pts{total}%
\def\correction@reached{reached}%
\stepcounter{assignment@probs}
\def\correction@table{\begin{tabular}{|l|*{\theassignment@probs}{c|}|p{3cm}|}\hline%
&\multicolumn{\theassignment@probs}{c||}%
{\footnotesize To be used for grading, do not write here} &\\\hline
\correction@probs & Sum & grade\\\hline
\correction@pts &\theassignment@totalpts & \strut\hspace{3cm}\strut\\\hline
\correction@reached & & \\[.7cm]\hline
\end{tabular}}
%</package>
%    \end{macrocode}
% \end{macro}
% 
% \subsection{Leftovers}
%
% at some point, we may want to reactivate the logos font, then we use
% \begin{verbatim}
% here we define the logos that characterize the assignment
% \font\bierfont=../assignments/bierglas
% \font\denkerfont=../assignments/denker
% \font\uhrfont=../assignments/uhr
% \font\warnschildfont=../assignments/achtung
%
% \def\bierglas{{\bierfont\char65}}
% \def\denker{{\denkerfont\char65}}
% \def\uhr{{\uhrfont\char65}}
% \def\warnschild{{\warnschildfont\char 65}}
% \def\hardA{\warnschild}
% \def\longA{\uhr}
% \def\thinkA{\denker}
% \def\discussA{\bierglas}
% \end{verbatim}
%
% Finally, we need to terminate the file with a success mark for perl.
%    \begin{macrocode}
%<ltxml>1;
%    \end{macrocode}
% \Finale
\endinput
% \iffalse
% LocalWords:  GPL structuresharing STR
%%% Local Variables: 
%%% mode: doctex
%%% TeX-master: t
%%% End: 
% \fi