You are here

function scale_schema in Quiz 7.4

Same name and namespace in other branches
  1. 8.6 question_types/quiz_scale/quiz_scale.install \scale_schema()
  2. 8.4 question_types/scale/scale.install \scale_schema()
  3. 8.5 question_types/quiz_scale/quiz_scale.install \scale_schema()
  4. 6.6 question_types/scale/scale.install \scale_schema()
  5. 6.4 question_types/scale/scale.install \scale_schema()
  6. 7.6 question_types/scale/scale.install \scale_schema()
  7. 7 question_types/scale/scale.install \scale_schema()
  8. 7.5 question_types/scale/scale.install \scale_schema()

Implements hook_schema().

File

question_types/scale/scale.install, line 32
Sponsored by: Norwegian Centre for Telemedicine Code: falcon

Code

function scale_schema() {
  $schema['quiz_scale_node_properties'] = array(
    'description' => 'Properties specific to this question type. Holds information about what answer collection this node uses',
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer_collection_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );

  // Stores the users answers to a question.
  $schema['quiz_scale_user_answers'] = array(
    'description' => 'Store the users answers',
    'fields' => array(
      'answer_id' => array(
        'type' => 'int',
        '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,
      ),
    ),
    'primary key' => array(
      'result_id',
      'question_nid',
      'question_vid',
    ),
  );
  $schema['quiz_scale_answer_collection'] = array(
    'description' => 'Answer collection ids and properties',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'for_all' => array(
        'description' => '1 for global presets, 0 otherwise',
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  $schema['quiz_scale_user'] = array(
    'description' => 'User settings, store what answer collections the user have as presets',
    'fields' => array(
      'uid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer_collection_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
    ),
    'primary key' => array(
      'uid',
      'answer_collection_id',
    ),
  );

  /*
   * Holds each answer in the answer_collections.
   */
  $schema['quiz_scale_answer'] = array(
    'description' => 'Holds all the possible answers and what answer collections they belong to',
    'fields' => array(
      'id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer_collection_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'answer' => array(
        'type' => 'text',
      ),
    ),
    'primary key' => array(
      'id',
    ),
  );
  return $schema;
}