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
|
%%
%% This is file `hwexam.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% hwexam.dtx (with options: `package')
%%
\ProvidesExplPackage{hwexam}{2022/09/14}{3.2.0}{homework assignments and exams}
\RequirePackage{l3keys2e}
\newif\iftest\testfalse
\DeclareOption{test}{\testtrue\PassOptionsToPackage{\CurrentOption}{problem}}
\newif\ifmultiple\multiplefalse
\DeclareOption{multiple}{\multipletrue}
\DeclareOption{lang}{\PassOptionsToPackage{\CurrentOption}{problem}}
\DeclareOption*{\PassOptionsToPackage{\CurrentOption}{problem}}
\ProcessOptions
\RequirePackage{keyval}[1997/11/10]
\RequirePackage{problem}
\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\hwexam@minutes@kw{minutes}
\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}
\AddToHook{begindocument}{
\ltx@ifpackageloaded{babel}{
\makeatletter
\clist_set:Nx \l_tmpa_clist {\bbl@loaded}
\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{ngerman}}{
\input{hwexam-ngerman.ldf}
}
\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{finnish}}{
\input{hwexam-finnish.ldf}
}
\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{french}}{
\input{hwexam-french.ldf}
}
\exp_args:NNx \clist_if_in:NnT \l_tmpa_clist {\detokenize{russian}}{
\input{hwexam-russian.ldf}
}
\makeatother
}{}
}
\newcounter{assignment}
\keys_define:nn { hwexam / assignment } {
id .str_set_x:N = \l__problems_assign_id_str,
number .int_set:N = \l__problems_assign_number_int,
title .tl_set:N = \l__problems_assign_title_tl,
type .tl_set:N = \l__problems_assign_type_tl,
given .tl_set:N = \l__problems_assign_given_tl,
due .tl_set:N = \l__problems_assign_due_tl,
loadmodules .code:n = {
\bool_set_true:N \l__problems_assign_loadmodules_bool
}
}
\cs_new_protected:Nn \__problems_assignment_args:n {
\str_clear:N \l__problems_assign_id_str
\int_set:Nn \l__problems_assign_number_int {-1}
\tl_clear:N \l__problems_assign_title_tl
\tl_clear:N \l__problems_assign_type_tl
\tl_clear:N \l__problems_assign_given_tl
\tl_clear:N \l__problems_assign_due_tl
\bool_set_false:N \l__problems_assign_loadmodules_bool
\keys_set:nn { hwexam / assignment }{ #1 }
}
\newcommand\given@due[2]{
\bool_lazy_all:nF {
{\tl_if_empty_p:V \l__problems_inclassign_given_tl}
{\tl_if_empty_p:V \l__problems_assign_given_tl}
{\tl_if_empty_p:V \l__problems_inclassign_due_tl}
{\tl_if_empty_p:V \l__problems_assign_due_tl}
}{ #1 }
\tl_if_empty:NTF \l__problems_inclassign_given_tl {
\tl_if_empty:NF \l__problems_assign_given_tl {
\hwexam@given@kw\xspace\l__problems_assign_given_tl
}
}{
\hwexam@given@kw\xspace\l__problems_inclassign_given_tl
}
\bool_lazy_or:nnF {
\bool_lazy_and_p:nn {
\tl_if_empty_p:V \l__problems_inclassign_due_tl
}{
\tl_if_empty_p:V \l__problems_assign_due_tl
}
}{
\bool_lazy_and_p:nn {
\tl_if_empty_p:V \l__problems_inclassign_due_tl
}{
\tl_if_empty_p:V \l__problems_assign_due_tl
}
}{ ,~ }
\tl_if_empty:NTF \l__problems_inclassign_due_tl {
\tl_if_empty:NF \l__problems_assign_due_tl {
\hwexam@due@kw\xspace \l__problems_assign_due_tl
}
}{
\hwexam@due@kw\xspace \l__problems_inclassign_due_tl
}
\bool_lazy_all:nF {
{ \tl_if_empty_p:V \l__problems_inclassign_given_tl }
{ \tl_if_empty_p:V \l__problems_assign_given_tl }
{ \tl_if_empty_p:V \l__problems_inclassign_due_tl }
{ \tl_if_empty_p:V \l__problems_assign_due_tl }
}{ #2 }
}
\newcommand\assignment@title[3]{
\tl_if_empty:NTF \l__problems_inclassign_title_tl {
\tl_if_empty:NTF \l__problems_assign_title_tl {
#1
}{
#2\l__problems_assign_title_tl#3
}
}{
#2\l__problems_inclassign_title_tl#3
}
}
\newcommand\assignment@number{
\int_compare:nNnTF \l__problems_inclassign_number_int = {-1} {
\int_compare:nNnTF \l__problems_assign_number_int = {-1} {
\arabic{assignment}
} {
\int_use:N \l__problems_assign_number_int
}
}{
\int_use:N \l__problems_inclassign_number_int
}
}
\newenvironment{assignment}[1][]{
\__problems_assignment_args:n { #1 }
\int_compare:nNnTF \l__problems_assign_number_int = {-1} {
\global\stepcounter{assignment}
}{
\global\setcounter{assignment}{\int_use:N\l__problems_assign_number_int}
}
\setcounter{sproblem}{0}
\renewcommand\prob@label[1]{\assignment@number.##1}
\def\current@section@level{\document@hwexamtype}
\begin{@assignment}
}{
\end{@assignment}
}
\def\ass@title{
{\protect\document@hwexamtype}~\arabic{assignment}
\assignment@title{}{\;(}{)\;} -- \given@due{}{}
}
\ifmultiple
\newenvironment{@assignment}{
\bool_if:NTF \l__problems_assign_loadmodules_bool {
\begin{sfragment}[loadmodules]{\ass@title}
}{
\begin{sfragment}{\ass@title}
}
}{
\end{sfragment}
}
\else
\newenvironment{@assignment}{
\begin{center}\bf
\Large\@title\strut\\
\document@hwexamtype~\arabic{assignment}\assignment@title{\;}{:\;}{\\}
\large\given@due{--\;}{\;--}
\end{center}
}{}
\fi% multiple
\keys_define:nn { hwexam / inclassignment } {
number .int_set:N = \l__problems_inclassign_number_int,
title .tl_set:N = \l__problems_inclassign_title_tl,
type .tl_set:N = \l__problems_inclassign_type_tl,
given .tl_set:N = \l__problems_inclassign_given_tl,
due .tl_set:N = \l__problems_inclassign_due_tl,
mhrepos .str_set_x:N = \l__problems_inclassign_mhrepos_str
}
\cs_new_protected:Nn \__problems_inclassignment_args:n {
\int_set:Nn \l__problems_inclassign_number_int {-1}
\tl_clear:N \l__problems_inclassign_title_tl
\tl_clear:N \l__problems_inclassign_type_tl
\tl_clear:N \l__problems_inclassign_given_tl
\tl_clear:N \l__problems_inclassign_due_tl
\str_clear:N \l__problems_inclassign_mhrepos_str
\keys_set:nn { hwexam / inclassignment }{ #1 }
}
\__problems_inclassignment_args:n {}
\newcommand\inputassignment[2][]{
\__problems_inclassignment_args:n { #1 }
\str_if_empty:NTF \l__problems_inclassign_mhrepos_str {
\input{#2}
}{
\stex_in_repository:nn{\l__problems_inclassign_mhrepos_str}{
\input{\mhpath{\l__problems_inclassign_mhrepos_str}{#2}}
}
}
\__problems_inclassignment_args:n {}
}
\newcommand\includeassignment[2][]{
\newpage
\inputassignment[#1]{#2}
}
\ExplSyntaxOff
\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%
}
\ExplSyntaxOn
\def\hwexamheader{\input{hwexam-default.header}}
\def\hwexamminutes{
\tl_if_empty:NTF \testheading@duration {
{\testheading@min}~\hwexam@minutes@kw
}{
\testheading@duration
}
}
\keys_define:nn { hwexam / testheading } {
min .tl_set:N = \testheading@min,
duration .tl_set:N = \testheading@duration,
reqpts .tl_set:N = \testheading@reqpts,
tools .tl_set:N = \testheading@tools
}
\cs_new_protected:Nn \__problems_testheading_args:n {
\tl_clear:N \testheading@min
\tl_clear:N \testheading@duration
\tl_clear:N \testheading@reqpts
\tl_clear:N \testheading@tools
\keys_set:nn { hwexam / testheading }{ #1 }
}
\newenvironment{testheading}[1][]{
\__problems_testheading_args:n{ #1 }
\newcount\check@time\check@time=\testheading@min
\advance\check@time by -\theassignment@totalmin
\newif\if@bonuspoints
\tl_if_empty:NTF \testheading@reqpts {
\@bonuspointsfalse
}{
\newcount\bonus@pts
\bonus@pts=\theassignment@totalpts
\advance\bonus@pts by -\testheading@reqpts
\edef\bonus@pts{\the\bonus@pts}
\@bonuspointstrue
}
\edef\check@time{\the\check@time}
\makeatletter\hwexamheader\makeatother
}{
\newpage
}
\renewcommand\@problem[3]{
\stepcounter{assignment@probs}
\def\__problemspts{#2}
\ifx\__problemspts\@empty\else
\addtocounter{assignment@totalpts}{#2}
\fi
\def\__problemsmin{#3}\ifx\__problemsmin\@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}
\stepcounter{assignment@probs}
\newcommand\correction@table{
\resizebox{\textwidth}{!}{%
\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}}}
\endinput
%%
%% End of file `hwexam.sty'.
|