Architecture Information

Last updated on
2 May 2019

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

A Quiz is a Drupal node type, and thus the node table contains a row for each Quiz. Similarly, each Question type is also currently Drupal node type, so it too has an entry in the node table.

This Entity-based approach was introduced in Quiz 5.0 and resulted in a code reduction, as raw HTML, Forms, and Lists were converted to take advantage of the Entity API, Render API, Form API, and Views.

In D8 this will also likely change as a Quiz and Question and really not considered "content". Currently in D7, Quizzes, Questions, and Results do interally use the Entity API for storage, processing, and rendering.

The resulting Entity and tables look a little bit like this:

  • Entities
    • Quiz: quiz_node_properties stores configuration of the Quiz
    • QuizQuestion: quiz_node_question_properties store properties about the question
    • QuizQuestionRelationship: quiz_node_relationship stores the relation of Questions to Quizzes, and their hiearchy if using pages
    • QuizResult: quiz_node_results stores overall quiz attempt/results
    • QuizResultAnswer: quiz_node_results_answers stores each question in a user's attempt, or the "layout" of the attempt
  • Tables
    • quiz_node_result_options used for storing grade-based feedback
    • quiz_result_type: stores result type bundles (Quiz results can have fields presented before taking)
    • quiz_terms: stores which taxonomy vocabularies a Quiz should pull from, how many questions and points per question

The quiz_node_relationship table is the "glue" between Quizzes and Questions. In the quiz_node_relationship can be found three fields - parent_vid, child_vid, and status. Together, the parent_vid and child_vid represent a two-field unique key.

The quiz_node_results_answers table is the "glue" between a Quiz attempt and the Questions in it. Upon starting a new Quiz attempt, a question list is built of all questions that the user needs to take. This is known as the "layout" and could be different for each attempt, which is why it is stored in the database for each new attempt. Based on the Quiz this can either be a staticly built list or it can be generated from random pools of questions.

Each question-type also makes it's own set of tables to hold answers and user feedback. Question types are responsible for tying their result information to Result Answer IDs. Question types can provide their own feedback. For example, the tables used by the multiple choice question type:

  • quiz_multichoice_answers: stores possible answers and point values of a question
  • quiz_multichoice_properties: stores configuration about a question
  • quiz_multichoice_user_answer_multi: stores a user's response(s) to a question
  • quiz_multichoice_user_answers: stores a user's response information to a question (e.g. the order that was displayed)
  • quiz_multichoice_user_settings: stores a quiz admistrator's default question creation settings

If a Quiz or Question is edited after they have already been taken by a user, a new revision or the Quiz and/or the Question will be created. Administrators may turn off this functionality but data integrity issues may occur. The new VID will then be used in all revisionable Quiz and Question tables.

Help improve this page

Page status: No known problems

You can: