Skip to content

Commit

Permalink
Merge branch 'MDL-59518-master' of git://github.com/ankitagarwal/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewnicols committed Aug 1, 2017
2 parents 3ccd196 + 0b79129 commit 3ae7afc
Show file tree
Hide file tree
Showing 2 changed files with 423 additions and 26 deletions.
36 changes: 10 additions & 26 deletions backup/moodle2/restore_stepslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,7 @@ protected function process_grade_item($data) {
$data->scaleid = $this->get_mappingid('scale', $data->scaleid, NULL);
$data->outcomeid = $this->get_mappingid('outcome', $data->outcomeid, NULL);

$data->locktime = $this->apply_date_offset($data->locktime);
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);
$data->locktime = $this->apply_date_offset($data->locktime);

$coursecategory = $newitemid = null;
//course grade item should already exist so updating instead of inserting
Expand Down Expand Up @@ -264,10 +262,6 @@ protected function process_grade_grade($data) {
if (!empty($data->userid)) {
$data->usermodified = $this->get_mappingid('user', $data->usermodified, null);
$data->locktime = $this->apply_date_offset($data->locktime);
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
$data->overridden = $this->apply_date_offset($data->overridden);
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);

$gradeexists = $DB->record_exists('grade_grades', array('userid' => $data->userid, 'itemid' => $data->itemid));
if ($gradeexists) {
Expand All @@ -292,9 +286,6 @@ protected function process_grade_category($data) {
$data->course = $this->get_courseid();
$data->courseid = $data->course;

$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);

$newitemid = null;
//no parent means a course level grade category. That may have been created when the course was created
if(empty($data->parent)) {
Expand Down Expand Up @@ -1576,7 +1567,7 @@ public function process_section($data) {
$section = new stdclass();
$section->course = $this->get_courseid();
$section->section = $data->number;
$section->timemodified = isset($data->timemodified) ? $this->apply_date_offset($data->timemodified) : 0;
$section->timemodified = $data->timemodified ?? 0;
// Section doesn't exist, create it with all the info from backup
if (!$secrec = $DB->get_record('course_sections', ['course' => $this->get_courseid(), 'section' => $data->number])) {
$section->name = $data->name;
Expand Down Expand Up @@ -2534,8 +2525,8 @@ public function process_badge($data) {
$params = array(
'name' => $data->name,
'description' => $data->description,
'timecreated' => $this->apply_date_offset($data->timecreated),
'timemodified' => $this->apply_date_offset($data->timemodified),
'timecreated' => $data->timecreated,
'timemodified' => $data->timemodified,
'usercreated' => $data->usercreated,
'usermodified' => $data->usermodified,
'issuername' => $data->issuername,
Expand All @@ -2550,7 +2541,7 @@ public function process_badge($data) {
'attachment' => $data->attachment,
'notification' => $data->notification,
'status' => BADGE_STATUS_INACTIVE,
'nextcron' => $this->apply_date_offset($data->nextcron)
'nextcron' => $data->nextcron
);

$newid = $DB->insert_record('badge', $params);
Expand Down Expand Up @@ -2727,7 +2718,7 @@ public function process_calendarevents($data) {
'visible' => $data->visible,
'uuid' => $data->uuid,
'sequence' => $data->sequence,
'timemodified' => $this->apply_date_offset($data->timemodified),
'timemodified' => $data->timemodified,
'priority' => isset($data->priority) ? $data->priority : null);
if ($this->name == 'activity_calendar') {
$params['instance'] = $this->task->get_activityid();
Expand Down Expand Up @@ -2959,7 +2950,7 @@ public function process_course_completion_crit_compl($data) {
'userid' => $data->userid,
'course' => $data->course,
'criteriaid' => $data->criteriaid,
'timecompleted' => $this->apply_date_offset($data->timecompleted)
'timecompleted' => $data->timecompleted
);
if (isset($data->gradefinal)) {
$params['gradefinal'] = $data->gradefinal;
Expand Down Expand Up @@ -2989,9 +2980,9 @@ public function process_course_completions($data) {
$params = array(
'userid' => $data->userid,
'course' => $data->course,
'timeenrolled' => $this->apply_date_offset($data->timeenrolled),
'timestarted' => $this->apply_date_offset($data->timestarted),
'timecompleted' => $this->apply_date_offset($data->timecompleted),
'timeenrolled' => $data->timeenrolled,
'timestarted' => $data->timestarted,
'timecompleted' => $data->timecompleted,
'reaggregate' => $data->reaggregate
);

Expand Down Expand Up @@ -3693,8 +3684,6 @@ protected function process_grade_item($data) {
$data->idnumber = $idnumber;
$data->scaleid = $this->get_mappingid('scale', $data->scaleid);
$data->outcomeid = $this->get_mappingid('outcome', $data->outcomeid);
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->timemodified = $this->apply_date_offset($data->timemodified);

$gradeitem = new grade_item($data, false);
$gradeitem->insert('restore');
Expand All @@ -3720,8 +3709,6 @@ protected function process_grade_grade($data) {
if (!empty($data->userid)) {
$data->usermodified = $this->get_mappingid('user', $data->usermodified, null);
$data->rawscaleid = $this->get_mappingid('scale', $data->rawscaleid);
// TODO: Ask, all the rest of locktime/exported... work with time... to be rolled?
$data->overridden = $this->apply_date_offset($data->overridden);

$grade = new grade_grade($data, false);
$grade->insert('restore');
Expand Down Expand Up @@ -4288,7 +4275,6 @@ protected function process_completion($data) {

$data->coursemoduleid = $this->task->get_moduleid();
$data->userid = $this->get_mappingid('user', $data->userid);
$data->timemodified = $this->apply_date_offset($data->timemodified);

// Find the existing record
$existing = $DB->get_record('course_modules_completion', array(
Expand Down Expand Up @@ -5204,7 +5190,6 @@ protected function restore_question_attempt_worker($data, $nameprefix) {
if (!property_exists($data, 'variant')) {
$data->variant = 1;
}
$data->timemodified = $this->apply_date_offset($data->timemodified);

if (!property_exists($data, 'maxfraction')) {
$data->maxfraction = 1;
Expand Down Expand Up @@ -5239,7 +5224,6 @@ protected function restore_question_attempt_step_worker($data, $nameprefix) {
unset($data->response);

$data->questionattemptid = $this->get_new_parentid($nameprefix . 'question_attempt');
$data->timecreated = $this->apply_date_offset($data->timecreated);
$data->userid = $this->get_mappingid('user', $data->userid);

// Everything ready, insert and create mapping (needed by question_sessions)
Expand Down
Loading

0 comments on commit 3ae7afc

Please sign in to comment.