You are here

function matching_schema in Quiz 7.6

Same name and namespace in other branches
  1. 8.4 question_types/matching/matching.install \matching_schema()
  2. 6.6 question_types/matching/matching.install \matching_schema()
  3. 6.3 question_types/matching/matching.install \matching_schema()
  4. 6.4 question_types/matching/matching.install \matching_schema()
  5. 6.5 question_types/matching/matching.install \matching_schema()
  6. 7 question_types/matching/matching.install \matching_schema()
  7. 7.4 question_types/matching/matching.install \matching_schema()
  8. 7.5 question_types/matching/matching.install \matching_schema()

Implements hook_schema().

File

question_types/matching/matching.install, line 21
matching install file.

Code

function matching_schema() {

  // Properties for a question nodes go in here:
  $schema['quiz_matching_properties'] = array(
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'choice_penalty' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );
  $schema['quiz_matching_node'] = array(
    'fields' => array(
      'match_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,
      ),
      'question' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
      'answer' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
      'feedback' => array(
        'type' => 'text',
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'match_id',
    ),
    'indexes' => array(
      'question_id' => array(
        'nid',
        'vid',
      ),
    ),
  );

  // User answers go in here.
  $schema['quiz_matching_user_answers'] = array(
    'fields' => array(
      'answer_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'match_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'result_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'score' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      'answer' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'answer_id',
    ),
  );
  return $schema;
}