forked from firefly-cpp/exam-lite-latex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathiexam.cls
278 lines (225 loc) · 8.44 KB
/
iexam.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
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
\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{iexam}[2022/11/17 Latex template for exams]
% include dependencies
%-----------------------------------------------------------
\RequirePackage{babel}
\RequirePackage{graphicx}
\RequirePackage{fancyhdr}
\RequirePackage[skip=10pt plus1pt, indent=40pt]{parskip}
\RequirePackage[T1]{fontenc}
\RequirePackage[utf8]{inputenc}
\RequirePackage{framed}
\RequirePackage{lipsum}
\RequirePackage{datetime}
\RequirePackage{enumerate} % http://ctan.org/pkg/enumerate
\RequirePackage{totcount}
% global class options
%--------------------------------------------------------------------------------------------------------------
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}
\def\examlanguage#1{\def\@examlanguage{#1}}
\newcommand{\pexamlanguage}{\@examlanguage}
\def\subject#1{\def\@subject{#1}}
\newcommand{\psubject}{\@subject}
\def\academicyear#1{\def\@academicyear{#1}}
\newcommand{\pacademicyear}{\@academicyear}
\def\examdate#1{\def\@examdate{#1}}
\newcommand{\pexamdate}{\@examdate}
\def\programme#1{\def\@programme{#1}}
\newcommand{\pprogramme}{\@programme}
\def\location#1{\def\@location{#1}}
\newcommand{\plocation}{\@location}
\def\examid#1{\def\@examid{#1}}
\newcommand{\pexamid}{\@examid}
\def\subacronym#1{\def\@subacronym{#1}}
\newcommand{\psubacronym}{\@subacronym}
% Name and Surname of the student
\def\namesurname#1{\def\@namesurname{#1}}
\newcommand{\pnamesurname}{\@namesurname}
% ID Student
\def\studentid#1{\def\@studentid{#1}}
\newcommand{\pstudentid}{\@studentid}
\def\examperiod#1{\def\@examperiod{#1}}
\newcommand{\pexamperiod}{\@examperiod}
\def\instructions#1{\def\@instructions{#1}}
\newcommand{\pinstructions}{\@instructions}
\def\questioneng#1{\def\@questioneng{#1}}
\newcommand{\pquestioneng}{\@questioneng}
\questioneng{Question}
\def\questionslo#1{\def\@questionslo{#1}}
\newcommand{\pquestionslo}{\@questionslo}
\questionslo{Vpra\v{s}anje}
\def\questiontext#1{\def\@questiontext{#1}}
\newcommand{\pquestiontext}{\@questiontext}
\def\pointseng#1{\def\@pointseng{#1}}
\newcommand{\ppointseng}{\@pointseng}
\pointseng{point}
\def\pointsslo#1{\def\@pointsslo{#1}}
\newcommand{\ppointsslo}{\@pointsslo}
\pointsslo{to\v{c}k}
\def\pointstext#1{\def\@pointstext{#1}}
\newcommand{\ppointstext}{\@pointstext}
\def\instructionsslo#1{\def\@instructionsslo{#1}}
\newcommand{\pinstructionsslo}{\@instructionsslo}
\instructionsslo{
\begin{enumerate}
\item Izpit je sestavljen iz 10 vprašanj.\\
\item Uporaba kalkulatorja ni dovoljena. \\
\item Zapišite le tisto, kar zahteva vprašanje. \\
\item Napačni odgovori ne prinašajo minus točk. \\
\end{enumerate}
}
\def\instructionsang#1{\def\@instructionsang{#1}}
\newcommand{\pinstructionsang}{\@instructionsang}
\instructionsang{
\begin{enumerate}
\item The exam consists of 10 questions.\\
\item The use of a calculator is not allowed.\\
\item Write only what the question asks for.\\
\item You do not get minus points for wrong answers.\\
\end{enumerate}
}
\def\instructionslang#1{\def\@instructionslang{#1}}
\newcommand{\pinstructionslang}{\@instructionslang}
\def\sumpts#1{\def\@sumpts{#1}}
\newcommand{\psumpts}{\@sumpts}
\def\writingtime#1{\def\@writingtime{#1}}
\newcommand{\pwritingtime}{\@writingtime}
\def\writingtimeminutes#1{\def\@writingtimeminutes{#1}}
\newcommand{\pwritingtimeminutes}{\@writingtimeminutes}
\def\grade#1{\def\@grade{#1}}
\newcommand{\pgrade}{\@grade}
% use declared options
%-----------------------------------------------------------
% language of the exam
\DeclareOption{exam}{%
\def\examtype{1} % 1: izpit-exam, 2: kolokvij-midterm
}
\DeclareOption{midterm}{%
\def\examtype{2} % 1: izpit-exam, 2: kolokvij-midterm
}
\def\typeexam#1{\def\@typeexam{#1}}
\newcommand{\ptypeexam}{\@typeexam}
\def\aboutexamheader#1{\def\@aboutexamheader{#1}}
\newcommand{\paboutexamheader}{\@aboutexamheader}
% slovene version
%-----------------------------------------------------------
\DeclareOption{slovene}{%
\if\examtype1\typeexam{IZPIT}\fi
\if\examtype2\typeexam{KOLOKVIJ}\fi
\if\examtype1\examperiod{Kolokvij: }\fi
\if\examtype2\examperiod{Izpitni rok: }\fi
\namesurname{Ime in Priimek:}
\studentid{ID Študenta:}
\instructions{NAVODILA}
\instructionslang{\pinstructionsslo}
\questiontext{\pquestionslo}
\pointstext{\ppointsslo}
\sumpts{Število točk: }
\writingtime{Čas pisanja: }
\grade{Ocena: }
% define a command for the logo of institution and exam information
\newcommand{\aboutexam}[1]{
\noindent
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\pagestyle{fancy}
\fancyhf{}
% show logo of author's institution on the left side
\fancyhead[L]{\raisebox{\dimexpr-\height+\baselineskip}[0pt][0pt]{\includegraphics[width=2.2in]{imgs/um-logo.png}}}
% show exam information on right side
\fancyhead[R]{\leavevmode\large
\begin{tabular}[t]{l@{}}
#1
\end{tabular}}
\vspace*{3\baselineskip}
}
\aboutexamheader{\aboutexam{Predmet: \psubject \\
Študijsko leto: \pacademicyear \\
Študijski program: \pprogramme \\
\pexamperiod \pexamid \\
Prostor: \plocation \\
Datum: \displaydate{examdate}}}
}
% english version
%-----------------------------------------------------------
\DeclareOption{english}{%
\if\examtype1\typeexam{EXAM}\fi
\if\examtype2\typeexam{MIDTERM}\fi
\if\examtype1\examperiod{Exam period: }\fi
\if\examtype2\examperiod{Midterm: }\fi
\namesurname{Name and Surname:}
\studentid{Student ID:}
\instructions{INSTRUCTIONS}
\instructionslang{\pinstructionsang}
\questiontext{\pquestioneng}
\pointstext{\ppointseng}
\sumpts{Number of points: }
\writingtime{Writing time: }
\grade{Grade: }
% define a command for the logo of institution and exam information
\newcommand{\aboutexam}[1]{
\noindent
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
\pagestyle{fancy}
\fancyhf{}
% show logo of author's institution on the left side
\fancyhead[L]{\raisebox{\dimexpr-\height+\baselineskip}[0pt][0pt]{\includegraphics[width=2.2in]{imgs/logo-um-feri-ang.png}}}
% show exam information on right side
\fancyhead[R]{\leavevmode\large
\begin{tabular}[t]{l@{}}
#1
\end{tabular}}
\vspace*{3\baselineskip}
}
\aboutexamheader{\aboutexam{Subject: \psubject \\
Study year: \pacademicyear \\
Study program: \pprogramme \\
\pexamperiod \pexamid \\
Place: \plocation \\
Date: \displaydate{examdate}}}
}
\newtotcounter{sum_pts}
% process options
%-----------------------------------------------------------
\ProcessOptions\relax
% load class
\LoadClass[a4paper,onecolumn]{article}
%--------------------------------------------------------------------------------------------------------------
% set margins
\addtolength{\oddsidemargin}{-.800in}
\addtolength{\evensidemargin}{-.800in}
\addtolength{\textwidth}{1.75in}
\addtolength{\topmargin}{-.800in}
\addtolength{\textheight}{1.75in}
\setlength{\headheight}{12.05pt}
% set a little indendation for paragraphs
\setlength{\parindent}{0.1em}
% space between paragraphs
\setlength{\parskip}{1em}
\newcommand{\makefirstpage}{
\large
\paboutexamheader
\noindent\makebox[\linewidth]{\rule{0.9\paperwidth}{0.4pt}}
\psumpts\:\:\:\:\:\:\:/\total{sum_pts} \hfill \pwritingtime \pwritingtimeminutes min
\vspace{-1.2cm}
\begin{center}\textbf{{\LARGE\ptypeexam}}\end{center}
\vspace{1cm}
\pnamesurname\hrulefill
\vspace{0.5cm}
\pstudentid\hrulefill
\vspace{0.5cm}
\pgrade\hrulefill
\vspace*{4\baselineskip}
\noindent\underline{\pinstructions}
\vspace{5mm}
\pinstructionslang
}
% question command - Question i
\newcommand{\qncounter}[1]{\paragraph{\underline{\pquestiontext{ #1}}}\hfill\\\vspace{2mm}\\}
% question command - #1 What is ...? #2 No. pts #3 conjugation #4 vspace in cm
\newcommand{\question}[4]{{\parbox{14cm}{#1}} {\addtocounter{sum_pts}{#2}\hfill(#2~\ppointstext#3)}{\vspace{#4 cm}}}
% alinea command - \item #1 What is ...? #2 No. pts #3 conjugation #4 vspace in cm
\newcommand{\alinea}[4]{\item \!\!)\:{\parbox{12cm}{#1}} {\addtocounter{sum_pts}{#2}\hfill(#2~\ppointstext#3)}{\vspace{#4 cm}}}