%% %% This is file `hwexam.sty', %% generated with the docstrip utility. %% %% The original source files were: %% %% hwexam.dtx (with options: `package') %% \ProvidesExplPackage{hwexam}{2022/02/26}{3.0.1}{homework assignments and exams} \RequirePackage{l3keys2e} \newif\iftest\testfalse \DeclareOption{test}{\testtrue} \newif\ifmultiple\multiplefalse \DeclareOption{multiple}{\multipletrue} \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} \def\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} \clist_if_in:NnT \l_tmpa_clist {ngerman}{ \input{hwexam-ngerman.ldf} } \clist_if_in:NnT \l_tmpa_clist {finnish}{ \input{hwexam-finnish.ldf} } \clist_if_in:NnT \l_tmpa_clist {french}{ \input{hwexam-french.ldf} } \clist_if_in:NnT \l_tmpa_clist {russian}{ \input{hwexam-russian.ldf} } \makeatother }{} } \newcounter{assignment} \numberproblemsin{assignment} \renewcommand\prob@label[1]{\assignment@number.#1} \keys_define:nn { hwexam / assignment } { id .str_set_x:N = \l__hwexam_assign_id_str, number .int_set:N = \l__hwexam_assign_number_int, title .tl_set:N = \l__hwexam_assign_title_tl, type .tl_set:N = \l__hwexam_assign_type_tl, given .tl_set:N = \l__hwexam_assign_given_tl, due .tl_set:N = \l__hwexam_assign_due_tl, loadmodules .code:n = { \bool_set_true:N \l__hwexam_assign_loadmodules_bool } } \cs_new_protected:Nn \__hwexam_assignment_args:n { \str_clear:N \l__hwexam_assign_id_str \int_set:Nn \l__hwexam_assign_number_int {-1} \tl_clear:N \l__hwexam_assign_title_tl \tl_clear:N \l__hwexam_assign_type_tl \tl_clear:N \l__hwexam_assign_given_tl \tl_clear:N \l__hwexam_assign_due_tl \bool_set_false:N \l__hwexam_assign_loadmodules_bool \keys_set:nn { hwexam / assignment }{ #1 } } \newcommand\given@due[2]{ \bool_lazy_all:nF { {\tl_if_empty_p:V \l__hwexam_inclassign_given_tl} {\tl_if_empty_p:V \l__hwexam_assign_given_tl} {\tl_if_empty_p:V \l__hwexam_inclassign_due_tl} {\tl_if_empty_p:V \l__hwexam_assign_due_tl} }{ #1 } \tl_if_empty:NTF \l__hwexam_inclassign_given_tl { \tl_if_empty:NF \l__hwexam_assign_given_tl { \hwexam@given@kw\xspace\l__hwexam_assign_given_tl } }{ \hwexam@given@kw\xspace\l__hwexam_inclassign_given_tl } \bool_lazy_or:nnF { \bool_lazy_and_p:nn { \tl_if_empty_p:V \l__hwexam_inclassign_due_tl }{ \tl_if_empty_p:V \l__hwexam_assign_due_tl } }{ \bool_lazy_and_p:nn { \tl_if_empty_p:V \l__hwexam_inclassign_due_tl }{ \tl_if_empty_p:V \l__hwexam_assign_due_tl } }{ ,~ } \tl_if_empty:NTF \l__hwexam_inclassign_due_tl { \tl_if_empty:NF \l__hwexam_assign_due_tl { \hwexam@due@kw\xspace \l__hwexam_assign_due_tl } }{ \hwexam@due@kw\xspace \l__hwexam_inclassign_due_tl } \bool_lazy_all:nF { { \tl_if_empty_p:V \l__hwexam_inclassign_given_tl } { \tl_if_empty_p:V \l__hwexam_assign_given_tl } { \tl_if_empty_p:V \l__hwexam_inclassign_due_tl } { \tl_if_empty_p:V \l__hwexam_assign_due_tl } }{ #2 } } \newcommand\assignment@title[3]{ \tl_if_empty:NTF \l__hwexam_inclassign_title_tl { \tl_if_empty:NTF \l__hwexam_assign_title_tl { #1 }{ #2\l__hwexam_assign_title_tl#3 } }{ #2\l__hwexam_inclassign_title_tl#3 } } \newcommand\assignment@number{ \int_compare:nNnTF \l__hwexam_inclassign_number_int = {-1} { \int_compare:nNnTF \l__hwexam_assign_number_int = {-1} { \arabic{assignment} } { \int_use:N \l__hwexam_assign_number_int } }{ \int_use:N \l__hwexam_inclassign_number_int } } \newenvironment{assignment}[1][]{ \__hwexam_assignment_args:n { #1 } \int_compare:nNnTF \l__hwexam_assign_number_int = {-1} { \global\stepcounter{assignment} }{ \global\setcounter{assignment}{\int_use:N\l__hwexam_assign_number_int} } \setcounter{problem}{0} \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__hwexam_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__hwexam_inclassign_number_int, title .tl_set:N = \l__hwexam_inclassign_title_tl, type .tl_set:N = \l__hwexam_inclassign_type_tl, given .tl_set:N = \l__hwexam_inclassign_given_tl, due .tl_set:N = \l__hwexam_inclassign_due_tl, mhrepos .str_set_x:N = \l__hwexam_inclassign_mhrepos_str } \cs_new_protected:Nn \__hwexam_inclassignment_args:n { \int_set:Nn \l__hwexam_inclassign_number_int {-1} \tl_clear:N \l__hwexam_inclassign_title_tl \tl_clear:N \l__hwexam_inclassign_type_tl \tl_clear:N \l__hwexam_inclassign_given_tl \tl_clear:N \l__hwexam_inclassign_due_tl \str_clear:N \l__hwexam_inclassign_mhrepos_str \keys_set:nn { hwexam / inclassignment }{ #1 } } \__hwexam_inclassignment_args:n {} \newcommand\inputassignment[2][]{ \__hwexam_inclassignment_args:n { #1 } \str_if_empty:NTF \l__hwexam_inclassign_mhrepos_str { \input{#2} }{ \stex_in_repository:nn{\l__hwexam_inclassign_mhrepos_str}{ \input{\mhpath{\l__hwexam_inclassign_mhrepos_str}{#2}} } } \__hwexam_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 \__hwexam_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][]{ \__hwexam_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 } \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\__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'.