Skip to content
Snippets Groups Projects
Commit ef48ff7a authored by falcon's avatar falcon
Browse files

Update path has been improved

parent fc5c8601
No related branches found
No related tags found
No related merge requests found
......@@ -222,6 +222,12 @@ function multichoice_update_6300() {
*/
function multichoice_update_6400(&$sandbox = NULL) {
if (!module_exists('autoload')) {
drupal_install_modules(array('autoload' ,'quiz_question'));
if (!module_exists('autoload')) {
return array('#abort' => array('success' => FALSE, 'query' => 'The <a href="http://drupal.org/project/autoload">Autoload</a> module is missing. You need to <a href="http://drupal.org/project/autoload">download</a> and enable autoload before you run update.php.'));
}
}
$path = drupal_get_path('module', 'multichoice');
// This is a big update. We have put it in its own file to avoid cluttering
// this install file
......
......@@ -98,7 +98,7 @@ function _multichoice_move_old_answers(&$to_return, &$sandbox = NULL) {
FROM {quiz_multichoice_user_answers}
WHERE result_id >= %d
ORDER BY result_id, question_nid, question_vid, answer_id';
$res = db_query_range($sql, $sandbox['last_rid'], 0, 50);
$res = db_query_range($sql, $sandbox['last_rid'], 0, 500);
$progress_to_add = 0;
while ($res_o = db_fetch_object($res)) {
if ($res_o->question_nid == $sandbox['last_nid']
......@@ -269,7 +269,7 @@ function _multichoice_check_answers(&$to_return, &$sandbox) {
FROM {quiz_multichoice_answers}
WHERE question_nid >= %d AND question_vid >= %d
ORDER BY question_nid, question_vid';
$res = db_query_range($sql, $sandbox['last_nid'], $sandbox['last_vid'], 0, 50);
$res = db_query_range($sql, $sandbox['last_nid'], $sandbox['last_vid'], 0, 500);
$progress_to_add = 0;
while ($res_o = db_fetch_object($res)) {
if ($res_o->question_nid == $sandbox['last_nid']
......@@ -290,8 +290,8 @@ function _multichoice_check_answers(&$to_return, &$sandbox) {
// Store the format for this node
$sql = 'SELECT format
FROM {node_revisions}
WHERE nid = %d AND vid = %d';
$res2 = db_query($sql, $res_o->question_nid, $res_o->question_vid);
WHERE vid = %d';
$res2 = db_query($sql, $res_o->question_vid);
$sandbox['last_format'] = db_result($res2);
$sql = 'INSERT INTO {quiz_multichoice_properties}
(nid, vid, choice_boolean)
......@@ -312,9 +312,9 @@ function _multichoice_check_answers(&$to_return, &$sandbox) {
// Update all the formats
$sql = 'UPDATE {quiz_multichoice_answers}
SET answer_format = %d, feedback_if_chosen_format = %d, feedback_if_not_chosen_format = %d
WHERE question_nid = %d AND question_vid = %d';
WHERE question_vid = %d'; // This table haven't been indexed yet, making this query very slow... :/
$lf = $sandbox['last_format'];
db_query($sql, $lf, $lf, $lf, $res_o->question_nid, $res_o->question_vid);
db_query($sql, $lf, $lf, $lf, $res_o->question_vid);
$progress_to_add++;
}
$sandbox['step_progress'] += $progress_to_add;
......
......@@ -414,30 +414,33 @@ function quiz_update_6401(&$sandbox = NULL) {
'not null' => TRUE,
'default' => 0,
));
// THIS IS UGLY! But it needs to be installed here because we don't know in what order the updater
// Will execute the update hooks...
db_create_table($result, 'quiz_question_properties', array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
if (!db_table_exists('quiz_question_properties')) {
db_create_table($result, 'quiz_question_properties', array(
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'vid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
),
'max_score' => array(
'type' => 'int',
'unsigned' => TRUE,
'default' => 0,
),
),
'max_score' => array(
'type' => 'int',
'unsigned' => TRUE,
'default' => 0,
'primary key' => array(
'nid' , 'vid'
),
),
'primary key' => array(
'nid' , 'vid'
),
));
));
}
$sandbox['tables_changed'] = TRUE;
$sandbox['progress'] = 0;
......@@ -593,6 +596,10 @@ function quiz_update_6401(&$sandbox = NULL) {
* it is not beeing used at all, and therefore we remove it.
*/
function quiz_update_6400() {
drupal_install_modules(array('autoload' ,'quiz_question'));
if (!module_exists('autoload'))
return array('#abort' => array('success' => FALSE, 'query' => 'The <a href="http://drupal.org/project/autoload">Autoload</a> module is missing. You need to <a href="http://drupal.org/project/autoload">download</a> and enable autoload before you run update.php.'));
$result = array();
db_drop_table($result, 'quiz_node_question_properties');
return $result;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment