]> git.mjollnir.org Git - moodle.git/commitdiff
Added support to timeopen, timeclose, release and allowupdate
authorstronk7 <stronk7>
Thu, 1 Jul 2004 19:44:55 +0000 (19:44 +0000)
committerstronk7 <stronk7>
Thu, 1 Jul 2004 19:44:55 +0000 (19:44 +0000)
in backup and restore procedure.
Added some special checks to mantain backwards compatibility
whith pre-1.4 backup files, because the meaning of some settings
has changed just now. (I've applied the same differences executed
in the upgrade process). :-)

mod/choice/backuplib.php
mod/choice/restorelib.php

index 7dfcdfb2e73e77998f1b37072db46577ff197a68..a3d3115c39f66cc3e11fd6498a39f3badb2b070b 100644 (file)
                 fwrite ($bf,full_tag("ANSWER5",4,false,$choice->answer5));
                 fwrite ($bf,full_tag("ANSWER6",4,false,$choice->answer6));
                 fwrite ($bf,full_tag("SHOWUNANSWERED",4,false,$choice->showunanswered));
+                fwrite ($bf,full_tag("TIMEOPEN",4,false,$choice->timeopen));
+                fwrite ($bf,full_tag("TIMECLOSE",4,false,$choice->timeclose));
                 fwrite ($bf,full_tag("PUBLISH",4,false,$choice->publish));
+                fwrite ($bf,full_tag("RELEASE",4,false,$choice->release));
+                fwrite ($bf,full_tag("ALLOWUPDATE",4,false,$choice->allowupdate));
                 fwrite ($bf,full_tag("TIMEMODIFIED",4,false,$choice->timemodified));
                 //if we've selected to backup users info, then execute backup_choice_answers
                 if ($preferences->mods["choice"]->userinfo) {
index c817bf5005e085b0454cf4c9c550a0890a6c17a2..2d0f3bd53361989c541d0b45cb4a596c8d2f0a0a 100644 (file)
             $choice->answer5 = backup_todb($info['MOD']['#']['ANSWER5']['0']['#']);
             $choice->answer6 = backup_todb($info['MOD']['#']['ANSWER6']['0']['#']);
             $choice->showunanswered = backup_todb($info['MOD']['#']['SHOWUNANSWERED']['0']['#']);
+            $choice->timeopen = backup_todb($info['MOD']['#']['TIMEOPEN']['0']['#']);
+            $choice->timeclose = backup_todb($info['MOD']['#']['TIMECLOSE']['0']['#']);
             $choice->publish = backup_todb($info['MOD']['#']['PUBLISH']['0']['#']);
+            $choice->release = backup_todb($info['MOD']['#']['RELEASE']['0']['#']);
+            $choice->allowupdate = backup_todb($info['MOD']['#']['ALLOWUPDATE']['0']['#']);
             $choice->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);
 
+            //To mantain compatibilty, in 1.4 the publish setting meaning has changed. We
+            //have to modify some things it if the release field isn't present in the backup file.
+            if (! isset($info['MOD']['#']['RELEASE']['0']['#'])) {  //It's a pre-14 backup filea
+                //Set the allowupdate field
+                if ($choice->publish == 0) { 
+                    $choice->allowupdate = 1;
+                }
+                //Set the release field as defined by the old publish field
+                if ($choice->publish > 0) {
+                    $choice->release = 1;
+                }
+                //Recode the publish field to its 1.4 meaning
+                if ($choice->publish > 0) {
+                    $choice->publish--;
+                }
+            }
+                
             //The structure is equal to the db, so insert the choice
             $newid = insert_record ("choice",$choice);