Note:

If you want to create a new page for developers, you should create it on the Moodle Developer Resource site.

Quiz: Difference between revisions

From MoodleDocs
(Move explanation of database structure to separate page)
(Added explanation of some of the terminology)
Line 2: Line 2:


On this page I am planning to give an overview of how the module works. --[[User:Gustav|Gustav]] 07:12, 28 January 2006 (WST)
On this page I am planning to give an overview of how the module works. --[[User:Gustav|Gustav]] 07:12, 28 January 2006 (WST)
==Terminology==
In order to describe and understand the quiz module, it is necessary to
understand the terminology that is used to describe its aspects. Below
some important terms are listed and explained and in some cases linked to more
detailed documentation.
'''adaptive question''' (QTI speak: adaptive item)
Adaptive questions are questions that walk the user through a directed graph of question states depending on the user's responses. E.g. a complicated mathematical question that is answered incorrectly, but is likely to be incorrect because of a common mistake, could provide the user with a hint towards this mistake, apply a penalty and allow a second attempt at this question.
Quizzes can be run in adaptive mode, which provides buttons to mark each question individually.
'''answer(s)'''
The term answer is used exclusively for the teacher defined answers of a question. These answers are usually stored in the <code>quiz_answers</code> table and are compared to the responses for grading.
'''attempt(s)'''
The term attempt is used in the sense of "Attempt at the quiz". Depending on the quiz settings, a student may be allowed several attempts at a quiz. An attempt is finished when the student clicks on the corresponding button on the attempt page. Students do not have to complete an attempt in one visit. They can navigate away from the quiz page and return later to continue the same attempt.
Within one and the same quiz attempt a student may make several attempts        at answering a particular question, at least if the questiontype allows        it and the quiz is set up in adaptive mode. These will always be        referred to as &quot;attempts at a question&quot;, never just as        &quot;attempts&quot;.
'''event'''
The $stateobject (and the <code>quiz_states</code> table) has a        field <code>event</code>, which indicates the event that led to the        creation of the state. The field can take the value of any of the        following constants (defined in locallib.php):
*EVENTOPEN: The attempt has just been opened and this is the initial state of a question, i.e. the user has seen the question did not interact with it yet.
*EVENTSAVE: The responses are just being saved, either because the student requested this explicitly or because the student navigated to another quiz page.
*EVENTVALIDATE: The student requested a validation of the responses. (This is not supported by all questiontypes.)
*EVENTGRADE: The responses are being graded but the question session is not closed. This is generally the case for adaptive questions.
*EVENTCLOSE: The responses are being graded and the question session is closed. Usually this happens because the whole attempt closes, either because the student requests it or because the time is up or because we are beyond the due date.
*EVENTDUPLICATEGRADE: This is a strange one. It indicates that the responses would have been graded had they not been found to be identical to previous responses.
When new responses are being processed by the function <code>        quiz_process_responses</code>, then this function is being passed the        event type in <code>$action->event</code> while the responses are in        <code>$action->responses</code>.
'''question(s)'''
Strictly, a question in the context of the quiz module is the set of        definitions (question name, question text, possible answers, feedback,        etc.) that constitute a reusable item. Therefore a question itself is a        static entity. All data related to interactions with a particular        question (in a particular attempt on a particular quiz) is stored in its        corresponding states.
'''questiontype'''
There are several questiontypes built into the quiz module, however,      due to the plugin architecture of the quiz module, it is possible to        define custom questiontypes. Existing questiontypes include true/false,        multiple choice, short answer, numerical and  calculated questions.
'''responses'''
Conceptually these are the students' responses to a question. This is always used in plural, although for some questiontypes there is only one possible response. In the runtime <code>$state</code> object there is a field <code>$state-&gt;responses</code>, which holds an array of a student's responses to a question. See also: [[Quiz response storage]]
'''state'''
Question states are saved in the table <code>quiz_states</code>. States always "belong" to a question within a particular attempt and are therefore also user specific. The first state in a question's life cycle during an attempt records the fact that the user has seen the question. This state is never modified, however, it can be superseded by a new state, which represents a user interaction. Different user interactions are defined by the events, a set of constants, one for each possible type of user interaction.
'''session'''
A question session is the complete history of question states that the question is taken through. Usually only the most recent state and the last graded state are of interest though.
==More details==


