Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…ssignments and extensionsdates
  • Loading branch information...
commit b3de95afb4a03f783f1c73c8c456d056c873ddc7 1 parent 0272a0c
Damyon Wiese authored
14 mod/assign/backup/moodle2/restore_assign_stepslib.php
@@ -73,8 +73,10 @@ protected function process_assign($data) {
73 73 $data->timemodified = $this->apply_date_offset($data->timemodified);
74 74 $data->allowsubmissionsfromdate = $this->apply_date_offset($data->allowsubmissionsfromdate);
75 75 $data->duedate = $this->apply_date_offset($data->duedate);
76   - if ($data->teamsubmissiongroupingid > 0) {
  76 + if (!empty($data->teamsubmissiongroupingid)) {
77 77 $data->teamsubmissiongroupingid = $this->get_mappingid('grouping', $data->teamsubmissiongroupingid);
  78 + } else {
  79 + $data->teamsubmissiongroupingid = 0;
78 80 }
79 81
80 82 if (!isset($data->cutoffdate)) {
@@ -111,8 +113,10 @@ protected function process_assign_submission($data) {
111 113 if ($data->userid > 0) {
112 114 $data->userid = $this->get_mappingid('user', $data->userid);
113 115 }
114   - if ($data->groupid > 0) {
  116 + if (!empty($data->groupid)) {
115 117 $data->groupid = $this->get_mappingid('group', $data->groupid);
  118 + } else {
  119 + $data->groupid = 0;
116 120 }
117 121
118 122 $newitemid = $DB->insert_record('assign_submission', $data);
@@ -139,7 +143,11 @@ protected function process_assign_grade($data) {
139 143 $data->timecreated = $this->apply_date_offset($data->timecreated);
140 144 $data->userid = $this->get_mappingid('user', $data->userid);
141 145 $data->grader = $this->get_mappingid('user', $data->grader);
142   - $data->extensionduedate = $this->apply_date_offset($data->extensionduedate);
  146 + if (!empty($data->extensionduedate)) {
  147 + $data->extensionduedate = $this->apply_date_offset($data->extensionduedate);
  148 + } else {
  149 + $data->extensionduedate = 0;
  150 + }
143 151
144 152 $newitemid = $DB->insert_record('assign_grades', $data);
145 153
1  mod/assign/locallib.php
@@ -1957,6 +1957,7 @@ public function get_user_grade($userid, $create) {
1957 1957 $grade->locked = 0;
1958 1958 $grade->grade = -1;
1959 1959 $grade->grader = $USER->id;
  1960 + $grade->extensionduedate = 0;
1960 1961 $gid = $DB->insert_record('assign_grades', $grade);
1961 1962 $grade->id = $gid;
1962 1963 return $grade;

0 comments on commit b3de95a

Please sign in to comment.
Something went wrong with that request. Please try again.