A pure text quiz

Question and choices

Here is a typical quiz with a question and four alternative answers:

Question: What is the capital of Norway?

 Choice 1: Helsinki

Wrong!

 Choice 2: Drammen

Wrong!

 Choice 3: Oslo

Correct!

 Choice 4: Denmark

Wrong!

Click on the pencil symbol to the left of Choice to see whether the choice is correct or not.

The above quiz can be specified by the compact text

!bquiz
Q: What is the capital of Norway?
Cw: Helsinki
Cw: Drammen
Cr: Oslo
Cw: Denmark
!equiz

Syntax:

Multiple correct choices are possible. Here is an example with three right choices:

!bquiz
Q: Which of the following cities are capitals?
Cw: Sidney
Cr: Kigali
Cw: Bonn
Cr: Bern
Cr: Ottawa
Cw: New York
!equiz

Question: Which of the following cities are capitals?

 Choice 1: Sidney

Wrong!

 Choice 2: Kigali

Correct!

 Choice 3: Bonn

Wrong!

 Choice 4: Bern

Correct!

 Choice 5: Ottawa

Correct!

 Choice 6: New York

Wrong!

Explanations of choices

Sometimes it is desireable to give some explanation why certain choices are wrong (or right). If you click on the symbols in the quiz below, explanations will be shown for Choices 1 and 2.

Question: What is the capital of Norway?

 Choice 1: Helsinki

Helsinki is the capital of Finland.

 Choice 2: Drammen

Drammen is a small city close to Oslo.

 Choice 3: Oslo

Correct!

 Choice 4: Denmark

Wrong!

The quiz syntax applies E: ... after the choice to give an explanation of that choice.

!bquiz
Q: What is the capital of Norway?

Cw: Helsinki
E: Helsinki is the capital of Finland.

Cw: Drammen
E: Drammen is a small city close to Oslo.

Cr: Oslo

Cw: Denmark
!equiz

This time we also added some whitespace for enhanced reading of the text.

Typesetting

It is easy to use emphasize font, boldface, color, hyperlinks, etc., since the text in the specification of questions, choices, and explanations are rendered according to the DocOnce markup language. For simple typesetting (emphasize, boldface, links) DocOnce also accepts Markdown syntax. Here is an example:

Question: This is a very famous quote:

Premature optimization is the root of all evil.
This quote is attributed to

 Choice 1: Geroge W. Bush

Wrong!

 Choice 2: Donald Knuth

According to Wikiquote, Donald Knuth wrote this statement in Structured Programming with Goto Statements. Computing Surveys, 6:4, pp. 261-301, 1974.

 Choice 3: Ole-Johan Dahl

Ole-Johan Dahl was a famous Norwegian professor of computer science and together with Kristen Nygaard the inventor of object-oriented programming, but he is not the man behind this quote.

The corresponding specification reads

!bquiz
Q: Here is a famous quote:

!bquote
*Premature optimization is the root of all evil.*
!equote
This quote is attributed to

Cw: Geroge W. Bush

Cr: Donald Knuth
E: According to "Wikiquote": "http://en.wikiquote.org/wiki/Donald_Knuth",
Donald Knuth wrote this statement in *Structured Programming with
Goto Statements*. Computing Surveys, _6_:4,
pp. 261-301, _1974_.

Cw: Ole-Johan Dahl
E: Ole-Johan Dahl was a famous Norwegian professor of computer
science and together with Kristen Nygaard the inventor of
object-oriented programming, but he is not the man behind this
quote.
!equiz

Quiz inside admonitions

Question admonitions may well feature quizzes unless the output format is reStructuredText (rst, sphinx). A plain question admonition is

Question. What is the capital of Norway?
specified by the DocOnce syntax

!bquestion
What is the capital of Norway?
!equestion

Putting a quiz inside the question admonition looks like

Question.

What is the capital of Norway?

 Answer: Stockholm

Stockholm is the capital of Sweden, Norway's neighboring country.

 Choice 2: Bergen

Some people from Bergen may claim so... It is just the second largest city in Norway.

 Choice 3: Oslo

Correct!

 Choice 4: Denmark

Wrong!

specified as

!bquestion
!bquiz
Q: [] What is the capital of Norway?

Cw: [Answer:] Stockholm
E: Stockholm is the capital of Sweden, Norway's neighboring country.

Cw: Bergen
E: Some people from Bergen may claim so... It is just the second
largest city in Norway.

Cr: Oslo

Cw: Denmark
!equiz
!equestion

Choice and question prefix. In the above example, we demonstrate the possibility to control the word preceding the question and the choices. For the current output format (html), questions are by default preceded by Question: and choices by Choice X:, where X is the number of the choice.

The prefix appears inside square brackets. Empty brackets, as those in the question, leads to no prefix. The choice Stockholm has a prefix [Answer:], and exactly the text inside the square brackets precedes the text of this choice in the output.