Webquiz
Webquiz
WebQuiz is a LATEX package for writing online quizzes. It allows the quiz author to
concentrate on the content of quizzes, written in standard LATEX, unencumbered by
the technicalities of HTML and Javascript. Online quizzes written using WebQuiz can
contain any material that can be written using LATEX, including text, mathematics,
graphics and diagrams.
1 Introduction 2
1.1 What WebQuiz does and does not do . . . . . . . . . . . . 3
1.2 Credits . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4
2 The WebQuiz document class — LATEX commands 5
2.1 Question environments . . . . . . . . . . . . . . . . . . . . . 6
2.1a Question environments and the \answer macro . . . 6
2.1b Multiple choice questions . . . . . . . . . . . . . . . 10
2.1c Discussion environments . . . . . . . . . . . . . . . . 11
2.1d Index pages for quizzes . . . . . . . . . . . . . . . . 14
2.1e Breadcrumbs . . . . . . . . . . . . . . . . . . . . . . 15
2.2 WebQuiz document class options . . . . . . . . . . . . . . . 19
2.3 Including graphics and using pstricks and tikz . . . . . . . . 23
2.4 Configuring commands and environments for TEX4ht . . . . 27
3 System requirements, installation and configuration 28
3.1 System requirements . . . . . . . . . . . . . . . . . . . . . . 29
3.2 Installing WebQuiz . . . . . . . . . . . . . . . . . . . . . . . 29
3.3 Initialising WebQuiz . . . . . . . . . . . . . . . . . . . . . . 29
3.4 Graphics and dvisvgm . . . . . . . . . . . . . . . . . . . . . 31
4 The WebQuiz program 31
4.1 Command-line options . . . . . . . . . . . . . . . . . . . . . 31
4.2 WebQuiz settings and the webquizrc file . . . . . . . . . . . 34
4.3 Changing the layout of the WebQuiz web pages . . . . . . . 36
4.4 Bugs, issues and feature requests . . . . . . . . . . . . . . . 37
Appendices 38
A Catalogue of web page themes . . . . . . . . . . . . . . . . . 38
B The online WebQuiz manual . . . . . . . . . . . . . . . . . . 42
C Licence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
Index 56
Of course, the real reason for using WebQuiz is to create a web page for the quiz, which you do
by processing the quiz using the webquiz command )instead of, say pdflatex). If you do this and
open the resulting web page in your favourite browser, after selecting answer (a), you will see a
web page like this:
The actual page that you see may be slightly different to this because the appearance of the web
page depends partly on your choice of browser.
By default, the online version of the quiz displays one question at a time, with the question
buttons serving the dual purpose of navigation between questions and displaying how successful the
student was in answering the question. The decorations on the question buttons indicate whether
the question has been attempted and, if so, whether it was answered correctly or incorrectly on
the first or subsequent attempts. One of the main points of WebQuiz is that (optional) targeted
feedback can be given to the student taking the quiz based on their answer.
1.2 Credits
WebQuiz was written and developed in the School of Mathematics and Statistics at the University
of Sydney. The system is built on LATEX with the conversion from LATEX to HTML being done by
Eitan Gurari’s TEX4ht and make4ht.
To write quizzes using WebQuiz it is only necessary to know LATEX, however, the underlying
WebQuiz system actually has three components:
• A LATEX document class file, webquiz.cls, and a TEX4ht configuration file, webquiz.cfg, that
enables the quiz files to be processed by LATEX and TEX4ht, respectively.
• A python program, webquiz, that translates the LATEX into XML, using TEX4ht, and then
into HTML.
• CSS, HTML and Javascript code controls and style the quiz web pages.
The LATEX component of WebQuiz was written by Andrew Mathas and the python, CSS and
Javascript code was written by Andrew Mathas based on an initial prototype that was written by
...
\end{document}
You should write your quizzes using the editor that you normally use to write LATEX documents.
As you write your quiz, say quiz.tex, you should use pdflatex (or latex), in the usual way:
> pdflatex quiz
This is the easiest way to check that your quiz compiles and to proofread the output, just as if you
were writing a normal LATEX document. When you are satisfied with the content of the quiz, then
you can convert the quiz to an online quiz using the command
> webquiz quiz or > webquiz -d quiz # -d = draft mode = faster!
The quiz file, quiz.tex, should be in a directory on your web server because WebQuiz creates a
number of different files and directories when it converts the file into an online quiz and all of these
files are needed to display the quiz on the web.
The reasons for using this workflow are:
• Every file that you give to WebQuiz must be a valid LATEX file!
• The dvi or PDF file produced by LATEX shows all of the information in the quiz in an easy-to-
read format. That is, the PDF file displays the questions, the answers and the feedback that
you are giving to the students. In contrast, by design, the online version of the quiz hides
most of this information and shows it to the student only when they need to see it.
2 After you have initialised WebQuiz, you can find the WebQuiz example directory from the command-line using:
Each quiz question must be placed inside a question environment. Typically, a quiz has several
questions, each wrapped in its own question environment. For brevity, most of the examples in
this chapter have only one question. See the Online manual (Appendix B), in the WebQuiz web
directory for a more complete quiz file.
This manual describes the WebQuiz commands, often by example. The following code-block
generates a quiz with one question for which the student has to enter the answer. This answer is
then compared with the correct answer as a string, which it must match exactly.
\documentclass[hidesidemenu]{webquiz}
\title{An answer with comparison=string}
\begin{document}
\begin{question} % a quiz question
What is the capital of Australia?
\answer[string]{Canberra} (Correct answer ‘‘Canberra’’)
\whenRight Yes, Sydney is the capital of NSW and Melbourne is the
capital of Victoria
\whenWrong Remember to correctly capitalise your answer!
\end{question}
\end{document}
The optional macros \whenRight and \whenWrong are used to give the student additional feedback,
when they are right, or further hints etc for approaching the question, when they are wrong. This
feedback is displayed on the quiz page only when the student checks their answer.
This example shows one way of using the \answer macro, which asks for the student to type in an
answer to the question. The general syntax of this macro is:
\answer[comparison type]{correct answer}
with string being the default. In addition, there is a *-variant of the answer macro that does not
print the word “Answer” (or equivalent in other languages) before the input box. The syntax for
the \answer* command is identical to that for the \answer except, of course, that there is a *:
\answer*[comparison type]{correct answer}
As string is the default answer comparison method, if we instead use \answer*{Canberra} in the
last example then the quiz page generated by WebQuiz looks like:
Notice that the word Answer no longer appears in front of the answer box. Of course, if you use the
unstarred version of the \answer-macro together with the document class option language=xxx to
change the default language (Section 2.2), then the appropriate translation of Answer will appear
on the web page.
We now give a description of the other comparison types for the \answer and \answer* macros
together with code examples and screenshots.
complex comparison The answers are compared as complex numbers: the answer is marked as
correct if it has the same real and imaginary parts.
\documentclass[onepage]{webquiz}
\title{An answer with comparison=complex}
\begin{document}
\begin{question} % a quiz question
If $a=3-i$ and $b=2+i$ then what is $ab$?
\answer[complex]{7+i} (Correct answer $7+i$)
Observe that the correct answer is given in the quiz file as 7 + 𝑖 and that WebQuiz accepts 𝑖 + 7
as the correct answer.
integer comparison The answers are compared as integers. If the correct answer was 18 and a
student entered 36/2 then their answer would be marked wrong.
\documentclass[hidesidemenu]{webquiz}
\title{An answer with comparison=integer}
\begin{document}
\begin{question} % a quiz question
How long is a piece of string?
\answer[integer]{18} mm (Correct answer $18$)
\whenRight Yes, $18$mm pieces of string are $18$mm long!
\whenWrong Incorrect! Is your ruler working?
\end{question}
\end{document}
lowercase comparison The quiz answer and the students’ answer are both converted to lower
case and then compared as strings.
\documentclass[onepage]{webquiz}
\title{An answer with comparison=lowercase}
\begin{document}
\begin{question} % a quiz question
How long is a piece of string?
\answer[lowercase]{Long} (Correct answer ‘‘Long’’)
\whenRight Correct! Obviously your ruler is working!
\whenWrong Incorrect! Is your ruler working?
number comparison The quiz answer and the students’ answer are compared as numbers.
\documentclass[onepage]{webquiz}
\title{An answer with comparison=number}
\begin{document}
\begin{question} % a quiz question
What is $\frac12+\frac14$?
\answer[number]{3/4} (Correct answer $3/4$)
\whenRight Correct!
\whenWrong Incorrect! Is your ruler working?
\end{question}
\begin{question} % a quiz question
What is $\frac12+\frac14$?
\answer[number]{3/4} (Correct answer $3/4$)
\whenRight Correct!
\whenWrong Incorrect! Is your ruler working?
\end{question}
\end{document}
Notice that the answer is given in the LATEX file as 3/4 and that the equivalent fraction, 0.75, is
accepted as the correct answer.
string comparison This is the default, so \answer{word} and \answer[string]{word} are equiva-
lent. The student’s answer is marked correct if and only if it agrees exactly with the quiz answer.
The multiple choice options for a quiz question need to be placed inside a choice environment –
and every choice environment needs to be inside a question environment.
The choice environment accepts two optional arguments, can appear in any order:
• The word single (default, and can be omitted) or multiple, which indicates whether the quiz
has a single correct answer or whether 0 or more of the answers are correct, respectively.
• The number of columns in which to typeset the choices. This is specified as columns=n, where
𝑛 is a non-negative integer. By default, the choices appear in 𝑛 = 1 columns (columns=1).
Use columns=n with care when 𝑛 > 1 as multiple columns do not always display well on mobile
devices.
The key difference between these two types of choice questions is that a single-choice environ-
ment uses radio boxes, so it is only possible to select one correct answer. In a multiple-choice
environment checkboxes are used, so that is possible to select zero or more correct answers.
A choice environment modelled on the standard LATEX list environments (enumerate, itemize,
description, ...), except that instead of using the \item command to separate the items the choice
environment uses \correct \incorrect , which indicate correct and incorrect answers respectively.
In addition, after each \correct or \incorrect you can, optionally, use \feedback to give feedback
to the student taking the quiz. Like \whenRight and \whenWrong this feedback is displayed only
when the student checks their answer.
Here is an example of a single-choice question with a unique answer:
\documentclass{webquiz}
\title{A multiple choice question with a unique answer}
\begin{document}
\begin{question} % a quiz question
What is the cube root of $64$?
\begin{choice}[columns=4]% unique answer rendered in four columns
\incorrect 1 \feedback No, $1^3=1$
\incorrect 2 \feedback No, $2^3=8$
\incorrect 3 \feedback No, $3^3=27$
\correct 4 \feedback Yes, $4^3=64$
\end{choice}
\end{question}
\end{document}
It is not necessary to put the \feedback lines on the same line as the \incorrect and \incorrect;
this is done only to make the example more compact. This results in the following web page:
Here is an example of a multiple choice question that has two correct answers:
\documentclass[theme=vibrant]{webquiz}
Notice that this example uses the document-class option theme=vibrant, which changes the We-
bQuiz colour theme; see Section 2.2.
When the optional argument multiple to the choice environment is used, as above, then the
question is marked correct if and only if all of the correct choices, and none of the incorrect
choices, are selected. If the student’s selections are not completely correct then are given feedback
that is randomly selected from amongst their wrong choices (that is, the feedback is randomly
selected from the set of \correct choices that were not selected and the \incorrect choices that
were selected).
Finally, observe that the multiple choice items in the screenshot above are labelled by roman
numerals. The items in a choice environment are labelled by a standard LATEX counter, that is also
called choice. Redefining the LATEX macro \thechoice changes how the corresponding question
choices are labelled in the online quiz. For example, to label the items in a choice environment by
A), B), C) . . . add the line:
\renewcommand\thechoice{\Alph{choice})}
The short heading is used in the side-menu. Both the heading and short-heading are optional,
both defaulting to Discussion. If only one heading is given then this sets both the short heading
and heading for the discussion item. For example, running the following LATEX file, which uses
theme=muted, through WebQuiz
\documentclass[theme=muted]{webquiz}
\usepackage{lipsum}% for some random text
\title{A discussion environment example}
\begin{document}
\begin{discussion}[First bit]
\lipsum[1]
\end{discussion}
\begin{discussion}[Two][Second bit]
\lipsum[2]
\end{discussion}
\end{document}
As with the questions, only one discussion environment is displayed on the quiz web page at a time
(unless the document-class option onepage is used). It is possible to have quizzes that contain only
discussion environments, with no questions, and quizzes that contain only question environments,
with no discussion.
If you have a mixture of discussion and question environments then it is useful to be able to
add thinks between them. LATEX provides the \label and \ref commands for cross-referencing, so
WebQuiz builds on this idea and provides the three commands \dref, \qref and \Qref to reference
discussion and question environments. The syntax for these commands is as follows:
\dref[optional text]{LaTeX label} % inserts discussion button
\dref*[optional text]{LaTeX label} % inserts discussion link
\qref[optional text]{LaTeX label} % inserts question button by label
\qref*[optional text]{LaTeX label} % inserts question link by label
\Qref[optional text]{question number} % inserts question button by number
\Qref*[optional text]{question number} % inserts question link by number
In each case the text in the link or button defaults to either the short-title, for discussion envi-
ronments, or the question number for questions. The “optional text” is used instead whenever it
is supplied. These commands can be used anywhere in a quiz, including discussion, question and
choice environments and inside feedback text for the students written using \feedback, \whenRight
and \whenWrong.
The macros \dref and \qref use a standard LATEX label, defined using the \label command, to
insert a button or a link. In contrast, \Qref uses the actual question number, so it is not necessary
to define a \label for a question when using \Qref.
Even though the macros \qref and \Qref are quite similar they serve different functions when
the randomorder document class option is used (see Section 2.2). In this case we do not know
ahead of time the question numbers that will be used in the quiz. So if q:one is the label for the
Similarly, here is an example showing how \dref and qref are used:
\documentclass[onepage]{webquiz}
\title{A dref and qref example}
\begin{document}
\begin{discussion}[First bit][First discussion item]\label{d:one}
Some cross-references to question 1: \qref{q:one}, \qref*{q:one},
\qref[some text]{q:one}, and \qref*[some text]{q:one}.
\end{discussion}
\begin{question}\label{q:one}
Cross-references to discussion: \answer{1} \dref{d:one}, \dref*{d:one},
\dref[some text]{d:one} and \dref*[some text]{d:one}.
\end{question}
\end{document}
When using the randomorder document class option (Section 2.2), “optional text” should always
be given when using \qref. This is because the question number that is displayed by default will
always be the question number in the LATEX file rather than the question number in the online
quiz.
Most quizzes occur in sets that cover related material, such as for a particular unit of study. The
quizindex environment creates an index web page for related sets of quizzes. The LATEX files for
all of these quizzes must be in the same directory, or folder, on the web server. The index web
page is a WebQuiz file of the form:
\documentclass[hidesidemenu]{webquiz}
\BreadCrumbs{ Mathematics / | Math101 /math101 | Index of quizzes }
\title{Elementary calculus}
\begin{document}
\begin{quizindex}
\quiz{Numbers and sets}
\quiz{Polar form and roots of complex numbers}
\quiz{Polar exponential form and functions}
\quiz*{Optimizing functions of two variables}
\end{quizindex}
\end{document}
As the next section describes, index files are also used to automatically add a drop-down menu
that contains the quiz-index to the breadcrumbs on all of the quiz web pages. This drop-down
menu provides an easy way to navigate between all of the quizzes for a particular unit of study.
As the example above shows, the entries in the quizindex are given using the \quiz or the \quiz*
command. The syntax for these commands is
\quiz[URL for quiz]{Title for quiz}
\quiz*[URL for quiz]{Title for quiz}
The \quiz macro automatically inserts the quiz numbers into the index listing. The \quiz* com-
mand is identical except that it does not add Quiz 1., Quiz 2 etc to the index listing. By default,
the URLs for the quizzes in the index are assumed to be of the form quiz1.html, quiz2.html,
quiz3.html, .... These URLs can be changed using the optional argument of the \quiz and \quiz*
commands. For example,
\quiz[realquiz.html]{This is the real quiz}
would create an item in a quiz index that links to the web page realquiz.html.
Index pages in other languages are produced in exactly the same way. For example,
\documentclass[hidesidemenu,language=czech]{webquiz}
\usepackage[czech]{babel}
\usepackage[T1]{fontenc}
\Department{Matematika}\DepartmentURL{/}
\BreadCrumbs{ department | Mat101 /mat101 | breadcrumb }
\BreadCrumb{ Index kvízů }
\title{Elementární počet}
\begin{document}
\begin{quizindex}
A Czech index
2.1e Breadcrumbs
WebQuiz provides a straightforward way to place navigation breadcrumbs at the top of the quiz
web page. By default the breadcrumbs are disabled. If you have a \BreadCrumbs command like:
\BreadCrumbs{Mathematics /|Math1001 /u/Math1001|quizindex|title}
in your LATEX file then WebQuiz will add a corresponding strip of breadcrumbs, or navigation links,
to the top of your quiz page:
Example breadcrumbs
The drop-down menu is normally hidden, appearing only after the ≡ “button” on the web page is
clicked.
Usually, most of the breadcrumbs are navigation links to other web pages. In the example above:
• The first “crumb’ inside the \BreadCrumbs command is Mathematics /. This inserts the text
Mathematics together with a (relative) URL to /, the root directory for the web server, which
is often the correct URL for the department (or the institution)
• The Math101 /u/math101 inserts the text Math101 as the second breadcrumb with URL /u/
math101.
• The quizindex inserts the text Quizzes together with the symbol ≡, which opens a drop-down
menu that contains the list of quizzes in the quiz index for the unit. This is described in
more detail below.
• Finally the title in the breadcrumbs inserts, as text, the part of the title before the first
colon in the title, where the title is given by \title{...}.
The breadcrumbs for the quiz web page can be either be configured quiz-by-quiz, using the
\BreadCrumbs macro , as above, or by setting default breadcrumbs in the webquizrc file (Section 4.2)
using the command-line option
To make this the default set of breadcrumbs use webquiz --edit-settings to set breadcrumbs in
the webquizrc file (Section 4.2) to:
department | unitcode | quizindex | title
In principle, there can be arbitrarily many crumbs in your breadcrumbs but, in practice, five is
more than enough. The crumbs inside a \BreadCrumbs command have the following meanings:
breadcrumb
The breadcrumb for the current quiz, which is set using the \BreadCrumb macro. This
breadcrumb is purely descriptive, with no hyperlink being added: only the text given by
\BreadCrumb appears.
department
This expands to a link to your department, where the department text is set using the macro
\Department and its URL is set by \DepartmentURL.
institution
This expands to a link to your institution, where the institution text is set using \Institution
and its URL is set by \InstitutionURL. The institution also appears in the side-menu above
the WebQuiz copyright notice.
quizindex
This expands to Quizzes, which is a link to the index page for your unit, as defined by
\QuizzesURL, which is described below. In addition, if the directory contains a BashCode|quizindex.js|
file, which is created by the quizindex environment (see §2.1d), then the symbol ≡ will ap-
pear, giving access to a drop-down menu to the index page, looking something like this:
Such drop-down menus are automatically added to quiz web pages that have a quizindex
breadcrumb| as soon as an quiz page that contained a WebQuiz quizindex environment has
been compiled in the current directory.
For those interested in how this is done, whenever WebQuiz compiles a quizindex environment
it creates a Javascript file quizindex.js. Every quiz file includes this Javascript file, if it exists,
and this allows it to display a drop-down menu for the quiz index.
Title
This expands to the full title of the quiz page, without a hyperlink, as given by the \title.
title
This expands to the part of title of the quiz page, without a hyperlink, that occurs before
the first colon in the title of the quiz. For example, if the title is given as
then “Quiz 1” will be added to the list of breadcrumbs. If the title does not contain a colon
then the full title is printed.
unitcode
This expands to a link to the unit code, where the unit code text is set using \UnitCode, and
its URL is set by \UnitURL
unitname
This expands to a link to the unit name, where the unit name text is set using \UnitName,
and its URL is set by \UnitURL
In addition, each crumb in a breadcrumb, except for the “magic crumbs” listed above, is allowed
to be arbitrary text — although, non-ascii characters may cause problems. In this case, the last
“word” in the crumb is treated as a URL if it either beings with a forward slash, /, or if it begins
with http. For example, the code:
\documentclass[hidesidemenu]{webquiz}
\BreadCrumbs{ Monty Python http://www.montypython.com/
| Our work http://www.montypython.com/ourwork
| The Meaning of life http://www.montypython.com/film_Monty\%20
Python’s\%20The\%20Meaning\%20of\%20Life\%20(1983)/17
}
\title{I didn’t even eat the mousse...}
\begin{document}
\begin{question}
What is the meaning of life?
\answer{42}
\end{question}
\end{document}
Notice that it is necessary to correctly escape spaces etc in URLs that are specified this way.
Similarly, all of the characters in the breadcrumbs should be ascii characters as unicode is likely
to cause encoding issues (compare with the Czech index given in §2.1d).
If any part of a “magic” breadcrumb has not been defined then it is printed with a question
mark on the web page. For example, the quiz file
\documentclass[hidesidemenu]{webquiz}
\BreadCrumb{Wholemeal bread}
\BreadCrumbs{unitcode|quizindex|breadcrumb}
\begin{document}\end{document}
does not define the unit code, so it results in the “questionable” first breadcrumb:
\BreadCrumb
The \BreadCrumb command sets the breadcrumb variable in the \BreadCrumbs. The primary
use for this is when you have default breadcrumbs in the webquizrc file (Section 4.2) like
breadcrumbs = department | unitcode | breadcrumb
Using \BreadCrumb allows you to set the last crumb to some meaningful text that describes
the quiz.
\Department
The \Department command sets the name of the department. As described earlier in this sec-
tion, by default, the department is the first item in the breadcrumbs that appear at the top
of the web page.
The default department can be set in the webquizrc file (Section 4.2) using webquiz --edit-
settings.
Default value: '' (i.e. the empty string)
\DepartmentURL
The \DepartmentURL command sets URL for the department. As described earlier in this sec-
tion, by default the department URL is the link in the first breadcrumb on each web page.
The default department URL can be set in the webquizrc file (Section 4.2) using webquiz --
edit-settings.
Default value: /
\Institution
The \Institution command sets the institution, or university. The institution appears be-
low the question buttons in the left-hand navigation menu that appears on every quiz web
page (provided that the screen size is not too small). As described earlier in this section, the
institution can be used in the web page breadcrumbs.
The default institution can be set in the webquizrc file (Section 4.2) using webquiz --edit-
settings.
Default value: '' (i.e. the empty string)
\InstitutionURL
The \InstitutionURL command sets the institution URL. This is used as the link for the
institution in the left-hand navigation menu that appears on every quiz page. As described
earlier in this section, the institution URL can be used in the web page breadcrumbs.
The default institution URL can be set in the webquizrc file (Section 4.2) using webquiz --
edit-settings.
Default value: /
\QuizzesURL
The \QuizzesURL command sets the URL for the suite of quizzes attached to this unit of study.
As described earlier in this section, this can be used in the breadcrumb at the top of the quiz
web page.
Default value: UnitURL/Quizzes, where UnitURL is set using \UnitURL
\UnitCode
The \UnitCode command sets the unit of study code for the unit that the quiz is part of.
\UnitName
The \UnitName command sets the name of the unit of study for the unit that the quiz is at-
tached to.
It makes sense to set defaults for \BreadCrumbs \Department, \DepartmentURL, \Institution and
\InstitutionURL in the webquizrc file (Section 4.2). After doing this, a typical WebQuiz file might
look like this:
\documentclass{webquiz}
\UnitName{Fundamental stuff}
\UnitCode{Stuff101}
\UnitURL{/courses/stuff101}
\begin{document}
\begin{question}
first question...
\end{question}
\begin{question}
second question...
\end{question}
\end{document}
If you have many quizzes for many different units then a better approach is to create a LATEX
“package”, say ourunits.sty, to set these variables:
% ourunits.sty - set unit names, codes and URLs
\DeclareOption{stuff101}{
\UnitName{Fundamental stuff}
\UnitCode{Stuff101}
\UnitURL{/courses/stuff101}
}
\DeclareOption{stuff102}{
\UnitName{Fundamental stuff too}
\UnitCode{Stuff102}
\UnitURL{/courses/stuff102}
}
\ProcessOptions
\endinput
Then you can replace the opening lines of the quiz file with \usepackage[stuff101]{ourunits
}. Of course, you could also set the default \Department, \DepartmentURL, \Institution and
\InstitutionURL in such a style file as well.
This section describes all of these document-class options except for tikz and pst2pdf, which are
discussed in Section 2.3. Many of the document-class options below occur in pairs and defaults for
many of these can be set in the webquizrc file (Section 4.2) file. The settings given in the LATEX
file for a quiz will always override the default settings in the webquizrc file.
fixedorder, randomorder
By default, the questions in the quiz are displayed in a fixedorder for all students who take
the quiz. This order is the order that the question appear in the LATEX file for the quiz. That
is, the first question in the online quiz is the first question appearing in the LATEXfile, the
produces the quiz with randomly arranged quiz questions, such as:
(So the first question in the LATEX file is being displayed as the fourth online quiz question.
The next time the page is loaded, such as for the next student, the question order will
change again.) When using the randomorder document-class option only the questions appear
in random order. If the quiz contains multiple choice questions then the choices are not
randomly permuted. That is, the choices always appear in the order that they are written
in the LATEX file.
hidesidemenu, sidemenu
If the hidesidemenu option is set then the side menu on the left-hand side of the quiz web
page will not be displayed when the quiz first loads. By default, the side menu appears unless
the screen size is too small, such as on a mobile phone. Many examples of the hidesidemenu
and showsidemenu class options can be found above.
The display of the side menu can is also toggled by clicking on the $ and v symbols. The
side-menu automatically disappears for devices with narrow screens, such as mobile phones.
language=<lang>
Set the language used by the web pages constructed by WebQuiz. The following languages
are currently supported by WebQuiz:
Czech, English, French, German, Greek, Italian, Japanese, Mandarin, Russian,
Spanish and Swedish
The languages files are used to print the various buttons and text that is generated on the
web pages constructed by WebQuiz. The language option does not affect the DVI or PDF
versions of the quiz and it does not load language packages like babel or polyglossia.
The language keyword can be in upper or lower case, with the result that either (but not
both!) of the following two lines set the quiz language to German:
As a general rule, LATEX and TEX4ht do not cope well with unicode characters, so if your quiz
contains (a lot of) unicode characters then we recommend using LuaLATEX or XELATEX, which
corresponds to the WebQuiz command-line options webquiz -x or webquiz -l, respectively.
The default TEX engine can be set in the webquizrc file (Section 4.2).
The language files were created largely using google translate so they may well need fine-
tuning3 . You can use kpsewhich to look at the language files, which all have names of the
form webquiz-xxx.lang, where xxx is the name of the language in lower case. For example,
the English language file, which is the default, can be found using the command:
> kpsewhich webquiz-english.lang
In these files, the material to the left of the equals signs are effectively variables, and so they
should never be changed, or deleted, whereas anything to the right of the equals signs is the
text that will appear on the WebQuiz web pages. The pairs of braces, {}, in the language
files must be present because in the online quizzes they expand to expressions like (a), (b). . .
To add WebQuiz support for a new language, say language xxx, copy any WebQuiz language
file to a new file webquiz-xxx.lang and then translate all of the words to the right of the
equals signs.4 WebQuiz will be able to find the new language file as long as it appears in
the LATEX search path5 . Once the new language file webquiz-xxx.lang is in the LATEX search
path it can be used by WebQuiz using language=xxx as a document-class option:
\documentclass[language=xxx]{webquiz}
\begin{document}
...quiz code here...
\end{document}
Please submit any new language files, or corrections to existing language files, as a new issue
at: github.com/AndrewAtLarge/WebQuiz/issues.
onepage, separatepages
By default, only one question, or one discussion environment, is displayed by the quiz at any
time. As separatepages is the default, every example so far is of this form. With the
document-class option onepage all questions, and discussion environments, are displayed at
the same time on a single web page. So, for example, the code:
\documentclass[onepage]{webquiz}
\title{A one page quiz}
\begin{document}
\begin{discussion}[One short][The full heading for discussion one]
This is discussion $1$ (one). It is very interesting.
\end{discussion}
\begin{discussion}[Two short][The full heading for discussion two]
This is discussion $2$ (two). It is very interesting.
\end{discussion}
\begin{question} Is this question $1$ (one)? \answer{1}\end{question}
\begin{question} Is a good question?
\begin{choice}\correct Yes \incorrect no\end{choice}
\end{question}
\begin{question} Is this question $3$ (three)? \answer{3}\end{question}
\end{document}
4 WebQuiz assumes that all language names are in lower case so xxx, and not XXX, should be used.
5 Tohelp LATEX/WebQuiz fined your language file you may need to run a program like mktexlsr using an
administrators account
theme
WebQuiz has a small number of different themes for setting the colours on the quiz web pages.
The theme can be set as an option to the document class or in the webquizrc file (Section 4.2).
Most, but not all, of the examples so far have used the default theme. WebQuiz currently
supports the following themes:
blue, darkblue, darkred, default, earthy, fresh, light, lively, muted, sleek, spring
and vibrant
Example screenshots of all WebQuiz themes can be found in Appendix A.
to your document preamble. You need to use \DeclareGraphicsExtensions to tell WebQuiz the
different types of images you are using, so the code above works for png images. More generally,
you can use a comma separated list of extensions, such as:
\DeclareGraphicsExtensions{.png, .jpg, .gif}
The option dvipdfmx to graphicx is only necessary if you want to be able to rescale images. For
example, the code:
\documentclass{webquiz}
\usepackage[dvipdfmx]{graphicx}
\DeclareGraphicsExtensions{.jpg}
\title{I am not Lion to you}
\begin{document}
\begin{question}
Do you recognise this Lion?
\begin{center}
Including a lion
Note that WebQuiz assumes that all images are SVG images by default so it is necessary to give the
full filename in any \includegraphics command.
Using pstricks is often just as easy, such as the following code that works out of the box:
\documentclass[svgnames]{webquiz}
\usepackage{pst-all}
\newcommand\C{\mathbb{C}}
\title{A pstricks example}
\begin{document}
\begin{question}
The shaded region in the graph
\begin{center}
\begin{pspicture}[unit=0.6cm](-3,-1.5)(3,4)
\pscircle[linewidth=1pt,linestyle=dashed,
fillcolor=SkyBlue,fillstyle=solid](1,1){2}
\psaxes[linecolor=red,linewidth=1pt,labels=none]
{->}(0,0)(-1.5,-1.5)(3.5,3.5)
\rput(3.75,0){$x$} \rput(0,3.85){$iy$}
\rput(3,-0.4){3} \rput(-0.4,3){3$i$}
\psdots(1,1)
\end{pspicture}
\end{center}
is equal to which of the following sets of complex numbers?
\begin{choice}[columns=2]
\incorrect $\{z \in \C : (z-1)^{2}+(z-(i+1))^{2}<2\}$
\incorrect $\{z \in \C : z+(i+1)<2\}$
\correct $\{z \in \C : |z-(i+1)|<2\}$
\incorrect None of the above.
\end{choice}
\end{question}
\end{document}
WebQuiz – version 5.2 Including graphics and using pstricks and tikz 24
Pstricks example
Even though tikz and pstricks can be used in WebQuiz quizzes, both of these packages
sometimes have problems. WebQuiz tries to solve some these problems for you if you use the
pst2pdf or tikz document-class options, which we now describe.
pst2pdf
For the most part, pstricks drawings display correctly. When they do fail they can some-
times be salvaged using pst2pdf. Applying pst2pdf to a WebQuiz quiz is not completely
straightforward, so WebQuiz provides the document-class option pst2pdf to automatically
apply pst2pdf as part of the quiz web page build process. If your pstricks drawings do not
display correctly it is worthwhile to see if pst2pdf fixes the problems.
For example, the following quiz compiles only with the pst2pdf document-class option:
\documentclass[pst2pdf]{webquiz}
\usepackage{pst-all,pst-3dplot}
\title{A pst2pdf example}
\begin{document}
\begin{question} % a quiz question
Which of the equations below could describe the following surface?
\begin{pspicture*}(-4,-4)(4,4)
\psplotThreeD[linecolor=blue, plotstyle=curve, drawStyle=yLines,
yPlotpoints=30, xPlotpoints=30, linewidth=1pt](-4,1)(-4,1){
x dup mul y dup mul add 1.01 exp}
\pstThreeDCoor[linewidth=1pt, xMin=-4,xMax=4,yMin=-4,yMax=4,zMin=-2,zMax
=6]
\end{pspicture*}
\begin{choice}
\incorrect \( z=\log(x^2+y^2) \)
\correct \( z=e^{x^2+y^2} \)
\incorrect \( z=1-e^{x^2+y^2} \)
\incorrect \( z=\dfrac1{x^2+y^2}\)
\end{choice}
\end{question}
\end{document}
The position of the image adjusts with the screen size and it does, in fact, display well on a
mobile device. WebQuiz is not able to display this image without the pst2pdf document-class
option.
Unfortunately, pst2pdf can fail silently without giving any warnings. If you plan to use
the pst2pdf document-class option then you should first check to make that the pst2pdf
package and executable is properly installed. According to the pst2pdf manual:
pst2pdf needs Ghostscript (>=9.14), perl (>=5.18), pdf2svg, pdftoppm and pdftops
(from poppler-utils or xpdf-utils) to process a file using pst2pdf.
If using pst2pdf does not produce an image then, rather than pst2pdf not working, the
problem might be that you have not installed all of the programs that pst2pdf relies upon,
so look in your log files for error messages and check that all of the programs listed above
are correctly installed, with the specified version numbers. See also Section 3.4.
tikz
Giving this class option both loads the tikz package and it fixes several issues with PGF
that prevent it from working with TEX4ht. It is important that you use the WebQuiz tikz
document-class option, and not \usepackage{tikz}, because WebQuiz loads slightly different
configuration files for tikz that are optimised for use with TEX4ht. Please note that for
WebQuiz – version 5.2 Including graphics and using pstricks and tikz 26
tikz you need to use TEXLive 2018 with all packages updated. Thanks are due to Michal
Hoftich for the enormous amount of effort that he has put into making TEX4ht and tikz
more compatible. As an example, the quiz file
\documentclass[tikz]{webquiz}
\usepackage{tikz}
\title{A tikz example}
\begin{document}
\begin{question} % a quiz question
What number is represented by the dot on the following number line?
\begin{center}
\begin{tikzpicture}
\foreach \x in {-3,...,3} { \draw(\x,0.25) --(\x,0)node[below]{$\x$}; }
\foreach \x in {-2.5,...,2.5} { \draw(\x,0.18) --(\x,0); }
\draw[thick,<->](-3.5,0)--(3.5,0);
\filldraw[blue!50!white](1.5,0) circle (1mm);
\end{tikzpicture}
\end{center}
\answer[number]{1.5} % inserts an answer box and specifies the answer as 1.5
\whenRight Correct!
\whenWrong Incorrect!
\end{question}
\end{document}
Tikz example
Most people use either pstricks or tikz. A quiz that tries to use both pstricks and tikz will
probably not compile.
shows that if you add the line \DisplayAsImage{ce} to your quiz after \begin{document} then it is
possible to use \ce in your quizzes:
Using DisplayAsImage
As the example code shows, \DisplayAsImage accepts an optional argument that can be used to
fine-tune the placement of the image on the quiz web page using CSS. For those interested in the
technical details, the definition of \DisplayAsImage is:
\RequirePackage{etoolbox}
\renewcommand\DisplayAsImage[2][]{%
\csletcs{real:#2}{#2}%
\NewConfigure{#2}{2}
\csdef{#2}##1{\Picture+[#1]{}\csuse{real:#2}{##1}\EndPicture}
\Configure{#2}{\Picture+[#1]{}}{\EndPicture}
}
This will install the different components of WebQuiz to their “standard” locations in he TEX
search tree. If you are using MiKTEX you may need to open the MiKTEX console, go to the Tasks
menu and then rebuild the TeX filename database.
Once the WebQuiz package is installed you should initialise thew package, following the steps
given in Section 3.3.
WebQuiz will actually work without being initialised, however, any quiz web pages that are created
before initialisation will be emblazoned with a message reminding you to initialise WebQuiz.
The location of the files on the web server depends both on the operating system that is running
on your computer and how your web server has been configured. It is essential that the WebQuiz
files are installed in a directory that is accessible from the web. It does not matter if they are put
into a user web directory or into a system web directory. If in doubt please consult your system
administrator.
Common locations for the web root of the server are:
WebQuiz needs to copy several files into a subdirectory of this web root. When you run
> webquiz --initialise
Once the initialisation step is complete, WebQuiz is ready to use although you, possibly from an
administrators account or using sudo, may also want to run:
> webquiz --edit-settings
This will talk you the process of setting system defaults for the quizzes that, for example, specify
the name and URL for your department and institution as well as the default language and theme
used for the quizzes. If in doubt about any of the option press return to accept the default. See
Section 4.2 for more details.
You can test your WebQuiz installation by compiling the example files from the WebQuiz man-
ual. You can find these files in the directory web_root/doc/examples, where the web_root is the
directory where you just installed the WebQuiz web files. If Ghostscript and dvisvgm are installed
and properly configured (see Section 2.3) then you should also be able to compile the Online manual
(Appendix B) using WebQuiz.
To install the WebQuiz files for general use on your system, or to save system wide settings,
you need to run the initialisation command webquiz --initialise using an administrator account
or using sudo on a UNIX or Mac OSX system.
If you have already saved a user webquizrc file (Section 4.2) file then to change the system
webquizrc file you will use need to use the --rcfile command-line option:
> webquiz --rcfile /path/to/system/rc-file --initialise
Remark To remove all WebQuiz files from your web server use:
> webquiz --uninstall
to my .bashrc file. To see whether you need to do something similar on your system you need to
look at the output from the following two commands:
> dvisvgm -h
> dvisvgm -l
One feature of WebQuiz is that you can process more than one quiz file at a time. For example, if
you have quiz files quiz1.tex, ..., quiz9.tex in the current directory then, on a UNIX system, you
can rebuild the web pages for all of these quizzes using the single command:
> webquiz quiz[1-9].tex
This is useful if some generic aspect of all of the quizzes has changed, such as the theme, the
language, thebreadcrumbs or a department URL. In fact, one would probably use
> webquiz -dqq quiz*.tex
because the webquiz --qq command-line option suppresses almost all of the output produced by
LATEX and TEX4ht and -d, which is draft mode, is faster and it is probably sufficient if the quizzes
were compiled recently. The next section discusses the WebQuiz command-line options.
optional arguments:
-h, --help show this help message and exit
-q, --quiet Suppress tex4ht messages (also -qq etc)
-d, --draft Use make4ht draft mode
-s, --shell-escape Shell escape for tex4ht/make4ht
--latex Use latex to compile document with make4ht (default)
-l, --lua Use lualatex to compile the quiz
-x, --xelatex Use xelatex to compile the quiz
-r RCFILE, --rcfile RCFILE
Specify location of the webquiz rc-file
-i, --initialise, --initialize
Install web components of webquiz
-e, --edit-settings Edit default settings for webquiz
--settings [SETTINGS]
List default settings for webquiz
The command-line options are listed on separate lines above to improve readability. In practice,
the different options need to be one the same line, although they can appear in any order.
We describe the different options, grouping them according to functionality.
-h, –help
list the command-line options and exit
-q, -qq, ——quiet
Suppress LATEX and TEX4ht error messages: -q is quiet and -qq is very quiet. If you use
webquiz -qq texfile.tex then almost no output will be printed by WebQuiz when it is pro-
cessing your quiz file. Be warned, however, that both of these options can make it harder to
find and fix errors, so using the -q and -qq options is recommended if your file is known to
compile.
TEX options
-d, ——draft
draft mode. The LATEXfile is processed only once by htlatex, which gives a much faster com-
pilation time but cross references etc may not be completely up to date. This is equivalent
to using: make4ht --mode draft
-s,——shell-escape
Shell escape for LATEX/htLATEX/make4ht
——latex
Use LATEX to compile the quiz (the default)
-l,——lua
Use luaLATEX to compile the quiz
-x, ——xelatex
Use xeLATEX to compile the quiz
——settings [SETTING]
List system settings for webquiz stored in webquizrc file (Section 4.2), the (run-time config-
uration file). Optionally, a single SETTING can be given in which case the value of only that
setting is returned. If SETTING is omitted then the list of current settings are printed. Use
SETTING=verbose for a more verbose listing of the settings and SETTING=help for a summary
of the settings.
The rc-file can be edited by hand, however, it is recommended that you instead use
webquiz --edit-settings
——make4ht MAKE4HT-OPTIONS
Options to be passed to make4ht when converting the LATEX to XML. This option is equiva-
lent to setting the make4ht in the webquizrc file (Section 4.2); see Section 4.2. At least under
UNIX, multiple arguments should be enclosed in quotes. For example, to give make4ht a
custom mk4 file (note that myquiz.mk4 is included, if it exists), you would use
> webquiz --make4ht "-e file.mk4" myquiz.tex
Other options
The following command-line options are mainly useful mainly for code developers.
——version
Prints the WebQuiz version number and exit (currently 5.2)
——tex-install
Use this command-line option if you are installing the LATEX components of WebQuiz from
the ctan zip-filei (see Section 3.2). It will install the different LATEX components of WebQuiz
into TEXMFMAIN. If you installed WebQuiz as part of a TEX distribution, such as TEXLive,
then you do not need to use this option.
——tex-uninstall
Use this command-line option to remove the LATEX components of WebQuiz from your sys-
tem. Only use this option if you installed WebQuiz using the ctan zip-file.
——debugging
Displays extra debugging information when compiling and prevents WebQuiz from deleting
the many intermediary files that are created when building the quiz web pages.
By default, the WebQuiz settings are saved here so that you do not need to reinitialise WebQuiz
whenever you update your TEX distribution. If you do not have permission to write to this directory
then you will be asked if you would like to save the rc-file somewhere else. The location of the user
rc-file is:
• ~/.dotfiles/config/webquizrc if the directory ~/.dotfiles/config exists,
• ~/.config/webquizrc if the directory ~/.config exists,
• ~/.webquizrc otherwise.
Each time WebQuiz is run it reads the system and user rc-files, if they exist. When using webquiz
--edit-settings you will be promoted for a different installation location if you do not have
permission to write to the specified rc-file. To use a particular webquizrc file use the --rcfile
command-line option:
> webquiz --rcfile <full path to rc-file> ...
If you save the settings to a non-standard location then you will need to use the command-line
option webquiz --rcfile RCFILE to access these settings.
To describe the WebQuiz defaults settings we consider them by category.
Institution settings
department
Sets the default department name. This can be overridden in the LATEX file using \Department
in §2.1e
department-url
Sets the URL for the department. This can be overridden in the LATEX file using \DepartmentURL
in §2.1e
institution
Sets the default institution name. This can be overridden in the LATEX file using \Institution
in §2.1e
institution-url
Sets the URL for the institution.This can be overridden in the LATEX file using \InstitutionURL
in §2.1e
Formatting options
breadcrumbs
Sets the default breadcrumbs at the top of quiz page. The default breadcrumbs can be over-
written in the quiz file using the \BreadCrumbs command. See §2.1e for more details.
engine
Sets the default TEX engine to be used when compiling the quiz. By default, latex is used,
with the two other possibilities being lua and xelatex, for LuaLATEX and XELATEX respec-
tively. Behind the scenes, the two choices correspond to invoking make4ht with the --lua and
--xelatex options, respectively. The engine setting in the webquizrc file can be overridden
by the webquizrc --latex, --lua and --xelatex.
Advanced options
make4ht
Options for make4ht. Rather than using TEX4ht directly, WebQuiz uses make4ht to convert
the LATEX file to XML. Use this option to customise how make4ht is called. See the make4ht
manual for more information.
mathjax
WebQuiz web pages use mathjax to render the mathematics on the quiz web pages. By de-
fault this is done by loading mathjax from
https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js
Fetching mathjax from an external site can cause a delay when the quiz web pages are loaded.
This setting in the rc-file allows you to change where mathjax is loaded from. For example,
if you install mathjax on your web server then you would replace this will the corresponding
relative URL.
webquiz-layout
Sets the python file that writes the HTML file for the quiz. Most people will not need this
option. The next subsection describes how to do this in more detail.
Configuration settings
webquiz-url
This is the relative URL for WebQuiz web directory
webquiz-www
This is the full path to the WebQuiz web directory. The Online manual (Appendix B) and
other example code can be found in the docs subdirectory. If you use bash, then the command
> cd $(webquiz --settings webquiz-www)/docs
The construction of the online quizzes is controlled by the python file webquiz_standard.py. If
you want to change the structure of the web pages for the quizzes then the easiest way to do this is
to make a copy of webquiz_standard.py, say webquiz_myformat.py, and then edit this file directly.
This will require working knowledge of python and HTML. To give you an idea of what needs to
be done, the python file webquiz_standard contains a single function write_web_page that returns
the HTML for the page as a string using the following:
WebQuiz – version 5.2 Changing the layout of the WebQuiz web pages 36
quiz_page = r'''<!DOCTYPE HTML>
<html lang="en">
<head>
<title> {title} </title>
{htmlpreamble}
</head>
<body>
{no_script}{breadcrumbs}
<div class="quiz-page">
{side_menu}
<div class="quiz-questions">
{quiz_header}
{quiz_questions}
</div>
</div>
{webquiz_init}
</body>
</html>
'''
By changing this output you can change the layout of the quizzes produced by WebQuiz. For
example, by adding code to the <head>...</head> section of quiz_page it is easy to include new
CSS code and by modifying <body>....</body> you can change the layout of the page. More
sophisticated versions of webquiz_standard.py, where you change the underlying python code, are
possible. At the University of Sydney we have a custom version of webquiz_standard.py that calls
our content management system and, in this way, embeds the quiz web page inside a web page
that used the official “branding” required by our university.
When experimenting with a new layout can run WebQuiz using the command:
> webquiz --webquiz-layout webquiz_myformat quizfile.tex
Once the new layout is finalised you can make it the default layout by setting webquiz-layout equal
to webquiz_my_format in the webquizrc file (Section 4.2) using webquiz --edit-settings.
If you do make modifications to any of these files then, by the WebQuiz Licensing agreement,
you are required to create a new version of this file that has a different name. Doing this will also
make it easier for you to integrate your changes with any future releases of WebQuiz.
github.com/AndrewAtLarge/WebQuiz/issues.
When reporting a bug please provide a minimal working example that clearly demonstrates your
problem. This should be a compilable LATEXfile that looks something like the following:
\documentclass{webquiz}
\begin{document}
** insert problematic code here **
\end{document}
Bug reports that do not have a minimal working example can be hard to reproduce in which case
it is not possible to fix them. Before submitting a bug export please first compile your quiz using
(pdf)latex to check to see if your problem is an issue with LATEXor with WebQuiz. If you can,
please also test to see if your code compiles using TEX4ht directly.
github.com/AndrewAtLarge/WebQuiz/issues/issues.
Where possible these will be incorporated into a future release of the package, although there is a
potential technical issue here in that the underlying CSS files are written using sass.
1. Multiple choice questions with a unique correct answer. (See button to to question 1 )
2. Multiple choice questions with several (or no) correct answers. (See button to to question 2 )
3. Questions that require the student to enter an answer, which can then
be compared with the correct answer in several different ways. (See
button to to question 3 )
The use of WebQuiz is described in the next section. Later sections describe
how each of the WebQuiz environments are used.
The discussion environment in WebQuiz can also be used to write Web Pages
like this one (The pages you are reading here were written using WebQuiz.)
Basic Usage (Basic Usage) Once you have a WebQuiz file, you can run it
through LATEX, in the usual way, to produce a readable version of your quiz.
When you are happy with the quiz, use WebQuiz to create the HTML version.
Note that the printable version of the quiz does not look like the web page;
rather, it contains all of the information in an easily readable layout.
If, for example, your quiz file is called quiz1.tex then you can use the following
commands:
> latex quiz1 % latex a quiz file
> pdflatex quiz1 % a PDF versio of the quiz
> xdvi quiz1 % view the quiz using xdvi
> dvips quiz1 % print the quiz
> webquiz quiz1 % converts the quiz to html
Converting the quiz to html can take quite a long time, particularly if a large
number of images need to be created.
\UnitCode{MATH1001}
\UnitName{Differential Calculus}
\UnitURL{/u/UG/JM/MATH1001/}
\QuizzesURL{/u/UG/JM/MATH1001/Quizzes/}
\begin{document}
\begin{question} % question 1
. . .
\end{question}
\begin{question} % question 2
. . .
\end{question}
.
.
\end{document}
In the preamble of the LATEX file you can specify the unit code, the name of the
unit of study, the location of the homepage for the unit and the index file for
the quizzes for this unit; this is done using the commands \UnitCode, \UnitName,
\UnitURL and \QuizzesURL respectively. If the command \QuizzesURL is omitted
then the URL for the quiz index file is set to \UnitURL/Quizzes.
The title of the quiz can be set in the preamble using the \title command. Note
that the \title command must appear before the \begin{document} command.
As in any LATEX document, the preamble can define macros and load other
LATEX packages the usual way .
By using the discussion environment you can summarise the material for the
students or add introductory material for the quiz. For example, discussion
environments can be used to recall that main concepts being covered by the
quiz or to give references to the lecture notes for the unit. The syntax for the
Questions are set inside a question environment. The text is followed by the
answers.
With each of these types of questions you can (and should) provide feedback to
the students depending on whether their answer is correct or incorrect. Below
we describe how to produce these different types of questions.
At most one \feedback response should be given for each \correct and each
\incorrect response. The \feedback commands are optional; however, it is
recommended that you use them because targeted feedback to the students
based on their responses can be beneficial.
For example, the code below, when run through WebQuiz, produces button to to question 1
in the online manual quiz.
\begin{question}
The shaded region in the graph
\begin{center}
\begin{pspicture}(-3,-1.5)(3,4)
\pscircle[linewidth=1pt,linestyle=dashed,%
fillcolor=SkyBlue,fillstyle=solid](1,1){2}
\psaxes[linecolor=red,linewidth=1pt,labels=none]%
{->}(0,0)(-1.5,-1.5)(3.5,3.5)
\rput(3.75,0){$x$}
\rput(0,3.85){$iy$}
\rput(3,-0.4){3}
\rput(-0.4,3){3$i$}
\psdots(1,1)
\end{pspicture}
\end{center}
is equal to which of the following sets of complex numbers?
\begin{choice}
\incorrect $\{z \in \C : (z-1)^{2}+(z-(i+1))^{2}<2\}$
\feedback The equation of a circle in the complex plane with
centre $a+ib$ and radius $r$ is
\begin{displaymath}
\{z\in\C : |z-(a+ib)|<r \}.
\end{displaymath}
The only difference to the previous case is that zero or more \correct commands
can appear.
For example, button to to question 2 below was typed into WebQuiz using the
following commands:
\begin{question}
Which of the following numbers are prime?
\begin{choice}[multiple]
\incorrect 1
\feedback By definition, a prime is a number greater than 1
whose only factors are 1 and itself.
\correct 19
\feedback The only factors of 19 are 1 and itself.
\incorrect 6
\feedback 2 is a factor of 6
\correct 23
\feedback The only factors of 23 are 1 and itself.
\correct 191
\feedback The only factors of 191 are 1 and itself.
\end{choice}
\end{question}
Question 3 (Question 3)
By default, the choice environments puts the multiple choice options into one
column format. Sometimes the options look better when listed in two or more
columns, however, this should be used sparingly as multiple columns do not
always display well if the quiz is viewed on a mobile device. By using the columns
key word in a choice environment you can specify the number of columns in the
HTML version of the quiz.
\begin{question}
. . .question text. . .
\begin{choice}[multiple, columns=n] . . . n columns
\(in)correct . . . text for (in)correct option
\feedback . . . feedback on response
If the optional argument [multiple] is not present, then the question admits
precisely one correct answer.
For example, button to to question 3 below was typed into WebQuiz using the
following commands:
\begin{question}
What are suitable parametric equations for this plane curve?
\begin{center}
\psset{unit=.6cm}
\begin{pspicture}(-2.5,-0.5)(5,5.5)
\psaxes[linecolor=red,linewidth=1pt,labels=none]%
{->}(0,0)(-2.5,-1.5)(5,5)
\psellipse[linecolor=SkyBlue,linewidth=2pt](1,2)(3,2)
\end{pspicture}
\end{center}
\begin{choice}[columns=1]
\incorrect $x=2\cos t + 1$, $y=3\sin t + 2$
\feedback This is an ellipse with centre $(1,2)$ and with axes of
length $4$ in the $x$-direction and $6$ in the $y$-direction.
\begin{center}
\psset{unit=.6cm}
\begin{pspicture}(-2.5,-0.5)(5,5.5)
\psaxes[linecolor=red,linewidth=1pt,labels=none]%
{->}(0,0)(-2.5,-1.5)(5,5)
\parametricplot[linecolor=SkyBlue,linewidth=2pt]{0}{360}%
Feedback for correct and incorrect answers is given using the macros \whenRight
and \whenWrong, respectively. The structure of questions with \answer’s is as
follows:
\begin{question}
. . .question text. . .
\answer[*][complex|integer|lowercase|number|string]{actual answer}
\whenRight . . . feedback when right (optional)
\whenWrong . . . feedback when wrong (optional)
\end{question}
See the WebQuiz manual for details of the different comparison types. For
example, button to to question 4 below was typed into WebQuiz using the
following commands:
\begin{question}
If the vectors $\vect{a}$ (of magnitude 8 units) and $\vect{b}$
(of magnitude 3 units) are perpendicular, what is the value
of
\begin{displaymath}
|\vect{a} -2\vect{b}|~?
\end{displaymath}
(Hint: Draw a diagram!)
\answer[number]{10}
\whenRight The vectors $\vect{a}$, \(-2\vect{b}\), and
$\vect{a} - 2\vect{b}$ form the sides of a right-angled
triangle, with sides of length $8$ and $6$ and
hypotenuse of length $|\vect{a} -2\vect{b}|$. Therefore
by Pythagoras’ Theorem,
\(|\vect{a} -2\vect{b}|=\sqrt{8^2+6^2}=10\).
Index Files (Index Files) WebQuiz also provides a mechanism for creating a
web page containing an index of all quizzes for a given Unit of Study. This is
done with a WebQuiz file that contains a quizindex environment. The syntax
for this environment is as follows:
\begin{quizindex}
\quiz[url1]{title for quiz 1}
\quiz[url2]{title for quiz 2}
. . .
\end{quizindex}
Credits (Credits) WebQuiz was written and developed in the School of Mathematics and Statistics
at the University of Sydney. The system is built on LATEX with the conver-
sion from LATEX to HTML using Eitan Gurari’s TeX4ht, and Michal Hoftich’s
make4ht.
The LATEX component of WebQuiz was written by Andrew Mathas and the
python, CSS and Javascript code was written by Andrew Mathas (and Don
Taylor), based on an initial prototype of Don Taylor’s from 2001. Since 2004
the program has been maintained and developed by Andrew Mathas. Although
the program has changed substantially since 2004, Don’s idea of using TEX4ht,
and some of his code, is still in use.
Thanks are due to Bob Howlett for general help with CSS and, for Version 5,
to Michal Hoftich for technical advice.
Question 1.
The shaded region in the graph
iy
3i
x
3
Feedback: The equation of a circle in the complex plane with centre a + ib and
radius r is
{z ∈ C : |z − (a + ib)| < r}.
Question 2.
Which of the following numbers are prime?
% Option 2(a): 1
Feedback: By definition, a prime is a number greater than 1 whose only factors
are 1 and itself.
% Option 2(c): 6
Feedback: 2 is a factor of 6
Question 3.
What are suitable parametric equations for this plane curve?
Feedback: This is an ellipse with centre (−1, −2) and with axes of length 6 in
the x-direction and 4 in the y-direction.
Question 4.
If the vectors a (of magnitude 8 units) and b (of magnitude 3 units) are per-
pendicular, what is the value of |a − 2b| ? (Hint: Draw a diagram!)
Feedback when wrong: Draw a diagram and then use Pythagoras’ theorem.
56
\Qref, 12, 13 tex4ht, 28 webquiz-layout, 37
\qref, 12, 13 TEXLive, 29 webquiz-url, 36
question environment, 6 TEXShop, 4 webquiz-www, 36
\answer, 6 \thechoice, 11 webquizrc, 15, 16, 18, 19,
choice, 10 theme, 23, 36, 38 21, 23, 30, 32–35,
quiet, 32 blue, 23, 38 37, 38
quiet mode, 32 darkblue, 23, 38 \BreadCrumbs, 35
\quiz, 14 darkred, 23, 39 \Department, 35
quizindex, 16 default, 23, 39 \DepartmentURL, 35
quizindex environment, 14 earthy, 23, 39 engine, 35
\quiz, 14 fresh, 23, 40 \Institution, 35
\QuizzesURL, 16, 18 light, 23, 40
\InstitutionURL‘, 35
lively, 23, 40
randomorder, 19 language, 36
muted, 23, 41
rcfile, 30, 32 latex, 35
sleek, 23, 41
see webquizrc layout, 36
spring, 23, 41
vibrant, 23, 42 lualatex, 35
separatepages, 22
tikz, 26 make4ht, 36
settings, 33
Title, 16 mathjax, 36
shell-escape, 32
showsidemenu, 20 title, 17 theme, 36
single, 10 webquiz-url, 36
string, 9 unicode, 21 webquiz-www, 36
student, 2 unitcode, 17 xelatex, 35
system requirements, 28, \UnitCode, 17, 18 \whenRight, 6, 10
29 unitname, 17 \whenWrong, 6, 10
make4ht, 28 \UnitName, 17, 18
python, 28 \UnitURL, 17, 19
tex4ht, 28 usage, 31 xelatex, 21, 32, 33, 35