diff --git a/backup/moodle2/backup_local_adler_plugin.class.php b/backup/moodle2/backup_local_adler_plugin.class.php index 4406c68..8e63ded 100644 --- a/backup/moodle2/backup_local_adler_plugin.class.php +++ b/backup/moodle2/backup_local_adler_plugin.class.php @@ -9,7 +9,7 @@ protected function define_course_plugin_structure(): backup_plugin_element { // Define each element separated $pluginwrapper = new backup_nested_element($this->get_recommended_name(), null, [ - 'plugin_set_version', + 'plugin_release_set_version', ]); // Moodle does not allow names in nested elements that are used in the root element, therefore "score" is not allowed @@ -23,7 +23,7 @@ protected function define_course_plugin_structure(): backup_plugin_element { // Define sources // version number according to https://github.com/ProjektAdLer/moodle-docker/blob/main/plugin-releases.json - $pluginwrapper->set_source_array([['plugin_set_version' => '4.0.0']]); + $pluginwrapper->set_source_array([['plugin_release_set_version' => '4.0.0']]); $adler_course->set_source_table('local_adler_course', array('course_id' => backup::VAR_COURSEID)); // Define id annotations diff --git a/backup/moodle2/restore_local_adler_plugin.class.php b/backup/moodle2/restore_local_adler_plugin.class.php index ced39d3..06862a4 100644 --- a/backup/moodle2/restore_local_adler_plugin.class.php +++ b/backup/moodle2/restore_local_adler_plugin.class.php @@ -13,7 +13,7 @@ class restore_local_adler_plugin extends restore_local_plugin { // define_module_plugin_structure, define_grade_item_plugin_structure, define_question_plugin_structure protected $db; - private $plugin_set_version; + private $plugin_release_set_version; private $log; public function __construct($name, $plugin, $restore) { @@ -21,24 +21,24 @@ public function __construct($name, $plugin, $restore) { parent::__construct($name, $plugin, $restore); $this->db = $DB; $this->log = new logger('local_adler', self::class); - $this->plugin_set_version = null; + $this->plugin_release_set_version = null; } protected function define_course_plugin_structure(): array { return [ - new restore_path_element('plugin_set_version', $this->get_pathfor('/')), + new restore_path_element('plugin_release_set_version', $this->get_pathfor('/')), new restore_path_element('adler_course', $this->get_pathfor('/adler_course')) ]; } - public function process_plugin_set_version($data) { + public function process_plugin_release_set_version($data) { $data = (object)$data; - if (property_exists($data, 'plugin_set_version') ) { - if (version_compare($data->plugin_set_version, '4.0.0', '<')) { - throw new moodle_exception('invalid_plugin_set_version', 'local_adler', '', null, 'plugin_set_version is below 3.2.0'); + if (property_exists($data, 'plugin_release_set_version') ) { + if (version_compare($data->plugin_release_set_version, '4.0.0', '<')) { + throw new moodle_exception('invalid_plugin_release_set_version', 'local_adler', '', null, 'plugin_release_set_version is below 3.2.0'); } - $this->plugin_set_version = $data->plugin_set_version; + $this->plugin_release_set_version = $data->plugin_release_set_version; } } @@ -137,8 +137,8 @@ public function process_adler_module($data) { * @throws not_an_adler_course_exception */ public function after_restore_course() { - $this->log->info('Restoring course with plugin set version ' . $this->plugin_set_version); - if (empty($this->plugin_set_version)) { + $this->log->info('Restoring course with plugin set version ' . $this->plugin_release_set_version); + if (empty($this->plugin_release_set_version)) { try { (new upgrade_3_2_0_to_4_0_0_completionlib($this->task->get_courseid()))->execute(); } catch (not_an_adler_course_exception $e) { diff --git a/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php b/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php index 8cf29a4..8d1bffb 100644 --- a/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php +++ b/classes/local/upgrade/upgrade_3_2_0_to_4_0_0_completionlib.php @@ -2,7 +2,6 @@ namespace local_adler\local\upgrade; -use cm_info; use dml_exception; use local_adler\helpers; use local_adler\local\db\moodle_core_repository; diff --git a/tests/backup/moodle2/backup_adler_plugin_test.php b/tests/backup/moodle2/backup_adler_plugin_test.php index 88461d7..ba3feeb 100644 --- a/tests/backup/moodle2/backup_adler_plugin_test.php +++ b/tests/backup/moodle2/backup_adler_plugin_test.php @@ -195,7 +195,7 @@ public function test_backup_course_not_adler_course() { /** * # ANF-ID: [MVP1] */ - public function test_plugin_set_version_property() { + public function test_plugin_release_set_version_property() { // Create score item with generator $adler_course_object = $this ->getDataGenerator() @@ -218,6 +218,6 @@ public function test_plugin_set_version_property() { $xml = $this->get_xml_from_backup($bc, 'course'); // Validate xml values - $this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', (string)$xml->plugin_local_adler_course->plugin_set_version, 'plugin_set_version should be a valid semantic version'); + $this->assertMatchesRegularExpression('/^\d+\.\d+\.\d+$/', (string)$xml->plugin_local_adler_course->plugin_release_set_version, 'plugin_release_set_version should be a valid semantic version'); } } \ No newline at end of file diff --git a/tests/backup/moodle2/restore_adler_plugin_test.php b/tests/backup/moodle2/restore_adler_plugin_test.php index 061b482..72b9e2a 100644 --- a/tests/backup/moodle2/restore_adler_plugin_test.php +++ b/tests/backup/moodle2/restore_adler_plugin_test.php @@ -247,8 +247,8 @@ public function test_define_course_plugin_structure() { // verify $this->assertCount(2, $paths); - $this->assertEquals('adler_course', $paths[0]->get_name()); - $this->assertStringContainsString('adler_course', $paths[0]->get_path()); + $this->assertEquals('plugin_release_set_version', $paths[0]->get_name()); + $this->assertEquals('adler_course', $paths[1]->get_name()); } /** @@ -401,6 +401,7 @@ public function provide_test_call_upgrade_3_2_0_to_4_0_0_completionlib_data() { /** * @dataProvider provide_test_call_upgrade_3_2_0_to_4_0_0_completionlib_data + * @runInSeparateProcess */ public function test_call_upgrade_3_2_0_to_4_0_0_completionlib($version) { // setup mock @@ -413,20 +414,20 @@ public function test_call_upgrade_3_2_0_to_4_0_0_completionlib($version) { if ($version === '1.1.0') { $this->expectException(moodle_exception::class); - $this->expectExceptionMessage('invalid_plugin_set_version'); + $this->expectExceptionMessage('invalid_plugin_release_set_version'); } // setup data list($data, $stub) = $this->setUpCourse(); if ($version !== null) { - $data->plugin_set_version = $version; + $data->plugin_release_set_version = $version; } // create test object $plugin = new restore_local_adler_plugin('local', 'adler', $stub); // call the method to test - $plugin->process_plugin_set_version($data); + $plugin->process_plugin_release_set_version($data); $plugin->after_restore_course(); } } \ No newline at end of file