Permalink
Browse files

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.
  • Loading branch information...
1 parent 757a0ab commit 19232856352cceed5c219a172e8eb1e1b2f1073c stronk7 committed Aug 23, 2003
Showing with 10 additions and 14 deletions.
  1. +2 −2 backup/version.php
  2. +2 −0 mod/quiz/backuplib.php
  3. +6 −12 mod/quiz/restorelib.php
View
@@ -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
View
@@ -144,6 +144,8 @@ function quiz_backup_question($bf,$preferences,$category) {
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);
View
@@ -168,20 +168,14 @@ function quiz_restore_questions ($old_category_id,$new_category_id,$info,$restor
$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;

0 comments on commit 1923285

Please sign in to comment.