first commit

This commit is contained in:
CHIEFSOFT\ameye
2024-09-30 18:11:26 -04:00
commit e592ca6823
27270 changed files with 5002257 additions and 0 deletions
@@ -0,0 +1,73 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* This file contains the backup activity for the assign module
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/assign/backup/moodle2/backup_assign_stepslib.php');
/**
* assign backup task that provides all the settings and steps to perform one complete backup of the activity
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_assign_activity_task extends backup_activity_task {
/**
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
// No particular settings for this activity.
}
/**
* Define (add) particular steps this activity can have
*/
protected function define_my_steps() {
$this->add_step(new backup_assign_activity_structure_step('assign_structure', 'assign.xml'));
}
/**
* Code the transformations to perform in the activity in
* order to get transportable (encoded) links
* @param string $content
* @return string
*/
public static function encode_content_links($content) {
global $CFG;
$base = preg_quote($CFG->wwwroot, "/");
$search="/(".$base."\/mod\/assign\/index.php\?id\=)([0-9]+)/";
$content= preg_replace($search, '$@ASSIGNINDEX*$2@$', $content);
$search="/(".$base."\/mod\/assign\/view.php\?id\=)([0-9]+)/";
$content= preg_replace($search, '$@ASSIGNVIEWBYID*$2@$', $content);
return $content;
}
}
@@ -0,0 +1,217 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Define all the backup steps that will be used by the backup_assign_activity_task
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/assign/locallib.php');
/**
* Define the complete choice structure for backup, with file and id annotations
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_assign_activity_structure_step extends backup_activity_structure_step {
/**
* Annotate files from plugin configuration
* @param backup_nested_element $assign the backup structure of the activity
* @param string $subtype the plugin type to handle
* @return void
*/
protected function annotate_plugin_config_files(backup_nested_element $assign, $subtype) {
$dummyassign = new assign(null, null, null);
$plugins = $dummyassign->load_plugins($subtype);
foreach ($plugins as $plugin) {
$component = $plugin->get_subtype() . '_' . $plugin->get_type();
$areas = $plugin->get_config_file_areas();
foreach ($areas as $area) {
$assign->annotate_files($component, $area, null);
}
}
}
/**
* Define the structure for the assign activity
* @return backup_nested_element
*/
protected function define_structure() {
// 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'),
array('name',
'intro',
'introformat',
'alwaysshowdescription',
'submissiondrafts',
'sendnotifications',
'sendlatenotifications',
'sendstudentnotifications',
'duedate',
'cutoffdate',
'gradingduedate',
'allowsubmissionsfromdate',
'grade',
'timemodified',
'completionsubmit',
'requiresubmissionstatement',
'teamsubmission',
'requireallteammemberssubmit',
'teamsubmissiongroupingid',
'blindmarking',
'hidegrader',
'revealidentities',
'attemptreopenmethod',
'maxattempts',
'markingworkflow',
'markingallocation',
'markinganonymous',
'preventsubmissionnotingroup',
'activity',
'activityformat',
'timelimit',
'submissionattachments'));
$userflags = new backup_nested_element('userflags');
$userflag = new backup_nested_element('userflag', array('id'),
array('userid',
'assignment',
'mailed',
'locked',
'extensionduedate',
'workflowstate',
'allocatedmarker'));
$submissions = new backup_nested_element('submissions');
$submission = new backup_nested_element('submission', array('id'),
array('userid',
'timecreated',
'timemodified',
'timestarted',
'status',
'groupid',
'attemptnumber',
'latest'));
$grades = new backup_nested_element('grades');
$grade = new backup_nested_element('grade', array('id'),
array('userid',
'timecreated',
'timemodified',
'grader',
'grade',
'attemptnumber'));
$pluginconfigs = new backup_nested_element('plugin_configs');
$pluginconfig = new backup_nested_element('plugin_config', array('id'),
array('plugin',
'subtype',
'name',
'value'));
$overrides = new backup_nested_element('overrides');
$override = new backup_nested_element('override', array('id'), array(
'groupid', 'userid', 'sortorder', 'allowsubmissionsfromdate', 'duedate', 'cutoffdate', 'timelimit'));
// Build the tree.
$assign->add_child($userflags);
$userflags->add_child($userflag);
$assign->add_child($submissions);
$submissions->add_child($submission);
$assign->add_child($grades);
$grades->add_child($grade);
$assign->add_child($pluginconfigs);
$pluginconfigs->add_child($pluginconfig);
$assign->add_child($overrides);
$overrides->add_child($override);
// Define sources.
$assign->set_source_table('assign', array('id' => backup::VAR_ACTIVITYID));
$pluginconfig->set_source_table('assign_plugin_config',
array('assignment' => backup::VAR_PARENTID));
// Assign overrides to backup are different depending of user info.
$overrideparams = array('assignid' => backup::VAR_PARENTID);
if ($userinfo) {
$userflag->set_source_table('assign_user_flags',
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));
// Support 2 types of subplugins.
$this->add_subplugin_structure('assignsubmission', $submission, true);
$this->add_subplugin_structure('assignfeedback', $grade, true);
} else {
$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.
$userflag->annotate_ids('user', 'userid');
$userflag->annotate_ids('user', 'allocatedmarker');
$submission->annotate_ids('user', 'userid');
$submission->annotate_ids('group', 'groupid');
$grade->annotate_ids('user', 'userid');
$grade->annotate_ids('user', 'grader');
$assign->annotate_ids('grouping', 'teamsubmissiongroupingid');
$override->annotate_ids('user', 'userid');
$override->annotate_ids('group', 'groupid');
// Define file annotations.
// These file areas don't have an itemid.
$assign->annotate_files('mod_assign', 'intro', null);
$assign->annotate_files('mod_assign', 'introattachment', null);
$assign->annotate_files('mod_assign', 'activityattachment', null);
$this->annotate_plugin_config_files($assign, 'assignsubmission');
$this->annotate_plugin_config_files($assign, 'assignfeedback');
// Return the root element (choice), wrapped into standard activity structure.
return $this->prepare_activity_structure($assign);
}
}
@@ -0,0 +1,141 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Define all the backup steps that will be used by the backup_assign_activity_task
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/assign/backup/moodle2/restore_assign_stepslib.php');
/**
* assign restore task that provides all the settings and steps to perform one complete restore of the activity
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_assign_activity_task extends restore_activity_task {
/**
* Define (add) particular settings this activity can have.
*/
protected function define_my_settings() {
// No particular settings for this activity.
}
/**
* Define (add) particular steps this activity can have.
*/
protected function define_my_steps() {
// Assignment only has one structure step.
$this->add_step(new restore_assign_activity_structure_step('assign_structure', 'assign.xml'));
}
/**
* Define the contents in the activity that must be
* processed by the link decoder.
*
* @return array
*/
public static function define_decode_contents() {
$contents = array();
$contents[] = new restore_decode_content('assign', array('intro'), 'assign');
return $contents;
}
/**
* Define the decoding rules for links belonging
* to the activity to be executed by the link decoder.
*
* @return array of restore_decode_rule
*/
public static function define_decode_rules() {
$rules = array();
$rules[] = new restore_decode_rule('ASSIGNVIEWBYID',
'/mod/assign/view.php?id=$1',
'course_module');
$rules[] = new restore_decode_rule('ASSIGNINDEX',
'/mod/assign/index.php?id=$1',
'course_module');
return $rules;
}
/**
* Define the restore log rules that will be applied
* by the {@link restore_logs_processor} when restoring
* assign logs. It must return one array
* of {@link restore_log_rule} objects.
*
* @return array of restore_log_rule
*/
public static function define_restore_log_rules() {
$rules = array();
$rules[] = new restore_log_rule('assign', 'add', 'view.php?id={course_module}', '{assign}');
$rules[] = new restore_log_rule('assign', 'update', 'view.php?id={course_module}', '{assign}');
$rules[] = new restore_log_rule('assign', 'view', 'view.php?id={course_module}', '{assign}');
return $rules;
}
/**
* Define the restore log rules that will be applied
* by the {@link restore_logs_processor} when restoring
* course logs. It must return one array
* of {@link restore_log_rule} objects
*
* Note this rules are applied when restoring course logs
* by the restore final task, but are defined here at
* activity level. All them are rules not linked to any module instance (cmid = 0)
*
* @return array
*/
public static function define_restore_log_rules_for_course() {
$rules = array();
return $rules;
}
/**
* Given a comment area, return the itemname that contains the itemid mappings.
*
* @param string $commentarea
* @return string
*/
public function get_comment_mapping_itemname($commentarea) {
switch ($commentarea) {
case 'submission_comments':
$itemname = 'submission';
break;
default:
$itemname = parent::get_comment_mapping_itemname($commentarea);
break;
}
return $itemname;
}
}
@@ -0,0 +1,435 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Define all the restore steps that will be used by the restore_assign_activity_task
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot . '/mod/assign/locallib.php');
/**
* Define the complete assignment structure for restore, with file and id annotations
*
* @package mod_assign
* @copyright 2012 NetSpot {@link http://www.netspot.com.au}
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_assign_activity_structure_step extends restore_activity_structure_step {
/**
* Store whether submission details should be included. Details may not be included if the
* this is a team submission, but groups/grouping information was not included in the backup.
*/
protected $includesubmission = true;
/**
* Define the structure of the restore workflow.
*
* @return restore_path_element $structure
*/
protected function define_structure() {
$paths = array();
// To know if we are including userinfo.
$userinfo = $this->get_setting_value('userinfo');
// Define each element separated.
$paths[] = new restore_path_element('assign', '/activity/assign');
if ($userinfo) {
$submission = new restore_path_element('assign_submission',
'/activity/assign/submissions/submission');
$paths[] = $submission;
$this->add_subplugin_structure('assignsubmission', $submission);
$grade = new restore_path_element('assign_grade', '/activity/assign/grades/grade');
$paths[] = $grade;
$this->add_subplugin_structure('assignfeedback', $grade);
$userflag = new restore_path_element('assign_userflag',
'/activity/assign/userflags/userflag');
$paths[] = $userflag;
}
$paths[] = new restore_path_element('assign_override', '/activity/assign/overrides/override');
$paths[] = new restore_path_element('assign_plugin_config',
'/activity/assign/plugin_configs/plugin_config');
return $this->prepare_activity_structure($paths);
}
/**
* Process an assign restore.
*
* @param object $data The data in object form
* @return void
*/
protected function process_assign($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$data->course = $this->get_courseid();
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
// See MDL-9367.
$data->allowsubmissionsfromdate = $this->apply_date_offset($data->allowsubmissionsfromdate);
$data->duedate = $this->apply_date_offset($data->duedate);
// If this is a team submission, but there is no group info we need to flag that the submission
// information should not be included. It should not be restored.
$groupinfo = $this->task->get_setting_value('groups');
if ($data->teamsubmission && !$groupinfo) {
$this->includesubmission = false;
}
// Reset revealidentities if blindmarking with no user data (MDL-43796).
$userinfo = $this->get_setting_value('userinfo');
if (!$userinfo && $data->blindmarking) {
$data->revealidentities = 0;
}
if (!empty($data->teamsubmissiongroupingid)) {
$data->teamsubmissiongroupingid = $this->get_mappingid('grouping',
$data->teamsubmissiongroupingid);
} else {
$data->teamsubmissiongroupingid = 0;
}
if (!isset($data->cutoffdate)) {
$data->cutoffdate = 0;
}
if (!isset($data->gradingduedate)) {
$data->gradingduedate = 0;
} else {
$data->gradingduedate = $this->apply_date_offset($data->gradingduedate);
}
if (!isset($data->markingworkflow)) {
$data->markingworkflow = 0;
}
if (!isset($data->markingallocation)) {
$data->markingallocation = 0;
}
if (!isset($data->markinganonymous)) {
$data->markinganonymous = 0;
}
if (!isset($data->preventsubmissionnotingroup)) {
$data->preventsubmissionnotingroup = 0;
}
if (!empty($data->preventlatesubmissions)) {
$data->cutoffdate = $data->duedate;
} else {
$data->cutoffdate = $this->apply_date_offset($data->cutoffdate);
}
if ($data->grade < 0) { // Scale found, get mapping.
$data->grade = -($this->get_mappingid('scale', abs($data->grade)));
}
$newitemid = $DB->insert_record('assign', $data);
$this->apply_activity_instance($newitemid);
}
/**
* Process a submission restore
* @param object $data The data in object form
* @return void
*/
protected function process_assign_submission($data) {
global $DB;
if (!$this->includesubmission) {
return;
}
$data = (object)$data;
$oldid = $data->id;
$data->assignment = $this->get_new_parentid('assign');
if ($data->userid > 0) {
$data->userid = $this->get_mappingid('user', $data->userid);
}
if (!empty($data->groupid)) {
$data->groupid = $this->get_mappingid('group', $data->groupid);
if (!$data->groupid) {
// If the group does not exist, then the submission cannot be viewed and restoring can
// violate the unique index on the submission table.
return;
}
} else {
$data->groupid = 0;
}
// We will correct this in set_latest_submission_field() once all submissions are restored.
$data->latest = 0;
$newitemid = $DB->insert_record('assign_submission', $data);
// Note - the old contextid is required in order to be able to restore files stored in
// sub plugin file areas attached to the submissionid.
$this->set_mapping('submission', $oldid, $newitemid, false, null, $this->task->get_old_contextid());
}
/**
* Process a user_flags restore
* @param object $data The data in object form
* @return void
*/
protected function process_assign_userflag($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$data->assignment = $this->get_new_parentid('assign');
$data->userid = $this->get_mappingid('user', $data->userid);
if (!empty($data->allocatedmarker)) {
$data->allocatedmarker = $this->get_mappingid('user', $data->allocatedmarker);
}
if (!empty($data->extensionduedate)) {
$data->extensionduedate = $this->apply_date_offset($data->extensionduedate);
} else {
$data->extensionduedate = 0;
}
// Flags mailed and locked need no translation on restore.
$newitemid = $DB->insert_record('assign_user_flags', $data);
}
/**
* Process a grade restore
* @param object $data The data in object form
* @return void
*/
protected function process_assign_grade($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$data->assignment = $this->get_new_parentid('assign');
$data->userid = $this->get_mappingid('user', $data->userid);
$data->grader = $this->get_mappingid('user', $data->grader);
// Handle flags restore to a different table (for upgrade from old backups).
if (!empty($data->extensionduedate) ||
!empty($data->mailed) ||
!empty($data->locked)) {
$flags = new stdClass();
$flags->assignment = $this->get_new_parentid('assign');
if (!empty($data->extensionduedate)) {
$flags->extensionduedate = $this->apply_date_offset($data->extensionduedate);
}
if (!empty($data->mailed)) {
$flags->mailed = $data->mailed;
}
if (!empty($data->locked)) {
$flags->locked = $data->locked;
}
$flags->userid = $this->get_mappingid('user', $data->userid);
$DB->insert_record('assign_user_flags', $flags);
}
// Fix null grades that were rescaled.
if ($data->grade < 0 && $data->grade != ASSIGN_GRADE_NOT_SET) {
$data->grade = ASSIGN_GRADE_NOT_SET;
}
$newitemid = $DB->insert_record('assign_grades', $data);
// Note - the old contextid is required in order to be able to restore files stored in
// sub plugin file areas attached to the gradeid.
$this->set_mapping('grade', $oldid, $newitemid, false, null, $this->task->get_old_contextid());
$this->set_mapping(restore_gradingform_plugin::itemid_mapping('submissions'), $oldid, $newitemid);
}
/**
* Process a plugin-config restore
* @param object $data The data in object form
* @return void
*/
protected function process_assign_plugin_config($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
$data->assignment = $this->get_new_parentid('assign');
$newitemid = $DB->insert_record('assign_plugin_config', $data);
}
/**
* For all submissions in this assignment, either set the
* submission->latest field to 1 for the latest attempts
* or create a new submission record for grades with no submission.
*
* @return void
*/
protected function set_latest_submission_field() {
global $DB, $CFG;
// Required for constants.
require_once($CFG->dirroot . '/mod/assign/locallib.php');
$assignmentid = $this->get_new_parentid('assign');
// First check for records with a grade, but no submission record.
// This happens when a teacher marks a student before they have submitted anything.
$records = $DB->get_recordset_sql('SELECT g.id, g.userid, g.attemptnumber
FROM {assign_grades} g
LEFT JOIN {assign_submission} s
ON s.assignment = g.assignment
AND s.userid = g.userid
WHERE s.id IS NULL AND g.assignment = ?', array($assignmentid));
$submissions = array();
foreach ($records as $record) {
$submission = new stdClass();
$submission->assignment = $assignmentid;
$submission->userid = $record->userid;
$submission->attemptnumber = $record->attemptnumber;
$submission->status = ASSIGN_SUBMISSION_STATUS_NEW;
$submission->groupid = 0;
$submission->latest = 0;
$submission->timecreated = time();
$submission->timemodified = time();
array_push($submissions, $submission);
}
$records->close();
$DB->insert_records('assign_submission', $submissions);
// This code could be rewritten as a monster SQL - but the point of adding this "latest" field
// to the submissions table in the first place was to get away from those hard to maintain SQL queries.
// First user submissions.
$sql = 'SELECT DISTINCT userid FROM {assign_submission} WHERE assignment = ? AND groupid = ?';
$params = array($assignmentid, 0);
$users = $DB->get_records_sql($sql, $params);
foreach ($users as $userid => $unused) {
$params = array('assignment'=>$assignmentid, 'groupid'=>0, 'userid'=>$userid);
// Only return the row with the highest attemptnumber.
$submission = null;
$submissions = $DB->get_records('assign_submission', $params, 'attemptnumber DESC', '*', 0, 1);
if ($submissions) {
$submission = reset($submissions);
$submission->latest = 1;
$DB->update_record('assign_submission', $submission);
}
}
// Then group submissions (if any).
$sql = 'SELECT DISTINCT groupid FROM {assign_submission} WHERE assignment = ? AND userid = ?';
$params = array($assignmentid, 0);
$groups = $DB->get_records_sql($sql, $params);
foreach ($groups as $groupid => $unused) {
$params = array('assignment'=>$assignmentid, 'userid'=>0, 'groupid'=>$groupid);
// Only return the row with the highest attemptnumber.
$submission = null;
$submissions = $DB->get_records('assign_submission', $params, 'attemptnumber DESC', '*', 0, 1);
if ($submissions) {
$submission = reset($submissions);
$submission->latest = 1;
$DB->update_record('assign_submission', $submission);
}
}
}
/**
* Restore files from plugin configuration
* @param string $subtype the plugin type to handle
* @return void
*/
protected function add_plugin_config_files($subtype) {
$dummyassign = new assign(null, null, null);
$plugins = $dummyassign->load_plugins($subtype);
foreach ($plugins as $plugin) {
$component = $plugin->get_subtype() . '_' . $plugin->get_type();
$areas = $plugin->get_config_file_areas();
foreach ($areas as $area) {
$this->add_related_files($component, $area, null);
}
}
}
/**
* Process a assign override restore
* @param object $data The data in object form
* @return void
*/
protected function process_assign_override($data) {
global $DB;
$data = (object)$data;
$oldid = $data->id;
// Based on userinfo, we'll restore user overides or no.
$userinfo = $this->get_setting_value('userinfo');
// Skip user overrides if we are not restoring userinfo.
if (!$userinfo && !is_null($data->userid)) {
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)) {
$data->userid = $this->get_mappingid('user', $data->userid);
}
if (!is_null($data->groupid)) {
$data->groupid = $this->get_mappingid('group', $data->groupid);
}
$data->allowsubmissionsfromdate = $this->apply_date_offset($data->allowsubmissionsfromdate);
$data->duedate = $this->apply_date_offset($data->duedate);
$data->cutoffdate = $this->apply_date_offset($data->cutoffdate);
$newitemid = $DB->insert_record('assign_overrides', $data);
// Add mapping, restore of logs needs it.
$this->set_mapping('assign_override', $oldid, $newitemid);
}
/**
* Once the database tables have been fully restored, restore the files
*/
protected function after_execute() {
$this->add_related_files('mod_assign', 'intro', null);
$this->add_related_files('mod_assign', 'introattachment', null);
$this->add_related_files('mod_assign', 'activityattachment', null);
$this->add_plugin_config_files('assignsubmission');
$this->add_plugin_config_files('assignfeedback');
$this->set_latest_submission_field();
}
}