This page describes the structure of a quiz problem in
Jutge.org and how to prepare it with the
jutge-make-quiz
command of the tookit.
Some sample quizzes are given under the examples/quizzes
directory.
In order to generate a quiz, simply execute jutge-make-quiz
inside a directory
that contains the quiz, passing as a unique parameter an integer number that
will be used as the random seed. The output will be a JSON file with the generated
quiz.
A quiz is a problem that can have many different generic questions. There are several question templates.
A quiz must be placed inside a .pbm
directory. It must have all the metadata described in the regular problem toolkit [https://github.com/jutge-org/problems-toolkit/blob/master/Help.md].
The content of the file handler.yml
must be:
handler: quiz
The quiz is described in the following way by the file quiz.yml
title: The Title of The Quiz
statement: Here you can put a statement for the quiz
questions:
- title: Question 1
file: question1
score: 30
- title: Question 2
file: question2
score: 70
Each quiz must pe provided with a title, a statement and a list of questions. Each question has a title, a file and a score. The score of all the questions in a quiz must add 100 points. The file
of a question must be the name of the .yml
file that describes it. In this example we must have a question1.yml
and a question2.yml
in the same directory as our quiz.yml
.
Each question is described in a questionName.yml
file. This file must specify a text
for the statement. Any text in the question can be generated randomly using python language. A questionName.py
file can be created for each question, and the value of variables after the execution of the script will be swapped for expressions like `$a + $b`
in the questionName.yml
file, where a
and b
are variables defined in questionName.py
.
The other mandatory attribute is the type
of the question, which can be described in the following way:
SingleChoice
: A question with multiple pre-defined answers where only one is true. Each answer must have atext
field and can have ahint
field with text to be displayed if that answer is chosen. There must be one and only one choice with acorrect: true
attribute.
type: SingleChoice
text: "The statement of the question"
choices:
- text: "Correct answer"
correct: true
hint: "You did well!"
- text: ""Nearly correct answer`"
hint: "Sorry..."
- text: "Wrong answer"
MultipleChoice
: A question with multiple pre-defined answers where one or more of them are true. Each answer must have atext
field and can optionally have ahint
field with text to be displayed if that answer is chosen. There can be more than one choice with acorrect: true
attribute.
type: MultipleChoice
text: "Which of the following are true?"
choices:
- text: "1 + 1 = 2"
correct: true
- text: "`$s != $a + $b`"
hint: "Sorry..."
- text: "`$a + $b >= $s`"
correct: true
-
FillIn
: A fill-in-the-blanks question with acontext
and a list ofitems
:-
context
: is a text where some words are replaced with the attributes in the item list. -
items
: can be either a blank space where the student can type the answer or a dropdown list with multiple pre-defined choices. A blank space has the following attributes:correct
: describes the correct answer.maxlength
: integer maximum length of the answer.placeholder
:OPTIONAL
text to display when the answer is blank. Default is?
.ignorecase
:OPTIONAL
indicates whether to ignore the case of the answer or not. Default istrue
.trim
:OPTIONAL
indicates whether to ignore the blanks before and after the answer. Default istrue
.
A dropdown list of items has the following attributes:
correct
: describes the correct answer.options
: a list of all the other possible answers that are not correct.
For code examples on FillIn questions please check the
quizzes/demo.pbm/en
folder. -
-
Ordering
: A question with a list ofitems
that has to be permutated to a specific order. Thelabel
attribute expects a text which will be the title of the box containing the items.
type: Ordering
text: Drag and drop the item to place the list in alfabetic order.
label: Programming language
items:
- A
- B
- C
- D
- F
- Z
Matching
: A match between pairs of items in two lists. An attributelabels
is needed, with two titles for the left and right boxes. Aleft
and aright
list of items is needed, with the same number of elements in each one.
type: Matching
text: Match the lower case with their capitals.
labels:
- Lower Case
- Capitals
left:
- p
- b
- m
right:
- P
- B
- M
OpenQuestion
: A simple text field where anything can be written. The open question has only aplaceholder
attribute which is the text dsplayed in the answer box as a hint to the student.
type: OpenQuestion
text: What is your name/quest/favourite color?
placeholder: 'My name is Arthur, I want to pass this course and blue. No, yel... '
Examples for all question templates can be found in the
quizzes/demo.pbm/en
folder.
As mentioned before, there can be a python script for every different question that calculates the value of any string preceded by the sigil $
. After the python code is executed, all variables in the yml file will be swapped for their values in the python program. Please note that:
- You don't need to import the random module since it will be already imported and given a seed in the jutge code.
- Some question types don't support multiple identyc answers, you may need to check if the random generated numbers are the same.
Check the demo directory for more examples and uses of this feature.
- Shuffle: the
shuffle
attribute indicates whether the order of the questions in the quiz must be changed everytime the quiz is taken. If not specified it's default value istrue
.
shuffle: False
In this case the questions will always appear in the same order as in the
quiz.yml
file.
- Shuffle: The
shuffle
attribute will change the order of the question's choices or options.Does not apply to Ordering, Matching or Open questions.
- Partial answer: The attribute
partial_answer
will divide the question's score by all the possible answers and take into account a partial correct answer. The default value of this attribute isfalse
.Only applies to Multiple Choice, Fill-in and Matching questions.
You can add images to quiz statements. In rder to do so, use the following code ![](FIG_DIR/yourimage.png)
.All images must have the .png
extension and they have to be placed directly inside the same directory as the language's .yml
files. Please note that the FIG_DIR/
prefix is mandatory in order for the jutge to be able to diplay the image.
More examples of this feature in the demo quiz directory.
You can use LaTeX mathematics in the quiz statements. Just write LaTeX formulas between high dots, such as ·\sqrt{x^2+y^2}·
. The system uses MathJax to display the formulas.
You can hide the sccore of a particular question in the quiz by setting
hide_score: true