. /** * Define all the restore steps that will be used by the restore_expcontent_activity_task. * * @package mod_expcontent * @copyright 2013 Mark Nelson , 2021 Klaus-Uwe Mitterer * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.'); /** * Define the complete expcontent structure for restore, with file and id annotations. * * @package mod_expcontent * @copyright 2013 Mark Nelson , 2021 Klaus-Uwe Mitterer * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class restore_expcontent_activity_structure_step extends restore_activity_structure_step { /** * Define the different items to restore. * * @return array the restore paths */ protected function define_structure() { // The array used to store the path to the items we want to restore. $paths = array(); // The expcontent instance. $paths[] = new restore_path_element('expcontent', '/activity/expcontent'); // Return the paths wrapped into standard activity structure. return $this->prepare_activity_structure($paths); } /** * Handles restoring the expcontent activity. * * @param stdClass $data the expcontent data */ protected function process_expcontent($data) { global $DB, $USER; $data = (object) $data; $data->course = $this->get_courseid(); $data->timecreated = $this->apply_date_offset($data->timecreated); $data->timemodified = $this->apply_date_offset($data->timemodified); $data->usermodified = $USER->id; // Insert the expcontent record. $newitemid = $DB->insert_record('expcontent', $data); // Immediately after inserting record call this. $this->apply_activity_instance($newitemid); } }