Permalink
Browse files

MDL-35337: Fixes for restoring a course backup with no data for teama…

…ssignments and extensionsdates
  • Loading branch information...
1 parent 0272a0c commit b3de95afb4a03f783f1c73c8c456d056c873ddc7 Damyon Wiese committed Sep 18, 2012
Showing with 12 additions and 3 deletions.
  1. +11 −3 mod/assign/backup/moodle2/restore_assign_stepslib.php
  2. +1 −0 mod/assign/locallib.php
View
14 mod/assign/backup/moodle2/restore_assign_stepslib.php
@@ -73,8 +73,10 @@ protected function process_assign($data) {
$data->timemodified = $this->apply_date_offset($data->timemodified);
$data->allowsubmissionsfromdate = $this->apply_date_offset($data->allowsubmissionsfromdate);
$data->duedate = $this->apply_date_offset($data->duedate);
- if ($data->teamsubmissiongroupingid > 0) {
+ if (!empty($data->teamsubmissiongroupingid)) {
$data->teamsubmissiongroupingid = $this->get_mappingid('grouping', $data->teamsubmissiongroupingid);
+ } else {
+ $data->teamsubmissiongroupingid = 0;
}
if (!isset($data->cutoffdate)) {
@@ -111,8 +113,10 @@ protected function process_assign_submission($data) {
if ($data->userid > 0) {
$data->userid = $this->get_mappingid('user', $data->userid);
}
- if ($data->groupid > 0) {
+ if (!empty($data->groupid)) {
$data->groupid = $this->get_mappingid('group', $data->groupid);
+ } else {
+ $data->groupid = 0;
}
$newitemid = $DB->insert_record('assign_submission', $data);
@@ -139,7 +143,11 @@ protected function process_assign_grade($data) {
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->userid = $this->get_mappingid('user', $data->userid);
$data->grader = $this->get_mappingid('user', $data->grader);
- $data->extensionduedate = $this->apply_date_offset($data->extensionduedate);
+ if (!empty($data->extensionduedate)) {
+ $data->extensionduedate = $this->apply_date_offset($data->extensionduedate);
+ } else {
+ $data->extensionduedate = 0;
+ }
$newitemid = $DB->insert_record('assign_grades', $data);
View
1 mod/assign/locallib.php
@@ -1957,6 +1957,7 @@ public function get_user_grade($userid, $create) {
$grade->locked = 0;
$grade->grade = -1;
$grade->grader = $USER->id;
+ $grade->extensionduedate = 0;
$gid = $DB->insert_record('assign_grades', $grade);
$grade->id = $gid;
return $grade;

0 comments on commit b3de95a

Please sign in to comment.