function quiz_update_6408 in Quiz 6.4
Implementation of hook_update_N().
- Adding table for saving quiz user settings
- Merging randomize and shuffle into randomization
File
- ./
quiz.install, line 324 - Quiz install schema for installing the quiz module
Code
function quiz_update_6408() {
$results = array();
db_create_table($results, 'quiz_user_settings', array(
'fields' => array(
'uid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'nid' => array(
'description' => 'nid for the last node the user edited',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'description' => 'vid for the last node the user edited',
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'aid' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
),
'number_of_random_questions' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'pass_rate' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
),
'summary_pass' => array(
'type' => 'text',
),
'summary_default' => array(
'type' => 'text',
),
'randomization' => array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
),
'backwards_navigation' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
),
'keep_results' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
),
'repeat_until_correct' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'feedback_time' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
),
'takes' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
),
'time_limit' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'quiz_always' => array(
'type' => 'int',
'size' => 'tiny',
'not null' => TRUE,
'default' => 0,
),
'has_userpoints' => array(
'type' => 'int',
'size' => 'tiny',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
),
'allow_skipping' => array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
),
),
'primary key' => array(
'uid',
),
));
db_add_field($results, 'quiz_node_properties', 'randomization', array(
'type' => 'int',
'size' => 'small',
'not null' => TRUE,
'default' => 0,
));
$sql = 'UPDATE {quiz_node_properties}
SET randomization = 1
WHERE shuffle = 1';
$results[] = update_sql($sql);
db_drop_field($results, 'quiz_node_properties', 'shuffle');
$sql = 'UPDATE {quiz_node_properties}
SET randomization = 2
WHERE randomize = 1';
$results[] = update_sql($sql);
db_drop_field($results, 'quiz_node_properties', 'randomize');
return $results;
}