-
Notifications
You must be signed in to change notification settings - Fork 0
/
exsheetans.cls
98 lines (80 loc) · 3.81 KB
/
exsheetans.cls
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
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{exsheetans}[2015/04/14 Exercise sheet answer]
\LoadClass[11pt,oneside,a4paper]{scrartcl}
\newif\ifexsheetans@ngerman
\DeclareOption{ngerman}{
\exsheetans@ngermantrue
}
\ProcessOptions\relax
\RequirePackage{xfp}
\RequirePackage[headsepline, footsepline]{scrlayer-scrpage}
\raggedbottom
\RequirePackage{geometry}
\RequirePackage{enumitem}
\RequirePackage{ifthen}
% init score
\edef\@totalscore{0}
\edef\@calcscore{0}
\edef\@savedscore{0}
% page formatting
\geometry{a4paper, top=30mm, left=20mm, right=10mm, bottom=30mm, headsep=10mm, footskip=10mm, head=30pt}
\KOMAoption{parskip}{half-}
\pagestyle{scrheadings}
% page header and footer
\clearpairofpagestyles
\ihead{\textsc{\stringsheet{} \arabic{sheet}}\\\textsc{\thegroup}}
\chead{\textsc{\thecourse\\\thesemester}}
\ohead{\textsc{\stringpage{} \pagemark}\\%
\ifthenelse{\equal{\@totalscore}{0}}{%
\ifthenelse{\equal{\@savedscore}{0}}{}{%
\textsc{\stringtotal{}} $\underline{\qquad}\,$\textbf{/\@savedscore\,\stringpoints}}
}{%
\textsc{\stringtotal{}} $\underline{\qquad}\,$\textbf{/\@totalscore\,\stringpoints}%
}}
\cfoot{\textsc{\@author}}
\ofoot{\textsc{}}
\KOMAoption{cleardoublepage}{scrheadings}
% Counter der den Namen des Blatt festlegt
\newcounter{sheet}
%\newcounter{totalscore}
%\newtotcounter{totalscorecalc}
\newcounter{canswer}[sheet]
\newcounter{csubanswer}[canswer]
\newenvironment{quiz}[1][]{\begin{addmargin}[0.5cm]{0.5cm}\noindent\textbf{\stringquizanswer{} #1}\begin{enumerate}[label=\textbf{\arabic*.}]}{\end{enumerate}\vspace{5mm}\end{addmargin}}
\newenvironment{answer}[2][]{\stepcounter{canswer}\begin{addmargin}[0.5cm]{0.5cm}\noindent\textbf{\stringanswer{} \arabic{sheet}.\arabic{canswer} \ifx&%
\else{[#2]}\fi}\ifx&%
\else{\global\edef\@calcscore{\fpeval{\@calcscore+#1}}\protected@write\@auxout{}{\gdef\protect\@savedscore{\@calcscore}}\hfill $\underline{\quad}\,$\textbf{/#1 \stringpoints}}\fi\\}{\end{addmargin}\vspace{5mm}
}
\newenvironment{supplement}[2][]{\begin{addmargin}[0.5cm]{0.5cm}\noindent\textbf{\stringsupplementanswer{} [#2]}%
\ifx&%
\else{\global\edef\@calcscore{\fpeval{\@calcscore+#1}}\protected@write\@auxout{}{\gdef\protect\@savedscore{\@calcscore}}\hfill $\underline{\quad}\,$\textbf{/#1 \stringpoints}}\fi\\}{\end{addmargin}}
\newenvironment{subanswers}[2][]{\stepcounter{canswer}\begin{addmargin}[0.5cm]{0.5cm}\noindent\textbf{\stringanswer{} \arabic{sheet}.\arabic{canswer} \ifx&%
\else{[#2]}\fi}\ifx&%
\else{\global\edef\@calcscore{\fpeval{\@calcscore+#1}}\protected@write\@auxout{}{\gdef\protect\@savedscore{\@calcscore}}\hfill $\underline{\quad}\,$\textbf{/#1 \stringpoints}}\fi
\begin{enumerate}[label=\textbf{\alph*)}]}{\end{enumerate}\vspace{5mm}\end{addmargin}}
\newcommand\stringsheet{Sheet}
\newcommand\stringpage{Page}
\newcommand\stringquizanswer{Quiz answers}
\newcommand\stringanswer{Answer}
\newcommand\stringpoints{Points}
\newcommand\stringtotal{$\sum$}
\newcommand\stringsupplementanswer{Supplement answer}
\newcommand\thegroup{}
\newcommand\thecourse{}
\newcommand\thesemester{}
\newcommand\theauthor{}
\newcommand\group[1]{\renewcommand\thegroup{#1}}
\newcommand\course[1]{\renewcommand\thecourse{#1}}
\newcommand\semester[1]{\renewcommand\thesemester{#1}}
\newcommand\sheet[1]{\setcounter{sheet}{#1}}
\newcommand\totalscore[1]{\edef\@totalscore{#1}}
\newcommand\setstringsheet[1]{\renewcommand\stringsheet{#1}}
\newcommand\setstringtotal[1]{\renewcommand\stringtotal{#1}}
\newcommand\setstringpage[1]{\renewcommand\stringpage{#1}}
\newcommand\setstringquizanswer[1]{\renewcommand\stringquizanswer{#1}}
\newcommand\setstringanswer[1]{\renewcommand\stringanswer{#1}}
\newcommand\setstringpoints[1]{\renewcommand\stringpoints{#1}}
\newcommand\setstringsupplementanswer[1]{\renewcommand\stringsupplementanswer{#1}}
\ifexsheetans@ngerman
\protect\RequirePackage{exsheetans-ngerman}
\fi