| 1 |
%----------------------------------------------------------------------------- |
| 2 |
% Copyright (C) 2004-2019 Andrew Mathas, University of Sydney |
| 3 |
% |
| 4 |
% Distributed under the terms of the GNU General Public License (GPL) |
| 5 |
% http://www.gnu.org/licenses/ |
| 6 |
% |
| 7 |
% This file is part of the WebQuiz system. |
| 8 |
% |
| 9 |
% <[email protected]> |
| 10 |
%----------------------------------------------------------------------------- |
| 11 |
|
| 12 |
\synctex=1 |
| 13 |
|
| 14 |
\PassOptionsToClass{tikz,svgnames}{xcolor} |
| 15 |
\documentclass[svgnames]{article} |
| 16 |
\usepackage[a4paper,margin=30mm]{geometry} |
| 17 |
\parindent=4mm |
| 18 |
\parskip=1mm |
| 19 |
\hfuzz 5pt |
| 20 |
\synctex=1 |
| 21 |
|
| 22 |
% load webquiz-ini and webquiz-doc code -- doc needs ini so ini is first |
| 23 |
\input{webquiz-ini.code} |
| 24 |
\input{webquiz-doc.code} |
| 25 |
|
| 26 |
% Can't use same definition in webquiz-online-manual because of conflict |
| 27 |
% with code in webquiz.cfg to make color work with listings |
| 28 |
\newcommand\WebQuiz{\textcolor{Sienna}{WebQuiz}\xspace} |
| 29 |
|
| 30 |
\usepackage{textcomp} |
| 31 |
\usepackage{pdfpages} |
| 32 |
\usepackage{manfnt} |
| 33 |
\usepackage{booktabs} |
| 34 |
\usepackage{bbding} |
| 35 |
\usepackage{pifont} |
| 36 |
\usepackage{pgffor} |
| 37 |
|
| 38 |
\usepackage{etoolbox}% used below to patch l@section to remove extraneous spacing |
| 39 |
\usepackage{appendix} |
| 40 |
\def\sectionautorefname{Chapter} |
| 41 |
\def\subsectionautorefname{Section} |
| 42 |
\def\subsubsectionautorefname{\S\kern-0.8ex} |
| 43 |
\def\appendixautorefname{Appendix} |
| 44 |
|
| 45 |
\usepackage{imakeidx} |
| 46 |
\indexsetup{level=\section*,toclevel=section,noclearpage} |
| 47 |
\makeindex[intoc,columns=3] |
| 48 |
|
| 49 |
\newenvironment{heading}[1][] |
| 50 |
{\noindent\trivlist\item[\hskip\labelsep\textbf{#1}]} |
| 51 |
{\endtrivlist} |
| 52 |
|
| 53 |
\newenvironment{dangerous}{\trivlist\item[\hskip\labelsep\textcolor{red}{\textdbend}]}{\endtrivlist} |
| 54 |
|
| 55 |
\setcounter{secnumdepth}{3} |
| 56 |
\setcounter{tocdepth}{3} |
| 57 |
\renewcommand\thesubsubsection{\thesubsection\alph{subsubsection}} |
| 58 |
\newcommand\lowerCaseIndex[1]{% |
| 59 |
\lowercase{\def\temp{#1}}% |
| 60 |
\expandafter\index\expandafter{\temp@#1}% |
| 61 |
} |
| 62 |
% usage: \CrossIndex[*]{main entry}[*]{subentry} with *'s for macros |
| 63 |
\NewDocumentCommand\CrossIndex{ smsm }{% |
| 64 |
\IfBooleanTF{#1}{% |
| 65 |
\lowercase{\def\tempa{#2}}% |
| 66 |
\xdef\tempa{\tempa@\noexpand\textbackslash#2}% |
| 67 |
}{\def\tempa{#2}}% |
| 68 |
\IfBooleanTF{#3}{% |
| 69 |
\lowercase{\def\tempb{#4}}% |
| 70 |
\xdef\tempb{\tempb@\noexpand\textbackslash#4}% |
| 71 |
}{\def\tempb{#4}}% |
| 72 |
\expandafter\index\expandafter{\tempa!\tempb}% |
| 73 |
\expandafter\index\expandafter{\tempb}% |
| 74 |
} |
| 75 |
\newcommand\macroIndex[1]{% |
| 76 |
\lowercase{\def\temp{#1}}% |
| 77 |
\expandafter\index\expandafter{\temp@\textbackslash#1}% |
| 78 |
} |
| 79 |
\newcommand\gobbleone[1]{}% https://tex.stackexchange.com/questions/318472 |
| 80 |
\newcommand{\See}[2]{\unskip\emph{see } #1} |
| 81 |
\newcommand\SeeIndex[2]{\index{#1!zzzz@\protect\gobbleone|See{#2}}} |
| 82 |
|
| 83 |
\newif\ifCtan\Ctantrue % condition compilation for ctan distribution |
| 84 |
|
| 85 |
\renewcommand*\contentsname{\relax} |
| 86 |
|
| 87 |
% hyperref links to ctan |
| 88 |
\newcommand\TeXLive{\href{https://www.tug.org/texlive/}{\TeX Live}\xspace} |
| 89 |
\newcommand\Ctan{\ctan[]{ctan}\xspace} |
| 90 |
\newcommand\ddash{\texttt{\textemdash\textemdash}} |
| 91 |
\NewDocumentCommand\webquizrc{s}{\index{webquizrc}% |
| 92 |
\BashCode|webquizrc| file\IfBooleanF{#1}{ (\autoref{SS:rcfile})}\xspace% |
| 93 |
} |
| 94 |
\newcommand\MiKTeX{\href{https://miktex.org/}{MiK\TeX}\xspace} |
| 95 |
\NewDocumentCommand\OnlineManual{s}{% |
| 96 |
\href{http://www.maths.usyd.edu.au/u/mathas/WebQuiz/webquiz-online-manual.html}{Online manual}% |
| 97 |
\IfBooleanF{#1}{ (\hyperref[S:online]{Appendix~B})}\xspace% |
| 98 |
} |
| 99 |
|
| 100 |
\indexprologue{% |
| 101 |
\noindent\textit{This is an index only for the main \WebQuiz manual. |
| 102 |
It does not index the \OnlineManual.}} |
| 103 |
|
| 104 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 105 |
\input{webquiz.themes} % defines a comma separated list of themes \WebQuizThemes |
| 106 |
\newcommand\ListWebQuizThemes{% |
| 107 |
\begin{quote} |
| 108 |
\def\sep{} |
| 109 |
\foreach \theme in \WebQuizThemes {% |
| 110 |
\ifx\theme\empty\gdef\sep{ and }% |
| 111 |
\else\sep\index{theme!\theme}\theme\gdef\sep{, }% |
| 112 |
\fi |
| 113 |
} |
| 114 |
\end{quote} |
| 115 |
} |
| 116 |
\newcommand\ShowcaseThemes{% |
| 117 |
\foreach \theme in \WebQuizThemes { |
| 118 |
\ifx\theme\empty\relax% |
| 119 |
\else% |
| 120 |
\ScreenShot[0.75]{Example of the \textbf{\theme} theme}{theme-\theme}% |
| 121 |
\index{theme!\theme}% |
| 122 |
\fi |
| 123 |
} |
| 124 |
} |
| 125 |
|
| 126 |
\input{webquiz.languages} % defines a comma separated list of themes \WebQuizLanguages |
| 127 |
\newcommand\ListWebQuizLanguages{% |
| 128 |
\begin{quote} |
| 129 |
\def\sep{} |
| 130 |
\foreach \lang in \WebQuizLanguages {% |
| 131 |
\ifx\lang\empty\gdef\sep{ and }% |
| 132 |
\else\sep\index{language!\lang}\lang\gdef\sep{, }% |
| 133 |
\fi |
| 134 |
} |
| 135 |
\end{quote} |
| 136 |
} |
| 137 |
|
| 138 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 139 |
%% WebQuiz title box for front page |
| 140 |
\usepackage{tikz} |
| 141 |
\usetikzlibrary{shadows.blur} |
| 142 |
|
| 143 |
\definecolor{stone}{HTML}{E9E0D8} |
| 144 |
\tikzset{shadowed/.style={blur shadow={shadow blur steps=5}, |
| 145 |
top color=stone, |
| 146 |
bottom color=PapayaWhip, |
| 147 |
draw=SaddleBrown, |
| 148 |
shade, |
| 149 |
font=\normalfont\Huge\bfseries\scshape, |
| 150 |
rounded corners=8pt, |
| 151 |
}, |
| 152 |
boxes/.style={draw=Sienna, |
| 153 |
fill=Cornsilk, |
| 154 |
font=\sffamily\small, |
| 155 |
inner sep=5pt, |
| 156 |
rectangle, |
| 157 |
rounded corners=8pt, |
| 158 |
text=Brown, |
| 159 |
} |
| 160 |
} |
| 161 |
|
| 162 |
\def\WebQuizTitle{ |
| 163 |
\begin{tikzpicture}[remember picture,overlay] |
| 164 |
\node[yshift=-3cm] at (current page.north west) |
| 165 |
{\begin{tikzpicture}[remember picture, overlay] |
| 166 |
\draw[shadowed](30mm,0) rectangle node[Brown]{\WebQuiz} (\paperwidth-30mm,16mm); |
| 167 |
\node[Sienna,font=\normalfont\small\itshape] at (\paperwidth/2,2mm) |
| 168 |
{\small \webquiz{description}}; |
| 169 |
\node[anchor=west,boxes] at (4cm,0cm) {\webquiz{name}}; |
| 170 |
\node[anchor=east,boxes] at (\paperwidth-4cm,0) {Version \webquiz{version}}; |
| 171 |
\end{tikzpicture} |
| 172 |
}; |
| 173 |
\end{tikzpicture} |
| 174 |
} |
| 175 |
|
| 176 |
|
| 177 |
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |
| 178 |
|
| 179 |
%% headers and footers |
| 180 |
\makeatletter |
| 181 |
\def\ps@webquiz{ |
| 182 |
\ps@empty |
| 183 |
\def\@oddfoot{\tiny\WebQuiz\space -- version \webquiz{version}\hfill% |
| 184 |
\textsc{\ifodd\thepage The \WebQuiz manual\else \webquizheader\fi}\hfill\thepage} |
| 185 |
} |
| 186 |
% hijack section and subsectionmark for our headers |
| 187 |
\def\webquizheader{\WebQuiz} |
| 188 |
\def\sectionmark#1{\def\webquizheader{#1}} |
| 189 |
\def\subsectionmark#1{\def\webquizheader{#1}} |
| 190 |
\pagestyle{webquiz} |
| 191 |
\patchcmd\l@section{1.0em}{0.5em}{}{} |
| 192 |
\makeatother |
| 193 |
|
| 194 |
\begin{document} |
| 195 |
\hypersetup{pdftitle={WebQuiz manual}} |
| 196 |
|
| 197 |
\WebQuizTitle |
| 198 |
|
| 199 |
\begin{quote} |
| 200 |
\WebQuiz is a \LaTeX{} package for writing online quizzes. It allows |
| 201 |
the quiz author to concentrate on the content of quizzes, written |
| 202 |
in standard \LaTeX, unencumbered by the technicalities of \HTML and |
| 203 |
\Javascript. Online quizzes written using \WebQuiz can contain any |
| 204 |
material that can be written using \LaTeX, including text, |
| 205 |
mathematics, graphics and diagrams. |
| 206 |
\ScreenShot[0.68]{An example \WebQuiz web page}{quiz-page} |
| 207 |
\begin{center} |
| 208 |
\hfil |
| 209 |
\begin{minipage}{0.75\textwidth} |
| 210 |
\tableofcontents |
| 211 |
\end{minipage} |
| 212 |
\end{center} |
| 213 |
\end{quote} |
| 214 |
|
| 215 |
\newpage |
| 216 |
|
| 217 |
\section{Introduction} |
| 218 |
Online quizzes provide a good way to reinforce learning, especially |
| 219 |
because they can give ``interactive'' feedback to the |
| 220 |
students\footnote{Throughout this manual, ``student'' means any |
| 221 |
person taking the online quiz.\index{student}} based on the answers that they |
| 222 |
give. Unfortunately, in addition to writing the actual quiz content there |
| 223 |
are significant technical hurdles that need to be overcome when |
| 224 |
writing an online quiz -- and there are additional complications if |
| 225 |
the quiz involves mathematics or diagrams. |
| 226 |
|
| 227 |
\WebQuiz makes it possible to write online quizzes using \LaTeX, |
| 228 |
which is the typesetting language used by mathematicians who use |
| 229 |
\LaTeX\ to write their research papers, books and teaching |
| 230 |
materials. In principle, a \WebQuiz quiz can contain anything that |
| 231 |
can be typeset using \LaTeX. In practise, the \LaTeX\ is converted |
| 232 |
to \HTML using \TeXfht (and |
| 233 |
\ctan{make4ht}), so the |
| 234 |
quizzes can contain any \LaTeX commands that are understood by \TeX |
| 235 |
4ht, which is almost everything. In particular, it is possible to |
| 236 |
use graphics constructed using \ctan{pstricks} and |
| 237 |
\ctan{tikz}; see \autoref{SS:graphics}. |
| 238 |
|
| 239 |
\WebQuiz supports the following three types of questions: |
| 240 |
\begin{itemize} |
| 241 |
\item Multiple choice questions with a unique correct answer |
| 242 |
\item Multiple choice questions zero or more correct answers |
| 243 |
\item Questions with an answer that is supplied by the student. |
| 244 |
\end{itemize} |
| 245 |
Each time a student answers a question it is possible to give them |
| 246 |
feedback, reinforcing their learning when they answer correctly and |
| 247 |
giving them further hints when they are wrong. This allows the |
| 248 |
quiz author to give targeted feedback to the student based on their |
| 249 |
answer. |
| 250 |
|
| 251 |
The online quizzes constructed using \WebQuiz can, in principle, |
| 252 |
contain anything that can be typeset by \LaTeX. In particular, they |
| 253 |
do not need to contain mathematics. In fact, the quizzes do not even |
| 254 |
have to contain ``questions'' as it is possible for a \WebQuiz |
| 255 |
``quiz'' to contain only \LatexCode|discussion| environments that can |
| 256 |
be used to revise material, or to introduce new material, for the |
| 257 |
students; see \autoref{SS:discussion}. |
| 258 |
|
| 259 |
This introduction outlines how to use \WebQuiz, however, the |
| 260 |
impatient reader may want to skip ahead directly to the |
| 261 |
\autoref{S:documentclass}, where the \LaTeX\ commands used by |
| 262 |
\WebQuiz are described. |
| 263 |
|
| 264 |
The easiest way to explain how \WebQuiz works is by example. The |
| 265 |
following \LaTeX\ file defines a quiz with a single multiple choice |
| 266 |
question that has four possible answers, each of which has a |
| 267 |
customised feedback. Giving feedback to the students in each |
| 268 |
question is optional but the capability of being able to give |
| 269 |
students feedback on their answer is one of the main pedagogical |
| 270 |
advantages of online quizzes. |
| 271 |
|
| 272 |
\InputLatexCode{simple} |
| 273 |
|
| 274 |
Since this is a \LaTeX\ file it can be processed using |
| 275 |
\BashCode|pdflatex|, or \BashCode|latex|, to produce a readable and |
| 276 |
printable version of the quiz, which can be useful when |
| 277 |
proofreading. With the example above, the PDF version of the quiz looks |
| 278 |
like this: |
| 279 |
\ScreenShot[0.5]{Sample \BashCode|PDF| output}{simple-pdf} |
| 280 |
Of course, the real reason for using \WebQuiz is to create a |
| 281 |
web page for the quiz, which you do by processing the quiz using |
| 282 |
the \BashCode|webquiz| command )instead of, say |
| 283 |
\BashCode|pdflatex|). If you do this and open the resulting |
| 284 |
web page in your favourite browser, after selecting answer~(a), you |
| 285 |
will see a web page like this: |
| 286 |
\ScreenShot{Sample web page}{simple-html} |
| 287 |
The actual page that you see may be slightly different to |
| 288 |
this because the appearance of the web page depends partly on your |
| 289 |
choice of browser. |
| 290 |
|
| 291 |
By default, the online version of the quiz displays one question at |
| 292 |
a time, with the question buttons serving the dual purpose of |
| 293 |
navigation between questions and displaying how successful the |
| 294 |
student was in answering the question. The decorations on the |
| 295 |
question buttons indicate whether the question has been attempted |
| 296 |
and, if so, whether it was answered correctly or incorrectly on the |
| 297 |
first or subsequent attempts. One of the main points of \WebQuiz is |
| 298 |
that (optional) targeted feedback can be given to the student taking |
| 299 |
the quiz based on their answer. |
| 300 |
|
| 301 |
\subsection{What \WebQuiz does and does not do} |
| 302 |
|
| 303 |
\WebQuiz is a tool that makes it possible to write ``interactive'' |
| 304 |
online quizzes using \LaTeX{}. To use \WebQuiz you only need |
| 305 |
basic working knowledge of \LaTeX{}. In particular, no familiarity |
| 306 |
of the underlying \CSS, \HTML or \Javascript is required. |
| 307 |
|
| 308 |
\WebQuiz can be used to ask students a series of ``quiz'' |
| 309 |
questions. In addition, your online quiz web pages can contain |
| 310 |
course material using the \WebQuiz \LatexCode|discussion| |
| 311 |
environment; see \autoref{SS:discussion}. You can write \WebQuiz |
| 312 |
quizzes that only contain questions, and no |
| 313 |
\LatexCode|discussion|, quizzes that contain questions and |
| 314 |
\LatexCode|discussion|, and (pseudo) quizzes that contains only |
| 315 |
\LatexCode{discussion} and no quiz questions. |
| 316 |
|
| 317 |
By default, the online quizzes display one question (or |
| 318 |
\LatexCode|discussion| environment) at a time. It is also possible |
| 319 |
to display all of the quiz questions on a single web page |
| 320 |
(\autoref{SS:classOptions}). One of the key features of \WebQuiz is |
| 321 |
that you can give feedback to the students based on their answers. |
| 322 |
In this way you can give hints to the students to correct their |
| 323 |
mistakes and you can reinforce the students' understanding when they |
| 324 |
are correct. Each question in a quiz, and each quiz itself, can be |
| 325 |
attempted as many times as the student wants. \WebQuiz does not |
| 326 |
limit the number of times that questions can be attempted. |
| 327 |
|
| 328 |
As described in \autoref{SS:Questions}, \WebQuiz supports the following question types: |
| 329 |
\begin{itemize} |
| 330 |
\item Multiple choice questions with a unique correct answer |
| 331 |
\item Multiple choice questions zero or more correct answers |
| 332 |
\item Questions that require students to type in an answer. There |
| 333 |
are several different ``comparison'' methods available for |
| 334 |
comparing the students answer where |
| 335 |
for example, the entered answers can be a ``string'' or a ``number''. |
| 336 |
\end{itemize} |
| 337 |
|
| 338 |
Questions can appear in either the same order that they appear in |
| 339 |
the \LaTeX{} file for the quiz or in a random order that changes |
| 340 |
each time the quiz page is loaded. For multiple choice questions the |
| 341 |
order in which the choices appear is always the order that they |
| 342 |
appear in the \LaTeX{} file for the quiz, even if the questions |
| 343 |
appear in random order. |
| 344 |
|
| 345 |
\WebQuiz supports several different languages and it |
| 346 |
provides a number of different colour schemes (see |
| 347 |
\autoref{SS:commandline} and \hyperref[SS:themes]{Appendix A}). |
| 348 |
|
| 349 |
\WebQuiz quizzes are not timed and they do not have time-limits. |
| 350 |
|
| 351 |
Quizzes made using \WebQuiz are intended to be used as a |
| 352 |
revision resource rather than as an assessment tool. In particular, |
| 353 |
\WebQuiz does not provide a mechanism for recording the marks |
| 354 |
obtained by the students taking the quiz |
| 355 |
(\autoref{SS:classOptions}). Technically, it probably would not be |
| 356 |
very hard to record marks but this introduces a significant amount |
| 357 |
of extra overhead in terms of student authentication and interfacing |
| 358 |
with a database. In addition, if \WebQuiz were used as an assessment |
| 359 |
tool then there would be additional ``security issues'' to ensure |
| 360 |
that the quiz content is secure. Currently, even though the |
| 361 |
solutions to the quiz questions do not appear in the \HTML source |
| 362 |
code for the quiz pages it is possible to access the answers if you |
| 363 |
know what you are doing. |
| 364 |
|
| 365 |
The questions in a \WebQuiz quiz are static. In particular, |
| 366 |
\WebQuiz quiz questions do not accept variables. |
| 367 |
|
| 368 |
The \WebQuiz program was designed to be run from the command-line. |
| 369 |
To process the file \BashCode|quiz.tex| using \WebQuiz you would |
| 370 |
type |
| 371 |
\begin{bashcode} |
| 372 |
> webquiz quiz or > webquiz quiz.tex |
| 373 |
\end{bashcode} |
| 374 |
\index{$>$ command-line prompt}\index{command-line prompt!$>$} |
| 375 |
(Throughout this manual, \BashCode|>| is used for the command-line |
| 376 |
prompt.) |
| 377 |
|
| 378 |
It is possible to use \WebQuiz from inside editors like |
| 379 |
\TeX Shop, but exactly how this is done will depend on the program |
| 380 |
that you use. In the case of \TeX Shop you need to define a |
| 381 |
new \textit{engine} following, for example the instructions at |
| 382 |
\href{https://tex.stackexchange.com/questions/376649} |
| 383 |
{tex.stackexchange.com/questions/376649}. |
| 384 |
\index{TeXShop@\TeX Shop} |
| 385 |
|
| 386 |
\subsection{Credits} |
| 387 |
\WebQuiz{} was written and developed in the |
| 388 |
\href{http://www.maths.usyd.edu.au/}{School of Mathematics and |
| 389 |
Statistics} at the \href{http://www.usyd.edu.au/}{University of |
| 390 |
Sydney}. The system is built on \LaTeX{} with the conversion from |
| 391 |
\LaTeX{} to \HTML being done by Eitan Gurari's |
| 392 |
\TeXfht and \ctan{make4ht}. |
| 393 |
|
| 394 |
To write quizzes using \WebQuiz it is only necessary to know |
| 395 |
\LaTeX, however, the underlying \WebQuiz system actually has three |
| 396 |
components: |
| 397 |
\begin{itemize} |
| 398 |
\item A \href{https://www.latex-project.org/}{\LaTeX} document class |
| 399 |
file, \BashCode|webquiz.cls|, and a \TeXfht |
| 400 |
configuration file, \BashCode|webquiz.cfg|, that enables the |
| 401 |
quiz files to be processed by \LaTeX{} and \TeXfht, respectively. |
| 402 |
\item A \python program, |
| 403 |
\BashCode|webquiz|, that translates the |
| 404 |
\LaTeX{} into \XML, using \TeXfht, and then into \HTML. |
| 405 |
\item \CSS, \HTML and \Javascript code controls and style the |
| 406 |
quiz web pages. |
| 407 |
\end{itemize} |
| 408 |
|
| 409 |
The \LaTeX{} component of \WebQuiz{} was written by Andrew Mathas and |
| 410 |
the \python, \CSS and \Javascript code was written by Andrew Mathas |
| 411 |
based on an initial prototype that was written by Don Taylor in 2001-2. |
| 412 |
Since 2004 the program has been maintained and developed by Andrew |
| 413 |
Mathas. Although the program has changed substantially since 2004, |
| 414 |
Don's idea of using \TeXfht, and some of his code, is still |
| 415 |
in use. Prior to releasing \WebQuiz on \Ctan, the program was known |
| 416 |
as \texttt{MathQuiz}. |
| 417 |
|
| 418 |
Hendrik Suess contributed code to improve session history |
| 419 |
and suggested the \LatexCode|\qref| command. |
| 420 |
|
| 421 |
Thanks are due to Bob Howlett for general help with \CSS and to |
| 422 |
Michal Hoftich for invaluable technical advice on \TeXfht. Thanks |
| 423 |
are due to |
| 424 |
Thomas Cailleteau |
| 425 |
Michael Palmer and |
| 426 |
Hendrik Suess |
| 427 |
for helpful feedback on the package. |
| 428 |
|
| 429 |
\section{The \WebQuiz document class --- \hologo{LaTeX}{} commands} |
| 430 |
\label{S:documentclass} |
| 431 |
|
| 432 |
This chapter describes the commands and environments provided by the |
| 433 |
\WebQuiz document class. This assumes that you have already installed |
| 434 |
and configured \WebQuiz. If you have not yet initialised \WebQuiz |
| 435 |
then please follow the instructions in \autoref{S:configuration}. |
| 436 |
|
| 437 |
All of the code examples given in this and other sections can be |
| 438 |
found in the \BashCode|examples| subdirectory of the \WebQuiz web |
| 439 |
directory.\footnote{After you have initialised \WebQuiz, you can find the |
| 440 |
\WebQuiz example directory from the command-line using: |
| 441 |
\texttt{webquiz --settings webquiz-www}.} |
| 442 |
Additional examples can be found in the \OnlineManual*, |
| 443 |
which is included, in \BashCode|PDF| form, as |
| 444 |
\hyperref[S:online]{Appendix B}. |
| 445 |
|
| 446 |
Zoomed out, the structure of a typical \WebQuiz quiz file is a \LaTeX{} file of the form: |
| 447 |
\begin{latexcode} |
| 448 |
\documentclass{webquiz} |
| 449 |
\title{A quiz}% optional, but potentially informative, title |
| 450 |
\begin{document} |
| 451 |
|
| 452 |
\begin{question}% text for first question |
| 453 |
\end{question} |
| 454 |
|
| 455 |
\begin{question}% text for second question |
| 456 |
\end{question} |
| 457 |
|
| 458 |
\begin{question}% text for third question |
| 459 |
\end{question} |
| 460 |
|
| 461 |
... |
| 462 |
|
| 463 |
\end{document} |
| 464 |
\end{latexcode} |
| 465 |
You should write your quizzes using the editor that you normally use |
| 466 |
to write \LaTeX{} documents. As you write your quiz, say |
| 467 |
\BashCode|quiz.tex|, you should use \BashCode|pdflatex| |
| 468 |
(or \BashCode|latex|), in the usual way: |
| 469 |
\begin{bashcode} |
| 470 |
> pdflatex quiz |
| 471 |
\end{bashcode} |
| 472 |
This is the easiest way to check that your quiz compiles and to |
| 473 |
proofread the output, just as if you were writing a normal \LaTeX{} |
| 474 |
document. When you are satisfied with the content of the quiz, then |
| 475 |
you can convert the quiz to an online quiz using the command |
| 476 |
\begin{bashcode} |
| 477 |
> webquiz quiz or > webquiz -d quiz # -d = draft mode = faster! |
| 478 |
\end{bashcode} |
| 479 |
The quiz file, \BashCode|quiz.tex|, should be in a directory on your |
| 480 |
web server because \WebQuiz creates a number of different files and |
| 481 |
directories when it converts the file into an online quiz and all |
| 482 |
of these files are needed to display the quiz on the web. |
| 483 |
|
| 484 |
The reasons for using this workflow are: |
| 485 |
\begin{itemize} |
| 486 |
\item \textit{Every file that you give to \WebQuiz must be a valid |
| 487 |
\LaTeX{} file!} |
| 488 |
|
| 489 |
\item The \BashCode|dvi| or \BashCode|PDF| file produced by \LaTeX{} |
| 490 |
shows all of the information in the quiz |
| 491 |
\textit{in an easy-to-read format}. That is, the \BashCode|PDF| file |
| 492 |
displays the questions, the answers and the feedback that you are |
| 493 |
giving to the students. In contrast, by design, the online version |
| 494 |
of the quiz hides most of this information and shows it to the |
| 495 |
student only when they need to see it. |
| 496 |
|
| 497 |
\item Typesetting the quiz file with \LaTeX{} is \textit{much |
| 498 |
faster} than processing it with \WebQuiz. In fact, \WebQuiz uses |
| 499 |
\BashCode|htlatex| to process the quiz file at least |
| 500 |
\textit{three times} in order to produce an \XML file and it is only |
| 501 |
then that the \WebQuiz program kicks in to rewrite this data as an |
| 502 |
\HTML file. (If you use \textit{draft mode} then |
| 503 |
\BashCode|htlatex| processes the quiz file only once.) |
| 504 |
|
| 505 |
\item If \LaTeX{} produces errors then \WebQuiz will produce more |
| 506 |
errors. Further, \textit{\LaTeX{} error messages are much easier to |
| 507 |
read and understand than those produced by \TeXfht and \WebQuiz}. |
| 508 |
\end{itemize} |
| 509 |
This said, \WebQuiz does check for more errors in the quiz than |
| 510 |
\LaTeX{} is (easily) able to do. |
| 511 |
|
| 512 |
The \BashCode|PDF| version of a quiz does not contain information about |
| 513 |
the unit, department or institution, which can be used in the |
| 514 |
breadcrumbs. |
| 515 |
|
| 516 |
The next sections describe the commands and environments provided by |
| 517 |
\WebQuiz for typesetting quizzes as well as the document-class options |
| 518 |
for the package. If you plan to use \ctan{pstricks} or |
| 519 |
\ctan[pgf]{tikz} then you should read \autoref{SS:graphics}, which |
| 520 |
describes how to use graphics in a \WebQuiz quiz. |
| 521 |
\autoref{SS:config} describes a work-around for using (some?) \LaTeX{} |
| 522 |
features that have not been configured for use with \TeXfht. |
| 523 |
|
| 524 |
\subsection{Question environments}\label{SS:Questions} |
| 525 |
|
| 526 |
The \WebQuiz document class defines the following four environments: |
| 527 |
\begin{quote} |
| 528 |
\begin{description} |
| 529 |
\item[question] Each quiz question needs to be inside |
| 530 |
\LatexCode|question| environment |
| 531 |
\item[choice] Typesets multiple choice questions, with |
| 532 |
one or more correct answers |
| 533 |
\item[discussion] Includes (optional) discussion, or revision, |
| 534 |
material at the start of the quiz web page |
| 535 |
\item[quizindex] Writes an index file for the quizzes in |
| 536 |
a ``unit of study'' and generates drop-drop menus in each quiz for |
| 537 |
the unit |
| 538 |
\end{description} |
| 539 |
\end{quote} |
| 540 |
This section describes these environments and gives examples |
| 541 |
of their use. |
| 542 |
|
| 543 |
\subsubsection{Question environments and the \textcolor{blue}{\textbackslash answer} macro} |
| 544 |
\index{environment!question} |
| 545 |
\index{question environment} |
| 546 |
|
| 547 |
Each quiz question must be placed inside a \LatexCode|question| |
| 548 |
environment. Typically, a quiz has several questions, each wrapped in |
| 549 |
its own \LatexCode|question| environment. For brevity, most of the |
| 550 |
examples in this chapter have only one question. See the |
| 551 |
\OnlineManual, in the \WebQuiz web directory for a more complete quiz |
| 552 |
file. |
| 553 |
|
| 554 |
This manual describes the \WebQuiz commands, often by example. The |
| 555 |
following code-block generates a quiz with one question for which the |
| 556 |
student has to enter the answer. This answer is then compared with the |
| 557 |
correct answer as a string, which it must match exactly. |
| 558 |
\InputLatexCode{answer-string} |
| 559 |
\macroIndex{answer}\CrossIndex{question environment}*{answer} |
| 560 |
\CrossIndex*{answer}*{whenRight} |
| 561 |
\CrossIndex*{answer}*{whenWrong} |
| 562 |
\index{feedback!whenRight} |
| 563 |
\index{feedback!whenWrong} |
| 564 |
The \textit{optional} macros \LatexCode|\whenRight| and |
| 565 |
\LatexCode|\whenWrong| are used to give the student additional |
| 566 |
feedback, when they are right, or further hints etc for approaching |
| 567 |
the question, when they are wrong. This feedback is displayed on the |
| 568 |
quiz page only when the student checks their answer. |
| 569 |
|
| 570 |
The web page created by the code above, when an incorrect answer of |
| 571 |
``canberra'', instead of ``Canberra'' is given, looks something like |
| 572 |
the following: |
| 573 |
\ScreenShot{A question with an answer}{answer-string} |
| 574 |
This example shows one way of using the \LatexCode|\answer| macro, which |
| 575 |
asks for the student to type in an answer to the question. The general syntax of |
| 576 |
this macro is: |
| 577 |
\begin{latexcode} |
| 578 |
\answer[comparison type]{correct answer} |
| 579 |
\end{latexcode} |
| 580 |
where the optional \textit{comparison type} is one of: |
| 581 |
\begin{latexcode} |
| 582 |
complex integer lowercase number string |
| 583 |
\end{latexcode} |
| 584 |
with \LatexCode|string| being the default. In addition, there is a |
| 585 |
$*$-variant of the answer macro that does not print the word |
| 586 |
``Answer'' (or equivalent in other languages) before the input box. |
| 587 |
The syntax for the \LatexCode|\answer*| command is identical to that |
| 588 |
for the \LatexCode|\answer| except, of course, that there is a~$*$: |
| 589 |
\begin{latexcode} |
| 590 |
\answer*[comparison type]{correct answer} |
| 591 |
\end{latexcode} |
| 592 |
As \LatexCode|string| is the default answer comparison method, if we |
| 593 |
instead use \LatexCode|\answer*{Canberra}| in the last example then |
| 594 |
the quiz page generated by \WebQuiz looks like: |
| 595 |
\ScreenShot{A question with answer$*$}{answer-star} |
| 596 |
Notice that the word \LatexCode|Answer| no longer appears in front of |
| 597 |
the answer box. Of course, if you use the unstarred version of the |
| 598 |
\LatexCode|\answer|-macro together with the document class option |
| 599 |
\LatexCode|language=xxx| to change the default language |
| 600 |
(\autoref{SS:classOptions}), then the appropriate translation of |
| 601 |
\LatexCode|Answer| will appear on the web page. |
| 602 |
|
| 603 |
We now give a description of the other comparison types for the |
| 604 |
\LatexCode|\answer| and \LatexCode|\answer*| macros together with |
| 605 |
code examples and screenshots. |
| 606 |
|
| 607 |
\CrossIndex*{answer}{complex} |
| 608 |
\begin{heading}[complex comparison] The answers are compared as complex |
| 609 |
numbers: the answer is marked as correct if it has the same real and |
| 610 |
imaginary parts. |
| 611 |
\InputLatexCode{answer-complex} |
| 612 |
\ScreenShot{A question with a complex answer}{answer-complex} |
| 613 |
\end{heading} |
| 614 |
Observe that the correct answer is given in the quiz file as $7+i$ |
| 615 |
and that \WebQuiz accepts $i+7$ as the correct answer. |
| 616 |
|
| 617 |
\begin{heading}[integer comparison] The answers are compared as |
| 618 |
integers. If the correct answer was $18$ and a student entered |
| 619 |
$36/2$ then their answer would be marked wrong. |
| 620 |
\CrossIndex*{answer}{integer} |
| 621 |
\InputLatexCode{answer-integer} |
| 622 |
\ScreenShot{A question with a integer answer}{answer-integer} |
| 623 |
\end{heading} |
| 624 |
|
| 625 |
\begin{heading}[lowercase comparison] The quiz answer and the |
| 626 |
students' answer are both converted to lower case and then compared as |
| 627 |
strings. |
| 628 |
\CrossIndex*{answer}{lowercase} |
| 629 |
\InputLatexCode{answer-lowercase} |
| 630 |
\ScreenShot{A question with a lowercase string answer}{answer-lowercase} |
| 631 |
\end{heading} |
| 632 |
|
| 633 |
\begin{heading}[number comparison] The quiz answer and the students' |
| 634 |
answer are compared as numbers. \CrossIndex*{answer}{number} |
| 635 |
\InputLatexCode{answer-number} |
| 636 |
\ScreenShot{A question with a numeric answer}{answer-number} |
| 637 |
Notice that the answer is given in the \LaTeX{} file as $3/4$ and |
| 638 |
that the equivalent fraction, $0.75$, is accepted as the correct |
| 639 |
answer. |
| 640 |
\end{heading} |
| 641 |
|
| 642 |
\begin{heading}[string comparison] |
| 643 |
This is the default, so \LatexCode|\answer{word}| and |
| 644 |
\LatexCode|\answer[string]{word}| are equivalent. The student's |
| 645 |
answer is marked correct if and only if it agrees exactly with |
| 646 |
the quiz answer. |
| 647 |
\CrossIndex*{answer}{string} |
| 648 |
\end{heading} |
| 649 |
|
| 650 |
\subsubsection{Multiple choice questions}\label{SS:choice} |
| 651 |
\index{environment!choice} |
| 652 |
\index{question environment!choice} |
| 653 |
\SeeIndex{multiple choice}{choice environment} |
| 654 |
|
| 655 |
The multiple choice options for a quiz question need to be placed inside |
| 656 |
a \LatexCode|choice| environment -- and every \LatexCode|choice| |
| 657 |
environment needs to be inside a \LatexCode|question| environment. |
| 658 |
|
| 659 |
The \LatexCode|choice| environment accepts two optional arguments, |
| 660 |
can appear in any order: |
| 661 |
\begin{itemize} |
| 662 |
\item\CrossIndex{choice environment}{single} |
| 663 |
\CrossIndex{choice environment}{multiple} |
| 664 |
The word \LatexCode|single| (default, and can be omitted) or |
| 665 |
\LatexCode|multiple|, which indicates whether the quiz has a |
| 666 |
\textit{single} correct answer or whether 0 or more of the answers are |
| 667 |
correct, respectively. |
| 668 |
\item \index{choice environment!columns} |
| 669 |
The number of \textit{columns} in which to typeset the choices. This |
| 670 |
is specified as \LatexCode|columns=n|, where $n$ is a non-negative integer. |
| 671 |
By default, the choices appear in $n=1$ columns |
| 672 |
(\DefaultValue{columns=1}).\\ |
| 673 |
\textit{Use \LatexCode|columns=n| with care when $n>1$ as multiple |
| 674 |
columns do not always display well on mobile devices.} |
| 675 |
\end{itemize} |
| 676 |
The key difference between these two types of \LatexCode|choice| |
| 677 |
questions is that a \LatexCode|single|-choice environment uses radio |
| 678 |
boxes, so it is only possible to select \textit{one correct answer}. |
| 679 |
In a \LatexCode|multiple|-choice environment checkboxes are used, so |
| 680 |
that is possible to select \textit{zero or more correct answers}. |
| 681 |
|
| 682 |
A \LatexCode|choice| environment modelled on the standard |
| 683 |
\LaTeX{} list environments (\textit{enumerate}, \textit{itemize}, |
| 684 |
\textit{description}, ...), except that instead of using the |
| 685 |
\LatexCode|\item| command to separate the items the |
| 686 |
\LatexCode|choice| environment uses \LatexCode|\correct| |
| 687 |
\CrossIndex{choice environment}*{correct} \LatexCode|\incorrect| |
| 688 |
\CrossIndex{choice environment}*{incorrect}, which indicate correct |
| 689 |
and incorrect answers respectively. In addition, after each |
| 690 |
\LatexCode|\correct| or \LatexCode|\incorrect| you can, optionally, use |
| 691 |
\LatexCode|\feedback| \CrossIndex{choice environment}*{feedback} to give |
| 692 |
feedback to the student taking the quiz. Like |
| 693 |
\LatexCode|\whenRight| and \LatexCode|\whenWrong| this feedback is |
| 694 |
displayed only when the student checks their answer. |
| 695 |
\index{feedback} |
| 696 |
\CrossIndex{feedback}*{whenRight} |
| 697 |
\CrossIndex{feedback}*{whenWrong} |
| 698 |
|
| 699 |
Here is an example of a \LatexCode|single|-choice question with a unique |
| 700 |
answer: |
| 701 |
\InputLatexCode{choice-single} |
| 702 |
Note that \LatexCode|single| is the default, so this could also be written as |
| 703 |
\begin{latexcode} |
| 704 |
\begin{choice}[columns=3, single] |
| 705 |
... |
| 706 |
\end{choice} |
| 707 |
\end{latexcode} |
| 708 |
It is not necessary to put the \LatexCode|\feedback| lines on the same |
| 709 |
line as the \LatexCode|\incorrect| and \LatexCode|\incorrect|; this is |
| 710 |
done only to make the example more compact. This results in the |
| 711 |
following web page: |
| 712 |
\ScreenShot{Single answer multiple choice question}{choice-single} |
| 713 |
|
| 714 |
Here is an example of a multiple choice question that has |
| 715 |
two correct answers: |
| 716 |
\InputLatexCode{choice-multiple} |
| 717 |
Notice that this example uses the document-class option |
| 718 |
\LatexCode{theme=vibrant}, which changes the \WebQuiz colour theme; |
| 719 |
see \autoref{SS:classOptions}. |
| 720 |
\ScreenShot{Multi-answer multiple choice question}{choice-multiple} |
| 721 |
|
| 722 |
When the optional argument \LatexCode|multiple| to the |
| 723 |
\LatexCode|choice| environment is used, as above, then the question is |
| 724 |
marked correct if and only if \textit{all} of the correct choices, and |
| 725 |
none of the incorrect choices, are selected. If the student's |
| 726 |
selections are not completely correct then are given feedback that is |
| 727 |
randomly selected from amongst their wrong choices (that is, the |
| 728 |
feedback is randomly selected from the set of \LatexCode|\correct| |
| 729 |
choices that were not selected and the \LatexCode|\incorrect| choices |
| 730 |
that were selected). |
| 731 |
|
| 732 |
Finally, observe that the multiple choice items in the screenshot |
| 733 |
above are labelled by roman numerals. The items in a |
| 734 |
\LatexCode{choice} environment are labelled by a standard \LaTeX{} |
| 735 |
counter, that is also called \LatexCode|choice|. Redefining the |
| 736 |
\LaTeX{} macro \LatexCode|\thechoice| changes how the corresponding |
| 737 |
question choices are labelled in the online quiz. For example, to |
| 738 |
label the items in a \LatexCode|choice| environment by A), B), C) |
| 739 |
$\dots$ add the line: |
| 740 |
\begin{latexcode} |
| 741 |
\renewcommand\thechoice{\Alph{choice})} |
| 742 |
\end{latexcode} |
| 743 |
to the preamble of the \LaTeX{} file for your quiz. |
| 744 |
\CrossIndex{choice environment}*{thechoice}\macroIndex{thechoice} |
| 745 |
|
| 746 |
\subsubsection{Discussion environments}\label{SS:discussion} |
| 747 |
\index{environment!discussion} |
| 748 |
|
| 749 |
In addition to asking questions, it is possible to display revision, |
| 750 |
or discussion, material on the quiz web page using the |
| 751 |
\LatexCode|discussion| environment. All discussion material is |
| 752 |
displayed on the quiz page \textit{before} the questions in the quiz |
| 753 |
and the (short) titles for the discussion items appear before the quiz |
| 754 |
questions in the menu on the left-hand side of the page --- it is |
| 755 |
not possible to interleave discussion items and questions in the side |
| 756 |
menu. |
| 757 |
|
| 758 |
Each quiz can have zero or more discussion environments. These |
| 759 |
environments can, in principle, contain arbitrary \LaTeX{} code. The |
| 760 |
syntax for the \LatexCode|discussion| environment is: |
| 761 |
\begin{latexcode} |
| 762 |
\begin{dicussion}[short heading][heading] |
| 763 |
... |
| 764 |
\end{dicussion} |
| 765 |
\end{latexcode} |
| 766 |
The \textit{short heading} is used in the side-menu. Both the |
| 767 |
\textit{heading} and \textit{short-heading} are optional, both |
| 768 |
defaulting to \LatexCode|Discussion|. If only one heading is given |
| 769 |
then this sets both the \textit{short heading} and \textit{heading} |
| 770 |
for the discussion item. For example, running the following \LaTeX\ |
| 771 |
file, which uses \LatexCode|theme=muted|, through \WebQuiz |
| 772 |
\InputLatexCode{discussion} |
| 773 |
produces the quiz page: |
| 774 |
\ScreenShot{Web page: discussion environment}{discussion} |
| 775 |
As with the questions, only one \LatexCode|discussion| environment is |
| 776 |
displayed on the quiz web page at a time (unless the document-class |
| 777 |
option \LatexCode|onepage| is used). It is possible to have quizzes |
| 778 |
that contain only \LatexCode|discussion| environments, with no |
| 779 |
questions, and quizzes that contain only \LatexCode|question| |
| 780 |
environments, with no discussion. |
| 781 |
|
| 782 |
If you have a mixture of \LatexCode|discussion| and |
| 783 |
\LatexCode|question| environments then it is useful to be able to add |
| 784 |
thinks between them. \LaTeX{} provides the \LatexCode|\label| and |
| 785 |
\LatexCode|\ref| commands for cross-referencing, so \WebQuiz builds |
| 786 |
on this idea and provides the three commands \LatexCode|\dref|, |
| 787 |
\LatexCode|\qref| and \LatexCode|\Qref| to reference |
| 788 |
\LatexCode|discussion| and \LatexCode|question| environments. The |
| 789 |
syntax for these commands is as follows: |
| 790 |
\begin{latexcode} |
| 791 |
\dref[optional text]{LaTeX label} % inserts discussion button |
| 792 |
\dref*[optional text]{LaTeX label} % inserts discussion link |
| 793 |
\qref[optional text]{LaTeX label} % inserts question button by label |
| 794 |
\qref*[optional text]{LaTeX label} % inserts question link by label |
| 795 |
\Qref[optional text]{question number} % inserts question button by number |
| 796 |
\Qref*[optional text]{question number} % inserts question link by number |
| 797 |
\end{latexcode} |
| 798 |
\CrossIndex{cross-reference}*{dref} |
| 799 |
\CrossIndex{cross-reference}*{qref} |
| 800 |
\CrossIndex{cross-reference}*{Qref} |
| 801 |
\CrossIndex{cross-reference}*{label} |
| 802 |
In each case the text in the link or button defaults to either the |
| 803 |
short-title, for discussion environments, or the question number for |
| 804 |
questions. The ``optional text'' is used instead whenever it is |
| 805 |
supplied. These commands can be used anywhere in a quiz, including |
| 806 |
\LatexCode|discussion|, \LatexCode|question| and \LatexCode|choice| |
| 807 |
environments and inside feedback text for the students written using |
| 808 |
\LatexCode|\feedback|, \LatexCode|\whenRight| and \LatexCode|\whenWrong|. |
| 809 |
|
| 810 |
The macros \LatexCode|\dref| and \LatexCode|\qref| use a standard |
| 811 |
\LaTeX{} \textit{label}, defined using the \LatexCode|\label| command, |
| 812 |
to insert a button or a link. In contrast, \LatexCode|\Qref| uses the actual |
| 813 |
\textit{question number}, so it is not necessary to define a |
| 814 |
\LatexCode|\label| for a question when using \LatexCode|\Qref|. |
| 815 |
|
| 816 |
Even though the macros \LatexCode|\qref| and \LatexCode|\Qref| are |
| 817 |
quite similar they serve different functions when the |
| 818 |
\LatexCode|randomorder| document class option is used (see |
| 819 |
\autoref{SS:classOptions}). In this case we do not know ahead of time |
| 820 |
the question numbers that will be used in the quiz. So if |
| 821 |
\LatexCode|q:one| is the label for the first question in the \LaTeX{} |
| 822 |
file then \LatexCode|\qref{q:one}| will insert a button to this |
| 823 |
question \textit{but} this will almost certainly not be Question~$1$. |
| 824 |
On the other hand, we can create a ``Start quiz'' button, for example, |
| 825 |
that will open Question~1 on any quiz, using |
| 826 |
\LatexCode|\Qref[Start quiz]{1}|. |
| 827 |
|
| 828 |
Here is an example that shows how \LatexCode|\Qref| works: |
| 829 |
\InputLatexCode{discussion-Qref}\macroIndex{Qref} |
| 830 |
which produces the online quiz: |
| 831 |
\ScreenShot{Crossing-referencing using question numbers}{discussion-Qref} |
| 832 |
Similarly, here is an example showing how \LatexCode|\dref| and \LatexCode|qref| |
| 833 |
are used: |
| 834 |
\InputLatexCode{discussion-ref}\macroIndex{dref}\macroIndex{qref} |
| 835 |
This code produces the online quiz: |
| 836 |
\ScreenShot{Crossing-referencing using labels}{discussion-ref} |
| 837 |
|
| 838 |
\begin{dangerous} |
| 839 |
When using the \LatexCode|randomorder| document class option |
| 840 |
(\autoref{SS:classOptions}), ``optional text'' should always be |
| 841 |
given when using \LatexCode|\qref|. This is because the question |
| 842 |
number that is displayed by default will always be the question |
| 843 |
number \textit{in the \LaTeX{} file} rather than the question number |
| 844 |
in the online quiz. |
| 845 |
\end{dangerous} |
| 846 |
|
| 847 |
\subsubsection{Index pages for quizzes}\label{SS:index} |
| 848 |
\index{quizindex environment} |
| 849 |
\index{environment!quizindex} |
| 850 |
|
| 851 |
Most quizzes occur in sets that cover related material, such as for |
| 852 |
a particular unit of study. The \LatexCode|quizindex| environment |
| 853 |
creates an index web page for related sets of quizzes. The \LaTeX{} |
| 854 |
files for all of these quizzes must be in the same directory, or |
| 855 |
folder, on the web server. The index web page is a \WebQuiz file of |
| 856 |
the form: |
| 857 |
\InputLatexCode{index-en} |
| 858 |
which generates a web page that looks like: |
| 859 |
\ScreenShot[0.7]{Example index page}{index-en} |
| 860 |
As the next section describes, index files are also used to |
| 861 |
automatically add a drop-down menu that contains the quiz-index to |
| 862 |
the breadcrumbs on all of the quiz web pages. This drop-down menu |
| 863 |
provides an easy way to navigate between all of the quizzes for a |
| 864 |
particular unit of study. |
| 865 |
|
| 866 |
As the example above shows, the entries in the \LatexCode|quizindex| are |
| 867 |
given using the \LatexCode|\quiz| or the \LatexCode|\quiz*| command. |
| 868 |
\CrossIndex{quizindex environment}*{quiz} |
| 869 |
The syntax for these commands is |
| 870 |
\begin{latexcode} |
| 871 |
\quiz[URL for quiz]{Title for quiz} |
| 872 |
\quiz*[URL for quiz]{Title for quiz} |
| 873 |
\end{latexcode} |
| 874 |
The \LatexCode|\quiz| macro automatically inserts the quiz numbers |
| 875 |
into the index listing. The \LatexCode|\quiz*| command is identical |
| 876 |
\textit{except} that it does not add \BashCode|Quiz 1.|, |
| 877 |
\BashCode|Quiz 2| etc to the index listing. By default, the URLs for |
| 878 |
the quizzes in the index are assumed to be of the form |
| 879 |
\BashCode|quiz1.html|, \BashCode|quiz2.html|, \BashCode|quiz3.html|, |
| 880 |
.... These URLs can be changed using the optional argument of the |
| 881 |
\LatexCode|\quiz| and \LatexCode|\quiz*| commands. For example, |
| 882 |
\begin{latexcode} |
| 883 |
\quiz[realquiz.html]{This is the real quiz} |
| 884 |
\end{latexcode} |
| 885 |
would create an item in a quiz index that links to the web page |
| 886 |
\BashCode|realquiz.html|. |
| 887 |
|
| 888 |
Index pages in other languages are produced in exactly the same way. For example, |
| 889 |
\InputLatexCode{index-cz} |
| 890 |
produces the web page: |
| 891 |
\ScreenShot[0.7]{A Czech index}{index-cz} |
| 892 |
The next section describes the \LatexCode|\BreadCrumb| and |
| 893 |
\LatexCode|\BreadCrumbs| commands. |
| 894 |
|
| 895 |
At most one file in each directory should contain a |
| 896 |
\LatexCode|quizindex| environment. This is because \WebQuiz creates |
| 897 |
the file \Javascript file \BashCode|quizindex.js| whenever it |
| 898 |
compiles a \LatexCode|quizindex| environment. This file contains |
| 899 |
\Javascript commands for displaying the quiz index. |
| 900 |
|
| 901 |
\subsubsection{Breadcrumbs}\label{SS:breadcrumbs}\index{breadcrumbs} |
| 902 |
\WebQuiz provides a straightforward way to place navigation breadcrumbs |
| 903 |
at the top of the quiz web page. By default the |
| 904 |
breadcrumbs are disabled. If you have a \LatexCode|\BreadCrumbs| command |
| 905 |
like: |
| 906 |
\begin{latexcode} |
| 907 |
\BreadCrumbs{Mathematics /|Math1001 /u/Math1001|quizindex|title} |
| 908 |
\end{latexcode} |
| 909 |
in your \LaTeX{} file then \WebQuiz will add a corresponding strip |
| 910 |
of breadcrumbs, or navigation links, to the top of your quiz page: |
| 911 |
\ScreenShot{Example breadcrumbs}{breadcrumbs} |
| 912 |
The drop-down menu is normally hidden, appearing only after the |
| 913 |
$\equiv$ ``button'' on the web page is clicked. |
| 914 |
|
| 915 |
Usually, most of the breadcrumbs are navigation links to other web pages. In |
| 916 |
the example above: |
| 917 |
\begin{itemize} |
| 918 |
\item The first ``crumb' inside the |
| 919 |
\LatexCode|\BreadCrumbs| command is \BashCode|Mathematics /|. This inserts the text |
| 920 |
\BashCode|Mathematics| together with a (relative) URL to |
| 921 |
\BashCode|/|, the root directory for the web |
| 922 |
server, which is often the correct URL for the department (or the |
| 923 |
institution) |
| 924 |
\item The \BashCode|Math101 /u/math101| inserts the text |
| 925 |
\BashCode|Math101| as the second breadcrumb with URL |
| 926 |
\BashCode|/u/math101|. |
| 927 |
\item The \BashCode|quizindex| inserts the text \BashCode|Quizzes| |
| 928 |
together with the symbol $\equiv$, which opens a drop-down menu |
| 929 |
that contains the list of quizzes in the quiz index for the unit. |
| 930 |
This is described in more detail below. |
| 931 |
\item Finally the \LatexCode|title| in the breadcrumbs inserts, as |
| 932 |
text, the part of the title \textit{before the first colon} in the title, |
| 933 |
where the title is given by \LatexCode|\title{...}|. |
| 934 |
\end{itemize} |
| 935 |
The breadcrumbs for the quiz web page can be either be configured |
| 936 |
quiz-by-quiz, using the \LatexCode|\BreadCrumbs| macro |
| 937 |
\macroIndex{BreadCrumbs}, as above, or by setting default |
| 938 |
\LatexCode|breadcrumbs| in the \webquizrc using the command-line |
| 939 |
option |
| 940 |
\begin{bashcode} |
| 941 |
> webquiz --edit-settings |
| 942 |
\end{bashcode} |
| 943 |
as described in \autoref{SS:commandline}. Breadcrumbs are disabled by default. |
| 944 |
|
| 945 |
The breadcrumbs inside the \LatexCode|\BreadCrumbs{...}| command are given as |
| 946 |
a ``|-separated list''. For example, quite reasonable breadcrumbs are given by: |
| 947 |
\begin{latexcode} |
| 948 |
\BreadCrumbs{ department | unitcode | quizindex | title } |
| 949 |
\end{latexcode} |
| 950 |
To make this the default set of breadcrumbs use |
| 951 |
\BashCode{webquiz --edit-settings} to set breadcrumbs |
| 952 |
in the \webquizrc to: |
| 953 |
\begin{latexcode} |
| 954 |
department | unitcode | quizindex | title |
| 955 |
\end{latexcode} |
| 956 |
More generally, the breadcrumbs can be specified as: |
| 957 |
\begin{latexcode} |
| 958 |
\BreadCrumbs{ crumb1 | crumb2 | crumb3 | crumb4 | ... } |
| 959 |
\end{latexcode} |
| 960 |
In principle, there can be arbitrarily many crumbs in your |
| 961 |
breadcrumbs but, in practice, five is more than enough. |
| 962 |
The crumbs inside a \LatexCode|\BreadCrumbs| command have the |
| 963 |
following meanings: |
| 964 |
|
| 965 |
\begin{description} |
| 966 |
\item[breadcrumb] The breadcrumb for the current quiz, which is |
| 967 |
set using the \LatexCode|\BreadCrumb| macro. This breadcrumb is |
| 968 |
purely descriptive, with no hyperlink being added: only the text given by |
| 969 |
\LatexCode|\BreadCrumb| appears. |
| 970 |
\CrossIndex*{BreadCrumbs}{breadcrumb}\macroIndex{BreadCrumb} |
| 971 |
|
| 972 |
\item[department] This expands to a link to your department, where |
| 973 |
the department text is set using the macro \LatexCode|\Department| and its URL is set by |
| 974 |
\LatexCode|\DepartmentURL|. |
| 975 |
\macroIndex{Department}\macroIndex{DepartmentURL} |
| 976 |
\CrossIndex*{BreadCrumbs}{department} |
| 977 |
|
| 978 |
\item[institution] This expands to a link to your institution, where |
| 979 |
the institution text is set using \LatexCode|\Institution| and its URL is set by |
| 980 |
\LatexCode|\InstitutionURL|. The institution also appears in the |
| 981 |
side-menu above the \WebQuiz copyright notice. |
| 982 |
\macroIndex{Institution}\macroIndex{InstitutionURL} |
| 983 |
\CrossIndex*{BreadCrumbs}{institution} |
| 984 |
|
| 985 |
\item[quizindex] This expands to \BashCode|Quizzes|, which is a |
| 986 |
link to the index page for your unit, as defined by |
| 987 |
\LatexCode|\QuizzesURL|, which is described below. In addition, |
| 988 |
if the directory contains a BashCode|quizindex.js| file, which is |
| 989 |
created by the \LatexCode|quizindex| environment (see |
| 990 |
\autoref{SS:index}), then the symbol {\large$\equiv$} will appear, |
| 991 |
giving access to a drop-down menu to the index page, looking |
| 992 |
something like this: |
| 993 |
\ScreenShot{Drop-down menu giving index of quizzes}{quizindex-dropdown} |
| 994 |
\macroIndex{QuizzesURL} |
| 995 |
\CrossIndex*{BreadCrumbs}{quizindex} Such drop-down menus are |
| 996 |
automatically added to quiz web pages that have a |
| 997 |
\LatexCode|quizindex| breadcrumb| as soon as |
| 998 |
an quiz page that contained a \WebQuiz \LatexCode|quizindex| environment has |
| 999 |
been compiled in the current directory. |
| 1000 |
\CrossIndex{breadcrumbs}{quizindex} |
| 1001 |
|
| 1002 |
For those interested in how this is done, whenever \WebQuiz |
| 1003 |
compiles a \LatexCode|quizindex| environment it creates a |
| 1004 |
\Javascript file \BashCode|quizindex.js|. Every quiz file includes |
| 1005 |
this \Javascript file, if it exists, and this allows it to display |
| 1006 |
a drop-down menu for the quiz index. |
| 1007 |
|
| 1008 |
\item[Title] This expands to the full title of the quiz page, |
| 1009 |
without a hyperlink, as given by the \LatexCode|\title|. |
| 1010 |
\CrossIndex*{BreadCrumb*}{Title} |
| 1011 |
|
| 1012 |
\item[title] This expands to the part of title of the quiz page, |
| 1013 |
without a hyperlink, that occurs \textit{before} the first colon |
| 1014 |
in the title of the quiz. For example, if the title is given as |
| 1015 |
\begin{latexcode} |
| 1016 |
\title{Quiz 1: The wonders of life} |
| 1017 |
\end{latexcode} |
| 1018 |
then ``Quiz 1'' will be added to the list of breadcrumbs. If the |
| 1019 |
title does not contain a colon then the full title is printed. |
| 1020 |
\CrossIndex*{BreadCrumbs}{title} |
| 1021 |
|
| 1022 |
\item[unitcode] This expands to a link to the unit code, where the |
| 1023 |
unit code text is set using \LatexCode|\UnitCode|, and its URL is |
| 1024 |
set by |
| 1025 |
\LatexCode|\UnitURL| |
| 1026 |
\macroIndex{UnitCode}\macroIndex{UnitURL} |
| 1027 |
\CrossIndex*{BreadCrumbs}{unitcode} |
| 1028 |
|
| 1029 |
\item[unitname] This expands to a link to the unit name, where the |
| 1030 |
unit name text is set using \LatexCode|\UnitName|, and its URL is |
| 1031 |
set by |
| 1032 |
\LatexCode|\UnitURL| |
| 1033 |
\macroIndex{UnitName}\macroIndex{UnitURL} |
| 1034 |
\CrossIndex*{BreadCrumbs}{unitname} |
| 1035 |
|
| 1036 |
\end{description} |
| 1037 |
|
| 1038 |
\noindent |
| 1039 |
In addition, each \textit{crumb} in a breadcrumb, except for the |
| 1040 |
``magic crumbs'' listed above, is allowed to be arbitrary text --- |
| 1041 |
although, non-ascii characters may cause problems. In this case, the |
| 1042 |
last ``word'' in the crumb is treated as a URL if it either beings |
| 1043 |
with a forward slash, \BashCode|/|, or if it begins with |
| 1044 |
\BashCode|http|. For example, the code: |
| 1045 |
\InputLatexCode{montypython} |
| 1046 |
\noindent |
| 1047 |
results in the following breadcrumbs: |
| 1048 |
\ScreenShot{Guaranteed to offend some one}{montypython} |
| 1049 |
Notice that it is necessary to correctly escape spaces etc in |
| 1050 |
URLs that are specified this way. Similarly, all of the characters |
| 1051 |
in the breadcrumbs should be ascii characters as unicode is likely to |
| 1052 |
cause encoding issues (compare with the Czech index given in |
| 1053 |
\autoref{SS:index}). |
| 1054 |
|
| 1055 |
If any part of a ``magic'' breadcrumb has not been defined then it |
| 1056 |
is printed with a question mark on the web page. For example, the |
| 1057 |
quiz file |
| 1058 |
\InputLatexCode{nounits} |
| 1059 |
does not define the unit code, so it results in the ``questionable'' first breadcrumb: |
| 1060 |
\ScreenShot{Breadcrumbs with no unit code}{nounits} |
| 1061 |
|
| 1062 |
Here is the list of \WebQuiz macros that we be used to set the |
| 1063 |
values of the ``magic'' breadcrumbs inside a |
| 1064 |
\LatexCode|\BreadCrumbs|. Note that default values for many of these |
| 1065 |
``crumbs'' can be given in the \webquizrc. |
| 1066 |
|
| 1067 |
\newcommand\Item[1]{\item[\textbackslash#1]\CrossIndex{breadcrumbs}*{#1}} |
| 1068 |
\begin{description} |
| 1069 |
\Item{BreadCrumb}\macroIndex{BreadCrumb} |
| 1070 |
The \LatexCode|\BreadCrumb| command sets the \LatexCode|breadcrumb| |
| 1071 |
variable in the \LatexCode|\BreadCrumbs|. The primary use for this |
| 1072 |
is when you have default breadcrumbs in the \webquizrc like |
| 1073 |
\begin{bashcode} |
| 1074 |
breadcrumbs = department | unitcode | breadcrumb |
| 1075 |
\end{bashcode} |
| 1076 |
Using \LatexCode|\BreadCrumb| allows you to set the last crumb to |
| 1077 |
some meaningful text that describes the quiz. |
| 1078 |
|
| 1079 |
\Item{Department}\macroIndex{Department} |
| 1080 |
The \LatexCode|\Department| command sets the name of the |
| 1081 |
\LatexCode|department|. As described earlier in this section, by |
| 1082 |
default, the \LatexCode|department| is the first item in the |
| 1083 |
breadcrumbs that appear at the top of the web page. |
| 1084 |
|
| 1085 |
The default department can be set in the \webquizrc using |
| 1086 |
\BashCode|webquiz --edit-settings|. |
| 1087 |
|
| 1088 |
Default value: \BashCode{''} \qquad(i.e. the empty string) |
| 1089 |
|
| 1090 |
\Item{DepartmentURL}\macroIndex{DepartmentURL} |
| 1091 |
The \LatexCode|\DepartmentURL| command sets URL for the department. As |
| 1092 |
described earlier in this section, by default the department URL is |
| 1093 |
the link in the first breadcrumb on each web page. |
| 1094 |
|
| 1095 |
The default department URL can be set in the \webquizrc using |
| 1096 |
\BashCode|webquiz --edit-settings|. |
| 1097 |
|
| 1098 |
Default value: \DefaultValue{/} |
| 1099 |
|
| 1100 |
\Item{Institution}\macroIndex{Institution} |
| 1101 |
The \LatexCode|\Institution| command sets the institution, or university. |
| 1102 |
The \LatexCode|institution| appears below the question buttons in the |
| 1103 |
left-hand navigation menu that appears on every quiz web page |
| 1104 |
(provided that the screen size is not too small). As described |
| 1105 |
earlier in this section, the institution can be used in the web |
| 1106 |
page breadcrumbs. |
| 1107 |
|
| 1108 |
The default institution can be set in the \webquizrc using |
| 1109 |
\BashCode|webquiz --edit-settings|. |
| 1110 |
|
| 1111 |
Default value: \BashCode{''} \qquad(i.e. the empty string) |
| 1112 |
|
| 1113 |
|
| 1114 |
\Item{InstitutionURL}\macroIndex{InstitutionURL} |
| 1115 |
The \LatexCode|\InstitutionURL| command sets the institution URL. This is |
| 1116 |
used as the link for the \LatexCode|institution| in the left-hand |
| 1117 |
navigation menu that appears on every quiz page. As described |
| 1118 |
earlier in this section, the institution URL can be used in the |
| 1119 |
web page breadcrumbs. |
| 1120 |
|
| 1121 |
The default institution URL can be set in the \webquizrc using |
| 1122 |
\BashCode|webquiz --edit-settings|. |
| 1123 |
|
| 1124 |
Default value: \DefaultValue{/} |
| 1125 |
|
| 1126 |
\Item{QuizzesURL}\macroIndex{QuizzesURL} |
| 1127 |
The \LatexCode|\QuizzesURL| command sets the URL for the suite of quizzes |
| 1128 |
attached to this unit of study. As described earlier in this |
| 1129 |
section, this can be used in the breadcrumb at the top of the quiz |
| 1130 |
web page. |
| 1131 |
|
| 1132 |
Default value: \DefaultValue{UnitURL/Quizzes}, where \DefaultValue{UnitURL} is set |
| 1133 |
using \LatexCode|\UnitURL| |
| 1134 |
|
| 1135 |
\Item{UnitCode}\macroIndex{UnitCode} |
| 1136 |
The \LatexCode|\UnitCode| command sets the unit of study code for the |
| 1137 |
unit that the quiz is part of. |
| 1138 |
|
| 1139 |
\Item{UnitName}\macroIndex{UnitName} |
| 1140 |
The \LatexCode|\UnitName| command sets the name of the unit of study for |
| 1141 |
the unit that the quiz is attached to. |
| 1142 |
|
| 1143 |
\Item{UnitURL}\macroIndex{UnitURL} |
| 1144 |
The \LatexCode|\UnitURL| command sets the URL for the unit of study code |
| 1145 |
for the unit that the quiz is attached to. |
| 1146 |
|
| 1147 |
\end{description} |
| 1148 |
|
| 1149 |
\noindent |
| 1150 |
It makes sense to set defaults for \LatexCode|\BreadCrumbs| |
| 1151 |
\LatexCode|\Department|, \LatexCode|\DepartmentURL|, |
| 1152 |
\LatexCode|\Institution| and \LatexCode|\InstitutionURL| in the |
| 1153 |
\webquizrc. After doing this, a typical \WebQuiz file might look like this: |
| 1154 |
|
| 1155 |
\begin{latexcode} |
| 1156 |
\documentclass{webquiz} |
| 1157 |
\UnitName{Fundamental stuff} |
| 1158 |
\UnitCode{Stuff101} |
| 1159 |
\UnitURL{/courses/stuff101} |
| 1160 |
|
| 1161 |
\title{Stuffing: the art of taxidermy} |
| 1162 |
|
| 1163 |
\begin{document} |
| 1164 |
\begin{question} |
| 1165 |
first question... |
| 1166 |
\end{question} |
| 1167 |
\begin{question} |
| 1168 |
second question... |
| 1169 |
\end{question} |
| 1170 |
\end{document} |
| 1171 |
\end{latexcode} |
| 1172 |
|
| 1173 |
If you have many quizzes for many different units then a better approach is to create |
| 1174 |
a \LaTeX{} ``package'', say \BashCode|ourunits.sty|, to set these variables: |
| 1175 |
\begin{latexcode} |
| 1176 |
% ourunits.sty - set unit names, codes and URLs |
| 1177 |
\DeclareOption{stuff101}{ |
| 1178 |
\UnitName{Fundamental stuff} |
| 1179 |
\UnitCode{Stuff101} |
| 1180 |
\UnitURL{/courses/stuff101} |
| 1181 |
} |
| 1182 |
\DeclareOption{stuff102}{ |
| 1183 |
\UnitName{Fundamental stuff too} |
| 1184 |
\UnitCode{Stuff102} |
| 1185 |
\UnitURL{/courses/stuff102} |
| 1186 |
} |
| 1187 |
\ProcessOptions |
| 1188 |
\endinput |
| 1189 |
\end{latexcode} |
| 1190 |
Then you can replace the opening lines of the quiz file with |
| 1191 |
\LatexCode|\usepackage[stuff101]{ourunits}|. Of course, you could also |
| 1192 |
set the default \LatexCode|\Department|, \LatexCode|\DepartmentURL|, |
| 1193 |
\LatexCode|\Institution| and \LatexCode|\InstitutionURL| in such a |
| 1194 |
style file as well. |
| 1195 |
|
| 1196 |
\subsection{\WebQuiz document class options}\label{SS:classOptions} |
| 1197 |
|
| 1198 |
The \WebQuiz document class supports the following options: |
| 1199 |
\begin{latexcode} |
| 1200 |
fixedorder, hidesidemenu, language, onepage, pst2pdf, |
| 1201 |
separatepages, showsidemenu, theme, tikz |
| 1202 |
\end{latexcode} |
| 1203 |
This section describes all of these document-class options except for |
| 1204 |
\ctan{tikz} and \ctan{pst2pdf}, which are discussed in |
| 1205 |
\autoref{SS:graphics}. Many of the document-class options below occur |
| 1206 |
in pairs and defaults for many of these can be set in the \webquizrc |
| 1207 |
file. The settings given in the \LaTeX{} file |
| 1208 |
for a quiz will always override the default settings in the \webquizrc*. |
| 1209 |
|
| 1210 |
\begin{description} |
| 1211 |
|
| 1212 |
\item[fixedorder, randomorder] |
| 1213 |
\CrossIndex{document class options}{fixedorder} |
| 1214 |
\CrossIndex{document class options}{randomorder} |
| 1215 |
By default, the questions in the quiz are displayed in a |
| 1216 |
\DefaultValue{fixedorder} for all students who take the quiz. |
| 1217 |
This order is the order that the question appear in the \LaTeX{} |
| 1218 |
file for the quiz. That is, the first question in the online quiz |
| 1219 |
is the first question appearing in the \LaTeX file, the second |
| 1220 |
question in the quiz is the second question in the \LaTeX{} file, |
| 1221 |
and so on. With the \LatexCode|randomorder| option the questions |
| 1222 |
in the quiz are displayed in a random order that changes each time |
| 1223 |
that the quiz is run. With this option, the online quiz questions |
| 1224 |
are generally in a different order for every student. For example, |
| 1225 |
the code: |
| 1226 |
\InputLatexCode{random} |
| 1227 |
produces the quiz with randomly arranged quiz questions, such as: |
| 1228 |
\ScreenShot{Randomly ordered questions}{random} |
| 1229 |
(So the first question in the \LaTeX{} file is being displayed as |
| 1230 |
the fourth online quiz question. The next time the page is |
| 1231 |
loaded, such as for the next student, the question order will |
| 1232 |
change again.) When using the \LatexCode|randomorder| |
| 1233 |
document-class option only the questions appear in random order. |
| 1234 |
If the quiz contains multiple choice questions then the choices |
| 1235 |
are \textit{not} randomly permuted. That is, the choices always |
| 1236 |
appear in the order that they are written in the \LaTeX{} file. |
| 1237 |
|
| 1238 |
\item[hidesidemenu, sidemenu] |
| 1239 |
\CrossIndex{document class options}{hidesidemenu} |
| 1240 |
\CrossIndex{document class options}{showsidemenu} |
| 1241 |
If the \LatexCode|hidesidemenu| option is set then the side menu |
| 1242 |
on the left-hand side of the quiz web page will not be displayed |
| 1243 |
when the quiz first loads. By default, the side menu appears |
| 1244 |
unless the screen size is too small, such as on a mobile phone. |
| 1245 |
Many examples of the \LatexCode|hidesidemenu| and |
| 1246 |
\LatexCode|showsidemenu| class options can be found above. |
| 1247 |
|
| 1248 |
The display of the side menu can is also toggled by clicking on |
| 1249 |
the {\textcolor{red}{\small\XSolidBold}} and |
| 1250 |
{\textcolor{red}{\large\ding{118}}} symbols. The side-menu |
| 1251 |
automatically disappears for devices with narrow screens, such as |
| 1252 |
mobile phones. |
| 1253 |
|
| 1254 |
\item[language=<lang>] \CrossIndex{document class options}{language} |
| 1255 |
Set the language used by the \textit{web pages} constructed by \WebQuiz. |
| 1256 |
The following languages are currently supported by \WebQuiz: |
| 1257 |
\ListWebQuizLanguages |
| 1258 |
The languages files are used to print the various buttons and text |
| 1259 |
that is generated on the web pages constructed by \WebQuiz. The |
| 1260 |
\LatexCode|language| option does not affect the DVI or |
| 1261 |
\BashCode|PDF| versions of the quiz and it does not load language |
| 1262 |
packages like \ctan{babel} or \ctan{polyglossia}. |
| 1263 |
|
| 1264 |
The \LatexCode|language| keyword can be in upper or lower case, with |
| 1265 |
the result that either (but not both!) of the following two lines set the |
| 1266 |
quiz language to German: |
| 1267 |
\begin{latexcode} |
| 1268 |
\documentclass[language=German]{webquiz} |
| 1269 |
\documentclass[language=german]{webquiz} |
| 1270 |
\end{latexcode} |
| 1271 |
|
| 1272 |
Typical usage of the \LatexCode|language| option is the following: |
| 1273 |
\lstinputlisting[style=latexcode,extendedchars=false]{examples/french} |
| 1274 |
This produces a web page like this: |
| 1275 |
\ScreenShot{A web page with \textsf{language=french}}{french} |
| 1276 |
As a general rule, \LaTeX{} and \TeXfht do not cope well with |
| 1277 |
unicode characters, so if your quiz contains (a lot of) unicode |
| 1278 |
characters then we recommend using \hologo{LuaLaTeX} or \hologo{XeLaTeX}, which |
| 1279 |
corresponds to the \WebQuiz command-line options |
| 1280 |
\BashCode|webquiz -x| or \BashCode|webquiz -l|, respectively. The |
| 1281 |
default \TeX{} engine can be set in the \webquizrc. |
| 1282 |
\index{unicode}\index{lualatex}\index{xelatex} |
| 1283 |
|
| 1284 |
The language files were created largely using google translate so |
| 1285 |
they may well need fine-tuning\footnote{The word ``Copyright'' in |
| 1286 |
the left-hand side-margin is not translated but perhaps it should |
| 1287 |
be.}. You can use \BashCode|kpsewhich| to look at the language |
| 1288 |
files, which all have names of the form \BashCode|webquiz-xxx.lang|, |
| 1289 |
where \BashCode|xxx| is the name of the language in lower case. For example, |
| 1290 |
the \textit{English} language file, which is the default, can be |
| 1291 |
found using the command: |
| 1292 |
\begin{bashcode} |
| 1293 |
> kpsewhich webquiz-english.lang |
| 1294 |
\end{bashcode} |
| 1295 |
The file \BashCode|webquiz-english.lang| contains the following: |
| 1296 |
\InputBashCode{webquiz-english.lang} |
| 1297 |
In these files, the material to the left of the equals signs are |
| 1298 |
effectively variables, and so they should never be changed, or |
| 1299 |
deleted, whereas anything to the right of the equals signs is the |
| 1300 |
text that will appear on the \WebQuiz web pages. \textit{The pairs |
| 1301 |
of braces, }\LatexCode|{}|, \textit{in the language files must be present |
| 1302 |
because in the online quizzes they expand to expressions like} |
| 1303 |
\LatexCode|(a)|, \LatexCode|(b)|\dots |
| 1304 |
|
| 1305 |
To add \WebQuiz support for a new language, say language |
| 1306 |
\LatexCode|xxx|, copy any \WebQuiz language file to a new file |
| 1307 |
\BashCode|webquiz-xxx.lang| and then translate all of the words to |
| 1308 |
the right of the equals signs.\footnote{\WebQuiz assumes that all |
| 1309 |
language names are in lower case so \texttt{xxx}, and not |
| 1310 |
\texttt{XXX}, should be used.} \WebQuiz will be able to find the new |
| 1311 |
language file as long as it appears in the \LaTeX{} search |
| 1312 |
path\footnote{To help \LaTeX/\WebQuiz fined your language file you |
| 1313 |
may need to run a program like \texttt{mktexlsr} using an |
| 1314 |
administrators account}. Once the new language file |
| 1315 |
\BashCode|webquiz-xxx.lang| is in the \LaTeX{} search path it can be |
| 1316 |
used by \WebQuiz using \LatexCode|language=xxx| as a document-class |
| 1317 |
option: |
| 1318 |
\begin{latexcode} |
| 1319 |
\documentclass[language=xxx]{webquiz} |
| 1320 |
\begin{document} |
| 1321 |
...quiz code here... |
| 1322 |
\end{document} |
| 1323 |
\end{latexcode} |
| 1324 |
Please submit any new language files, or corrections to existing |
| 1325 |
language files, as a \textit{new issue} at: |
| 1326 |
\href{https://\webquiz{repository}}{\webquiz{repository}}. |
| 1327 |
|
| 1328 |
\item[onepage, separatepages] |
| 1329 |
\CrossIndex{document class options}{onepage} |
| 1330 |
\CrossIndex{document class options}{separatepages} |
| 1331 |
By default, only one question, or one discussion environment, is displayed |
| 1332 |
by the quiz at any time. As \LatexCode|separatepages| is the default, every |
| 1333 |
example so far is of this form. With the document-class option |
| 1334 |
\LatexCode|onepage| all questions, and discussion environments, are |
| 1335 |
displayed at the same time on a single web page. So, for example, the code: |
| 1336 |
\InputLatexCode{onepage} |
| 1337 |
produces the quiz page: |
| 1338 |
\ScreenShot{A one page quiz}{onepage} |
| 1339 |
|
| 1340 |
\item[theme]\CrossIndex{document class options}{theme} |
| 1341 |
|
| 1342 |
\WebQuiz\ has a small number of different themes for setting the |
| 1343 |
colours on the quiz web pages. The theme can be set as an option to |
| 1344 |
the document class or in the \webquizrc. Most, but not all, of the examples |
| 1345 |
so far have used the \LatexCode|default| theme. |
| 1346 |
\WebQuiz currently supports the following themes: |
| 1347 |
\ListWebQuizThemes |
| 1348 |
Example screenshots of all \WebQuiz themes can be found in |
| 1349 |
\hyperref[SS:themes]{Appendix A}. |
| 1350 |
|
| 1351 |
\end{description} |
| 1352 |
|
| 1353 |
|
| 1354 |
\subsection{Including graphics and using pstricks and tikz}\label{SS:graphics} |
| 1355 |
It is also possible to include complicated diagrams in \WebQuiz |
| 1356 |
quizzes using packages like \ctan{tikz} and \ctan{pstricks}. |
| 1357 |
\textit{As there have been several recent updates to these packages it |
| 1358 |
is advisable to install the latest version of both of these packages, |
| 1359 |
as well as the packages \ctan{make4ht}, \ctan{pgf} and \TeXfht.} In |
| 1360 |
fact, it is recommended that you update all installed \TeX{} packages. |
| 1361 |
|
| 1362 |
By far the easiest way to include images when using \WebQuiz is by |
| 1363 |
adding the following lines to your document preamble: |
| 1364 |
\begin{latexcode} |
| 1365 |
\usepackage[dvipdfmx]{graphicx} |
| 1366 |
\DeclareGraphicsExtensions{.png} |
| 1367 |
\end{latexcode} |
| 1368 |
to your document preamble. You need to use |
| 1369 |
\LatexCode|\DeclareGraphicsExtensions| to tell \WebQuiz the different |
| 1370 |
types of images you are using, so the code above works for |
| 1371 |
\LatexCode{png} images. More generally, you can use a comma separated |
| 1372 |
list of extensions, such as: |
| 1373 |
\begin{latexcode} |
| 1374 |
\DeclareGraphicsExtensions{.png, .jpg, .gif} |
| 1375 |
\end{latexcode} |
| 1376 |
The option \LatexCode|dvipdfmx| |
| 1377 |
to \LatexCode|graphicx| is only necessary if you want to be able to |
| 1378 |
rescale images. For example, the code: |
| 1379 |
\InputLatexCode{ctanLion} |
| 1380 |
produces the quiz page: |
| 1381 |
\ScreenShot{Including a lion}{ctanLion} |
| 1382 |
Note that \WebQuiz assumes that all images are \BashCode|SVG| images by |
| 1383 |
default so it is necessary to give the full filename in any |
| 1384 |
\LatexCode|\includegraphics| command. |
| 1385 |
|
| 1386 |
Using \ctan{pstricks} is often just as easy, such as the following |
| 1387 |
code that works out of the box: |
| 1388 |
\InputLatexCode{pstricks-ex} |
| 1389 |
to produce the web page: |
| 1390 |
\ScreenShot{Pstricks example}{pstricks-ex} |
| 1391 |
|
| 1392 |
Even though \ctan{tikz} and \ctan{pstricks} can be used in \WebQuiz |
| 1393 |
quizzes, both of these packages sometimes have problems. \WebQuiz tries |
| 1394 |
to solve some these problems for you if you use the |
| 1395 |
\LatexCode|pst2pdf| or \LatexCode|tikz| document-class options, which |
| 1396 |
we now describe. |
| 1397 |
|
| 1398 |
\begin{description} |
| 1399 |
\item[pst2pdf] \index{pstricks}\CrossIndex{document class options}{pst2pdf} |
| 1400 |
|
| 1401 |
For the most part, \ctan{pstricks} drawings display correctly. |
| 1402 |
When they do fail they can sometimes be salvaged using |
| 1403 |
\ctan{pst2pdf}. Applying \ctan{pst2pdf} to a \WebQuiz quiz is not |
| 1404 |
completely straightforward, so \WebQuiz provides the |
| 1405 |
document-class option \ctan{pst2pdf} to automatically apply |
| 1406 |
\ctan{pst2pdf} as part of the quiz web page build process. If your |
| 1407 |
\ctan{pstricks} drawings do not display correctly it is worthwhile |
| 1408 |
to see if \ctan{pst2pdf} fixes the problems. |
| 1409 |
|
| 1410 |
For example, the following quiz compiles only with the |
| 1411 |
\ctan{pst2pdf} document-class option: |
| 1412 |
\InputLatexCode{pst2pdf} |
| 1413 |
to produce the quiz: |
| 1414 |
\ScreenShot{Example requiring the pst2pdf document class option}{pst2pdf} |
| 1415 |
The position of the image adjusts with the screen size and it |
| 1416 |
does, in fact, display well on a mobile device. \WebQuiz is not |
| 1417 |
able to display this image without the \LatexCode|pst2pdf| |
| 1418 |
document-class option. |
| 1419 |
|
| 1420 |
\begin{dangerous} |
| 1421 |
Unfortunately, \ctan{pst2pdf} can fail silently without giving any |
| 1422 |
warnings. If you plan to use the \LatexCode|pst2pdf| |
| 1423 |
document-class option then you should first check to make that the |
| 1424 |
\ctan{pst2pdf} package and executable is properly installed. |
| 1425 |
According to the \ctan{pst2pdf} manual: |
| 1426 |
\begin{quote} |
| 1427 |
\ctan{pst2pdf} needs \Ghostscript (>=9.14), perl (>=5.18), pdf2svg, pdftoppm |
| 1428 |
and pdftops (from poppler-utils or xpdf-utils) to process a file |
| 1429 |
using \ctan{pst2pdf}. |
| 1430 |
\end{quote} |
| 1431 |
If using \ctan{pst2pdf} does not produce an image then, rather |
| 1432 |
than \ctan{pst2pdf} not working, the problem might be that you |
| 1433 |
have not installed all of the programs that \ctan{pst2pdf} relies |
| 1434 |
upon, so look in your log files for error messages and check that |
| 1435 |
all of the programs listed above are correctly installed, with the |
| 1436 |
specified version numbers. See also \autoref{SS:pstricks}. |
| 1437 |
\end{dangerous} |
| 1438 |
|
| 1439 |
\item[tikz]\CrossIndex{document class options}{tikz} |
| 1440 |
Giving this class option both loads the \ctan[pgf]{tikz} package |
| 1441 |
and it fixes several issues with PGF that prevent it from working |
| 1442 |
with \TeXfht. It is important that you use the \WebQuiz |
| 1443 |
\LatexCode|tikz| document-class option, and not |
| 1444 |
\LatexCode|\usepackage{tikz}|, because \WebQuiz loads slightly |
| 1445 |
different configuration files for \ctan[pgf]{tikz} that are |
| 1446 |
optimised for use with \TeXfht. \textit{Please note that for |
| 1447 |
\ctan[pfd]{tikz} you need to use \TeXLive \textsf{2018} with all |
| 1448 |
packages updated.} Thanks are due to Michal Hoftich for the |
| 1449 |
enormous amount of effort that he has put into making \TeXfht and |
| 1450 |
\ctan[pgf]{tikz} more compatible. As an example, the quiz file |
| 1451 |
\InputLatexCode{tikz-ex} |
| 1452 |
produces the online quiz: |
| 1453 |
\ScreenShot{Tikz example}{tikz-ex} |
| 1454 |
\end{description} |
| 1455 |
|
| 1456 |
Most people use either \ctan{pstricks} or \ctan{tikz}. A quiz that |
| 1457 |
tries to use both \ctan{pstricks} and \ctan{tikz} will probably not |
| 1458 |
compile. |
| 1459 |
|
| 1460 |
\subsection{Configuring commands and environments for \TeXfht}\label{SS:config}\macroIndex{DisplayAsImage} |
| 1461 |
|
| 1462 |
The underlying engine used by \WebQuiz is \TeXfht so, because |
| 1463 |
\TeXfht is not able process all \LaTeX{} code, there is \LaTeX{} |
| 1464 |
code that \WebQuiz is not able to cope with. This said, \TeXfht is |
| 1465 |
able to display \textit{most} \LaTeX{} code and \WebQuiz has been |
| 1466 |
used to write literally thousands of quiz questions so it is likely |
| 1467 |
that you will be able to typeset what you want in your online |
| 1468 |
quizzes. In particular, as discussed in \autoref{SS:graphics}, it |
| 1469 |
is possible to use \ctan[pgf]{tikz} and \ctan{pstricks} in \WebQuiz |
| 1470 |
quizzes. |
| 1471 |
|
| 1472 |
\WebQuiz uses \TeXfht{} to convert the quiz content from \LaTeX{} to |
| 1473 |
\HTML. If \TeXfht{} has not been configured to for some of the |
| 1474 |
commands or environments that you are using then they may not |
| 1475 |
display correctly in your online quizzes. The ``correct'' way to |
| 1476 |
fix such problems is to write appropriate \TeXfht{} configuration |
| 1477 |
commands, however, this can be tricky to do --- especially if you |
| 1478 |
are not familiar with the inner workings of \TeX{} and \TeXfht. |
| 1479 |
|
| 1480 |
As a workaround, \WebQuiz provides the command |
| 1481 |
\LatexCode|\DisplayAsImage| that, in effect, tells \TeXfht to treat |
| 1482 |
your command as an image when it creates the web page. This is an |
| 1483 |
easy work-around that often produces good results -- and it is much |
| 1484 |
easier than writing your own \TeXfht configuration commands. |
| 1485 |
|
| 1486 |
For example, the \ctan{mhchem} package is a powerful package that |
| 1487 |
defines a macro \LatexCode{\ce} for writing chemical symbols but, |
| 1488 |
unfortunately, the \LatexCode{\ce} macro has not (yet) been |
| 1489 |
configured to work with \TeXfht, which means that this command does |
| 1490 |
not work very well when used in \WebQuiz quizzes. |
| 1491 |
|
| 1492 |
For example, the following code: |
| 1493 |
\InputLatexCode{display-as-image} |
| 1494 |
shows that if you add the line |
| 1495 |
\LatexCode|\DisplayAsImage{ce}| to your quiz after |
| 1496 |
\LatexCode|\begin{document}| then it is |
| 1497 |
possible to use \LatexCode|\ce| in your quizzes: |
| 1498 |
\ScreenShot{Using DisplayAsImage}{display-as-image} |
| 1499 |
As the example code shows, \LatexCode|\DisplayAsImage| accepts an optional |
| 1500 |
argument that can be used to fine-tune the placement of the image on |
| 1501 |
the quiz web page using \CSS. For those interested in the technical details, the |
| 1502 |
definition of \LatexCode|\DisplayAsImage| is: |
| 1503 |
\begin{latexcode} |
| 1504 |
\RequirePackage{etoolbox} |
| 1505 |
\renewcommand\DisplayAsImage[2][]{% |
| 1506 |
\csletcs{real:#2}{#2}% |
| 1507 |
\NewConfigure{#2}{2} |
| 1508 |
\csdef{#2}##1{\Picture+[#1]{}\csuse{real:#2}{##1}\EndPicture} |
| 1509 |
\Configure{#2}{\Picture+[#1]{}}{\EndPicture} |
| 1510 |
} |
| 1511 |
\end{latexcode} |
| 1512 |
|
| 1513 |
\section{System requirements, installation and configuration} |
| 1514 |
\label{S:configuration} |
| 1515 |
\index{system requirements} |
| 1516 |
\CrossIndex{system requirements}{tex4ht} |
| 1517 |
\CrossIndex{system requirements}{make4ht} |
| 1518 |
\CrossIndex{system requirements}{python} |
| 1519 |
|
| 1520 |
\WebQuiz takes a \LaTeX\ file and translates it into a functional |
| 1521 |
web page. To use \WebQuiz the quiz author only needs to know how to |
| 1522 |
use \LaTeX\ \textit{and} to have all of the programs used by \WebQuiz |
| 1523 |
installed. Fortunately, most of the system requirements will already |
| 1524 |
be installed on a system with an up-to-date installation of |
| 1525 |
\TeXLive, however, some tweaking may still be necessary. |
| 1526 |
|
| 1527 |
Behind the scenes, \WebQuiz uses \TeXfht, \python, \Javascript and |
| 1528 |
several other tools to construct and operate the online quizzes. |
| 1529 |
The \WebQuiz program has three main components: |
| 1530 |
\begin{itemize} |
| 1531 |
\item \LaTeX\ files (a class file and \TeXfht configuration files) |
| 1532 |
\item A Python3 program that uses \TeXfht to convert \LaTeX\ |
| 1533 |
files into web pages |
| 1534 |
\item Web files (\Javascript, \CSS and online documentation) |
| 1535 |
%\item Documentation |
| 1536 |
\end{itemize} |
| 1537 |
Of course, to use the online quizzes created by \WebQuiz you |
| 1538 |
need a web server. To use \WebQuiz all of these files need to |
| 1539 |
be in appropriate places. Fortunately, \Ctan takes care of |
| 1540 |
most of this but the web-related files still need to be put onto |
| 1541 |
your web server. |
| 1542 |
|
| 1543 |
\WebQuiz has been tested extensively on Linux and Mac operating |
| 1544 |
systems. Several people have used \WebQuiz on windows computers, |
| 1545 |
but I have not tested the program on a windows computer myself. |
| 1546 |
|
| 1547 |
\subsection{System requirements}\index{system requirements} |
| 1548 |
|
| 1549 |
In order to work \WebQuiz needs the following programs to be |
| 1550 |
installed on your system: |
| 1551 |
\begin{itemize}[nosep] |
| 1552 |
\item An up-to-date \LaTeX{} distribution, such as that provided |
| 1553 |
by \TeXLive. In particular, you need to have \TeXfht{} and |
| 1554 |
\ctan{make4ht} installed. |
| 1555 |
|
| 1556 |
Unfortunately, the version of \ctan{make4ht} that was released |
| 1557 |
with \TeXLive{} 2018 had some bugs and there have been many |
| 1558 |
recent changes to \ctan{make4ht} and \ctan{pstricks}, |
| 1559 |
so it is strongly recommended that you update all packages |
| 1560 |
from \Ctan before you try and use \WebQuiz. |
| 1561 |
|
| 1562 |
\item \python[Python 3]. As of writing python 3.7.2 is available. |
| 1563 |
\item \Javascript |
| 1564 |
\item If your quizzes use \ctan{pstricks}, or if you want to |
| 1565 |
compile the \OnlineManual, then you need to ensure that |
| 1566 |
\Ghostscript and \ctan{dvisvgm} are installed and properly |
| 1567 |
configured; see \autoref{SS:pstricks} for more details. |
| 1568 |
\item A web server. As detailed in \autoref{SS:Initialise}, you |
| 1569 |
will need to install the web components of \WebQuiz. |
| 1570 |
\end{itemize} |
| 1571 |
|
| 1572 |
\subsection{Installing |
| 1573 |
\WebQuiz}\label{SS:Install}\index{install}\index{miktex@Mik\TeX}\index{texlive@\TeXLive} |
| 1574 |
\WebQuiz will be included as a package in \TeXLive 2019 and, once a |
| 1575 |
packaging issue is sorted out, it will be included in \MiKTeX. If |
| 1576 |
\WebQuiz is available as a package from either of these distributions |
| 1577 |
then it can be installed in the usual way. |
| 1578 |
|
| 1579 |
Alternatively, it is possible to download the |
| 1580 |
\href{http://mirrors.ctan.org/macros/latex/contrib/webquiz.zip}{WebQuiz zipfile} from \Ctan. |
| 1581 |
To install \WebQuiz from the zipfile you should: |
| 1582 |
\begin{enumerate}[nosep] |
| 1583 |
\item Download the |
| 1584 |
\href{http://mirrors.ctan.org/macros/latex/contrib/webquiz.zip}{WebQuiz zipfile} from \Ctan. |
| 1585 |
\item Unzip the file |
| 1586 |
\item Change directory of the \BashCode|webquiz/scripts| subdirectory from the zipfile |
| 1587 |
\item From an administrators account, or using \BashCode|sudo| on a |
| 1588 |
unix-like system, run he command: |
| 1589 |
\begin{bashcode} |
| 1590 |
> webquiz --tex-install |
| 1591 |
\end{bashcode} |
| 1592 |
On windows, use: |
| 1593 |
\begin{bashcode} |
| 1594 |
> webquiz.bat --tex-install |
| 1595 |
\end{bashcode} |
| 1596 |
\end{enumerate} |
| 1597 |
This will install the different components of \WebQuiz to their |
| 1598 |
``standard'' locations in he \TeX\ search tree. If you are using |
| 1599 |
\MiKTeX you may need to open the \MiKTeX console, go to the Tasks menu |
| 1600 |
and then rebuild the TeX filename database. |
| 1601 |
|
| 1602 |
Once the \WebQuiz package is installed you should initialise thew |
| 1603 |
package, following the steps given in \autoref{SS:Initialise}. |
| 1604 |
|
| 1605 |
\subsection{Initialising \WebQuiz}\label{SS:Initialise} |
| 1606 |
\CrossIndex{command-line option}{initialise} |
| 1607 |
\index{initialisation} |
| 1608 |
|
| 1609 |
\WebQuiz is a tool for creating online quizzes and in order for |
| 1610 |
it to work efficiently various files |
| 1611 |
(\href{https://en.wikipedia.org/wiki/JavaScript}{javascript} and |
| 1612 |
\href{https://www.w3schools.com/css/css_intro.asp}{cascading style |
| 1613 |
sheets}) need to put onto your web server. \WebQuiz has an |
| 1614 |
\textit{initialisation} routine for installing the web components |
| 1615 |
of the program. In fact, until \WebQuiz has been initialised it |
| 1616 |
will ask you if you to run the initialisation routine every time |
| 1617 |
you use \WebQuiz. You can reinitialise \WebQuiz at any time using |
| 1618 |
the command-line option: |
| 1619 |
\begin{bashcode} |
| 1620 |
> webquiz --initialise |
| 1621 |
\end{bashcode} |
| 1622 |
\WebQuiz will actually work without being initialised, however, any |
| 1623 |
quiz web pages that are created before initialisation will be |
| 1624 |
emblazoned with a message reminding you to initialise \WebQuiz. |
| 1625 |
|
| 1626 |
The location of the files on the web server depends both on the |
| 1627 |
operating system that is running on your computer and how your web |
| 1628 |
server has been configured. It is essential that the \WebQuiz files |
| 1629 |
are installed in a directory that is accessible from the web. It |
| 1630 |
does not matter if they are put into a user web directory or into a |
| 1631 |
system web directory. If in doubt please consult your system |
| 1632 |
administrator. |
| 1633 |
|
| 1634 |
Common locations for the \textit{web root} of the server are: |
| 1635 |
\begin{center} |
| 1636 |
\begin{tabular}{ll} |
| 1637 |
\toprule |
| 1638 |
Operating system & Root of web server \\\midrule |
| 1639 |
Mac OSX & \BashCode|/Library/WebServer/Documents|\\ |
| 1640 |
Linux & \BashCode|/var/www/html|\\ |
| 1641 |
Windows & \BashCode|C:\inetpub\wwwroot|\\ |
| 1642 |
\bottomrule |
| 1643 |
\end{tabular} |
| 1644 |
\end{center} |
| 1645 |
\WebQuiz needs to copy several files into a subdirectory of this |
| 1646 |
\textit{web root}. When you run |
| 1647 |
\begin{bashcode} |
| 1648 |
> webquiz --initialise |
| 1649 |
\end{bashcode} |
| 1650 |
you will be prompted for the following: |
| 1651 |
\begin{itemize} |
| 1652 |
\item The location of the \WebQuiz web directory, which needs to |
| 1653 |
be a directory that is visible to your web server |
| 1654 |
\item The relative URL for this directory, which tells your web |
| 1655 |
browser where to find these files |
| 1656 |
\end{itemize} |
| 1657 |
For example, on my system the web root for our web server is |
| 1658 |
\BashCode|/usr/local/httpd/| and the \WebQuiz web files are in |
| 1659 |
the directory \BashCode|/usr/local/httpd/UoS/WebQuiz|. So, I set: |
| 1660 |
\begin{quote} |
| 1661 |
\begin{tabular}{lll} \WebQuiz web |
| 1662 |
directory &=& \BashCode|/usr/local/httpd/UoS/WebQuiz|\\ |
| 1663 |
\WebQuiz relative URL &=& \BashCode|/UoS/WebQuiz| |
| 1664 |
\end{tabular} |
| 1665 |
\end{quote} |
| 1666 |
Once the initialisation step is complete, \WebQuiz is ready to use |
| 1667 |
although you, possibly from an administrators account or using |
| 1668 |
\BashCode|sudo|, may also want to run: |
| 1669 |
\begin{bashcode} |
| 1670 |
> webquiz --edit-settings |
| 1671 |
\end{bashcode} |
| 1672 |
This will talk you the process of setting system defaults for the quizzes that, |
| 1673 |
for example, specify the name and URL for your department and |
| 1674 |
institution as well as the default language and theme used for the |
| 1675 |
quizzes. If in doubt about any of the option press return to accept |
| 1676 |
the default. See \autoref{SS:rcfile} for more details. |
| 1677 |
|
| 1678 |
You can test your \WebQuiz installation by compiling the example |
| 1679 |
files from the \WebQuiz manual. You can find these files in the |
| 1680 |
directory \BashCode|web_root/doc/examples|, where the |
| 1681 |
\BashCode|web_root| is the directory where you just installed |
| 1682 |
the \WebQuiz web files. If \Ghostscript and \ctan{dvisvgm} are |
| 1683 |
installed and properly configured (see \autoref{SS:graphics}) then you |
| 1684 |
should also be able to compile the \OnlineManual using \WebQuiz. |
| 1685 |
|
| 1686 |
\begin{dangerous} |
| 1687 |
\textit{To install the \WebQuiz files for general use on |
| 1688 |
your system, or to save system wide settings, you need to run |
| 1689 |
the initialisation command }\BashCode|webquiz --initialise| |
| 1690 |
\textit{using an administrator account or using \BashCode|sudo| on a |
| 1691 |
UNIX or Mac OSX system.} |
| 1692 |
|
| 1693 |
If you have already saved a \textit{user} \webquizrc file then to |
| 1694 |
change the \textit{system} \webquizrc* you will use need to |
| 1695 |
use the \BashCode|--rcfile| command-line option: |
| 1696 |
\begin{latexcode} |
| 1697 |
> webquiz --rcfile /path/to/system/rc-file --initialise |
| 1698 |
\end{latexcode}\index{rcfile} |
| 1699 |
\end{dangerous} |
| 1700 |
|
| 1701 |
\begin{heading}[Remark] |
| 1702 |
To remove all \WebQuiz files from your web server use: |
| 1703 |
\begin{bashcode} |
| 1704 |
> webquiz --uninstall |
| 1705 |
\end{bashcode} |
| 1706 |
\end{heading} |
| 1707 |
|
| 1708 |
\subsection{Graphics and \texorpdfstring{\ctan{dvisvgm}}{dvisvgm}} |
| 1709 |
\label{SS:pstricks} |
| 1710 |
|
| 1711 |
\index{pstricks} |
| 1712 |
\noindent |
| 1713 |
\WebQuiz, via \TeXfht, uses \ctan{dvisvgm} to convert certain images to |
| 1714 |
\href{https://en.wikipedia.org/wiki/Scalable_Vector_Graphics}{Scalable |
| 1715 |
Vector Graphics} (SVG). This is done using his is done |
| 1716 |
using \ctan{dvisvgm}. At first sight this is OK because \ctan{dvisvgm} is |
| 1717 |
included in \TeXLive and \MiKTeX, however, \ctan{dvisvgm} uses |
| 1718 |
\Ghostscript and this needs to be correctly configured and, as |
| 1719 |
outlined in \href{http://dvisvgm.bplaced.net/FAQ}{FAQ}, \ctan{dvisvgm} |
| 1720 |
needs to know where to find the \Ghostscript libraries. For example, |
| 1721 |
to get \ctan{dvisvgm} to work on my system I needed to add the line |
| 1722 |
\begin{bashcode} |
| 1723 |
export LIBGS=/usr/local/lib/libgs.dylib |
| 1724 |
\end{bashcode} |
| 1725 |
to my \BashCode|.bashrc| file. To see whether you need to do something |
| 1726 |
similar on your system you need to look at the output from the following |
| 1727 |
two commands: |
| 1728 |
|
| 1729 |
\begin{bashcode} |
| 1730 |
> dvisvgm -h |
| 1731 |
> dvisvgm -l |
| 1732 |
\end{bashcode} |
| 1733 |
|
| 1734 |
\noindent There are three possibilities: |
| 1735 |
|
| 1736 |
\begin{itemize} |
| 1737 |
\item the \BashCode|-h| output does not contain \BashCode|-libgs| |
| 1738 |
and the \BashCode|-l| output contains \BashCode|ps|: |
| 1739 |
ghostscript was linked at build time, so everything should work |
| 1740 |
\item |
| 1741 |
the \BashCode|-h| output contains \BashCode|-libgs| and the |
| 1742 |
\BashCode|-l| output does not contain \BashCode|ps|: |
| 1743 |
gpostscript support is enabled but ghostscript is not linked. You |
| 1744 |
need to locate the ghostscript library |
| 1745 |
\BashCode|libgs.so| or \BashCode|libgs.dylib| on your system and set |
| 1746 |
the \BashCode|LIBGS| environment variable, or equivalent, |
| 1747 |
accordingly |
| 1748 |
\item the \BashCode|-h| output does not contain \BashCode|-libgs| |
| 1749 |
and the \BashCode|-l| output does not contain \BashCode|ps|: |
| 1750 |
\ctan{dvisvgm} was not built with postscript support. In this |
| 1751 |
case, \WebQuiz will not be able to process \ctan{svg} images. You |
| 1752 |
need to reinstall \ctan{dvisvgm} with ghostscript support. |
| 1753 |
\end{itemize} |
| 1754 |
|
| 1755 |
\section{The \WebQuiz program} \index{usage} |
| 1756 |
|
| 1757 |
The \WebQuiz program was designed to be run from the command-line. |
| 1758 |
To produce an online quiz from a \WebQuiz \LaTeX{} file \BashCode|quiz.tex| |
| 1759 |
type: |
| 1760 |
\begin{bashcode} |
| 1761 |
> webquiz quiz or > webquiz quiz.tex |
| 1762 |
\end{bashcode} |
| 1763 |
One feature of \WebQuiz is that you can process more than one |
| 1764 |
quiz file at a time. For example, if you have quiz files |
| 1765 |
\BashCode|quiz1.tex|, ..., \BashCode|quiz9.tex| in the current directory |
| 1766 |
then, on a UNIX system, you can rebuild the web pages for all of |
| 1767 |
these quizzes using the single command: |
| 1768 |
\begin{bashcode} |
| 1769 |
> webquiz quiz[1-9].tex |
| 1770 |
\end{bashcode} |
| 1771 |
This is useful if some generic aspect of all of the quizzes has |
| 1772 |
changed, such as the theme, the language, thebreadcrumbs or a |
| 1773 |
department URL. In fact, one would probably use |
| 1774 |
\begin{bashcode} |
| 1775 |
> webquiz -dqq quiz*.tex |
| 1776 |
\end{bashcode} |
| 1777 |
because the \BashCode|webquiz --qq| command-line option suppresses |
| 1778 |
almost all of the output produced by \LaTeX\ and \TeXfht and |
| 1779 |
\BashCode|-d|, which is \textit{draft mode}, is faster and it is |
| 1780 |
probably sufficient if the quizzes were compiled recently. The |
| 1781 |
next section discusses the \WebQuiz command-line options. |
| 1782 |
|
| 1783 |
\subsection{Command-line options}\label{SS:commandline} |
| 1784 |
\index{command-line option} |
| 1785 |
Typing \BashCode|webquiz -h|, or \BashCode|webquiz --help| on |
| 1786 |
the command-line gives the following summary of the \WebQuiz |
| 1787 |
command-line options: |
| 1788 |
\InputBashCode{webquiz.usage} |
| 1789 |
The command-line options are listed on separate lines above to |
| 1790 |
improve readability. In practice, the different options need to be |
| 1791 |
one the same line, although they can appear in any order. |
| 1792 |
|
| 1793 |
We describe the different options, grouping them according to |
| 1794 |
functionality. |
| 1795 |
|
| 1796 |
\begin{description} |
| 1797 |
\item[-h, --help] \CrossIndex{command-line option}{help} |
| 1798 |
list the command-line options and exit |
| 1799 |
\CrossIndex{command-line option}{help} |
| 1800 |
|
| 1801 |
\item[-q, -qq, \ddash quiet] \CrossIndex{command-line option}{quiet mode} |
| 1802 |
Suppress \LaTeX{} and \TeXfht error messages: \BashCode|-q| is |
| 1803 |
quiet and \BashCode|-qq| is very quiet. If you use |
| 1804 |
\BashCode|webquiz -qq texfile.tex| then almost no output will |
| 1805 |
be printed by \WebQuiz when it is processing your quiz file. Be |
| 1806 |
warned, however, that both of these options can make it harder |
| 1807 |
to find and fix errors, so using the \BashCode|-q| and |
| 1808 |
\BashCode|-qq| options is recommended if your file is known |
| 1809 |
to compile. |
| 1810 |
\CrossIndex{command-line option}{quiet} |
| 1811 |
|
| 1812 |
\end{description} |
| 1813 |
|
| 1814 |
\subsubsection*{\TeX{} options} |
| 1815 |
|
| 1816 |
\begin{description} |
| 1817 |
|
| 1818 |
\item[-d, \ddash draft] draft mode. The \LaTeX file is processed |
| 1819 |
only once by \BashCode|htlatex|, which gives a much faster |
| 1820 |
compilation time but cross references etc may not be completely |
| 1821 |
up to date. This is equivalent to using: |
| 1822 |
\BashCode|make4ht --mode draft| |
| 1823 |
\CrossIndex{command-line option}{draft mode} |
| 1824 |
|
| 1825 |
\item[-s,\ddash shell-escape] Shell escape for \LaTeX/ht\LaTeX/make4ht |
| 1826 |
\CrossIndex{command-line option}{shell-escape} |
| 1827 |
|
| 1828 |
\item[\ddash latex] Use \LaTeX{} to compile the quiz (the default) |
| 1829 |
\CrossIndex{command-line option}{lua} |
| 1830 |
|
| 1831 |
\item[-l,\ddash lua] Use lua\LaTeX{} to compile the quiz |
| 1832 |
\CrossIndex{command-line option}{lua} |
| 1833 |
|
| 1834 |
\item[-x, \ddash xelatex] Use xe\LaTeX{} to compile the quiz |
| 1835 |
\CrossIndex{command-line option}{xelatex} |
| 1836 |
\index{xelatex} |
| 1837 |
|
| 1838 |
\end{description} |
| 1839 |
|
| 1840 |
\subsubsection*{Settings and configuration} |
| 1841 |
|
| 1842 |
\begin{description} |
| 1843 |
|
| 1844 |
\item[-r {[RCFILE]}, \ddash rcfile {[RCFILE]}] |
| 1845 |
\CrossIndex{command-line option}{rcfile} Specify the |
| 1846 |
location of the \webquizrc file to use. This setting is only |
| 1847 |
necessary if you want to override the default \webquizrc*. |
| 1848 |
|
| 1849 |
\item[-i, \ddash initialise] \CrossIndex{command-line |
| 1850 |
option}{initialisation} Initialise files and settings for |
| 1851 |
webquiz. See \autoref{SS:Initialise} for more details. |
| 1852 |
|
| 1853 |
\item[\ddash edit-settings] \CrossIndex{command-line |
| 1854 |
option}{edit-settings} Edit the webquiz settings in the |
| 1855 |
\WebQuiz rc-file. See \autoref{SS:rcfile} for more details. |
| 1856 |
|
| 1857 |
\textit{If you do not have permission to write to the system |
| 1858 |
rc-file, which is in the \WebQuiz scripts directory, then you |
| 1859 |
will be given the option of saving the \WebQuiz settings to an |
| 1860 |
rc-file in your home directory or another file of your choice. |
| 1861 |
If you want to save the settings to a particular rc-file use |
| 1862 |
the \BashCode|--rcfile| option. If you want to change the |
| 1863 |
system \webquizrc then use a administrator account or, |
| 1864 |
on a unix-like system,} use \BashCode|sudo webquiz --edit-settings|. |
| 1865 |
|
| 1866 |
\item[\ddash settings {[SETTING]}] \CrossIndex{command-line option}{settings} |
| 1867 |
\SeeIndex{rcfile}{webquizrc} |
| 1868 |
\SeeIndex{default settings}{webquizrc} |
| 1869 |
List system settings for webquiz stored in \webquizrc, the |
| 1870 |
(\textit{run-time configuration file}). Optionally, a single |
| 1871 |
\BashCode|SETTING| can be given in which case the value of |
| 1872 |
only that setting is returned. If \BashCode|SETTING| is |
| 1873 |
omitted then the list of current settings are printed. Use |
| 1874 |
\BashCode|SETTING=verbose| for a more verbose listing of the |
| 1875 |
settings and \BashCode|SETTING=help| for a summary of the |
| 1876 |
settings. |
| 1877 |
|
| 1878 |
The rc-file can be edited by hand, however, it is |
| 1879 |
recommended that you instead use |
| 1880 |
\begin{bashcode} |
| 1881 |
webquiz --edit-settings |
| 1882 |
\end{bashcode} |
| 1883 |
Typical settings returned by this command look like: |
| 1884 |
\InputBashCode{webquiz.settings} |
| 1885 |
See \autoref{SS:rcfile} for more details. |
| 1886 |
|
| 1887 |
\end{description} |
| 1888 |
|
| 1889 |
\subsubsection*{Advanced command-line options} |
| 1890 |
|
| 1891 |
\begin{dangerous} |
| 1892 |
\textit{Change these settings with care: an incorrect value for |
| 1893 |
these settings can stop \WebQuiz from working.} |
| 1894 |
\end{dangerous} |
| 1895 |
|
| 1896 |
\begin{description} |
| 1897 |
\item[\ddash make4ht MAKE4HT-OPTIONS] |
| 1898 |
\CrossIndex{command-line option}{make4ht} |
| 1899 |
Options to be passed to \ctan{make4ht} when converting the |
| 1900 |
\LaTeX{} to \XML. This option is equivalent to setting |
| 1901 |
the \BashCode|make4ht| in the \webquizrc; see |
| 1902 |
\autoref{SS:rcfile}. At least under UNIX, multiple arguments |
| 1903 |
should be enclosed in quotes. For example, to give |
| 1904 |
\ctan{make4ht} a custom mk4 file (note that |
| 1905 |
\BashCode|myquiz.mk4| is included, if it exists), you would use |
| 1906 |
\begin{bashcode} |
| 1907 |
> webquiz --make4ht "-e file.mk4" myquiz.tex |
| 1908 |
\end{bashcode} |
| 1909 |
The \BashCode|make4ht| command-line option will be required |
| 1910 |
only in rare instances. |
| 1911 |
\index{lualatex}\index{xelatex} |
| 1912 |
|
| 1913 |
\item[\ddash uninstall] Remove all \WebQuiz files from your |
| 1914 |
web server directory. This command only removes files that |
| 1915 |
\WebQuiz may have installed on your web server. It does |
| 1916 |
\textit{not} remove \WebQuiz from your \LaTeX{} distribution. |
| 1917 |
|
| 1918 |
\item[\ddash webquiz-layout WEBQUIZ-LAYOUT] |
| 1919 |
\CrossIndex{command-line option}{layout} |
| 1920 |
Name of (local) \python code that controls the layout of quiz web page. This |
| 1921 |
option is equivalent to setting the \LatexCode|webquiz-layout| |
| 1922 |
in the \webquizrc. See \autoref{SS:layout} for |
| 1923 |
more details. |
| 1924 |
|
| 1925 |
\end{description} |
| 1926 |
|
| 1927 |
\subsubsection*{Other options} |
| 1928 |
|
| 1929 |
The following command-line options are mainly useful mainly for |
| 1930 |
code developers. |
| 1931 |
|
| 1932 |
\begin{description} |
| 1933 |
\item[\ddash version] Prints the \WebQuiz version number and |
| 1934 |
exit (currently \webquiz{version}) |
| 1935 |
|
| 1936 |
\item[\ddash tex-install] Use this command-line option if |
| 1937 |
you are installing the \LaTeX{} components of |
| 1938 |
\WebQuiz from the \Ctan zip-filei (see \autoref{SS:Install}). It will install the different |
| 1939 |
\LaTeX{} components of \WebQuiz into \BashCode|TEXMFMAIN|. If |
| 1940 |
you installed \WebQuiz as part of a \TeX{} distribution, such as |
| 1941 |
\TeXLive, then you do not need to use this option. |
| 1942 |
|
| 1943 |
\item[\ddash tex-uninstall] Use this command-line option to |
| 1944 |
remove the \LaTeX{} components of \WebQuiz from your system. |
| 1945 |
Only use this option if you installed \WebQuiz using the \Ctan |
| 1946 |
zip-file. |
| 1947 |
|
| 1948 |
\item[\ddash debugging] Displays extra debugging information |
| 1949 |
when compiling and prevents \WebQuiz from deleting the many |
| 1950 |
intermediary files that are created when building the quiz web |
| 1951 |
pages. |
| 1952 |
\end{description} |
| 1953 |
|
| 1954 |
\subsection{\WebQuiz settings and the webquizrc file} |
| 1955 |
\label{SS:rcfile}\index{default settings}\index{webquizrc} |
| 1956 |
|
| 1957 |
\WebQuiz stores the following default sets in \webquizrc*, a |
| 1958 |
\textit{run-time configuration file}: |
| 1959 |
\begin{description}[nosep, labelwidth=18ex] |
| 1960 |
\item[breadcrumbs] breadcrumbs at the top of quiz page (\autoref{SS:breadcrumbs}) |
| 1961 |
\item[department] name of department (\autoref{SS:breadcrumbs}) |
| 1962 |
\item[department-url] url for department (\autoref{SS:breadcrumbs}) |
| 1963 |
\item[engine] default tex engine used to compile web pages (\autoref{SS:classOptions}) |
| 1964 |
\item[hide-side-menu] do not display the side menu at start of quiz |
| 1965 |
(\autoref{SS:classOptions}) |
| 1966 |
\item[institution] institution or university (\autoref{SS:breadcrumbs}) |
| 1967 |
\item[institution-url] url for institution or university (\autoref{SS:breadcrumbs}) |
| 1968 |
\item[language] default language used on web pages (\autoref{SS:classOptions}) |
| 1969 |
\item[one-page] display questions on one page (\autoref{SS:classOptions}) |
| 1970 |
\item[random-order] randomly order the quiz questions (\autoref{SS:classOptions}) |
| 1971 |
\item[theme] default colour theme used on web pages (\autoref{SS:classOptions}) |
| 1972 |
\item[version] webquiz version number for webquizrc settings |
| 1973 |
(\autoref{SS:rcfile}) |
| 1974 |
\item[webquiz-url] relative url for webquiz web directory (\autoref{SS:Initialise}) |
| 1975 |
\item[webquiz-www] full path to webquiz web directory (\autoref{SS:Initialise}) |
| 1976 |
\item[make4ht] build file for make4ht (\autoref{SS:Initialise}) |
| 1977 |
\item[mathjax] url for mathjax (\autoref{SS:Initialise}) |
| 1978 |
\item[webquiz-layout] name of \python module that formats the quizzes |
| 1979 |
(\autoref{SS:layout}) |
| 1980 |
\end{description} |
| 1981 |
The last three options are \textit{advanced options} that you should |
| 1982 |
change with care. |
| 1983 |
|
| 1984 |
The default values of all of these settings can be overridden in the |
| 1985 |
\LaTeX{} file for the quiz, or with the command-line options. The |
| 1986 |
default values can be changed at any time using |
| 1987 |
\begin{bashcode} |
| 1988 |
webquiz --edit-settings |
| 1989 |
\end{bashcode} |
| 1990 |
When changing the settings \WebQuiz tries to explain what it is |
| 1991 |
doing at each step. If you are unsure what a particular setting does |
| 1992 |
then \textit{press return} to accept the default value --- the |
| 1993 |
default value is printed inside square brackets as |
| 1994 |
\BashCode|[default]|. In particular, when you first start using |
| 1995 |
\WebQuiz it is recommended that you accept the default values |
| 1996 |
for all of the advanced options because it is very unlikely that you |
| 1997 |
will need to change these initially. |
| 1998 |
|
| 1999 |
The first line of output from \BashCode|webquiz --settings| gives |
| 2000 |
the location of the rc-file being used. The system rc-file, |
| 2001 |
\webquizrc*, is saved in the \BashCode|tex/latex/webquiz| subdirectory |
| 2002 |
of the \BashCode|TEXMFLOCAL| directory. A typically location for |
| 2003 |
this file is |
| 2004 |
\begin{bashcode} |
| 2005 |
/usr/local/texlive/texmf-local/tex/latex/webquiz/webquizrc |
| 2006 |
\end{bashcode} |
| 2007 |
By default, the \WebQuiz settings are saved here so that you do not |
| 2008 |
need to reinitialise \WebQuiz whenever you update your \TeX{} |
| 2009 |
distribution. If you do not have permission to write to this |
| 2010 |
directory then you will be asked if you would like to save the |
| 2011 |
rc-file somewhere else. The location of the user rc-file is: |
| 2012 |
\begin{itemize} |
| 2013 |
\item \BashCode|~/.dotfiles/config/webquizrc| |
| 2014 |
if the directory \BashCode|~/.dotfiles/config| exists, |
| 2015 |
\item \BashCode|~/.config/webquizrc| |
| 2016 |
if the directory \BashCode|~/.config| exists, |
| 2017 |
\item \BashCode|~/.webquizrc| otherwise. |
| 2018 |
\end{itemize} |
| 2019 |
Each time \WebQuiz is run it reads the system and user rc-files, if |
| 2020 |
they exist. When using \BashCode|webquiz --edit-settings| you will |
| 2021 |
be promoted for a different installation location if you do not have |
| 2022 |
permission to write to the specified rc-file. To use a particular |
| 2023 |
\webquizrc* use the \BashCode|--rcfile| command-line option: |
| 2024 |
\begin{bashcode} |
| 2025 |
> webquiz --rcfile <full path to rc-file> ... |
| 2026 |
\end{bashcode} |
| 2027 |
If you save the settings to a non-standard location then you will |
| 2028 |
need to use the command-line option \BashCode|webquiz --rcfile RCFILE| to access |
| 2029 |
these settings. |
| 2030 |
|
| 2031 |
\noindent To describe the \WebQuiz defaults settings we consider them by category. |
| 2032 |
|
| 2033 |
\subsubsection*{Institution settings} |
| 2034 |
\begin{description} |
| 2035 |
|
| 2036 |
\item[department] |
| 2037 |
Sets the default department name. This can be overridden in |
| 2038 |
the \LaTeX{} file using \LatexCode|\Department| in |
| 2039 |
\autoref{SS:breadcrumbs} |
| 2040 |
\CrossIndex{webquizrc}*{Department} |
| 2041 |
|
| 2042 |
\item[department-url] |
| 2043 |
Sets the URL for the department. This can be overridden in |
| 2044 |
the \LaTeX{} file using \LatexCode|\DepartmentURL| in |
| 2045 |
\autoref{SS:breadcrumbs} |
| 2046 |
\CrossIndex{webquizrc}*{DepartmentURL} |
| 2047 |
|
| 2048 |
\item[institution] |
| 2049 |
Sets the default institution name. This can be overridden in the |
| 2050 |
\LaTeX{} file using \LatexCode|\Institution| in |
| 2051 |
\autoref{SS:breadcrumbs} |
| 2052 |
\CrossIndex{webquizrc}*{Institution} |
| 2053 |
|
| 2054 |
\item[institution-url] |
| 2055 |
Sets the URL for the institution.This can be overridden in |
| 2056 |
the \LaTeX{} file using \LatexCode|\InstitutionURL| in |
| 2057 |
\autoref{SS:breadcrumbs} |
| 2058 |
\CrossIndex{webquizrc}*{InstitutionURL`} |
| 2059 |
|
| 2060 |
\end{description} |
| 2061 |
|
| 2062 |
\subsubsection*{Formatting options} |
| 2063 |
|
| 2064 |
\begin{description} |
| 2065 |
|
| 2066 |
\item[breadcrumbs]\index{breadcrumbs} |
| 2067 |
Sets the default breadcrumbs at the top of quiz page. The |
| 2068 |
default breadcrumbs can be overwritten in the quiz file using |
| 2069 |
the \LatexCode{\BreadCrumbs} command. See |
| 2070 |
\autoref{SS:breadcrumbs} for more details. |
| 2071 |
\CrossIndex{webquizrc}*{BreadCrumbs} |
| 2072 |
|
| 2073 |
\item[engine] Sets the default \TeX{} engine to be used when |
| 2074 |
compiling the quiz. By default, \BashCode|latex| is used, with |
| 2075 |
the two other possibilities being \BashCode|lua| and |
| 2076 |
\BashCode|xelatex|, for \Hologo{LuaLaTeX} and \hologo{XeLaTeX} |
| 2077 |
respectively. Behind the scenes, the two choices |
| 2078 |
correspond to invoking \ctan{make4ht} with the |
| 2079 |
\BashCode|--lua| and \BashCode|--xelatex| options, |
| 2080 |
respectively. The \BashCode|engine| setting in the |
| 2081 |
\webquizrc* can be overridden by the webquizrc |
| 2082 |
\BashCode|--latex|, \BashCode|--lua| and \BashCode|--xelatex|. |
| 2083 |
\CrossIndex{webquizrc}{engine} |
| 2084 |
\CrossIndex{webquizrc}{latex} |
| 2085 |
\CrossIndex{webquizrc}{lualatex} |
| 2086 |
\CrossIndex{webquizrc}{xelatex} |
| 2087 |
|
| 2088 |
\item[language]\index{language} |
| 2089 |
Sets the default language for the \WebQuiz web pages. This can |
| 2090 |
be overridden in the quiz file by using the document class |
| 2091 |
\LatexCode|language| option: \LatexCode|language=xxx| |
| 2092 |
See \autoref{SS:classOptions}. |
| 2093 |
\CrossIndex{webquizrc}{language} |
| 2094 |
|
| 2095 |
\item[theme]\index{theme} |
| 2096 |
Sets the default colour theme for the \WebQuiz web pages. This can |
| 2097 |
be overridden in the quiz file by using the document class |
| 2098 |
\LatexCode|theme| option: \LatexCode|theme=xxx|. |
| 2099 |
See \autoref{SS:classOptions}. |
| 2100 |
\CrossIndex{webquizrc}{theme} |
| 2101 |
|
| 2102 |
\end{description} |
| 2103 |
|
| 2104 |
\subsubsection*{Advanced options} |
| 2105 |
|
| 2106 |
\begin{description} |
| 2107 |
|
| 2108 |
\item[make4ht]\index{make4ht} |
| 2109 |
Options for \ctan{make4ht}. Rather than using \TeXfht |
| 2110 |
directly, \WebQuiz uses \ctan{make4ht} to convert the |
| 2111 |
\LaTeX\ file to \XML. Use this option to |
| 2112 |
customise how \ctan{make4ht} is called. See the |
| 2113 |
\ctan[make4ht]{make4ht manual} for more information. |
| 2114 |
\CrossIndex{webquizrc}{make4ht} |
| 2115 |
|
| 2116 |
\item[mathjax] \WebQuiz web pages use \href{https://www.mathjax.org/}{mathjax} to |
| 2117 |
render the mathematics on the quiz web pages. By default this |
| 2118 |
is done by loading \BashCode|mathjax| from |
| 2119 |
\begin{bashcode} |
| 2120 |
https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js |
| 2121 |
\end{bashcode} |
| 2122 |
Fetching \BashCode|mathjax| from an external site can |
| 2123 |
cause a delay when the quiz web pages are loaded. This setting |
| 2124 |
in the rc-file allows you to change where \BashCode|mathjax| is |
| 2125 |
loaded from. For example, if you install \BashCode|mathjax| on |
| 2126 |
your web server then you would replace this will the |
| 2127 |
corresponding relative URL. |
| 2128 |
\CrossIndex{webquizrc}{mathjax} |
| 2129 |
|
| 2130 |
\item[webquiz-layout] |
| 2131 |
Sets the \python file that writes the \HTML file for the quiz. |
| 2132 |
Most people will not need this option. The next subsection |
| 2133 |
describes how to do this in more detail. |
| 2134 |
\CrossIndex{webquizrc}{layout} |
| 2135 |
|
| 2136 |
\end{description} |
| 2137 |
|
| 2138 |
\subsubsection*{Configuration settings} |
| 2139 |
Use \BashCode|webquiz --initialise| to change these settings. |
| 2140 |
|
| 2141 |
\begin{description} |
| 2142 |
|
| 2143 |
\item[webquiz-url] This is the relative URL for \WebQuiz web directory |
| 2144 |
\CrossIndex{webquizrc}{webquiz-url} |
| 2145 |
|
| 2146 |
\item[webquiz-www] This is the full path to the \WebQuiz web |
| 2147 |
directory. The \OnlineManual and other example code can be found |
| 2148 |
in the \BashCode|docs| subdirectory. If you use \BashCode|bash|, |
| 2149 |
then the command |
| 2150 |
\begin{bashcode} |
| 2151 |
> cd $(webquiz --settings webquiz-www)/docs |
| 2152 |
\end{bashcode}%$ |
| 2153 |
will take you to the \WebQuiz online \BashCode|docs/| directory. |
| 2154 |
\CrossIndex{webquizrc}{webquiz-www} |
| 2155 |
|
| 2156 |
\end{description} |
| 2157 |
|
| 2158 |
\subsection{Changing the layout of the \WebQuiz web pages} |
| 2159 |
\label{SS:layout}\index{layout} |
| 2160 |
|
| 2161 |
\begin{dangerous} |
| 2162 |
\textit{This is an advanced \WebQuiz feature that most people will |
| 2163 |
not need. To change the layout of the quiz web pages created by |
| 2164 |
\WebQuiz requires working knowledge of \HTML and \python.} |
| 2165 |
\end{dangerous} |
| 2166 |
|
| 2167 |
The construction of the online quizzes is controlled by the \python |
| 2168 |
file \PythonCode|webquiz_standard.py|. If you want to change the |
| 2169 |
structure of the web pages for the quizzes then the easiest way to |
| 2170 |
do this is to make a copy of \PythonCode|webquiz_standard.py|, say |
| 2171 |
\PythonCode|webquiz_myformat.py|, and then edit this file directly. |
| 2172 |
This will require working knowledge of \python and \HTML. To give |
| 2173 |
you an idea of what needs to be done, the \python file |
| 2174 |
\PythonCode|webquiz_standard| contains a single function |
| 2175 |
\PythonCode|write_web_page| that returns the \HTML for the page as a |
| 2176 |
string using the following: |
| 2177 |
\begin{htmlcode} |
| 2178 |
quiz_page = r'''<!DOCTYPE HTML> |
| 2179 |
<html lang="en"> |
| 2180 |
<head> |
| 2181 |
<title> {title} </title> |
| 2182 |
{htmlpreamble} |
| 2183 |
</head> |
| 2184 |
<body> |
| 2185 |
{no_script}{breadcrumbs} |
| 2186 |
<div class="quiz-page"> |
| 2187 |
{side_menu} |
| 2188 |
<div class="quiz-questions"> |
| 2189 |
{quiz_header} |
| 2190 |
{quiz_questions} |
| 2191 |
</div> |
| 2192 |
</div> |
| 2193 |
{webquiz_init} |
| 2194 |
</body> |
| 2195 |
</html> |
| 2196 |
''' |
| 2197 |
\end{htmlcode} |
| 2198 |
By changing this output you can change the layout of the quizzes |
| 2199 |
produced by \WebQuiz. For example, by adding code to the |
| 2200 |
\HTMLCode|<head>...</head>| section of \HTMLCode|quiz_page| it is |
| 2201 |
easy to include new \CSS code and by modifying |
| 2202 |
\HTMLCode|<body>....</body>| you can change the layout of the page. |
| 2203 |
More sophisticated versions of \PythonCode|webquiz_standard.py|, |
| 2204 |
where you change the underlying \python code, are possible. At the |
| 2205 |
University of Sydney we have a custom version of |
| 2206 |
\PythonCode|webquiz_standard.py| that calls our content management |
| 2207 |
system and, in this way, embeds the quiz web page inside a web page |
| 2208 |
that used the official ``branding'' required by our university. |
| 2209 |
|
| 2210 |
When experimenting with a new layout can run |
| 2211 |
\WebQuiz using the command: |
| 2212 |
\begin{bashcode} |
| 2213 |
> webquiz --webquiz-layout webquiz_myformat quizfile.tex |
| 2214 |
\end{bashcode} |
| 2215 |
Once the new layout is finalised you can make it the default |
| 2216 |
layout by setting \BashCode|webquiz-layout| equal to \BashCode|webquiz_my_format| |
| 2217 |
in the \webquizrc using \BashCode|webquiz --edit-settings|. |
| 2218 |
\index{edit-settings}\index{webquiz-layout} |
| 2219 |
|
| 2220 |
If you do make modifications to any of these files then, by the |
| 2221 |
\WebQuiz Licensing agreement, you are required to create a new |
| 2222 |
version of this file that has a \textit{different name}. Doing this |
| 2223 |
will also make it easier for you to integrate your changes with any |
| 2224 |
future releases of \WebQuiz. |
| 2225 |
|
| 2226 |
\subsection{Bugs, issues and feature requests}\index{bug reports} |
| 2227 |
Please report any bugs, issues or feature requests using the |
| 2228 |
\textit{issue} tracker at |
| 2229 |
\begin{quote} |
| 2230 |
\href{https://\webquiz{repository}}{\webquiz{repository}}. |
| 2231 |
\end{quote} |
| 2232 |
When reporting a bug please provide a \textit{minimal working example} |
| 2233 |
that clearly demonstrates your problem. This should be a compilable |
| 2234 |
\LaTeX file that looks something like the following: |
| 2235 |
\begin{latexcode} |
| 2236 |
\documentclass{webquiz} |
| 2237 |
\begin{document} |
| 2238 |
** insert problematic code here ** |
| 2239 |
\end{document} |
| 2240 |
\end{latexcode} |
| 2241 |
Bug reports that do not have a minimal working example can be |
| 2242 |
hard to reproduce in which case it is not possible to fix them. |
| 2243 |
Before submitting a bug export please first compile your quiz using |
| 2244 |
(pdf)latex to check to see if your problem is an issue with \LaTeX |
| 2245 |
or with \WebQuiz. If you can, please also test to see if your code |
| 2246 |
compiles using \TeXfht directly. |
| 2247 |
|
| 2248 |
\appendix |
| 2249 |
\section*{Appendices} |
| 2250 |
\addcontentsline{toc}{section}{Appendices} |
| 2251 |
\renewcommand\thesection{} |
| 2252 |
\renewcommand\thesubsection{\Alph{subsection}} |
| 2253 |
|
| 2254 |
\subsection{Catalogue of web page themes}\index{theme}\label{SS:themes} |
| 2255 |
\WebQuiz{} comes with different themes for changing the colour scheme |
| 2256 |
of the online quizzes, which can be set using the \LatexCode|theme| |
| 2257 |
document-class option or in the \webquizrc; see |
| 2258 |
\autoref{SS:classOptions} for more details. Themes are easy to |
| 2259 |
construct in principle although finding colours that work well together |
| 2260 |
can be tricky in practice so, as a result, there are some themes that |
| 2261 |
I would not personally recommend! |
| 2262 |
|
| 2263 |
New themes, and modifications to existing themes, can be submitted as |
| 2264 |
an \textit{issue} at: |
| 2265 |
\begin{quote} |
| 2266 |
\href{https://\webquiz{repository}/issues}{\webquiz{repository}/issues}. |
| 2267 |
\end{quote} |
| 2268 |
Where possible these will be incorporated into a future release of the |
| 2269 |
package, although there is a potential technical issue here in that |
| 2270 |
the underlying \CSS files are written using |
| 2271 |
\href{http://sass-lang.com/}{sass}. |
| 2272 |
|
| 2273 |
\ShowcaseThemes |
| 2274 |
|
| 2275 |
\subsection{The online \WebQuiz manual}\label{S:online} |
| 2276 |
|
| 2277 |
\WebQuiz has an \OnlineManual* that is a \LaTeX file written with the |
| 2278 |
\LatexCode|webquiz| document class. The conversion of the manual from |
| 2279 |
\LaTeX{} to \HTML is done by \WebQuiz. The \BashCode|PDF| version of |
| 2280 |
this manual is included here as an easy reference. The source file |
| 2281 |
for the \OnlineManual* is included in the documentation of \WebQuiz to |
| 2282 |
allow you to create a local version of the \OnlineManual*. Look for the |
| 2283 |
file \BashCode|webquiz-online-manual.tex| in the |
| 2284 |
\BashCode|webquiz-www/docs| directory; see~\autoref{SS:rcfile}. |
| 2285 |
|
| 2286 |
The online manual can either be compiled as a PDF file (see below), |
| 2287 |
or using \WebQuiz to produce an online version of the manual. |
| 2288 |
The \OnlineManual* was written for ``internal use'' when \WebQuiz was |
| 2289 |
first written in 2004. \WebQuiz has evolved quite a lot since then. |
| 2290 |
There is some overlap between the \OnlineManual* and previous sections, |
| 2291 |
however, the \OnlineManual* only describes how to typeset questions and |
| 2292 |
it does not cover some of the more recent features of \WebQuiz, such |
| 2293 |
as the document class options, or how to use the program. If there |
| 2294 |
are any discrepancies between the \OnlineManual* and the earlier |
| 2295 |
sections of this manual then the \OnlineManual* should be discounted. |
| 2296 |
|
| 2297 |
The \OnlineManual* has diagrams that are drawn using \ctan{pstricks} |
| 2298 |
and, as a result, to create a \BashCode|PDF| version of the \OnlineManual* |
| 2299 |
use \BashCode|latex webquiz-online-manual| to create a |
| 2300 |
\BashCode|dvi| file. The \BashCode|dvi| file can be converted to |
| 2301 |
\BashCode|PDF| using \BashCode|dvipdf|. The online manual needs to be |
| 2302 |
compiled using \BashCode|latex| rather than \BashCode|pdflatex|, |
| 2303 |
which will generate errors. |
| 2304 |
|
| 2305 |
\includepdf[pages=-,pagecommand={\pagestyle{webquiz}}]{webquiz-online-manual} |
| 2306 |
|
| 2307 |
|
| 2308 |
\subsection{Licence} |
| 2309 |
|
| 2310 |
Version 3, Copyright (C) 2007, |
| 2311 |
|
| 2312 |
\href{https://www.gnu.org/licenses/gpl-3.0.en.html} |
| 2313 |
{GNU General Public License, Version 3, 29 June 2007} |
| 2314 |
|
| 2315 |
This program is free software: you can redistribute it and/or modify it under |
| 2316 |
the terms of the GNU General Public License (GPL) as published by the Free |
| 2317 |
Software Foundation, either version 3 of the License, or (at your option) any |
| 2318 |
later version. |
| 2319 |
|
| 2320 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY |
| 2321 |
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 2322 |
PARTICULAR PURPOSE. See the GNU General Public License for more details. |
| 2323 |
|
| 2324 |
|
| 2325 |
\vfil |
| 2326 |
\begin{tabular}{@{}ll} |
| 2327 |
Authors & \webquiz{authors}\\ |
| 2328 |
Description & \webquiz{description}\\ |
| 2329 |
Maintainer & \webquiz{name}\\ |
| 2330 |
System requirements & \webquiz{requirements}\\ |
| 2331 |
Licence & \webquiz{licence}\\ |
| 2332 |
Release date & \webquiz{release date}\\ |
| 2333 |
Repository & \href{https://\webquiz{repository}}{\webquiz{repository}} |
| 2334 |
\end{tabular} |
| 2335 |
\eject |
| 2336 |
|
| 2337 |
\printindex |
| 2338 |
|
| 2339 |
\end{document} |