More details can be found on the following pages:
More details can be found on the following pages:


*[[Quiz database structure]]
*[[Quiz database structure]]

Revision as of 00:24, 28 January 2006

The quiz module is a complex module with its own modular structure to allow question type plug-ins. The module has grown organically and in spite of a lot of rewriting for Moodle 1.5 the code is not very simple to understand.

On this page I am planning to give an overview of how the module works. --Gustav Delius 07:12, 28 January 2006 (WST)

Terminology

In order to describe and understand the quiz module, it is necessary to understand the terminology that is used to describe its aspects. Below some important terms are listed and explained and in some cases linked to more detailed documentation.

adaptive question (QTI speak: adaptive item)

Adaptive questions are questions that walk the user through a directed graph of question states depending on the user's responses. E.g. a complicated mathematical question that is answered incorrectly, but is likely to be incorrect because of a common mistake, could provide the user with a hint towards this mistake, apply a penalty and allow a second attempt at this question. Quizzes can be run in adaptive mode, which provides buttons to mark each question individually.

answer(s)

The term answer is used exclusively for the teacher defined answers of a question. These answers are usually stored in the quiz_answers table and are compared to the responses for grading.

attempt(s)

The term attempt is used in the sense of "Attempt at the quiz". Depending on the quiz settings, a student may be allowed several attempts at a quiz. An attempt is finished when the student clicks on the corresponding button on the attempt page. Students do not have to complete an attempt in one visit. They can navigate away from the quiz page and return later to continue the same attempt.

Within one and the same quiz attempt a student may make several attempts at answering a particular question, at least if the questiontype allows it and the quiz is set up in adaptive mode. These will always be referred to as "attempts at a question", never just as "attempts".

event

The $stateobject (and the quiz_states table) has a field event, which indicates the event that led to the creation of the state. The field can take the value of any of the following constants (defined in locallib.php):

  • EVENTOPEN: The attempt has just been opened and this is the initial state of a question, i.e. the user has seen the question did not interact with it yet.
  • EVENTSAVE: The responses are just being saved, either because the student requested this explicitly or because the student navigated to another quiz page.
  • EVENTVALIDATE: The student requested a validation of the responses. (This is not supported by all questiontypes.)
  • EVENTGRADE: The responses are being graded but the question session is not closed. This is generally the case for adaptive questions.
  • EVENTCLOSE: The responses are being graded and the question session is closed. Usually this happens because the whole attempt closes, either because the student requests it or because the time is up or because we are beyond the due date.
  • EVENTDUPLICATEGRADE: This is a strange one. It indicates that the responses would have been graded had they not been found to be identical to previous responses.

When new responses are being processed by the function quiz_process_responses, then this function is being passed the event type in $action->event while the responses are in $action->responses.

question(s)

Strictly, a question in the context of the quiz module is the set of definitions (question name, question text, possible answers, feedback, etc.) that constitute a reusable item. Therefore a question itself is a static entity. All data related to interactions with a particular question (in a particular attempt on a particular quiz) is stored in its corresponding states.

questiontype

There are several questiontypes built into the quiz module, however, due to the plugin architecture of the quiz module, it is possible to define custom questiontypes. Existing questiontypes include true/false, multiple choice, short answer, numerical and calculated questions.

responses

Conceptually these are the students' responses to a question. This is always used in plural, although for some questiontypes there is only one possible response. In the runtime $state object there is a field $state->responses, which holds an array of a student's responses to a question. See also: Quiz response storage

state

Question states are saved in the table quiz_states. States always "belong" to a question within a particular attempt and are therefore also user specific. The first state in a question's life cycle during an attempt records the fact that the user has seen the question. This state is never modified, however, it can be superseded by a new state, which represents a user interaction. Different user interactions are defined by the events, a set of constants, one for each possible type of user interaction.

session

A question session is the complete history of question states that the question is taken through. Usually only the most recent state and the last graded state are of interest though.

More details

More details can be found on the following pages: