Difference between revisions of "Cloze question type"

Jump to: navigation, search
(added information on the response storage model)
Line 1: Line 1:
 +
{{Questiontype developer docs}}
 +
 
The code for the cloze question type is in the directory mod/quiz/questiontypes/multianswer. The name of the questiontype class is <code>quiz_embedded_cloze_qtype</code> and it extends the default question type.
 
The code for the cloze question type is in the directory mod/quiz/questiontypes/multianswer. The name of the questiontype class is <code>quiz_embedded_cloze_qtype</code> and it extends the default question type.
 +
 +
A cloze question is a container for several subquestions. We call these subquestions ''''wrapped questions''''. Most of the methods of this questiontype simply call the corresponding methods of the wrapped questions. So mostly this questiontype class only has to do clever bookkeeping.
 +
 +
The way the questiontype it is implemented at the moment all wrapped questions must be of a type that use a single response field <code><nowiki>$state->responses['']</nowiki></code>.
 +
  
 
===quiz_multianswers database table===
 
===quiz_multianswers database table===
Line 22: Line 29:
  
 
The fact that the sequence number of the subquestion, rather than the id of the subquestion is used in the response storage is a pity. It could leads to problems when the teacher changes the layout of the cloze question.
 
The fact that the sequence number of the subquestion, rather than the id of the subquestion is used in the response storage is a pity. It could leads to problems when the teacher changes the layout of the cloze question.
 +
 +
 +
[[Category:Quiz]]

Revision as of 16:49, 5 February 2006

The code for the cloze question type is in the directory mod/quiz/questiontypes/multianswer. The name of the questiontype class is
quiz_embedded_cloze_qtype
and it extends the default question type.

A cloze question is a container for several subquestions. We call these subquestions 'wrapped questions'. Most of the methods of this questiontype simply call the corresponding methods of the wrapped questions. So mostly this questiontype class only has to do clever bookkeeping.

The way the questiontype it is implemented at the moment all wrapped questions must be of a type that use a single response field
$state->responses['']
.


quiz_multianswers database table

The quiz_multianswers table belongs to the multianswer questiontype and is an extension of the quiz_questions table. It merely stores a comma separated list of question ids in the sequence field, which is important, because that's the only way to know which sub question belongs to which position in the questiontext.

id
int(10) unsigned NOT NULL auto_increment,
Primary key
question
int(10) unsigned NOT NULL default '0',
Foreign key refering to the id field in the quiz_questions table
sequence
varchar(255) NOT NULL default ,
A comma separated list of question ids in the order in which they appear in the questiontext.

Response storage model

The multianswer question uses a serialized format consisting of a comma separated list of pairs. Each pair saves the response for one of the subquestions and is itself separated with a hyphen ('-'). In front of the hyphen there is the sequence number of the subquestion (starting at 1). After the hyphen is the raw response, that was submitted by the student. The serialized format could look like the following example:

1-34,2-Napoleon,3-4,4-correct response,5-1

All commas and hyphens that are part of the raw answer are HTML entity encoded to avoid problems.

The fact that the sequence number of the subquestion, rather than the id of the subquestion is used in the response storage is a pity. It could leads to problems when the teacher changes the layout of the cloze question.