Merge branch 'MDL-61870-35' of git://github.com/damyon/moodle into MOODLE_35_STABLE
This commit is contained in:
@@ -61,6 +61,7 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
||||
|
||||
// To know if we are including userinfo.
|
||||
$userinfo = $this->get_setting_value('userinfo');
|
||||
$groupinfo = $this->get_setting_value('groups');
|
||||
|
||||
// Define each element separated.
|
||||
$assign = new backup_nested_element('assign', array('id'),
|
||||
@@ -159,8 +160,12 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
||||
$userflag->set_source_table('assign_user_flags',
|
||||
array('assignment' => backup::VAR_PARENTID));
|
||||
|
||||
$submission->set_source_table('assign_submission',
|
||||
array('assignment' => backup::VAR_PARENTID));
|
||||
$submissionparams = array('assignment' => backup::VAR_PARENTID);
|
||||
if (!$groupinfo) {
|
||||
// Without group info, skip group submissions.
|
||||
$submissionparams['groupid'] = backup_helper::is_sqlparam(0);
|
||||
}
|
||||
$submission->set_source_table('assign_submission', $submissionparams);
|
||||
|
||||
$grade->set_source_table('assign_grades',
|
||||
array('assignment' => backup::VAR_PARENTID));
|
||||
@@ -172,6 +177,10 @@ class backup_assign_activity_structure_step extends backup_activity_structure_st
|
||||
$overrideparams['userid'] = backup_helper::is_sqlparam(null); // Without userinfo, skip user overrides.
|
||||
}
|
||||
|
||||
if (!$groupinfo) {
|
||||
// Without group info, skip group overrides.
|
||||
$overrideparams['groupid'] = backup_helper::is_sqlparam(0);
|
||||
}
|
||||
$override->set_source_table('assign_overrides', $overrideparams);
|
||||
|
||||
// Define id annotations.
|
||||
|
||||
@@ -387,6 +387,12 @@ class restore_assign_activity_structure_step extends restore_activity_structure_
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip group overrides if we are not restoring groupinfo.
|
||||
$groupinfo = $this->get_setting_value('groups');
|
||||
if (!$groupinfo && !is_null($data->groupid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data->assignid = $this->get_new_parentid('assign');
|
||||
|
||||
if (!is_null($data->userid)) {
|
||||
|
||||
+4
-1
@@ -258,8 +258,11 @@ function assign_update_events($assign, $override = null) {
|
||||
// Only load events for this override.
|
||||
if (isset($override->userid)) {
|
||||
$conds['userid'] = $override->userid;
|
||||
} else {
|
||||
} else if (isset($override->groupid)) {
|
||||
$conds['groupid'] = $override->groupid;
|
||||
} else {
|
||||
// This is not a valid override, it may have been left from a bad import or restore.
|
||||
$conds['groupid'] = $conds['userid'] = 0;
|
||||
}
|
||||
}
|
||||
$oldevents = $DB->get_records('event', $conds, 'id ASC');
|
||||
|
||||
@@ -362,14 +362,23 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
]);
|
||||
|
||||
$instance = $assign->get_instance();
|
||||
$eventparams = ['modulename' => 'assign', 'instance' => $instance->id];
|
||||
$eventparams = [
|
||||
'modulename' => 'assign',
|
||||
'instance' => $instance->id,
|
||||
'eventtype' => ASSIGN_EVENT_TYPE_DUE,
|
||||
'groupid' => 0
|
||||
];
|
||||
|
||||
// Make sure the calendar event for assignment 1 matches the initial due date.
|
||||
$eventtime = $DB->get_field('event', 'timestart', $eventparams, MUST_EXIST);
|
||||
$this->assertEquals($eventtime, $duedate);
|
||||
|
||||
// Manually update assignment 1's due date.
|
||||
$DB->update_record('assign', (object) ['id' => $instance->id, 'duedate' => $newduedate]);
|
||||
$DB->update_record('assign', (object) [
|
||||
'id' => $instance->id,
|
||||
'duedate' => $newduedate,
|
||||
'course' => $course->id
|
||||
]);
|
||||
|
||||
// Then refresh the assignment events of assignment 1's course.
|
||||
$this->assertTrue(assign_refresh_events($course->id));
|
||||
@@ -380,15 +389,25 @@ class mod_assign_lib_testcase extends advanced_testcase {
|
||||
|
||||
// Create a second course and assignment.
|
||||
$othercourse = $this->getDataGenerator()->create_course();;
|
||||
$otherassign = $this->create_instance($othercourse, ['duedate' => $duedate, 'course' => $othercourse->id]);
|
||||
$otherassign = $this->create_instance($othercourse, [
|
||||
'duedate' => $duedate,
|
||||
]);
|
||||
$otherinstance = $otherassign->get_instance();
|
||||
|
||||
// Manually update assignment 1 and 2's due dates.
|
||||
$newduedate += DAYSECS;
|
||||
$DB->update_record('assign', (object)['id' => $instance->id, 'duedate' => $newduedate]);
|
||||
$DB->update_record('assign', (object)['id' => $otherinstance->id, 'duedate' => $newduedate]);
|
||||
$DB->update_record('assign', (object)[
|
||||
'id' => $instance->id,
|
||||
'duedate' => $newduedate,
|
||||
'course' => $course->id
|
||||
]);
|
||||
$DB->update_record('assign', (object)[
|
||||
'id' => $otherinstance->id,
|
||||
'duedate' => $newduedate,
|
||||
'course' => $othercourse->id
|
||||
]);
|
||||
|
||||
// Refresh events of all courses.
|
||||
// Refresh events of all courses and check the calendar events matches the new date.
|
||||
$this->assertTrue(assign_refresh_events());
|
||||
|
||||
// Check the due date calendar event for assignment 1.
|
||||
|
||||
Reference in New Issue
Block a user