You are here

function short_answer_schema in Quiz 8.6

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

Implements hook_schema().

File

question_types/quiz_short_answer/quiz_short_answer.install, line 11
Short_answer questions install file.

Code

function short_answer_schema() {

  // Properties for a question nodes go in here:
  $schema['quiz_short_answer_node_properties'] = array(
    'fields' => array(
      'nid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'vid' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'maximum_score' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 1,
      ),
      // One of (0) textfield and (1) textarea.
      'text_entry_type' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      // One of exact (0), case insensitive (1), regex (2), manual (3).
      'correct_answer_evaluation' => array(
        'type' => 'int',
        'size' => 'tiny',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      // Correct answer.
      'correct_answer' => array(
        'type' => 'text',
      ),
      // Feedback if answer is correct.
      'feedback_correct' => array(
        'type' => 'text',
      ),
      // Feedback if answer is incorrect.
      'feedback_incorrect' => array(
        'type' => 'text',
      ),
    ),
    'primary key' => array(
      'nid',
      'vid',
    ),
  );

  // User answers go in here.
  $schema['quiz_short_answer_user_answers'] = array(
    'fields' => array(
      'answer_id' => array(
        'type' => 'serial',
        'unsigned' => TRUE,
        'not null' => TRUE,
      ),
      'result_answer_id' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'not null' => FALSE,
      ),
      'score' => array(
        'type' => 'float',
        'unsigned' => TRUE,
        'not null' => TRUE,
        'default' => 0,
      ),
      // This may be set to false if manual scoring is used.
      'is_evaluated' => array(
        'type' => 'int',
        'unsigned' => TRUE,
        'size' => 'tiny',
        'default' => 0,
        'not null' => TRUE,
      ),
      'answer' => array(
        'type' => 'text',
      ),
      'answer_feedback' => array(
        'type' => 'text',
      ),
      'answer_feedback_format' => array(
        'type' => 'varchar',
        'length' => 255,
      ),
    ),
    'primary key' => array(
      'answer_id',
    ),
    'unique keys' => array(
      'result_answer_id' => array(
        'result_answer_id',
      ),
    ),
  );
  return $schema;
}