You are here

function long_answer_update_6401 in Quiz 6.4

Implementation of hook_update_N()

Add a table for storing the rubric

File

question_types/long_answer/long_answer.install, line 134
Long answer questions.

Code

function long_answer_update_6401() {
  $results = array();
  if (db_table_exists('quiz_long_answer_node_properties') && !db_column_exists('quiz_long_answer_node_properties', 'rubric')) {
    db_add_field($results, 'quiz_long_answer_node_properties', 'rubric', array(
      'type' => 'text',
    ));
  }
  else {
    db_create_table($results, 'quiz_long_answer_node_properties', array(
      'fields' => array(
        'nid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ),
        'vid' => array(
          'type' => 'int',
          'unsigned' => TRUE,
          'not null' => TRUE,
        ),
        'rubric' => array(
          'type' => 'text',
        ),
      ),
      'primary key' => array(
        'nid',
        'vid',
      ),
    ));
    $sql = "INSERT INTO {quiz_long_answer_node_properties} (nid, vid)\n            SELECT nid, vid FROM node WHERE `type` = 'long_answer'";
    $results[] = update_sql($sql);
  }
  return $results;
}