Note:

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

Question database structure

From MoodleDocs
Revision as of 12:33, 5 March 2009 by Tim Hunt (talk | contribs)

This page documents the database tables use by the question bank and question engine.

The distinction between the question bank and the question engine is that the question bank stores the question definitions, organised into categories, while the question engine stores the information a user's attempts at a question or questions.

Overview

Question database.png

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

Common field types

  • Fields that hold a question score, like question.defaultgrade or question_answers.fraction, should be NUMBER(12,7).
  • Question text, feedback, etc. should be TEXT(short).

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.)

Individual question types

The following core question types have their own database tables:

Rough change-log

Moodle 2.0

  • New field question_sessions.flagged.
  • All fields that store grades were reviewed and set to the recommended types mentioned above.

Moodle 1.9

  • New question bank:
    • New fields question.timecreated, timemodified, createdby and modifiedby.
    • question_category.course changed to question_category.contextid.
    • Removed field question_category.published.

Moodle 1.7

  • question_sessions.comment renamed to manualcomment (reserved word).
  • new column question.generalfeedback.

TODO, check CVS history for more.

See also