You are here

function multichoice_schema in Quiz 6.2

Same name and namespace in other branches
  1. 8.6 question_types/quiz_multichoice/quiz_multichoice.install \multichoice_schema()
  2. 8.4 question_types/multichoice/multichoice.install \multichoice_schema()
  3. 8.5 question_types/quiz_multichoice/quiz_multichoice.install \multichoice_schema()
  4. 6.6 question_types/multichoice/multichoice.install \multichoice_schema()
  5. 6.3 question_types/multichoice/multichoice.install \multichoice_schema()
  6. 6.4 question_types/multichoice/multichoice.install \multichoice_schema()
  7. 6.5 question_types/multichoice/multichoice.install \multichoice_schema()
  8. 7.6 question_types/multichoice/multichoice.install \multichoice_schema()
  9. 7 question_types/multichoice/multichoice.install \multichoice_schema()
  10. 7.4 question_types/multichoice/multichoice.install \multichoice_schema()
  11. 7.5 question_types/multichoice/multichoice.install \multichoice_schema()

Implementation of hook_schema().

File

./multichoice.install, line 18
Multichoice Install (a quiz question type)

Code

function multichoice_schema() {

  /**
   * Stores correct answers for multichoice quiz.
   */

  // Create the quiz node user answers multichoice table.
  $schema['quiz_multichoice_user_answers'] = array(
    'fields' => array(
      'question_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'question_vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'result_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'result_id',
      'question_nid',
      'question_vid',
      'answer_id',
    ),
  );

  /**
   * Stores user answers for multichoice quiz.
   */

  // Create the quiz node answers multichoice table.
  $schema['quiz_multichoice_answers'] = array(
    'fields' => array(
      'answer_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'feedback' => array(
        'type' => 'text',
        'length' => 65535,
      ),
      'result_option' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'default' => 0,
      ),
      'is_correct' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'answer_id',
    ),
  );

  // Default the "Show Author and Date" for this question type to OFF.
  $temp_array = variable_get('theme_settings', array());
  $temp_array['toggle_node_info_multichoice'] = 0;
  variable_set('theme_settings', $temp_array);
  return $schema;
}