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

Quiz database structure

From MoodleDocs

This page documents the database tables used 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.

Note: the diagram below is a bit out of date. The significant change is that quiz_question_instances has been renamed quiz_slots. Quiz database.png

File:Quiz 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.x 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 built and available online.)

Rough change-log

Moodle 2.3

  • New column quiz_attempts.currentpage for MDL-3054.
  • New column quiz.navmethod for MDL-11047.
  • New columns quiz.gradeperiod, quiz.overduehandling and quiz_attempts.state for MDL-3030.
  • Old columns quiz_reports.cron and quiz_reports.lastcron dropped (MDL-30635). (config_plugins is now used, as for other plugin types.)

Moodle 2.2

  • Old quiz.popup column replaced by quiz.browsersecurity

Moodle 2.1 (new question engine)

  • Old quiz.optionflags and quiz.penaltyscheme columns replaced by quiz.preferredbehaviour.
  • New quiz.showblocks column.
  • Old column split into seven new* columns.

Moodle 2.0

  • New field quiz.introformat.
  • New field quiz.questiondecimalpoints.
  • New field quiz.showuserpicture. See MDL-3156.
  • All the quiz report tables are new. See 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.
  • New table quiz_overrides for MDL-16478.

Moodle 1.9

  • Time limit field changed to int(10).

Moodle 1.7

  • New table quiz_feedback.

See also