summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex/latex/stex/hwexam/hwexam.sty
blob: 5c0e175cf0a99ba6a40769425eb126b71ef4550d (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
%%
%% This is file `hwexam.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hwexam.dtx  (with options: `package')
%% 
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesPackage{hwexam}[2019/03/20 v1.1 homework assignments and exams]
\newif\if@hwexam@mh@\@hwexam@mh@false
\DeclareOption{mh}{\@hwexam@mh@true}
\newif\iftest\testfalse
\DeclareOption{test}{\testtrue}
\newif\ifmultiple\multiplefalse
\DeclareOption{multiple}{\multipletrue}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}}
\ProcessOptions
\RequirePackage{keyval}[1997/11/10]
\if@hwexam@mh@\RequirePackage{hwexam-mh}\fi
\RequirePackage{problem}
\AfterBabelLanguage{ngerman}{\input{hwexam-ngerman.ldf}}
\AfterBabelLanguage{arabic}{\input{hwexam-arabic.ldf}}
\newcommand\hwexam@assignment@kw{Assignment}
\newcommand\hwexam@given@kw{Given}
\newcommand\hwexam@due@kw{Due}
\newcommand\hwexam@testemptypage@kw{This page was intentionally left blank for extra
  space}%
\newcommand\correction@probs@kw{prob.}%
\newcommand\correction@pts@kw{total}%
\newcommand\correction@reached@kw{reached}%
\newcommand\correction@sum@kw{Sum}%
\newcommand\correction@grade@kw{grade}%
\newcommand\correction@forgrading@kw{To be used for grading, do not write here}
\newcounter{assignment}
\numberproblemsin{assignment}
\renewcommand\prob@label[1]{\arabic{assignment}.#1}
\srefaddidkey{assig}
\addmetakey{assig}{number}
\addmetakey*{assig}{title}
\addmetakey{assig}{type}
\addmetakey{assig}{given}
\addmetakey{assig}{due}
\addmetakey[false]{assig}{loadmodules}[true]
\newcommand\given@due[2]{%
\ifx \inclassig@given\@empty
\ifx \assig@given\@empty
\ifx \inclassig@due\@empty
\ifx \assig@due\@empty% all empty do nothing
\else #1%
\fi
\else #1%
\fi
\else #1%
\fi
\else #1%
\fi
\ifx\inclassig@given\@empty
\ifx\assig@given\@empty% do nothing
\else \hwexam@given@kw\xspace \assig@given%
\fi
\else \hwexam@given@kw\xspace \inclassig@given%
\fi
\ifx \inclassig@due\@empty
\ifx \assig@due\@empty% do nothing
\else
\ifx \inclassig@given\@empty
\ifx \assig@given\@empty% do nothing
\else ,~%
\fi
\else ,~%
\fi
\fi
\else
\ifx \inclassig@given\@empty
\ifx \assig@given\@empty% do nothing
\else ,~%
\fi
\else ,~%
\fi
\fi
\ifx \inclassig@due\@empty
\ifx \assig@due\@empty% do nothing
\else \hwexam@due@kw\xspace \assig@due%
\fi
\else \hwexam@due@kw\xspace \inclassig@due%
\fi
\ifx \inclassig@given\@empty
\ifx \assig@given\@empty
\ifx \inclassig@due\@empty
\ifx \assig@due\@empty% all empty do nothing
\else #2%
\fi
\else #2%
\fi
\else #2%
\fi
\else #2%
\fi
}
\newcommand\assignment@title[3]
{\ifx\inclassig@title\@empty% if there is no outside title
\ifx\assig@title\@empty{#1}\else{#2\assig@title{#3}}\fi
\else{#2}\inclassig@title{#3}\fi}% else show the outside title
\newcommand\assignment@number%
{\ifx\inclassig@number\@empty% if there is no outside number
\ifx\assig@number\@empty\else\assig@number\fi
\else\inclassig@number\fi}% else show the outside number
\newenvironment{assignment}[1][]{\metasetkeys{assig}{#1}\sref@target%
\edef\@@num{\assignment@number}%
\ifx\@@num\@empty\stepcounter{assignment}\else\setcounter{assignment}{\@@num}\fi%
\setcounter{problem}{0}%
\def\current@section@level{\document@hwexamtype}%
\sref@label@id{\document@hwexamtype \thesection}%
\begin{@assignment}}
{\end{@assignment}}
\def\@@asstitle{\protect\document@hwexamtype~\arabic{assignment}%
\assignment@title{}{\;(}{)\;} -- \given@due{}{}}
\ifmultiple
\newenvironment{@assignment}%
{\ifx\assig@loadmodules\@true
\begin{omgroup}[loadmodules]{\@@asstitle}
\else
\begin{omgroup}{\@@asstitle}
\fi}
{\end{omgroup}}
\else
\newenvironment{@assignment}
{\begin{center}\bf
\Large\@title\strut\\
\document@hwexamtype~\arabic{assignment}\assignment@title{\;}{:\;}{\\}%
\large\given@due{--\;}{\;--}
\end{center}}
{}
\fi% multiple
\addmetakey{inclassig}{number}
\addmetakey*{inclassig}{title}
\addmetakey{inclassig}{type}
\addmetakey{inclassig}{given}
\addmetakey{inclassig}{due}
\addmetakey{inclassig}{mhrepos}
\clear@inclassig@keys%initially
\newcommand\includeassignment[2][]{\metasetkeys{inclassig}{#1}%
\include{#2}\clear@inclassig@keys}
\newcommand\inputassignment[2][]{\metasetkeys{inclassig}{#1}%
\input{#2}\clear@inclassig@keys}
\addmetakey{quizheading}{tas}
\newcommand\quizheading[1]{\def\@tas{#1}%
\large\noindent NAME: \hspace{8cm}  MAILBOX:\\[2ex]%
\ifx\@tas\@empty\else%
\noindent TA: \@for\@I:=\@tas\do{{\Large$\Box$}\@I\hspace*{1em}}\\[2ex]\fi}
\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\testheading@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
  Different problems test different skills and knowledge, so do not get stuck on
  one problem.}\vfill\par\correction@table \\[3ex]
\end{center}}
{\newpage}
\newcommand\testspace[1]{\iftest\vspace*{#1}\fi}
\newcommand\testnewpage{\iftest\newpage\fi}
\newcommand\testemptypage[1][]{\iftest\begin{center}\hwexam@testemptypage@kw\end{center}\vfill\eject\else\fi}
\renewcommand\@problem[3]{\stepcounter{assignment@probs}
\def\@@pts{#2}\ifx\@@pts\@empty\else\addtocounter{assignment@totalpts}{#2}\fi
\def\@@min{#3}\ifx\@@min\@empty\else\addtocounter{assignment@totalmin}{#3}\fi
\xdef\correction@probs{\correction@probs & #1}%
\xdef\correction@pts{\correction@pts & #2}
\xdef\correction@reached{\correction@reached &}}
\newcounter{assignment@probs}
\newcounter{assignment@totalpts}
\newcounter{assignment@totalmin}
\def\correction@probs{\correction@probs@kw}%
\def\correction@pts{\correction@pts@kw}%
\def\correction@reached{\correction@reached@kw}%
\def\after@correction@table{}%
\stepcounter{assignment@probs}
\newcommand\correction@table{\begin{tabular}{|l|*{\theassignment@probs}{c|}|l|}\hline%
&\multicolumn{\theassignment@probs}{c||}%|
{\footnotesize\correction@forgrading@kw} &\\\hline
\correction@probs & \correction@sum@kw & \correction@grade@kw\\\hline
\correction@pts &\theassignment@totalpts & \\\hline
\correction@reached & & \\[.7cm]\hline
\end{tabular}
\ifx\after@correction@table\@empty\else\strut\par\noindent\after@correction@table\fi}
\endinput
%%
%% End of file `hwexam.sty'.