You are here

function multichoice_schema in Quiz 7

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.2 multichoice.install \multichoice_schema()
  6. 6.3 question_types/multichoice/multichoice.install \multichoice_schema()
  7. 6.4 question_types/multichoice/multichoice.install \multichoice_schema()
  8. 6.5 question_types/multichoice/multichoice.install \multichoice_schema()
  9. 7.6 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()

Implements hook_schema().

File

question_types/multichoice/multichoice.install, line 28
Sponsored by: Norwegian Centre for Telemedicine Code: falcon

Code

function multichoice_schema() {

  // Stores the users answers to a question.
  $schema['quiz_multichoice_user_answers'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'result_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'question_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'question_vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'choice_order' => array(
        'type' => 'text',
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'answer_id' => array(
        'result_id',
        'question_nid',
        'question_vid',
      ),
    ),
  );
  $schema['quiz_multichoice_user_answer_multi'] = array(
    'fields' => array(
      'user_answer_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'user_answer_id',
      'answer_id',
    ),
    'indexes' => array(
      'answer_id' => array(
        'user_answer_id',
      ),
    ),
  );
  $schema['quiz_multichoice_properties'] = array(
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'choice_multi' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'choice_random' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'choice_boolean' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );

  /*
   * Holds each answer in the answer_collections.
   */
  $schema['quiz_multichoice_answers'] = array(
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer' => array(
        'type' => 'text',
      ),
      'answer_format' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'feedback_if_chosen' => array(
        'type' => 'text',
      ),
      'feedback_if_chosen_format' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'feedback_if_not_chosen' => array(
        'type' => 'text',
      ),
      'feedback_if_not_chosen_format' => array(
        'type' => 'varchar',
        'length' => 255,
        'not null' => TRUE,
      ),
      'score_if_chosen' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'score_if_not_chosen' => array(
        'type' => 'int',
        'unsigned' => FALSE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'question_nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'question_vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'id',
    ),
    'indexes' => array(
      'quiz_id' => array(
        'question_nid',
        'question_vid',
      ),
    ),
  );
  $schema['quiz_multichoice_user_settings'] = array(
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'choice_multi' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'choice_random' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'choice_boolean' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'uid',
    ),
  );
  return $schema;
}