diff --git a/CHANGES.md b/CHANGES.md index f22aa94..3e2da0f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -4,6 +4,10 @@ moodle-local_differentiator Changes ------- +### Unreleased + +* 2024-03-02 - Fixing some linter errors. + ### v4.3-r2 * 2024-03-02 - Adding Behat tests. diff --git a/classes/differentiator.php b/classes/differentiator.php index 7fdff36..fc451e2 100644 --- a/classes/differentiator.php +++ b/classes/differentiator.php @@ -47,7 +47,7 @@ public function __construct() { * @return \moodle_url * @throws \moodle_exception */ - public function make_url(string $subpath, array $params = null) : \moodle_url { + public function make_url(string $subpath, array $params = null): \moodle_url { $path = '/local/differentiator/view.php/' . $subpath; return new \moodle_url($path, $params); } @@ -59,7 +59,7 @@ public function make_url(string $subpath, array $params = null) : \moodle_url { * @return bool * @throws \coding_exception */ - public function user_has_capability(string $capability) : bool { + public function user_has_capability(string $capability): bool { return \has_capability($capability, $this->context); } diff --git a/classes/external/learninggoal.php b/classes/external/learninggoal.php index f26664b..071ceb6 100644 --- a/classes/external/learninggoal.php +++ b/classes/external/learninggoal.php @@ -33,6 +33,20 @@ defined('MOODLE_INTERNAL') || die(); +// This work-around is required until Moodle 4.2 is the lowest version we support. +if (class_exists('core_external\external_api') && class_exists('core_external\external_function_parameters') + && class_exists('core_external\external_value') && class_exists('core_external\external_multiple_structure')) { + class_alias('core_external\external_api', '\local_differentiator_external_api_class_alias'); + class_alias('core_external\external_function_parameters', '\local_differentiator_external_function_parameters_class_alias'); + class_alias('core_external\external_value', '\local_differentiator_external_value_class_alias'); + class_alias('core_external\external_multiple_structure', '\local_differentiator_external_multiple_structure_class_alias'); +} else { + class_alias('external_api', '\local_differentiator_external_api_class_alias'); + class_alias('external_function_parameters', '\local_differentiator_external_function_parameters_class_alias'); + class_alias('external_value', '\local_differentiator_external_value_class_alias'); + class_alias('external_multiple_structure', '\local_differentiator_external_multiple_structure_class_alias'); +} + require_once($CFG->libdir.'/externallib.php'); /** @@ -51,8 +65,8 @@ class learninggoal extends \external_api { */ public static function get_learninggoal_parameters() { return new external_function_parameters([ - 'userid' => new external_value(PARAM_INT, 'userid'), - 'learninggoalid' => new external_value(PARAM_INT, 'learninggoalid'), + 'userid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'userid'), + 'learninggoalid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'learninggoalid'), ]); } @@ -64,19 +78,19 @@ public static function get_learninggoal_parameters() { */ public static function save_learninggoal_parameters() { return new external_function_parameters([ - 'userid' => new external_value(PARAM_INT, 'userid'), - 'learninggoalid' => new external_value(PARAM_INT, 'id of the learning goal'), - 'name' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'pre_thinking_skill' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'thinking_skill' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'content' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'subject' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'pre_resource' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'resource' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'pre_product' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'product' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'pre_group' => new external_value(PARAM_TEXT, 'name of the learning goal'), - 'group' => new external_value(PARAM_TEXT, 'name of the learning goal'), + 'userid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'userid'), + 'learninggoalid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'id of the learning goal'), + 'name' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'pre_thinking_skill' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'thinking_skill' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'content' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'subject' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'pre_resource' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'resource' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'pre_product' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'product' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'pre_group' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), + 'group' => new \local_differentiator_external_value_class_alias(PARAM_TEXT, 'name of the learning goal'), ]); } @@ -88,8 +102,8 @@ public static function save_learninggoal_parameters() { */ public static function delete_learninggoal_parameters() { return new external_function_parameters([ - 'userid' => new external_value(PARAM_INT, 'userid'), - 'learninggoalid' => new external_value(PARAM_INT, 'learninggoalid'), + 'userid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'userid'), + 'learninggoalid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'learninggoalid'), ]); } @@ -101,8 +115,8 @@ public static function delete_learninggoal_parameters() { */ public static function duplicate_learninggoal_parameters() { return new external_function_parameters([ - 'userid' => new external_value(PARAM_INT, 'userid'), - 'learninggoalid' => new external_value(PARAM_INT, 'learninggoalid'), + 'userid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'userid'), + 'learninggoalid' => new \local_differentiator_external_value_class_alias(PARAM_INT, 'learninggoalid'), ]); } @@ -113,7 +127,7 @@ public static function duplicate_learninggoal_parameters() { * @return external_multiple_structure */ public static function get_learninggoal_returns() { - return new external_multiple_structure( + return new \local_differentiator_external_multiple_structure_class_alias( exporter\learninggoal::get_read_structure() ); } diff --git a/classes/form/form_controller.php b/classes/form/form_controller.php index 167199c..85dfb2b 100644 --- a/classes/form/form_controller.php +++ b/classes/form/form_controller.php @@ -114,7 +114,7 @@ public function get_message() { * * @return bool */ - public function success() : bool { + public function success(): bool { return $this->formsubmittedsuccess; } @@ -131,7 +131,7 @@ abstract protected function build_customdata(); * @param \stdClass $data validated data from form * @return bool */ - abstract protected function handle_submit(\stdClass $data) : bool; + abstract protected function handle_submit(\stdClass $data): bool; /** * First display of the form. diff --git a/classes/form/learninggoal_edit_controller.php b/classes/form/learninggoal_edit_controller.php index 00ce36f..bec56db 100644 --- a/classes/form/learninggoal_edit_controller.php +++ b/classes/form/learninggoal_edit_controller.php @@ -71,7 +71,7 @@ protected function build_customdata() { * @return bool * @throws \dml_exception */ - protected function handle_submit(\stdClass $data) : bool { + protected function handle_submit(\stdClass $data): bool { global $DB; if ($this->learninggoalid && $data->learninggoalid != $this->learninggoalid) { diff --git a/tests/behat/add.feature b/tests/behat/add.feature index 7113f81..e68ecb4 100644 --- a/tests/behat/add.feature +++ b/tests/behat/add.feature @@ -5,10 +5,9 @@ Feature: Access differentiator and add a learning goal. Scenario: Access a differentiator and add a learning goal Given I log in as "admin" And I am on the "Differentiator" "local_differentiator > Differentiator" page - And I press "Add a new goal" + When I press "Add a new goal" And I set the field with xpath "//div[@class='learninggoals-edit-add-form']//input[@type='text']" to "Learning goal 1 (en)" And I set the field with xpath "//p[2]//input[@type='text'][4]" to "Quentin Tarantino films" And I press "Save" Then I should see "Learning goal 1 (en)" And I should see "Students will remember the big idea of the Quentin Tarantino films using a textbook and create an essay in groups of one." - diff --git a/vue/webpack.config.js b/vue/webpack.config.js index b17fb11..e8a9afc 100644 --- a/vue/webpack.config.js +++ b/vue/webpack.config.js @@ -51,11 +51,11 @@ module.exports = (env, options) => { noInfo: true, overlay: true, headers: { - 'Access-Control-Allow-Origin': '\*' + 'Access-Control-Allow-Origin': '*' }, disableHostCheck: true, https: true, - public: 'https://127.0.0.1:8080', + "public": 'https://127.0.0.1:8080', hot: true, }, performance: { @@ -123,7 +123,7 @@ module.exports = (env, options) => { } }), ] - } + }; } return exports;