Skip to content

Commit

Permalink
Fix some linter errors.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaboesch committed Mar 2, 2024
1 parent 04961ab commit ca6c87c
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions classes/differentiator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);
}

Expand Down
54 changes: 34 additions & 20 deletions classes/external/learninggoal.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');

/**
Expand All @@ -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'),
]);
}

Expand All @@ -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'),
]);
}

Expand All @@ -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'),
]);
}

Expand All @@ -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'),
]);
}

Expand All @@ -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()
);
}
Expand Down
4 changes: 2 additions & 2 deletions classes/form/form_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public function get_message() {
*
* @return bool
*/
public function success() : bool {
public function success(): bool {
return $this->formsubmittedsuccess;
}

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion classes/form/learninggoal_edit_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions tests/behat/add.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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."

6 changes: 3 additions & 3 deletions vue/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -123,7 +123,7 @@ module.exports = (env, options) => {
}
}),
]
}
};
}

return exports;
Expand Down

0 comments on commit ca6c87c

Please sign in to comment.