'maxbytes', 'maxattachments', 'forcesubscribe', 'trackingtype',
'rsstype', 'rssarticles', 'timemodified', 'warnafter',
'blockafter', 'blockperiod', 'completiondiscussions', 'completionreplies',
- 'completionposts', 'displaywordcount', 'lockdiscussionafter'));
+ 'completionposts', 'displaywordcount', 'lockdiscussionafter', 'grade_forum'));
$discussions = new backup_nested_element('discussions');
$track = new backup_nested_element('track', array('id'), array(
'userid'));
+ $grades = new backup_nested_element('grades');
+
+ $grade = new backup_nested_element('grade', ['id'], [
+ 'forum',
+ 'itemnumber',
+ 'userid',
+ 'grade',
+ 'timecreated',
+ 'timemodified',
+ ]);
+
// Build the tree
$forum->add_child($discussions);
$forum->add_child($tags);
$tags->add_child($tag);
+ $forum->add_child($grades);
+ $grades->add_child($grade);
+
$discussion->add_child($posts);
$posts->add_child($post);
backup_helper::is_sqlparam('mod_forum'),
backup::VAR_CONTEXTID));
}
+
+ $grade->set_source_table('forum_grades', array('forum' => backup::VAR_PARENTID));
}
// Define id annotations
$track->annotate_ids('user', 'userid');
+ $grade->annotate_ids('userid', 'userid');
+
+ $grade->annotate_ids('forum', 'forum');
// Define file annotations
$forum->annotate_files('mod_forum', 'intro', null); // This file area hasn't itemid
$paths[] = new restore_path_element('forum_digest', '/activity/forum/digests/digest');
$paths[] = new restore_path_element('forum_read', '/activity/forum/readposts/read');
$paths[] = new restore_path_element('forum_track', '/activity/forum/trackedprefs/track');
+ $paths[] = new restore_path_element('forum_grade', '/activity/forum/grades/grade');
}
// Return the paths wrapped into standard activity structure
$newitemid = $DB->insert_record('forum_digests', $data);
}
+ protected function process_forum_grade($data) {
+ global $DB;
+
+ $data = (object)$data;
+ $oldid = $data->id;
+
+ $data->forum = $this->get_new_parentid('forum');
+
+ $data->userid = $this->get_mappingid('user', $data->userid);
+
+ // We want to ensure the current user has an ID that we can associate to a grade.
+ if ($data->userid != 0) {
+ $newitemid = $DB->insert_record('forum_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('forum'), $oldid, $newitemid);
+ }
+ }
+
protected function process_forum_read($data) {
global $DB;