From 1909875912b345bee90d80cc6a806b39e580898f Mon Sep 17 00:00:00 2001 From: gustav_delius Date: Wed, 23 Mar 2005 20:59:55 +0000 Subject: [PATCH] Renamed quiz_question_version to quiz_question_versions as suggested by Eloy in bug 2777 --- mod/quiz/backuplib.php | 10 +++++----- mod/quiz/db/mysql.php | 4 ++++ mod/quiz/db/mysql.sql | 4 ++-- mod/quiz/db/postgres7.php | 4 ++++ mod/quiz/db/postgres7.sql | 4 ++-- mod/quiz/lib.php | 2 +- mod/quiz/question.php | 4 ++-- mod/quiz/restorelib.php | 8 ++++---- mod/quiz/version.php | 2 +- 9 files changed, 25 insertions(+), 17 deletions(-) diff --git a/mod/quiz/backuplib.php b/mod/quiz/backuplib.php index c60728389a3..e8e355a2ebe 100644 --- a/mod/quiz/backuplib.php +++ b/mod/quiz/backuplib.php @@ -13,7 +13,7 @@ // | | | | |....................................... // | | | | | . // | | | | | . - // quiz_attempts quiz_grades quiz_question_grades quiz_question_version | ----quiz_question_datasets---- . + // quiz_attempts quiz_grades quiz_question_grades quiz_question_versions | ----quiz_question_datasets---- . // (UL,pk->id, fk->quiz) (UL,pk->id,fk->quiz) (CL,pk->id,fk->quiz) (CL,pk->id,fk->quiz) | | (CL,pk->id,fk->question, | . // | | . | | fk->dataset_definition) | . // | | . | | | . @@ -86,7 +86,7 @@ // 2.-Standard module backup (Invoked via quiz_backup_mods). It includes this tables: // - quiz - // - quiz_question_version + // - quiz_question_versions // - quiz_question_grades // - quiz_attempts // - quiz_grades @@ -654,7 +654,7 @@ $status = true; - $quiz_question_versions = get_records("quiz_question_version","quiz",$quiz,"id"); + $quiz_question_versions = get_records("quiz_question_versions","quiz",$quiz,"id"); //If there are question_versions if ($quiz_question_versions) { //Write start tag @@ -662,7 +662,7 @@ //Iterate over each question_version foreach ($quiz_question_versions as $que_ver) { //Start question version - $status =fwrite ($bf,start_tag("QUESTION_VERSION",5,true)); + $status =fwrite ($bf,start_tag("QUESTION_VERSIONS",5,true)); //Print question_version contents fwrite ($bf,full_tag("ID",6,false,$que_ver->id)); fwrite ($bf,full_tag("OLDQUESTION",6,false,$que_ver->oldquestion)); @@ -670,7 +670,7 @@ fwrite ($bf,full_tag("USERID",6,false,$que_ver->userid)); fwrite ($bf,full_tag("TIMESTAMP",6,false,$que_ver->timestamp)); //End question version - $status =fwrite ($bf,end_tag("QUESTION_VERSION",5,true)); + $status =fwrite ($bf,end_tag("QUESTION_VERSIONS",5,true)); } //Write end tag $status =fwrite ($bf,end_tag("QUESTION_VERSIONS",4,true)); diff --git a/mod/quiz/db/mysql.php b/mod/quiz/db/mysql.php index 4dc2eb11f51..58fdc526ddd 100644 --- a/mod/quiz/db/mysql.php +++ b/mod/quiz/db/mysql.php @@ -332,6 +332,10 @@ function quiz_upgrade($oldversion) { execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('quiz', 'editquestions', 'quiz', 'name') "); } + if ($oldversion < 2005032300) { + modify_database ('', 'ALTER TABLE prefix_quiz_question_version RENAME prefix_quiz_question_versions;'); + } + return true; } diff --git a/mod/quiz/db/mysql.sql b/mod/quiz/db/mysql.sql index 73f83723c89..59c3e1ea56b 100644 --- a/mod/quiz/db/mysql.sql +++ b/mod/quiz/db/mysql.sql @@ -291,10 +291,10 @@ CREATE TABLE `prefix_quiz_question_grades` ( # -------------------------------------------------------- # -# Table structure for table `quiz_question_version` +# Table structure for table `quiz_question_versions` # -CREATE TABLE `prefix_quiz_question_version` ( +CREATE TABLE `prefix_quiz_question_versions` ( `id` int(10) unsigned NOT NULL auto_increment, `quiz` int(10) unsigned NOT NULL default '0', `oldquestion` int(10) unsigned NOT NULL default '0', diff --git a/mod/quiz/db/postgres7.php b/mod/quiz/db/postgres7.php index bdd27316fd0..191c06ac7c2 100644 --- a/mod/quiz/db/postgres7.php +++ b/mod/quiz/db/postgres7.php @@ -315,6 +315,10 @@ function quiz_upgrade($oldversion) { execute_sql(" INSERT INTO {$CFG->prefix}log_display VALUES ('quiz', 'editquestions', 'quiz', 'name') "); } + if ($oldversion < 2005032300) { + modify_database ('', 'ALTER TABLE prefix_quiz_question_version RENAME prefix_quiz_question_versions;'); + } + return true; } diff --git a/mod/quiz/db/postgres7.sql b/mod/quiz/db/postgres7.sql index f10024b1925..6b458997109 100644 --- a/mod/quiz/db/postgres7.sql +++ b/mod/quiz/db/postgres7.sql @@ -203,10 +203,10 @@ CREATE INDEX prefix_quiz_question_grades_question_idx ON prefix_quiz_question_gr # -------------------------------------------------------- # -# Table structure for table `quiz_question_version` +# Table structure for table `quiz_question_versions` # -CREATE TABLE prefix_quiz_question_version ( +CREATE TABLE prefix_quiz_question_versions ( id SERIAL PRIMARY KEY, quiz integer NOT NULL default '0', oldquestion integer NOT NULL default '0', diff --git a/mod/quiz/lib.php b/mod/quiz/lib.php index 1d71371ca5e..a2fa3614438 100644 --- a/mod/quiz/lib.php +++ b/mod/quiz/lib.php @@ -281,7 +281,7 @@ function quiz_get_participants($quizid) { //Get users from question_versions $us_versions = get_records_sql("SELECT DISTINCT u.id, u.id FROM {$CFG->prefix}user u, - {$CFG->prefix}quiz_question_version v + {$CFG->prefix}quiz_question_versions v WHERE v.quiz = '$quizid' and u.id = v.userid"); diff --git a/mod/quiz/question.php b/mod/quiz/question.php index a7cd789ebfe..e10dcda761b 100644 --- a/mod/quiz/question.php +++ b/mod/quiz/question.php @@ -127,7 +127,7 @@ if (isset($form->versioning)) { // use new code that // handles whether to overwrite or copy a question and keeps - // track of the versions in the quiz_question_version table + // track of the versions in the quiz_question_versions table // $replaceinquiz is an array with the ids of all quizzes in which the teacher has chosen to replace the old version $replaceinquiz = array(); @@ -187,7 +187,7 @@ foreach($replaceinquiz as $qid) { $version->quiz = $qid; - if(!insert_record("quiz_question_version", $version)) { + if(!insert_record("quiz_question_versions", $version)) { error("Could not store version information of question $oldquestionid in quiz $qid!"); } } diff --git a/mod/quiz/restorelib.php b/mod/quiz/restorelib.php index 2a3deb3defe..86692118f54 100644 --- a/mod/quiz/restorelib.php +++ b/mod/quiz/restorelib.php @@ -13,7 +13,7 @@ // | | | | |....................................... // | | | | | . // | | | | | . - // quiz_attempts quiz_grades quiz_question_grades quiz_question_version | ----quiz_question_datasets---- . + // quiz_attempts quiz_grades quiz_question_grades quiz_question_versions | ----quiz_question_datasets---- . // (UL,pk->id, fk->quiz) (UL,pk->id,fk->quiz) (CL,pk->id,fk->quiz) (CL,pk->id,fk->quiz) | | (CL,pk->id,fk->question, | . // | | . | | fk->dataset_definition) | . // | | . | | | . @@ -84,7 +84,7 @@ // 2.-Standard module restore (Invoked via quiz_restore_mods). It includes this tables: // - quiz - // - quiz_question_version + // - quiz_question_versions // - quiz_question_grades // - quiz_attempts // - quiz_grades @@ -1452,7 +1452,7 @@ $status = true; //Get the quiz_question_versions array - $versions = $info['MOD']['#']['QUESTION_VERSIONS']['0']['#']['QUESTION_VERSION']; + $versions = $info['MOD']['#']['QUESTION_VERSIONS']['0']['#']['QUESTION_VERSIONS']; //Iterate over question_versions for($i = 0; $i < sizeof($versions); $i++) { @@ -1492,7 +1492,7 @@ } //The structure is equal to the db, so insert the quiz_question_versions - $newid = insert_record ("quiz_question_version",$version); + $newid = insert_record ("quiz_question_versions",$version); //Do some output if (($i+1) % 10 == 0) { diff --git a/mod/quiz/version.php b/mod/quiz/version.php index b5bec9c74ff..0c696f8cd81 100644 --- a/mod/quiz/version.php +++ b/mod/quiz/version.php @@ -5,7 +5,7 @@ // This fragment is called by moodle_needs_upgrading() and /admin/index.php //////////////////////////////////////////////////////////////////////////////// -$module->version = 2005032000; // The (date) version of this module +$module->version = 2005032300; // The (date) version of this module $module->requires = 2005021600; // Requires this Moodle version $module->cron = 0; // How often should cron check this module (seconds)?