summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/exam-lite/exam-lite.cls
blob: 3d9344caa1a0b65fb8da171a5da6cb018f4e5235 (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
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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
% Author: Rok Kukovec and Iztok Fister Jr.
% CC-BY-SA-4.0 license 

\NeedsTeXFormat{LaTeX2e}
\ProvidesClass{exam-lite}[2023/02/06 Very simple 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} 
\RequirePackage{totcount}


% global class options
%--------------------------------------------------------------------------------------------------------------
\DeclareOption*{\PassOptionsToClass{\CurrentOption}{article}}

% Path to logo image
\def\ImagePath#1{\def\@ImagePath{#1}}
\newcommand{\pImagePath}{\@ImagePath}

% Language of the exam
\def\examlanguage#1{\def\@examlanguage{#1}}
\newcommand{\pexamlanguage}{\@examlanguage}

% Name of the subject
\def\subject#1{\def\@subject{#1}}
\newcommand{\psubject}{\@subject}

% Academic year
\def\academicyear#1{\def\@academicyear{#1}}
\newcommand{\pacademicyear}{\@academicyear}

% Date of the exam
\def\examdate#1{\def\@examdate{#1}}
\newcommand{\pexamdate}{\@examdate}

% Study program
\def\studyprogram#1{\def\@studyprogram{#1}}
\newcommand{\pstudyprogram}{\@studyprogram}

% Location of the exam (usually classroom label)
\def\location#1{\def\@location{#1}}
\newcommand{\plocation}{\@location}

% Exam period
\def\examperiod#1{\def\@examperiod{#1}}
\newcommand{\pexamperiod}{\@examperiod}

% Exam period, usually number (one subject has one or more exams)
\def\examid#1{\def\@examid{#1}}
\newcommand{\pexamid}{\@examid}

% Subacronym of the subject
\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  of the student
\def\studentid#1{\def\@studentid{#1}}
\newcommand{\pstudentid}{\@studentid}

% Instructions
\def\instructions#1{\def\@instructions{#1}}
\newcommand{\pinstructions}{\@instructions}

% Question (translation)
\def\questiontext#1{\def\@questiontext{#1}}
\newcommand{\pquestiontext}{\@questiontext}

% Question (translation)
\def\pointstext#1{\def\@pointstext{#1}}
\newcommand{\ppointstext}{\@pointstext}

% Points (translation)
\def\points#1{\def\@points{#1}}
\newcommand{\ppoints}{\@points}

\def\instructionstext#1{\def\@instructionstext{#1}}
\newcommand{\pinstructionstext}{\@instructionstext}

\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
}
% language of the 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{VMESNI IZPIT}\fi
    \if\examtype1\examperiod{Vmesni izpit: }\fi
    \if\examtype2\examperiod{Izpitni rok: }\fi
    \namesurname{Ime in Priimek:}
    \studentid{ID Študenta:}
    \instructions{NAVODILA}
    \questiontext{Vpra\v{s}anje}
    \pointstext{to\v{c}k}
    \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=5cm, height=4cm, keepaspectratio]{\pImagePath}}}
            % 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: \pstudyprogram \\
			   \pexamperiod \pexamid \\
			   Prostor: \plocation \\
			   Datum: \displaydate{examdate}}}
      
\newcommand{\@Conjugation}{Unknown}
\newcommand{\Conjugation}[1]{\renewcommand{\@Conjugation}{#1}}
\newcommand{\Apply@Conjugation}{%
    \begingroup
        \long\def\@one{1}\long\def\@two{2}\long\def\@three{3}\long\def\@four{4}%
            \ifx\@Conjugation\@one 
                a)%
            \else
            \ifx\@Conjugation\@two
                i)%
            \else
            \ifx\@Conjugation\@three
                e)%
           \else
           \ifx\@Conjugation\@four
                e)% Due to only 1 "all-"else option - this entry is duplicated
            \else
                )%
            \fi
            \fi
            \fi
            \fi
    \endgroup
    }
}
%-----------------------------------------------------------
% 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}
    \questiontext{Question}
    \pointstext{point}
    \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=6cm, height=3.5cm, keepaspectratio]{\pImagePath}}}
          % 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: \pstudyprogram \\
			   \pexamperiod \pexamid \\
			   Place: \plocation \\
			   Date: \displaydate{examdate}}}

\newcommand{\@Conjugation}{Unknown}
\newcommand{\Conjugation}[1]{\renewcommand{\@Conjugation}{#1}}
\newcommand{\Apply@Conjugation}{%
    \begingroup
        \long\def\@one{1}%
            \ifx\@Conjugation\@one 
                )%
            \else
                s)%
            \fi
    \endgroup
    }
      
}
\newtotcounter{sum_pts}
%-----------------------------------------------------------
% Process options
%-----------------------------------------------------------
\ProcessOptions\relax
% Load class
\LoadClass[a4paper,onecolumn]{article}
%--------------------------------------------------------------------------------------------------------------
% Set page 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}
%-----------------------------------------------------------
% First page
%-----------------------------------------------------------
\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}
    \pinstructionstext
}
%-----------------------------------------------------------
% Header of all pages but first
%-----------------------------------------------------------
\newcommand{\makenextheaders}{
    \newpage % put question in a new page
    \lhead{\displaydate{examdate}}
    \rhead{\pacademicyear}
    \chead{{\large\psubject}}
    % space between head and first question (text)
    \setlength{\headsep}{0.4in}
    \cfoot{\thepage}
    \setlength{\footskip}{30pt}
}
%-----------------------------------------------------------
% Commands for questions
%-----------------------------------------------------------

% Question counter command - Question i
\newcommand{\qncounter}[1]{\paragraph{\underline{\pquestiontext{ #1}}}\hfill\\\vspace{2mm}\\}

% Basic Question command - #1 What is ...? #2 No. pts #3 vspace in cm (points next to question)
\newcommand{\question}[3]{{\parbox{14cm}{#1}} {\Conjugation{#2} \addtocounter{sum_pts}{#2}\hfill\textsc{(#2~\ppointstext\Apply@Conjugation}}{\vspace{#3 cm}}}

% Long Question command - #1 What is ...? #2 No. pts #3 vspace in cm (points under question)
\newcommand{\longquestion}[3]{{\parbox{16.5cm}{#1}} {\Conjugation{#2} \addtocounter{sum_pts}{#2}\hfill\\\hspace*{\fill}\textsc{(#2~\ppointstext\Apply@Conjugation}}{\vspace{#3 cm}}}

% Alinea command - \item #1 What is ...? #2 No. pts #3 vspace in cm
\newcommand{\alinea}[3]{\item \!\!)\:{\parbox{12cm}{#1}} {\Conjugation{#2} \addtocounter{sum_pts}{#2}\hfill\textsc{(#2~\ppointstext\Apply@Conjugation}{\vspace{#3 cm}}}}