Skip to content

Commit

Permalink
MDL-37714: Correctly identify frequently used comments during restore
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-or committed Jan 30, 2014
1 parent 9788e26 commit 20c9f4a
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ protected function define_definition_plugin_structure() {

$pluginwrapper->add_child($criteria);
$criteria->add_child($criterion);
$criteria->add_child($comments);
$pluginwrapper->add_child($comments);
$comments->add_child($comment);

// Set sources to populate the data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ protected function define_definition_plugin_structure() {
$paths[] = new restore_path_element('gradingform_guide_comment',
$this->get_pathfor('/guidecomments/guidecomment'));

// MDL-37714: Correctly locate frequent used comments in both the
// current and incorrect old format.
$paths[] = new restore_path_element('gradingform_guide_comment_legacy',
$this->get_pathfor('/guidecriteria/guidecomments/guidecomment'));

return $paths;
}

Expand Down Expand Up @@ -99,6 +104,20 @@ public function process_gradingform_guide_comment($data) {
$DB->insert_record('gradingform_guide_comments', $data);
}

/**
* Processes comments element data
*
* @param array|stdClass $data The data to insert as a comment
*/
public function process_gradingform_guide_comment_legacy($data) {
global $DB;

$data = (object)$data;
$data->definitionid = $this->get_new_parentid('grading_definition');

$DB->insert_record('gradingform_guide_comments', $data);
}

/**
* Processes filling element data
*
Expand Down

0 comments on commit 20c9f4a

Please sign in to comment.