Note: You are currently viewing documentation for Moodle 3.3. Up-to-date documentation for the latest stable version of Moodle is probably available here: Quiz database structure.

Development:Quiz database structure

From MoodleDocs
(Redirected from Quiz database structure)

Template:Quiz developer docs

This page documents the database tables use by the quiz module.

Quiz settings and runtime overview

It is helpful to distinguish between quiz settings, which is where we store information about how the teacher has set up the quiz, and 'runtime' (not a great name) where we store information about people's attempts at the quiz.

Note that information about the attempter's interaction with each question is stored by the question engine. See Development:Question_database_structure for details.

Quiz database.png

File:Quiz database.dia Dia file, should you wish to have a copy of this diagram in an editable format.

Quiz report tables overview

Quiz reports database.png

File:Quiz reports database.dia Dia file, should you wish to have a copy of this diagram in an editable format.

Common field types

  • Fields that hold an overall score, like quiz.grade, should be NUMBER(10,5).
  • Fields that hold an individual question score, like quiz_question_instances.grade, should be NUMBER(12,7).

Detailed table descriptions

In Moodle 2.0 dev, you can get these by going to Administration -> Development -> XMLDB and clicking on the [Doc] link next in any of the relevant rows (mod/quiz/db, mod/quiz/report/xxx/db). Looking directly there is much more likely to be up-to-date than relying on information that has been copied here.

(Wouldn't it be nice if that documentation was automatically build and available online.)

Rough change-log

Moodle 2.0

  • New field quiz.showuserpicture. See MDL-3156.
  • All the quiz report tables are new. See Development:Quiz_report_enhancements
  • All fields that store grades were reviewed and set to the recommended types mentioned above.
  • Never used quiz_question_versions table was removed.

Moodle 1.9

  • Time limit field changed to int(10).

Moodle 1.7

  • New table quiz_feedback.

See also