]> git.mjollnir.org Git - moodle.git/commitdiff
"MDL-17469, fix assignment date when restore course, merged from 1.9"
authordongsheng <dongsheng>
Thu, 11 Dec 2008 04:39:33 +0000 (04:39 +0000)
committerdongsheng <dongsheng>
Thu, 11 Dec 2008 04:39:33 +0000 (04:39 +0000)
backup/restore.php
mod/assignment/restorelib.php

index 18663c70912a74d89d1d268f175b097025fe0f30..602bdd4264a7c2dac957827577d6c7bd1feab3ca 100644 (file)
     $method = optional_param( 'method' );
     $backup_unique_code = optional_param('backup_unique_code',0,PARAM_INT);
 
+    //Get and check course
+    if (! $course = get_record("course", "id", $id)) {
+        error("Course ID was incorrect (can't find it)");
+    }
+    // To some reasons, course_startdateoffset value was lost during restoring
+    // See MDL-17469
+    if (!empty($course->startdate) && !empty($SESSION->course_header->course_startdate)) {
+        $SESSION->restore->course_startdateoffset = $course->startdate - $SESSION->course_header->course_startdate;
+    } else {
+        $SESSION->restore->course_startdateoffset = 0;
+    }
+
     //Check login
     require_login();
 
 
     //We are here, so me have a file.
 
-    //Get and check course
-    if (! $course = $DB->get_record("course", array("id"=>$id))) {
-        print_error('invalidcourseid', '', '', $id);
-    }
-
     //Print header
     if (has_capability('moodle/site:config', get_context_instance(CONTEXT_SYSTEM))) {
         $navlinks[] = array('name' => basename($file), 'link' => null, 'type' => 'misc');
index e065ad2e9423bfbdfa7bebefc1b6ff37553901ac..3939800778c434f2530685874e62ecf69377a39a 100644 (file)
@@ -57,8 +57,8 @@
             $assignment->type = isset($info['MOD']['#']['TYPE']['0']['#'])?backup_todb($info['MOD']['#']['TYPE']['0']['#']):'';
             $assignment->assignmenttype = backup_todb($info['MOD']['#']['ASSIGNMENTTYPE']['0']['#']);
             $assignment->maxbytes = backup_todb($info['MOD']['#']['MAXBYTES']['0']['#']);
-            $assignment->timedue = backup_todb($data->info['MOD']['#']['TIMEDUE']['0']['#']);
-            $assignment->timeavailable = backup_todb($data->info['MOD']['#']['TIMEAVAILABLE']['0']['#']);
+            $assignment->timedue = backup_todb($info['MOD']['#']['TIMEDUE']['0']['#']);
+            $assignment->timeavailable = backup_todb($info['MOD']['#']['TIMEAVAILABLE']['0']['#']);
             $assignment->grade = backup_todb($info['MOD']['#']['GRADE']['0']['#']);
             $assignment->timemodified = backup_todb($info['MOD']['#']['TIMEMODIFIED']['0']['#']);