Note:

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

Flagging questions during a quiz attempt

From MoodleDocs
Revision as of 03:00, 29 August 2008 by Tim Hunt (talk | contribs)

Moodle 2.0


We want students to be able to mark certain questions as they are doing them for whatever purpose, for example:

  • because they want to go back and check their answer before submitting the quiz.
  • because the results will only be released later, and they particularly want to remember to check whether they got this question right.
  • because they want to ask their friend or teacher something relating to that question later.

This should be a simple togglable marker, so a question is either flagged or not. The flag is controlled the person attempting the quiz. Other people (for example a teacher reviewing the quiz) can see but not change the state.

Teachers should be able to configure whether flags are used on a particular quiz.

This is MDL-16263. Please discuss this proposal in the [ Quiz forum].

Code organisation

Flagging of questions actually be implemented as a feature of the question engine, because it is potentially useful shared functionality. However any user of the question engine will have control over whether the flagging interface appears using the $cmoptions parameter to the print_question function.

In addition, some other parts of the quiz interface will be enhanced to show the flagged state of questions.

We will just store the current state of the flag for each attempt at a question (per question session), so there will not be any history kept.

Interface within questions

The flags will be displayed to the left of the questions, under the question number and marks, if the $cmoptions->flags is set in the call to print_question. There are three modes: QUESTION_FLAGSHIDDEN, QUESTION_FLAGSSHOWN and QUESTION_FLAGSEDITABLE. QUESTION_FLAGSSHOWN means display the current state of the flag, but don't let it be changed. QUESTION_FLAGSEDITABLE means show the flag with UI to change it.

If JavaScript is on, the flag state will be toggled using an Ajax interface when it is clicked on. If JavaScript is off, there will be a check-box to show the state, which will be saved when that page of the quiz is submitted. Even with Ajax on, there will be a checkbox, and the flag image will be in its <label>, but the checkbox will be hidden.

Configuration options within the quiz

There will be a new capability moodle/question:flag, which can be overridden in the quiz context to control whether a particular quiz uses flagging.

Interface within the quiz

If flags are on, the quiz will use QUESTION_FLAGSEDITABLE in attempt.php, and on the review.php and reviewquestion.php page when a user is reviewing their own attempt. It will use QUESTION_FLAGSSHOWN on the two review pages when you are reviewing someone else's attempt.

In addition, if flags are in use

  • they will be shown on summary.php.
  • they may also be shown in the navigation block. (I will try it, is see if it looks good or if it is just confusing.)

Database changes

There will be a new column

flagged INT(2) NOT NULL DEFAULT 0

in the question_sessions table.

This will be accessed and updated through a few functions in questionlib.php.

Recording state changes

If JavaScript is on, there will be a new script question/toggleflag.php to receive the Ajax state update requests.

Also, in the standard response processing (question_process_responses) there will be additional code to get the state of the flag checkbox and store it.

Security of the Ajax interface

To be written. (The code is written! I just need to explain it.)

See also