From: stronk7 Date: Sat, 23 Aug 2003 15:21:58 +0000 (+0000) Subject: Now stamp and version are fully supported in backup/restore. X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=19232856352cceed5c219a172e8eb1e1b2f1073c;p=moodle.git Now stamp and version are fully supported in backup/restore. The process look for category, stamp and version to calculate when to create a question or use a existing one. This avoid duplicates in RANDOM and RANDOMSAMATCH qtypes. --- diff --git a/backup/version.php b/backup/version.php index 2807f48155..8bbe3f2cc3 100644 --- a/backup/version.php +++ b/backup/version.php @@ -5,6 +5,6 @@ // database (backup_version) to determine whether upgrades should // be performed (see db/backup_*.php) -$backup_version = 2003082300; // The current version is a date (YYYYMMDDXX) +$backup_version = 2003082301; // The current version is a date (YYYYMMDDXX) -$backup_release = "0.8.9 alpha"; // User-friendly version number +$backup_release = "0.8.10 alpha"; // User-friendly version number diff --git a/mod/quiz/backuplib.php b/mod/quiz/backuplib.php index a2ee252461..1f6cc1b556 100644 --- a/mod/quiz/backuplib.php +++ b/mod/quiz/backuplib.php @@ -144,6 +144,8 @@ fwrite ($bf,full_tag("IMAGE",6,false,$question->image)); fwrite ($bf,full_tag("DEFAULTGRADE",6,false,$question->defaultgrade)); fwrite ($bf,full_tag("QTYPE",6,false,$question->qtype)); + fwrite ($bf,full_tag("STAMP",6,false,$question->stamp)); + fwrite ($bf,full_tag("VERSION",6,false,$question->version)); //Now, depending of the qtype, call one function or other if ($question->qtype == "1") { $status = quiz_backup_shortanswer($bf,$preferences,$question->id); diff --git a/mod/quiz/restorelib.php b/mod/quiz/restorelib.php index ca437f6e24..5371a36e45 100644 --- a/mod/quiz/restorelib.php +++ b/mod/quiz/restorelib.php @@ -168,20 +168,14 @@ $question->image = backup_todb($que_info['#']['IMAGE']['0']['#']); $question->defaultgrade = backup_todb($que_info['#']['DEFAULTGRADE']['0']['#']); $question->qtype = backup_todb($que_info['#']['QTYPE']['0']['#']); + $question->stamp = backup_todb($que_info['#']['STAMP']['0']['#']); + $question->version = backup_todb($que_info['#']['VERSION']['0']['#']); //Check if the question exists - //by category,questiontext and qtype - //But do it only if the question type isn't RANDOM (4) or RANDOMSAMATCH (6), because this - //types can have duplicates in the fields I'm searching !! - //I think that some modifications should be done here !! - //Detected by scott dot elliott at mchsi dot com in Bug 84 - if ($question->qtype != 4 and $question->qtype != 6) { - $question_exists = get_record ("quiz_questions","category",$question->category, - "questiontext",$question->questiontext, - "qtype",$question->qtype); - } else { - $question_exists = false; - } + //by category,stamp and version + $question_exists = get_record ("quiz_questions","category",$question->category, + "stamp",$question->stamp, + "version",$question->version); //If the question exists, only record its id if ($question_exists) { $newid = $question_exists->id;