diff --git a/backup/moodle2/backup_stepslib.php b/backup/moodle2/backup_stepslib.php index f5a8544ebd1..ac8c91711e3 100644 --- a/backup/moodle2/backup_stepslib.php +++ b/backup/moodle2/backup_stepslib.php @@ -127,7 +127,7 @@ abstract class backup_activity_structure_step extends backup_structure_step { /** * Helper code for use by any plugin that stores question attempt data that it needs to back up. */ -trait backup_questions_activity_data_trait { +trait backup_questions_attempt_data_trait { /** * Attach to $element (usually attempts) the needed backup structures @@ -206,7 +206,7 @@ trait backup_questions_activity_data_trait { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class backup_questions_activity_structure_step extends backup_activity_structure_step { - use backup_questions_activity_data_trait; + use backup_questions_attempt_data_trait; } diff --git a/backup/moodle2/restore_plugin.class.php b/backup/moodle2/restore_plugin.class.php index cff602e5b85..31a94f50e9f 100644 --- a/backup/moodle2/restore_plugin.class.php +++ b/backup/moodle2/restore_plugin.class.php @@ -72,7 +72,7 @@ abstract class restore_plugin { if (method_exists($this, $methodname)) { if ($pluginpaths = $this->$methodname()) { foreach ($pluginpaths as $path) { - if ($path->get_processing_object() === null && !$this->grouped_parent_exists($path, $paths)) { + if ($path->get_processing_object() === null && !$this->step->grouped_parent_exists($path, $paths)) { $path->set_processing_object($this); } $paths[] = $path; @@ -273,26 +273,6 @@ abstract class restore_plugin { $this->pluginname . '_' . basename($this->connectionpoint->get_path()) . $path; } - /** - * Given one pathelement, return true if grouped parent was found. - * - * @param restore_path_element $pelement the element we are interested in. - * @param restore_path_element[] $elements the elements that exist. - * @return bool true if this element is inside a grouped parent. - */ - protected function grouped_parent_exists($pelement, $elements) { - foreach ($elements as $element) { - if ($pelement->get_path() == $element->get_path()) { - continue; // Don't compare against itself. - } - // If element is grouped and parent of pelement, return true. - if ($element->is_grouped() and strpos($pelement->get_path() . '/', $element->get_path()) === 0) { - return true; - } - } - return false; // No grouped parent found. - } - /** * Get the task we are part of. * diff --git a/backup/moodle2/restore_stepslib.php b/backup/moodle2/restore_stepslib.php index c68fab0d910..10199e0775b 100644 --- a/backup/moodle2/restore_stepslib.php +++ b/backup/moodle2/restore_stepslib.php @@ -5328,7 +5328,7 @@ class restore_process_file_aliases_queue extends restore_execution_step { /** * Helper code for use by any plugin that stores question attempt data that it needs to back up. */ -trait restore_questions_activity_data_trait { +trait restore_questions_attempt_data_trait { /** @var array question_attempt->id to qtype. */ protected $qtypes = array(); /** @var array question_attempt->id to questionid. */ @@ -5580,7 +5580,7 @@ trait restore_questions_activity_data_trait { * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ abstract class restore_questions_activity_structure_step extends restore_activity_structure_step { - use restore_questions_activity_data_trait; + use restore_questions_attempt_data_trait; /** * Attach below $element (usually attempts) the needed restore_path_elements @@ -5624,7 +5624,7 @@ abstract class restore_questions_activity_structure_step extends restore_activit /** * Process the attempt data defined by {@link add_legacy_question_attempt_data()}. * @param object $data contains all the grouped attempt data to process. - * @param pbject $quiz data about the activity the attempts belong to. Required + * @param object $quiz data about the activity the attempts belong to. Required * fields are (basically this only works for the quiz module): * oldquestions => list of question ids in this activity - using old ids. * preferredbehaviour => the behaviour to use for questionattempts. diff --git a/backup/util/plan/restore_structure_step.class.php b/backup/util/plan/restore_structure_step.class.php index b4e3ae56728..3fe1978deff 100644 --- a/backup/util/plan/restore_structure_step.class.php +++ b/backup/util/plan/restore_structure_step.class.php @@ -510,18 +510,22 @@ abstract class restore_structure_step extends restore_step { /** * Given one pathelement, return true if grouped parent was found + * + * @param restore_path_element $pelement the element we are interested in. + * @param restore_path_element[] $elements the elements that exist. + * @return bool true if this element is inside a grouped parent. */ - protected function grouped_parent_exists($pelement, $elements) { + public function grouped_parent_exists($pelement, $elements) { foreach ($elements as $element) { if ($pelement->get_path() == $element->get_path()) { - continue; // Don't compare against itself + continue; // Don't compare against itself. } - // If element is grouped and parent of pelement, return true + // If element is grouped and parent of pelement, return true. if ($element->is_grouped() and strpos($pelement->get_path() . '/', $element->get_path()) === 0) { return true; } } - return false; // no grouped parent found + return false; // No grouped parent found. } /** diff --git a/mod/quiz/tests/behat/backup.feature b/mod/quiz/tests/behat/backup.feature index 4c66d453429..eaa8b44c744 100644 --- a/mod/quiz/tests/behat/backup.feature +++ b/mod/quiz/tests/behat/backup.feature @@ -35,7 +35,7 @@ Feature: Backup and restore of quizzes And I should see "TF2" @javascript - Scenario: Backup and restore a coures containing a quiz with user data. + Scenario: Backup and restore a course containing a quiz with user data. Given the following "activities" exist: | activity | name | intro | course | idnumber | | quiz | Quiz 1 | For testing backup | C1 | quiz1 |