diff --git a/classes/api.php b/classes/api.php index 7c15355..a411fd1 100644 --- a/classes/api.php +++ b/classes/api.php @@ -137,10 +137,10 @@ public static function get_instance_by_categoryid($categoryid) { /** * Check whether only active users in course should be shown. * - * @param context_module $context context the verbal feedback belongs to. + * @param ?context_module $context context the verbal feedback belongs to. * @return bool true if only active users should be shown. */ - public static function show_only_active_users(context_module $context = null) { + public static function show_only_active_users(?context_module $context = null) { global $CFG; $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol); diff --git a/classes/helper.php b/classes/helper.php index a1eb20c..b0706e8 100644 --- a/classes/helper.php +++ b/classes/helper.php @@ -128,19 +128,19 @@ public static function prepare_items_view($categories) { /** * Wrapper for the Yaml::parseFile() function. - * @param string $someYaml + * + * @param string $someyaml * @param int|null $options * @param int|null $debug * @return array|\Dallgoot\Yaml\Types\YamlObject|\Dallgoot\Yaml\YamlObject|null * @throws Exception */ - public static function parseYamlFile(string $someYaml, ?int $options = null, ?int $debug = null) - { + public static function parseyamlfile(string $someyaml, ?int $options = null, ?int $debug = null) { if (version_compare(PHP_VERSION, '8.1.14') >= 0) { - require_once implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '81x', 'autoload.php']); - return \Dallgoot\Yaml\Yaml::parseFile($someYaml, $options, $debug); + require_once(implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '81x', 'autoload.php'])); + return \Dallgoot\Yaml\Yaml::parseFile($someyaml, $options, $debug); } - require_once implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '74x', 'autoload.php']); - return \Dallgoot\Yaml::parseFile($someYaml, $options, $debug); + require_once(implode(DIRECTORY_SEPARATOR, [dirname(__FILE__), 'vendor', '74x', 'autoload.php'])); + return \Dallgoot\Yaml::parseFile($someyaml, $options, $debug); } } diff --git a/classes/model/instance.php b/classes/model/instance.php index b30efe0..dd9abf1 100644 --- a/classes/model/instance.php +++ b/classes/model/instance.php @@ -162,7 +162,7 @@ public function __construct(int $course, int $id = 0, string $name = "", string public static function from_template(int $course, template $template, int $id = 0, string $name = "", string $intro = "", int $introformat = 0, int $gradecat = 0, int $grade = 0, float $gradepass = 0, int $status = instance_status::NOT_READY, int $timeopen = 0, int $timeclose = 0, int $timemodified = 0, - int $releasetype = instance_release_type::NONE, int $released = 0) : instance { + int $releasetype = instance_release_type::NONE, int $released = 0): instance { $instance = new instance($course, $id, $name, $intro, $introformat, $grade, $gradecat, $gradepass, $status, $timeopen, $timeclose, $timemodified, $releasetype, $released); @@ -181,7 +181,7 @@ public static function from_template(int $course, template $template, int $id = * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -199,7 +199,7 @@ public function set_id(int $id) { * * @return int|null The template id. */ - public function get_template_id() : ?int { + public function get_template_id(): ?int { return $this->templateid; } @@ -217,7 +217,7 @@ public function set_template_id(?int $templateid) { * * @return int The course id. */ - public function get_course() : int { + public function get_course(): int { return $this->course; } @@ -235,7 +235,7 @@ public function set_course(int $course) { * * @return string The instance name. */ - public function get_name() : string { + public function get_name(): string { return $this->name; } @@ -253,7 +253,7 @@ public function set_name(string $name) { * * @return string The intro. */ - public function get_intro() : string { + public function get_intro(): string { return $this->intro; } @@ -271,7 +271,7 @@ public function set_intro(string $intro) { * * @return int The introformat. */ - public function get_introformat() : int { + public function get_introformat(): int { return $this->introformat; } @@ -289,7 +289,7 @@ public function set_introformat(int $introformat) { * * @return int The max grade. */ - public function get_grade() : int { + public function get_grade(): int { global $DB; return $DB->get_field('verbalfeedback', 'grade', ['id' => $this->id]); } @@ -308,7 +308,7 @@ public function set_grade(int $grade) { * * @return int The grade category. */ - public function get_gradecat() : int { + public function get_gradecat(): int { return $this->gradecat; } @@ -326,7 +326,7 @@ public function set_gradecat(int $gradecat) { * * @return float The pass grade. */ - public function get_gradepass() : float { + public function get_gradepass(): float { return $this->gradepass; } @@ -344,7 +344,7 @@ public function set_gradepass(float $gradepass) { * * @return int The grade scale. */ - public function get_gradescale() : int { + public function get_gradescale(): int { return $this->gradescale; } @@ -362,7 +362,7 @@ public function set_gradescale(int $gradescale) { * * @return int The instance status. */ - public function get_status() : int { + public function get_status(): int { return $this->status; } @@ -380,7 +380,7 @@ public function set_status(int $status) { * * @return int The opening time. */ - public function get_timeopen() : int { + public function get_timeopen(): int { return $this->timeopen; } @@ -398,7 +398,7 @@ public function set_timeopen(int $timeopen) { * * @return int The closing time. */ - public function get_timeclose() : int { + public function get_timeclose(): int { return $this->timeclose; } @@ -416,7 +416,7 @@ public function set_timeclose(int $timeclose) { * * @return int The time of the last modification. */ - public function get_timemodified() : int { + public function get_timemodified(): int { return $this->timemodified; } @@ -439,7 +439,7 @@ public function set_timemodified(int $timemodified) { * * @return int The releasetype property value. */ - public function get_release_type() : int { + public function get_release_type(): int { return $this->releasetype; } @@ -462,7 +462,7 @@ public function set_release_type(int $releasetype) { * * @return int The released property value. */ - public function get_released() : int { + public function get_released(): int { return $this->released; } @@ -480,7 +480,7 @@ public function set_released(int $released) { * * @return array The categories. */ - public function get_categories() : array { + public function get_categories(): array { return $this->categories; } diff --git a/classes/model/instance_category.php b/classes/model/instance_category.php index ee1ee6f..94423db 100644 --- a/classes/model/instance_category.php +++ b/classes/model/instance_category.php @@ -68,7 +68,7 @@ public function __construct(int $id = 0, ?int $paramtemplatecategoryid = null, i * @param parametrized_template_category $paramtemplatecategory The parametrized template category id * @return instance_category */ - public static function from_template(parametrized_template_category $paramtemplatecategory) : instance_category { + public static function from_template(parametrized_template_category $paramtemplatecategory): instance_category { $instancecategory = new instance_category(); $instancecategory->set_parametrized_template_category_id($paramtemplatecategory->get_id()); $instancecategory->set_position($paramtemplatecategory->get_position()); @@ -107,7 +107,7 @@ public function set_id(int $id) { * * @return int */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -125,7 +125,7 @@ public function set_parametrized_template_category_id(?int $paramtemplatecategor * * @return int|null The parametrized template category id */ - public function get_parametrized_template_category_id() : ?int { + public function get_parametrized_template_category_id(): ?int { return $this->paramtemplatecategoryid; } @@ -143,7 +143,7 @@ public function set_position(int $position) { * * @return int The template category position */ - public function get_position() : int { + public function get_position(): int { return $this->position; } @@ -161,7 +161,7 @@ public function set_weight(float $weight) { * * @return float The category weight */ - public function get_weight() : float { + public function get_weight(): float { return $this->weight; } @@ -170,7 +170,7 @@ public function get_weight() : float { * * @return array The localized instance category headers. */ - public function get_headers() : array { + public function get_headers(): array { return $this->localizedheaders; } @@ -180,7 +180,7 @@ public function get_headers() : array { * @param string $languagestr The given language string * @return \mod_verbalfeedback\model\localized_string */ - public function get_header(string $languagestr) : localized_string { + public function get_header(string $languagestr): localized_string { $langrepo = new language_repository(); // Select the language string matching the current language. @@ -207,7 +207,7 @@ public function add_header(localized_string $header) { * * @return array The criteria */ - public function get_criteria() : array { + public function get_criteria(): array { return $this->instancecriteria; } diff --git a/classes/model/instance_criterion.php b/classes/model/instance_criterion.php index a9bd4e0..ebb9a88 100644 --- a/classes/model/instance_criterion.php +++ b/classes/model/instance_criterion.php @@ -124,7 +124,7 @@ public function set_id(int $id) { * * @return int */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -142,7 +142,7 @@ public function set_parametrized_template_criterion_id(?int $parametrizedtemplat * * @return int|null */ - public function get_parametrized_template_criterion_id() : ?int { + public function get_parametrized_template_criterion_id(): ?int { return $this->parametrizedtemplatecriterionid; } @@ -160,7 +160,7 @@ public function set_position(int $position) { * * @return int The instance criterion position */ - public function get_position() : int { + public function get_position(): int { return $this->position; } @@ -178,7 +178,7 @@ public function set_weight(float $weight) { * * @return float */ - public function get_weight() : float { + public function get_weight(): float { return $this->weight; } @@ -187,7 +187,7 @@ public function get_weight() : float { * * @return array The localized strings. */ - public function get_descriptions() : array { + public function get_descriptions(): array { return $this->descriptions; } @@ -197,7 +197,7 @@ public function get_descriptions() : array { * @param string $languagestr The given language string * @return \mod_verbalfeedback\model\localized_string|null */ - public function get_description(string $languagestr) : ?localized_string { + public function get_description(string $languagestr): ?localized_string { $languagerepository = new language_repository(); // Select the language string matching the current language. @@ -242,7 +242,7 @@ public function add_subrating(subrating $subrating) { * * @return array */ - public function get_subratings() : array { + public function get_subratings(): array { return $this->subratings; } } diff --git a/classes/model/language.php b/classes/model/language.php index 246fd65..41201fa 100644 --- a/classes/model/language.php +++ b/classes/model/language.php @@ -46,9 +46,9 @@ public function __construct(?int $id = null, string $language = '') { /** * Sets the id. * - * @param int|null $id The id. + * @param ?int|null $id The id. */ - public function set_id(int $id = null) { + public function set_id(?int $id = null) { $this->id = $id; } @@ -57,7 +57,7 @@ public function set_id(int $id = null) { * * @return int The id. */ - public function get_id() : ?int { + public function get_id(): ?int { return $this->id; } @@ -75,7 +75,7 @@ public function set_language(string $language) { * * @return string The language */ - public function get_language() : string { + public function get_language(): string { return $this->language; } } diff --git a/classes/model/localized_string.php b/classes/model/localized_string.php index 0186caf..dade33c 100644 --- a/classes/model/localized_string.php +++ b/classes/model/localized_string.php @@ -61,7 +61,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -79,7 +79,7 @@ public function set_language_id(int $languageid) { * * @return language The language. */ - public function get_language_id() : int { + public function get_language_id(): int { return $this->languageid; } @@ -97,7 +97,7 @@ public function set_string(string $string) { * * @return string The string. */ - public function get_string() : string { + public function get_string(): string { return $this->string; } } diff --git a/classes/model/report.php b/classes/model/report.php index 90edf39..745b04d 100644 --- a/classes/model/report.php +++ b/classes/model/report.php @@ -71,7 +71,7 @@ public function set_to_user_id(int $touserid) { * * @return int The id of the rated user. */ - public function get_to_user_id() : int { + public function get_to_user_id(): int { return $this->touserid; } @@ -80,7 +80,7 @@ public function get_to_user_id() : int { * * @return array The ids of the rating users. */ - public function get_from_user_ids() : array { + public function get_from_user_ids(): array { return $this->fromuserids; } @@ -98,7 +98,7 @@ public function add_from_user_id(int $fromuserid) { * * @return array */ - public function get_categories() : array { + public function get_categories(): array { return $this->reportcategories; } @@ -117,7 +117,7 @@ public function add_category(report_category $category) { * * @return float|null */ - public function get_result() : ?float { + public function get_result(): ?float { return $this->result; } @@ -126,7 +126,7 @@ public function get_result() : ?float { * * @return float */ - public function get_result_percentage() : float { + public function get_result_percentage(): float { return 100 * ($this->result / self::MAX_POINTS); } @@ -135,7 +135,7 @@ public function get_result_percentage() : float { * * @return float */ - public function get_result_part() : float { + public function get_result_part(): float { return $this->result / self::MAX_POINTS; } @@ -145,7 +145,7 @@ public function get_result_part() : float { * @return int * @throws \dml_exception */ - public function get_max_points() : int { + public function get_max_points(): int { global $DB; return $DB->get_field('verbalfeedback', 'grade', ['id' => $this->instanceid]); } diff --git a/classes/model/report_category.php b/classes/model/report_category.php index 7768948..b743ce1 100644 --- a/classes/model/report_category.php +++ b/classes/model/report_category.php @@ -52,7 +52,7 @@ public function __construct(instance_category $instancecategory) { * * @return int The report category position */ - public function get_position() : int { + public function get_position(): int { return $this->instancecategory->get_position(); } @@ -61,7 +61,7 @@ public function get_position() : int { * * @return float */ - public function get_weight() : float { + public function get_weight(): float { return $this->instancecategory->get_weight(); } @@ -70,7 +70,7 @@ public function get_weight() : float { * * @return array The localized category headers. */ - public function get_headers() : array { + public function get_headers(): array { return $this->instancecategory->get_headers(); } @@ -80,7 +80,7 @@ public function get_headers() : array { * @param string $languagestr The given language string * @return localized_string */ - public function get_header(string $languagestr) : localized_string { + public function get_header(string $languagestr): localized_string { $langrepo = new language_repository(); // Select the language string matching the current language. @@ -97,7 +97,7 @@ public function get_header(string $languagestr) : localized_string { * Gets the report criteria within the category. * @return array The criteria. */ - public function get_criteria() : array { + public function get_criteria(): array { return $this->reportcriteria; } @@ -117,7 +117,7 @@ public function add_criterion(report_criterion $criterion) { * * @return float|null The response value average or null. */ - public function get_avg() : ?float { + public function get_avg(): ?float { return $this->avg; } @@ -126,7 +126,7 @@ public function get_avg() : ?float { * * @return float|null The weighted result or null. */ - public function get_weighted_result() : ?float { + public function get_weighted_result(): ?float { return $this->weightedresult; } diff --git a/classes/model/report_criterion.php b/classes/model/report_criterion.php index 98c33b4..4f6ed89 100644 --- a/classes/model/report_criterion.php +++ b/classes/model/report_criterion.php @@ -51,7 +51,7 @@ public function __construct(instance_criterion $instancecriterion) { * * @return int The report criterion id */ - public function get_criterion_id() : int { + public function get_criterion_id(): int { return $this->instancecriterion->get_id(); } @@ -60,7 +60,7 @@ public function get_criterion_id() : int { * * @return int The report criterion position */ - public function get_position() : int { + public function get_position(): int { return $this->instancecriterion->get_position(); } @@ -69,7 +69,7 @@ public function get_position() : int { * * @return float */ - public function get_weight() : float { + public function get_weight(): float { return $this->instancecriterion->get_weight(); } @@ -78,7 +78,7 @@ public function get_weight() : float { * * @return array The localized strings. */ - public function get_descriptions() : array { + public function get_descriptions(): array { return $this->instancecriterion->get_descriptions(); } @@ -88,7 +88,7 @@ public function get_descriptions() : array { * @param string $languagestr The given language string * @return \mod_verbalfeedback\model\localized_string|null */ - public function get_description(string $languagestr) : ?localized_string { + public function get_description(string $languagestr): ?localized_string { $languagerepository = new language_repository(); // Select the language string matching the current language. @@ -115,7 +115,7 @@ public function add_response(response $response) { * * @return float|null The response value average or null. */ - public function get_avg() : ?float { + public function get_avg(): ?float { return $this->avg; } @@ -124,7 +124,7 @@ public function get_avg() : ?float { * * @return float|null The weighted result or null. */ - public function get_weighted_result() : ?float { + public function get_weighted_result(): ?float { $avg = $this->get_avg(); if ($avg === null || $this->get_weight() == null) { return null; @@ -136,7 +136,7 @@ public function get_weighted_result() : ?float { * Gets the students comments * @return array The students comments */ - public function get_student_comments() : array { + public function get_student_comments(): array { $comments = []; foreach ($this->responses as $response) { $comments[] = $response->get_student_comment(); diff --git a/classes/model/response.php b/classes/model/response.php index 6a2010e..4ae825e 100644 --- a/classes/model/response.php +++ b/classes/model/response.php @@ -82,7 +82,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -100,7 +100,7 @@ public function set_instance_id(int $instanceid) { * * @return int The instance id. */ - public function get_instance_id() : int { + public function get_instance_id(): int { return $this->instanceid; } @@ -118,7 +118,7 @@ public function set_criterion_id(int $criterionid) { * * @return int The criterion id. */ - public function get_criterion_id() : int { + public function get_criterion_id(): int { return $this->criterionid; } @@ -136,7 +136,7 @@ public function set_from_user_id(int $fromuserid) { * * @return int The id of the responding user. */ - public function get_from_user_id() : int { + public function get_from_user_id(): int { return $this->fromuserid; } @@ -154,14 +154,14 @@ public function set_to_user_id(int $touserid) { * * @return int The id of the rated user. */ - public function get_to_user_id() : int { + public function get_to_user_id(): int { return $this->touserid; } /** * Sets the response value. * - * @param int $value The response value. + * @param ?int $value The response value. */ public function set_value(?int $value) { $this->value = $value; @@ -172,7 +172,7 @@ public function set_value(?int $value) { * * @return ?int The response value. */ - public function get_value() : ?int { + public function get_value(): ?int { return $this->value; } @@ -190,7 +190,7 @@ public function set_student_comment(string $comment) { * * @return string The comment. */ - public function get_student_comment() : string { + public function get_student_comment(): string { return $this->studentcomment; } @@ -208,7 +208,7 @@ public function set_private_comment(string $comment) { * * @return string The comment. */ - public function get_private_comment() : string { + public function get_private_comment(): string { return $this->privatecomment; } } diff --git a/classes/model/submission.php b/classes/model/submission.php index c3c708b..8ee6176 100644 --- a/classes/model/submission.php +++ b/classes/model/submission.php @@ -78,7 +78,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -96,12 +96,10 @@ public function set_instance_id(int $instanceid) { * * @return int The instance id. */ - public function get_instance_id() : int { + public function get_instance_id(): int { return $this->instanceid; } - - /** * Sets the user id of the responding user. * @@ -116,7 +114,7 @@ public function set_from_user_id(int $fromuserid) { * * @return int The id of the responding user. */ - public function get_from_user_id() : int { + public function get_from_user_id(): int { return $this->fromuserid; } @@ -134,7 +132,7 @@ public function set_to_user_id(int $touserid) { * * @return int The id of the rated user. */ - public function get_to_user_id() : int { + public function get_to_user_id(): int { return $this->touserid; } @@ -152,7 +150,7 @@ public function set_status(int $status) { * * @return int The status. */ - public function get_status() : int { + public function get_status(): int { return $this->status; } @@ -170,7 +168,7 @@ public function set_remarks(string $remarks) { * * @return string The remarks. */ - public function get_remarks() : string { + public function get_remarks(): string { return $this->remarks; } @@ -179,7 +177,7 @@ public function get_remarks() : string { * * @return array The responses. */ - public function get_responses() : array { + public function get_responses(): array { return $this->responses; } diff --git a/classes/model/subrating.php b/classes/model/subrating.php index 1fe5928..a173f14 100644 --- a/classes/model/subrating.php +++ b/classes/model/subrating.php @@ -81,7 +81,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -89,7 +89,7 @@ public function get_id() : int { * Gets the localized titles. * @return array The localized strings. */ - public function get_titles() : array { + public function get_titles(): array { return $this->titles; } @@ -99,7 +99,7 @@ public function get_titles() : array { * @param string $languagestr The given language string * @return localized_string|null The localized title. */ - public function get_title(string $languagestr) : ?localized_string { + public function get_title(string $languagestr): ?localized_string { $languagerepository = new language_repository(); foreach ($this->get_titles() as $title) { @@ -124,7 +124,7 @@ public function add_title(localized_string $title) { * * @return array The localized subrating descriptions. */ - public function get_descriptions() : array { + public function get_descriptions(): array { return $this->descriptions; } @@ -134,7 +134,7 @@ public function get_descriptions() : array { * @param string $languagestr The given language string * @return localized_string|null The localized description. */ - public function get_description(string $languagestr) : ?localized_string { + public function get_description(string $languagestr): ?localized_string { $languagerepository = new language_repository(); foreach ($this->get_descriptions() as $description) { @@ -159,7 +159,7 @@ public function add_description(localized_string $description) { * Gets the localized verynegatives. * @return array The localized verynegative. */ - public function get_verynegatives() : array { + public function get_verynegatives(): array { return $this->verynegatives; } @@ -169,7 +169,7 @@ public function get_verynegatives() : array { * @param string $languagestr The given language string * @return localized_string|null The localized verynegative. */ - public function get_verynegative(string $languagestr) : ?localized_string { + public function get_verynegative(string $languagestr): ?localized_string { $languagerepository = new language_repository(); foreach ($this->get_verynegatives() as $verynegative) { @@ -193,7 +193,7 @@ public function add_verynegative(localized_string $verynegative) { * Gets the localized negatives. * @return array The localized negative. */ - public function get_negatives() : array { + public function get_negatives(): array { return $this->negatives; } @@ -203,7 +203,7 @@ public function get_negatives() : array { * @param string $languagestr The given language string * @return localized_string|null The localized negative. */ - public function get_negative(string $languagestr) : ?localized_string { + public function get_negative(string $languagestr): ?localized_string { $languagerepository = new language_repository(); foreach ($this->get_negatives() as $negative) { @@ -228,7 +228,7 @@ public function add_negative(localized_string $negative) { * Gets the localized positives. * @return array The localized positive. */ - public function get_positives() : array { + public function get_positives(): array { return $this->positives; } @@ -238,7 +238,7 @@ public function get_positives() : array { * @param string $languagestr The given language string * @return localized_string|null The localized positive. */ - public function get_positive(string $languagestr) : ?localized_string { + public function get_positive(string $languagestr): ?localized_string { $languagerepository = new language_repository(); foreach ($this->get_positives() as $positive) { @@ -262,7 +262,7 @@ public function add_positive(localized_string $positive) { * Gets the localized verypositives. * @return array The localized verypositive. */ - public function get_verypositives() : array { + public function get_verypositives(): array { return $this->verypositives; } @@ -272,7 +272,7 @@ public function get_verypositives() : array { * @param string $languagestr The given language string * @return localized_string|null The localized verypositive. */ - public function get_verypositive(string $languagestr) : ?localized_string { + public function get_verypositive(string $languagestr): ?localized_string { $languagerepository = new language_repository(); foreach ($this->get_verypositives() as $verypositive) { diff --git a/classes/model/template/parametrized_template_category.php b/classes/model/template/parametrized_template_category.php index 128e78a..9d146e5 100644 --- a/classes/model/template/parametrized_template_category.php +++ b/classes/model/template/parametrized_template_category.php @@ -67,7 +67,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -85,7 +85,7 @@ public function set_template_category_id(int $categoryid) { * * @return int The category id */ - public function get_template_category_id() : int { + public function get_template_category_id(): int { return $this->categoryid; } @@ -103,7 +103,7 @@ public function set_position(int $position) { * * @return int The parametrized template category position */ - public function get_position() : int { + public function get_position(): int { return $this->position; } @@ -121,7 +121,7 @@ public function set_weight(float $weight) { * * @return float */ - public function get_weight() : float { + public function get_weight(): float { return $this->weight; } } diff --git a/classes/model/template/parametrized_template_criterion.php b/classes/model/template/parametrized_template_criterion.php index a4912e2..5a7c472 100644 --- a/classes/model/template/parametrized_template_criterion.php +++ b/classes/model/template/parametrized_template_criterion.php @@ -68,7 +68,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -86,7 +86,7 @@ public function set_template_criterion_id(int $criterionid) { * * @return int The template criterion id */ - public function get_template_criterion_id() : int { + public function get_template_criterion_id(): int { return $this->criterionid; } @@ -104,7 +104,7 @@ public function set_position(int $position) { * * @return int The template criterion position */ - public function get_position() : int { + public function get_position(): int { return $this->position; } @@ -122,7 +122,7 @@ public function set_weight(float $weight) { * * @return float */ - public function get_weight() : float { + public function get_weight(): float { return $this->weight; } } diff --git a/classes/model/template/template.php b/classes/model/template/template.php index faede6b..6c8f6d6 100644 --- a/classes/model/template/template.php +++ b/classes/model/template/template.php @@ -71,7 +71,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -89,7 +89,7 @@ public function set_name(string $name) { * * @return string The template name. */ - public function get_name() : string { + public function get_name(): string { return $this->name; } @@ -107,7 +107,7 @@ public function set_description(string $description) { * * @return string The template description */ - public function get_description() : string { + public function get_description(): string { return $this->description; } @@ -134,7 +134,7 @@ public function add_template_category(parametrized_template_category $templateca * * @return parametrized_template_category[] The parametrized template categories */ - public function get_template_categories() : array { + public function get_template_categories(): array { return $this->templatecategories; } } diff --git a/classes/model/template/template_category.php b/classes/model/template/template_category.php index c116978..5823a50 100644 --- a/classes/model/template/template_category.php +++ b/classes/model/template/template_category.php @@ -63,7 +63,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -81,7 +81,7 @@ public function set_unique_name(string $uniquename) { * * @return string The category unique name */ - public function get_unique_name() : string { + public function get_unique_name(): string { return $this->uniquename; } @@ -108,7 +108,7 @@ public function add_header(localized_string $header) { * * @return array The localized template category headers */ - public function get_headers() : array { + public function get_headers(): array { return $this->headers; } @@ -135,7 +135,7 @@ public function add_template_criterion(parametrized_template_criterion $template * * @return array The template category criteria */ - public function get_template_criteria() : array { + public function get_template_criteria(): array { return $this->templatecriteria; } } diff --git a/classes/model/template/template_criterion.php b/classes/model/template/template_criterion.php index 8d3f575..acdbb19 100644 --- a/classes/model/template/template_criterion.php +++ b/classes/model/template/template_criterion.php @@ -64,7 +64,7 @@ public function set_id(int $id) { * * @return int The id. */ - public function get_id() : int { + public function get_id(): int { return $this->id; } @@ -91,7 +91,7 @@ public function add_description(localized_string $description) { * * @return array The localized strings. */ - public function get_descriptions() : array { + public function get_descriptions(): array { return $this->descriptions; } @@ -118,7 +118,7 @@ public function add_subrating(subrating $subrating) { * * @return array The criteria's subratings */ - public function get_subratings() : array { + public function get_subratings(): array { return $this->subratings; } } diff --git a/classes/output/template_criterion_list.php b/classes/output/template_criterion_list.php index 6fb26f4..9d3679c 100644 --- a/classes/output/template_criterion_list.php +++ b/classes/output/template_criterion_list.php @@ -39,12 +39,12 @@ */ class template_criterion_list implements renderable, templatable { /** - * @var array + * @var array $templatecriteria The template criteria data */ protected $templatecriteria = []; /** - * @var + * @var string $newtemplatecriterionurl The url to create a new template criterion */ protected $newtemplatecriterionurl; @@ -88,19 +88,19 @@ public function export_for_template(renderer_base $output) { */ class template_criterion_view_model { /** - * @var int + * @var int The criterion id */ public $id; /** - * @var + * @var string The criterion text */ public $text; /** - * @var string + * @var string The edit url */ public $editurl; /** - * @var + * @var string The delete url */ public $deleteurl; diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index 0c2e827..27a2098 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -56,7 +56,7 @@ class provider implements * @param collection $items a reference to the collection to use to store the metadata. * @return collection the updated collection of metadata items. */ - public static function get_metadata(collection $items) : collection { + public static function get_metadata(collection $items): collection { $items->add_database_table( 'verbalfeedback_submission', [ @@ -89,7 +89,7 @@ public static function get_metadata(collection $items) : collection { * @param int $userid the userid. * @return contextlist the list of contexts containing user info for the user. */ - public static function get_contexts_for_userid(int $userid) : contextlist { + public static function get_contexts_for_userid(int $userid): contextlist { // Fetch all verbalfeedback activity contexts where the user is participating. $sql = "SELECT ctx.id FROM {context} ctx diff --git a/classes/repository/instance_repository.php b/classes/repository/instance_repository.php index 56d4268..a46bfee 100644 --- a/classes/repository/instance_repository.php +++ b/classes/repository/instance_repository.php @@ -49,7 +49,7 @@ class instance_repository { * @param int $id The language id. * @return instance|null The language. */ - public static function get_by_id(int $id) : instance { + public static function get_by_id(int $id): instance { global $DB; // Return cached $byid instance if available and if we are not running a php unit test. @@ -162,6 +162,16 @@ public static function get_by_id(int $id) : instance { return $instance; } + /** + * Get all strings. + * + * @param string $type + * @param int $subratingid + * @param bool $throwonerror + * @return array + * @throws \coding_exception + * @throws \dml_exception + */ private static function get_strings(string $type, int $subratingid, bool $throwonerror = false): array { global $DB; diff --git a/classes/repository/language_repository.php b/classes/repository/language_repository.php index 284a641..1f31173 100644 --- a/classes/repository/language_repository.php +++ b/classes/repository/language_repository.php @@ -57,7 +57,7 @@ public function save(language $language) { * @param int $id The language id * @return bool True, if successful */ - public function delete_by_id(int $id) : bool { + public function delete_by_id(int $id): bool { global $DB; return $DB->delete_records(tables::LANGUAGE_TABLE, ['id' => $id]); } @@ -66,7 +66,7 @@ public function delete_by_id(int $id) : bool { * Selects all languages in the database * @return array The resulting languages */ - public function get_all() : array { + public function get_all(): array { global $DB; $languages = []; @@ -82,7 +82,7 @@ public function get_all() : array { * @param int $id The language id. * @return language|null The language. */ - public function get_by_id(int $id) : language { + public function get_by_id(int $id): language { global $DB; $dbo = $DB->get_record(tables::LANGUAGE_TABLE, ["id" => $id]); return db_language::to_language($dbo); diff --git a/classes/repository/model/db_instance.php b/classes/repository/model/db_instance.php index 97f1198..5f09a64 100644 --- a/classes/repository/model/db_instance.php +++ b/classes/repository/model/db_instance.php @@ -30,51 +30,51 @@ */ class db_instance { /** - * @var int + * @var int The id */ public $id = 0; /** - * @var + * @var int The template id */ public $templateid; /** - * @var + * @var string The name */ public $name; /** - * @var + * @var int The course */ public $course; /** - * @var + * @var string The intro */ public $intro; /** - * @var + * @var int The intro format */ public $introformat; /** - * @var + * @var int The status */ public $status; /** - * @var + * @var int The time open */ public $timeopen; /** - * @var + * @var int The time close */ public $timeclose; /** - * @var + * @var int The time modified */ public $timemodified; /** - * @var + * @var string The release type */ public $releasetype; /** - * @var + * @var bool Whether the instance is released */ public $released; @@ -108,7 +108,7 @@ public static function from_instance(instance $instance) { * @return instance * @throws \Exception */ - public static function to_instance($dbo) : instance { + public static function to_instance($dbo): instance { if (!isset($dbo->course) || $dbo->course == null) { throw new \Exception('Missing $dbo->course.'); } diff --git a/classes/repository/model/db_instance_category.php b/classes/repository/model/db_instance_category.php index 5180536..389b54b 100644 --- a/classes/repository/model/db_instance_category.php +++ b/classes/repository/model/db_instance_category.php @@ -30,23 +30,23 @@ */ class db_instance_category { /** - * @var + * @var int The id of the category */ public $id; /** - * @var + * @var int The id of the instance */ public $instanceid; /** - * @var + * @var int The id of the category */ public $paramtemplatecategoryid; /** - * @var + * @var int The position of the category */ public $position; /** - * @var + * @var float The weight of the category */ public $weight; @@ -73,7 +73,7 @@ public static function from_instance_category(instance_category $category, int $ * @param object $dbo The database object * @return instance_category */ - public static function to_instance_category($dbo) : instance_category { + public static function to_instance_category($dbo): instance_category { $category = new instance_category(); if (isset($dbo->id)) { $category->set_id($dbo->id); diff --git a/classes/repository/model/db_instance_criterion.php b/classes/repository/model/db_instance_criterion.php index 811cc60..132254a 100644 --- a/classes/repository/model/db_instance_criterion.php +++ b/classes/repository/model/db_instance_criterion.php @@ -30,23 +30,23 @@ */ class db_instance_criterion { /** - * @var + * @var int The id */ public $id; /** - * @var + * @var int The parametrized template criterion id */ public $paramtemplatecriterionid; /** - * @var + * @var int The category id */ public $categoryid; /** - * @var + * @var int The position */ public $position; /** - * @var + * @var float The weight */ public $weight; @@ -73,7 +73,7 @@ public static function from_instance_criterion(instance_criterion $criterion, in * @param object $dbo The database object * @return instance_criterion */ - public static function to_instance_criterion($dbo) : instance_criterion { + public static function to_instance_criterion($dbo): instance_criterion { $criterion = new instance_criterion(); if (isset($dbo->id)) { $criterion->set_id($dbo->id); diff --git a/classes/repository/model/db_instance_subrating.php b/classes/repository/model/db_instance_subrating.php index e0e6f92..242f967 100644 --- a/classes/repository/model/db_instance_subrating.php +++ b/classes/repository/model/db_instance_subrating.php @@ -54,7 +54,7 @@ public static function from_subrating(subrating $subrating, int $criterionid) { * @param object $dbo The database object * @return subrating */ - public static function to_subrating($dbo) : subrating { + public static function to_subrating($dbo): subrating { $subrating = new subrating(); if (isset($dbo->id)) { $subrating->set_id($dbo->id); diff --git a/classes/repository/model/db_language.php b/classes/repository/model/db_language.php index ad76cc6..a0f80d9 100644 --- a/classes/repository/model/db_language.php +++ b/classes/repository/model/db_language.php @@ -30,11 +30,11 @@ */ class db_language { /** - * @var int + * @var int The language id */ public $id = 0; /** - * @var + * @var string The language */ public $language; @@ -44,7 +44,7 @@ class db_language { * @param language $language * @return db_language */ - public static function from_language(language $language) : db_language { + public static function from_language(language $language): db_language { $dbo = new db_language(); $dbo->id = $language->get_id(); $dbo->language = $language->get_language(); @@ -57,7 +57,7 @@ public static function from_language(language $language) : db_language { * @param object $dbo The database object * @return language */ - public static function to_language($dbo) : language { + public static function to_language($dbo): language { $language = new language(); if (isset($dbo->id)) { $language->set_id($dbo->id); diff --git a/classes/repository/model/db_localized_string.php b/classes/repository/model/db_localized_string.php index 0cd9f89..9ff237e 100644 --- a/classes/repository/model/db_localized_string.php +++ b/classes/repository/model/db_localized_string.php @@ -80,7 +80,7 @@ public static function from_localized_string(localized_string $localizedstring, * @return localized_string The localized string * @throws \Exception */ - public static function to_localized_string($dbo) : localized_string { + public static function to_localized_string($dbo): localized_string { if (isset($dbo->languageid) && isset($dbo->id) && isset($dbo->string)) { return new localized_string($dbo->languageid, $dbo->id, $dbo->string); } else { diff --git a/classes/repository/model/db_parametrized_category.php b/classes/repository/model/db_parametrized_category.php index c3dd650..2c28e36 100644 --- a/classes/repository/model/db_parametrized_category.php +++ b/classes/repository/model/db_parametrized_category.php @@ -30,23 +30,23 @@ */ class db_parametrized_category { /** - * @var + * @var int $id The id */ public $id; /** - * @var + * @var int $templateid The category template id */ public $templateid; /** - * @var + * @var int $categoryid The category id */ public $categoryid; /** - * @var + * @var int The category position */ public $position; /** - * @var + * @var float The category weight */ public $weight; @@ -73,7 +73,7 @@ public static function from_parametrized_category(parametrized_template_category * @param object $dbo The database object * @return parametrized_template_category */ - public static function to_parametrized_category($dbo) : parametrized_template_category { + public static function to_parametrized_category($dbo): parametrized_template_category { $category = new parametrized_template_category(); if (isset($dbo->id)) { $category->set_id($dbo->id); diff --git a/classes/repository/model/db_parametrized_criterion.php b/classes/repository/model/db_parametrized_criterion.php index afce388..0d6077b 100644 --- a/classes/repository/model/db_parametrized_criterion.php +++ b/classes/repository/model/db_parametrized_criterion.php @@ -68,7 +68,7 @@ public static function from_parametrized_criterion(parametrized_template_criteri * @param object $dbo The database object * @return parametrized_template_criterion */ - public static function to_parametrized_criterion($dbo) : parametrized_template_criterion { + public static function to_parametrized_criterion($dbo): parametrized_template_criterion { $paramcriterion = new parametrized_template_criterion(); if (isset($dbo->id)) { $paramcriterion->set_id($dbo->id); diff --git a/classes/repository/model/db_response.php b/classes/repository/model/db_response.php index 0e0648c..7ff139e 100644 --- a/classes/repository/model/db_response.php +++ b/classes/repository/model/db_response.php @@ -30,15 +30,15 @@ */ class db_response { /** - * @var int + * @var int The id */ public $id = 0; /** - * @var + * @var int The submission id */ public $submissionid; /** - * @var + * @var int The instance id */ public $instanceid; /** @var int The criterion id */ @@ -81,7 +81,7 @@ public static function from_response(response $response, int $submissionid) { * @param object $dbo The database object * @return response */ - public static function to_response($dbo) : response { + public static function to_response($dbo): response { $response = new response(); if (isset($dbo->id)) { $response->set_id($dbo->id); diff --git a/classes/repository/model/db_submission.php b/classes/repository/model/db_submission.php index 6e5edec..54a3528 100644 --- a/classes/repository/model/db_submission.php +++ b/classes/repository/model/db_submission.php @@ -30,11 +30,11 @@ */ class db_submission { /** - * @var int + * @var int The id of the submission */ public $id = 0; /** - * @var + * @var int The id of the instance */ public $instanceid; /** @var int The rating user */ @@ -42,11 +42,11 @@ class db_submission { /** @var int The id of the rated user */ public $touserid; /** - * @var + * @var int The status of the submission */ public $status; /** - * @var + * @var string The remarks */ public $remarks; @@ -73,7 +73,7 @@ public static function from_submission(submission $submission) { * @param object $dbo The database object * @return submission */ - public static function to_submission($dbo) : submission { + public static function to_submission($dbo): submission { $submission = new submission(); if (isset($dbo->id)) { $submission->set_id($dbo->id); diff --git a/classes/repository/model/db_subrating.php b/classes/repository/model/db_subrating.php index dc9399a..a4e56a5 100644 --- a/classes/repository/model/db_subrating.php +++ b/classes/repository/model/db_subrating.php @@ -56,7 +56,7 @@ public static function from_subrating(subrating $subrating, int $criterionid) { * @param object $dbo The database object * @return subrating */ - public static function to_subrating($dbo) : subrating { + public static function to_subrating($dbo): subrating { $subrating = new subrating(); if (isset($dbo->id)) { $subrating->set_id($dbo->id); diff --git a/classes/repository/model/db_template.php b/classes/repository/model/db_template.php index 25650bb..7625287 100644 --- a/classes/repository/model/db_template.php +++ b/classes/repository/model/db_template.php @@ -62,7 +62,7 @@ public static function from_template(template $template) { * @param object $dbo The database object * @return template The template */ - public static function to_template($dbo) : template { + public static function to_template($dbo): template { $template = new template(); if (isset($dbo->id)) { $template->set_id($dbo->id); diff --git a/classes/repository/model/db_template_category.php b/classes/repository/model/db_template_category.php index b6cf52a..8a1358d 100644 --- a/classes/repository/model/db_template_category.php +++ b/classes/repository/model/db_template_category.php @@ -30,11 +30,11 @@ */ class db_template_category { /** - * @var int + * @var int The id */ public $id = 0; /** - * @var + * @var string The unique name */ public $uniquename; @@ -57,7 +57,7 @@ public static function from_template_category(template_category $templatecategor * @param object $dbo The database object * @return template_category The template category */ - public static function to_template_category($dbo) : template_category { + public static function to_template_category($dbo): template_category { $templatecategory = new template_category(); if (isset($dbo->id)) { $templatecategory->set_id($dbo->id); diff --git a/classes/repository/model/db_template_criterion.php b/classes/repository/model/db_template_criterion.php index bee5118..fa2cb58 100644 --- a/classes/repository/model/db_template_criterion.php +++ b/classes/repository/model/db_template_criterion.php @@ -57,7 +57,7 @@ public static function from_template_criterion(template_criterion $templatecrite * @param object $dbo The database object * @return template_criterion The template criterion */ - public static function to_template_criterion($dbo) : template_criterion { + public static function to_template_criterion($dbo): template_criterion { $templatecriterion = new template_criterion(); if (isset($dbo->id)) { $templatecriterion->set_id($dbo->id); diff --git a/classes/repository/submission_repository.php b/classes/repository/submission_repository.php index ee7b6d8..53c967f 100644 --- a/classes/repository/submission_repository.php +++ b/classes/repository/submission_repository.php @@ -79,7 +79,7 @@ public function save(submission $submission) { * @param int $id The submission id * @return bool True, if successful */ - public function delete_by_id(int $id) : bool { + public function delete_by_id(int $id): bool { global $DB; return $DB->delete_records('verbalfeedback_language', ['id' => $id]); } @@ -89,7 +89,7 @@ public function delete_by_id(int $id) : bool { * @param int $id The submission id * @return submission|null The submission */ - public function get_by_id(int $id) : submission { + public function get_by_id(int $id): submission { global $DB; $dbo = $DB->get_record(tables::SUBMISSION_TABLE, ["id" => $id]); $submission = db_submission::to_submission($dbo); @@ -109,7 +109,7 @@ public function get_by_id(int $id) : submission { * @param int $touserid The id of the rated user. * @return submission|null The submission. */ - public function get_by_instance_and_fromuser_and_touser(int $instanceid, int $fromuserid, int $touserid) : submission { + public function get_by_instance_and_fromuser_and_touser(int $instanceid, int $fromuserid, int $touserid): submission { global $DB; $dbo = $DB->get_record(tables::SUBMISSION_TABLE, ["instanceid" => $instanceid, "fromuserid" => $fromuserid, "touserid" => $touserid, ], ); @@ -129,7 +129,7 @@ public function get_by_instance_and_fromuser_and_touser(int $instanceid, int $fr * @param int $touserid The id of the rated user. * @return array|null The submission. */ - public function get_by_instance_and_touser(int $instanceid, int $touserid) : array { + public function get_by_instance_and_touser(int $instanceid, int $touserid): array { global $DB; $dbos = $DB->get_records(tables::SUBMISSION_TABLE, ["instanceid" => $instanceid, "touserid" => $touserid]); diff --git a/classes/repository/template_category_repository.php b/classes/repository/template_category_repository.php index 6344e43..f2b0881 100644 --- a/classes/repository/template_category_repository.php +++ b/classes/repository/template_category_repository.php @@ -42,7 +42,7 @@ class template_category_repository { * * @return array The resulting categories. */ - public function get_all() : array { + public function get_all(): array { global $DB; static $results = null; @@ -79,7 +79,7 @@ public function get_all() : array { * @param int $id The category template id. * @return template_category|null The template categories. */ - public function get_by_id(int $id) : ?template_category { + public function get_by_id(int $id): ?template_category { $all = $this->get_all(); return $all[$id] ?? null; } @@ -136,7 +136,7 @@ public function save(template_category $templatecategory) { * @param int $id The id of the category template. * @return bool True, if successful */ - public function delete_by_id(int $id) : bool { + public function delete_by_id(int $id): bool { global $DB; try { $transaction = $DB->start_delegated_transaction(); @@ -159,7 +159,7 @@ public function delete_by_id(int $id) : bool { * @return array The category headers * @throws \dml_exception */ - private function get_headers($foreignkey) : array { + private function get_headers($foreignkey): array { global $DB; $dboheaders = $DB->get_records('verbalfeedback_local_string', @@ -178,7 +178,7 @@ private function get_headers($foreignkey) : array { * @return array * @throws \dml_exception */ - private function get_headers_by_category_ids() : array { + private function get_headers_by_category_ids(): array { global $DB; $headers = []; @@ -200,7 +200,7 @@ private function get_headers_by_category_ids() : array { * @return array The parametrized criteria * @throws \dml_exception */ - private function get_parametrized_criteria($categoryid) : array { + private function get_parametrized_criteria($categoryid): array { global $DB; $dboparametrizedcriteria = $DB->get_records('verbalfeedback_t_param_crit', ['categoryid' => $categoryid]); @@ -216,7 +216,7 @@ private function get_parametrized_criteria($categoryid) : array { * @return array The paramterized criteria in an array hashed by category id * @throws \dml_exception */ - private function get_parameterized_criteria_by_categoryid() : array { + private function get_parameterized_criteria_by_categoryid(): array { global $DB; $critbycatid = []; diff --git a/classes/repository/template_criterion_repository.php b/classes/repository/template_criterion_repository.php index 99f1f45..61c1caa 100644 --- a/classes/repository/template_criterion_repository.php +++ b/classes/repository/template_criterion_repository.php @@ -44,7 +44,7 @@ class template_criterion_repository { * Gets the category templates * @return array. */ - public function get_all() : array { + public function get_all(): array { global $DB; $results = []; @@ -94,7 +94,7 @@ private function get_all_template_criterion(): array { * @param int $id The criteria template id. * @return template_criterion|null The template criterion. */ - public function get_by_id(int $id) : ?template_criterion { + public function get_by_id(int $id): ?template_criterion { static $all = null; if ($all === null || PHPUNIT_TEST) { @@ -109,7 +109,7 @@ public function get_by_id(int $id) : ?template_criterion { * @param int $id the template category id. * @return array. */ - public function get_by_template_category_id(int $id) : array { + public function get_by_template_category_id(int $id): array { global $DB; $results = []; $dboparamcriteria = $DB->get_records(tables::PARAMETRIZED_TEMPLATE_CRITERION_TABLE, ['categoryid' => $id]); @@ -285,12 +285,14 @@ public static function dbo_to_template_criterion($dbo) { /** * Get all localized strings for a type, hashed by foreignkey, cached in memory for speed. + * + * // phpcs:ignore moodle.Commenting.ValidTags.Invalid * @TODO - evaluate this for memory usage. * @param string $type * @return array * @throws \dml_exception */ - private function get_all_localized_strings_for_type(string $type) : array { + private function get_all_localized_strings_for_type(string $type): array { global $DB; static $strings = []; @@ -324,7 +326,7 @@ private function get_all_localized_strings_for_type(string $type) : array { * @return array Localized strings * @throws \dml_exception */ - private function get_localized_strings(int $foreignkey, string $type) : array { + private function get_localized_strings(int $foreignkey, string $type): array { if (!localized_string_type::exists($type)) { throw new \Exception("Unknown localized string type."); } diff --git a/classes/repository/template_repository.php b/classes/repository/template_repository.php index ee9bd89..269d53a 100644 --- a/classes/repository/template_repository.php +++ b/classes/repository/template_repository.php @@ -38,7 +38,7 @@ class template_repository { * Gets all the templates within the database. * @return array The resulting templates. */ - public function get_all() : array { + public function get_all(): array { global $DB; $results = []; $dbotemplates = $DB->get_records(tables::TEMPLATE_TABLE); @@ -64,7 +64,7 @@ public function get_all() : array { * @param int $id The template id. * @return template|null The template. */ - public function get_by_id(int $id) : template { + public function get_by_id(int $id): template { global $DB; $dbo = $DB->get_record(tables::TEMPLATE_TABLE, ['id' => $id]); $template = db_template::to_template($dbo); @@ -118,7 +118,7 @@ public function save(template $template) { * @param int $id The id of the template. * @return bool true */ - public function delete_by_id(int $id) : bool { + public function delete_by_id(int $id): bool { global $DB; try { $transaction = $DB->start_delegated_transaction(); diff --git a/classes/service/report_service.php b/classes/service/report_service.php index 2855d78..142ebef 100644 --- a/classes/service/report_service.php +++ b/classes/service/report_service.php @@ -56,7 +56,7 @@ public function __construct() { * @return int The id of the submission. * @throws dml_exception A DML specific exception is thrown for any errors. */ - public function create_report(int $instanceid, int $touserid) : report { + public function create_report(int $instanceid, int $touserid): report { $instance = $this->instancerepo->get_by_id($instanceid); $submissions = $this->submissionrepo->get_by_instance_and_touser($instanceid, $touserid); diff --git a/classes/utils/graph_utils.php b/classes/utils/graph_utils.php index 76096ec..64b6608 100644 --- a/classes/utils/graph_utils.php +++ b/classes/utils/graph_utils.php @@ -24,12 +24,8 @@ namespace mod_verbalfeedback\utils; -defined('MOODLE_INTERNAL') || die(); - - use mod_verbalfeedback\model\report; - /** * Class for creating graphs. For example, to display on the report. * @@ -45,7 +41,7 @@ class graph_utils { * @param report $report The report, for which the graph shall be created. * @return string The SVG image as XML string. */ - public static function create_radar_graph(report $report) : string { + public static function create_radar_graph(report $report): string { $settings = [ 'back_colour' => '#eee', 'back_stroke_width' => 0, @@ -94,7 +90,7 @@ public static function create_radar_graph(report $report) : string { if (strlen ($testlabel) <= $maxlen) { $label = $testlabel . ' ...'; } else { - $label = substr($testlabel,0,15) . '...'; + $label = substr($testlabel, 0, 15) . '...'; } } else { $label = $fulllabel; @@ -104,7 +100,7 @@ public static function create_radar_graph(report $report) : string { } } - $graph = self::getSvgGraph($width, $height, $settings); + $graph = self::getsvggraph($width, $height, $settings); $graph->values($values); @@ -113,19 +109,19 @@ public static function create_radar_graph(report $report) : string { /** * Wrapper for creating a new SVGGraph instance. - * @param $w - * @param $h - * @param $settings - * @param $subgraph + * @param int $w The width of the graph. + * @param int $h The height of the graph. + * @param array $settings The settings for the graph. + * @param bool $subgraph Whether the graph is a subgraph. * @return \Goat1000\SVGGraph\SVGGraph */ - public static function getSvgGraph($w, $h, $settings = null, $subgraph = false) { + public static function getsvggraph($w, $h, $settings = null, $subgraph = false) { $dir = (version_compare(PHP_VERSION, '8.1.14') >= 0) ? '81x' : '74x'; - require_once implode(DIRECTORY_SEPARATOR, - [dirname(__FILE__), '..', 'vendor', $dir, 'autoload.php']); + require_once(implode(DIRECTORY_SEPARATOR, + [dirname(__FILE__), '..', 'vendor', $dir, 'autoload.php'])); return new \Goat1000\SVGGraph\SVGGraph($w, $h, $settings, $subgraph); } diff --git a/classes/utils/user_utils.php b/classes/utils/user_utils.php index 8706ae2..328f023 100644 --- a/classes/utils/user_utils.php +++ b/classes/utils/user_utils.php @@ -78,11 +78,11 @@ public static function can_view_all_reports(context_module $context, $userid) { * Whether the user can view their own report. * * @param instance $instance The verbal feedback instance data. - * @param context_module|null $context The context the verbal feedback belongs to + * @param ?context_module|null $context The context the verbal feedback belongs to * @return bool * @throws coding_exception */ - public static function can_view_own_report(instance $instance, context_module $context = null) { + public static function can_view_own_report(instance $instance, ?context_module $context = null) { $isreleased = $instance->reports_are_released(); // Get context if not provided. if (empty($context)) { diff --git a/db/install.php b/db/install.php index 8dfff60..8e981f0 100644 --- a/db/install.php +++ b/db/install.php @@ -57,7 +57,7 @@ function xmldb_verbalfeedback_install() { $categoryrepository = new template_category_repository(); $templaterepository = new template_repository(); - $importdata = helper::parseYamlFile($yamlpath); + $importdata = helper::parseyamlfile($yamlpath); foreach ($importdata->languages as $yamllang) { if ($yamllang->id == null) { $lang = new language(0, $yamllang->language); diff --git a/db/upgradelib.php b/db/upgradelib.php index 51fd8a2..5b10f3f 100644 --- a/db/upgradelib.php +++ b/db/upgradelib.php @@ -41,7 +41,7 @@ function mod_verbalfeedback_ends_with($haystack, $needle) { * @param int|null $x The int or null * @return int The int */ -function mod_verbalfeedback_replace_null_with_zero(?int $x) : int { +function mod_verbalfeedback_replace_null_with_zero(?int $x): int { if ($x == null) { return 0; } diff --git a/lang/de/verbalfeedback.php b/lang/de/verbalfeedback.php index 0b28626..d23a7cc 100644 --- a/lang/de/verbalfeedback.php +++ b/lang/de/verbalfeedback.php @@ -26,8 +26,8 @@ defined('MOODLE_INTERNAL') || die(); $string['activity'] = 'Aktivität'; -$string['additem'] = 'Kriterium hinzufügen'; $string['addanewquestion'] = 'Eine neue Frage hinzufügen'; +$string['additem'] = 'Kriterium hinzufügen'; $string['allowundodecline'] = 'Teilnehmer/innen erlauben, das Einreichen eines abgelehnten Feedbacks rückgängig zu machen'; $string['allparticipants'] = 'Alle Kursteilnehmer/innen'; $string['anonymous'] = 'Anonym'; @@ -42,8 +42,8 @@ $string['closebeforeopen'] = 'Das Enddatum kann nicht vor dem Startdatum liegen.'; $string['commentfromuser'] = '{$a->comment} ({$a->fromuser})'; $string['comments'] = 'Kommentare'; -$string['confirmquestiondeletion'] = 'Wollen Sie diese Frage wirklich löschen?'; $string['confirmfinaliseanonymousfeedback'] = 'Damit werden Ihre Antworten auf Ihr Feedback für {$a->name} anonymisiert. Sie werden Ihre Antworten nicht mehr ändern können, sobald dies geschehen ist. Möchten Sie den Vorgang fortsetzen?'; +$string['confirmquestiondeletion'] = 'Wollen Sie diese Frage wirklich löschen?'; $string['course'] = 'Kurs'; $string['criteria'] = 'Kriterien'; $string['criterion'] = 'Kriterium'; @@ -73,24 +73,24 @@ $string['enableselfreview'] = 'Selbstbeurteilung aktivieren'; $string['entercomment'] = 'Geben Sie hier Ihren Kommentar ein.'; $string['enterquestion'] = 'Fragetext eingeben...'; -$string['errorverbalfeedbacknotfound'] = 'Verbales Feedback nicht gefunden.'; -$string['errorblankquestion'] = 'Erforderlich.'; $string['errorblankdeclinereason'] = 'Erforderlich.'; +$string['errorblankquestion'] = 'Erforderlich.'; $string['errorcannotadditem'] = 'Konnte das Kriterium des verbalen Feedbacks nicht hinzufügen.'; $string['errorcannotparticipate'] = 'Sie können an dieser verbalen Feedback-Aktivität nicht teilnehmen.'; $string['errorcannotrespond'] = 'Sie können in dieser verbalen Feedback-Aktivität kein Feedback geben.'; $string['errorcannotupdateitem'] = 'Konnte das Kriterium des verbalen Feedbacks nicht aktualisieren.'; $string['errorcannotviewallreports'] = 'Sie können nicht die Bewertungen anderer Teilnehmer*innen sehen.'; -$string['erroritemnotfound'] = 'Das Kriterium des verbalen Feedbacks wurde nicht gefunden.'; $string['errorinvalidstatus'] = 'Ungültiger Status'; +$string['erroritemnotfound'] = 'Das Kriterium des verbalen Feedbacks wurde nicht gefunden.'; $string['errornocaptoedititems'] = 'Sie haben aktuell kein Recht, verbales Feedback-Kriterien zu bearbeiten'; $string['errornotenrolled'] = 'Sie müssen in diesem Kurs eingeschrieben sein, um an dieser verbalen Feedback-Aktivität teilnehmen zu können.'; -$string['errornotingroup'] = 'Sie müssen Mitglied einer Gruppe sein, um an dieser verbalen Feedback-Aktivität teilnehmen zu können. Bitte kontaktieren Sie Ihren Kursadministrator.'; $string['errornothingtodecline'] = 'Es gibt kein Feedback zum Ablehnen.'; +$string['errornotingroup'] = 'Sie müssen Mitglied einer Gruppe sein, um an dieser verbalen Feedback-Aktivität teilnehmen zu können. Bitte kontaktieren Sie Ihren Kursadministrator.'; $string['errorquestionstillinuse'] = 'Diese Frage kann nicht gelöscht werden, da sie noch von mindestens einer verbalen Feedback-Instanz verwendet wird.'; $string['errorreportnotavailable'] = 'Ihr Feedbackbericht ist noch nicht verfügbar.'; $string['errorresponsesavefailed'] = 'Während des Speicherns der Antworten ist ein Fehler aufgetreten. Bitte versuchen Sie es später noch einmal.'; $string['errorroleconflict'] = 'Die/der aktuelle Nutzer/in ist für diese Instanz gleichzeitig Teilnehmer/in und Trainer/in, was nicht erlaubt ist.'; +$string['errorverbalfeedbacknotfound'] = 'Verbales Feedback nicht gefunden.'; $string['factor'] = 'Faktor'; $string['feedbacksurvey'] = 'Feedback-Umfrage für {$a}'; $string['feedbackgiven'] = 'Feedback gegeben'; @@ -222,7 +222,6 @@ $string['verbalfeedback:view'] = 'Verbales Feedback anzeigen'; $string['verbalfeedback:viewanalysepage'] = 'Verbales Feedback-Analyse anzeigen'; $string['verbalfeedback:view_all_reports'] = 'Verbales Feedback-Berichte aller Teilnehmer/innen anzeigen'; -$string['verbalfeedbacksettings'] = 'Verbales Feedback-Einstellungen'; $string['verbalfeedbacklanguages'] = 'Verbales Feedback-Sprachen'; $string['verbalfeedbacksettings'] = 'Verbales Feedback-Einstellungen'; $string['viewfeedbackforuser'] = 'Verbales Feedback für die/den Teilnehmer/in'; diff --git a/lang/en/verbalfeedback.php b/lang/en/verbalfeedback.php index 315aae0..50223f5 100644 --- a/lang/en/verbalfeedback.php +++ b/lang/en/verbalfeedback.php @@ -25,8 +25,8 @@ defined('MOODLE_INTERNAL') || die(); $string['activity'] = 'Activity'; -$string['additem'] = 'Add item'; $string['addanewquestion'] = 'Add a new question'; +$string['additem'] = 'Add item'; $string['allowundodecline'] = 'Allow participants to undo declined feedback submissions'; $string['allparticipants'] = 'All course participants'; $string['anonymous'] = 'Anonymous'; @@ -40,8 +40,8 @@ $string['closebeforeopen'] = 'You have specified a close date before the open date.'; $string['commentfromuser'] = '{$a->comment} ({$a->fromuser})'; $string['comments'] = 'Comments'; -$string['confirmquestiondeletion'] = 'Are you sure you want to delete this question?'; $string['confirmfinaliseanonymousfeedback'] = 'This will anonymise your responses on your feedback for {$a->name}. You will no longer be able to change your responses once it has been done. Proceed?'; +$string['confirmquestiondeletion'] = 'Are you sure you want to delete this question?'; $string['course'] = 'Course'; $string['criteria'] = 'Criteria'; $string['criterion'] = 'Criterion'; @@ -70,8 +70,6 @@ $string['edittemplate'] = 'Edit template'; $string['enableselfreview'] = 'Enable self-review'; $string['entercomment'] = 'Enter your comment here.'; -$string['enterquestion'] = 'Enter question text...'; -$string['errorverbalfeedbacknotfound'] = 'verbal feedback not found.'; $string['errorblankquestion'] = 'Required.'; $string['errorblankdeclinereason'] = 'Required.'; $string['errorcannotadditem'] = 'Cannot add the verbal feedback item.'; @@ -79,16 +77,18 @@ $string['errorcannotrespond'] = 'You cannot give feedback within this verbal feedback activity.'; $string['errorcannotupdateitem'] = 'Cannot update the verbal feedback item.'; $string['errorcannotviewallreports'] = 'You cannot view other participants results.'; -$string['erroritemnotfound'] = 'The verbal feedback item was not found.'; $string['errorinvalidstatus'] = 'Invalid status'; +$string['erroritemnotfound'] = 'The verbal feedback item was not found.'; $string['errornocaptoedititems'] = 'Sorry, but you don\'t have the capability to edit verbal feedback items.'; $string['errornotenrolled'] = 'You need to be enrolled in this course in order to be able to participate in this verbal feedback activity.'; -$string['errornotingroup'] = 'You need to be in a group in order to be able to participate in this verbal feedback activity. Please contact your course administrator.'; $string['errornothingtodecline'] = 'There is no feedback to decline to.'; +$string['errornotingroup'] = 'You need to be in a group in order to be able to participate in this verbal feedback activity. Please contact your course administrator.'; +$string['enterquestion'] = 'Enter question text...'; $string['errorquestionstillinuse'] = 'This question cannot be deleted as it is still being used by at least one verbal feedback instance.'; $string['errorreportnotavailable'] = 'Your feedback report is not yet available.'; $string['errorresponsesavefailed'] = 'An error has occured while the responses are being saved. Please try again later.'; $string['errorroleconflict'] = 'The current user is student and teacher at the same time for this instance, which is not allowed.'; +$string['errorverbalfeedbacknotfound'] = 'verbal feedback not found.'; $string['factor'] = 'Factor'; $string['feedbacksurvey'] = 'Feedback survey for {$a}'; $string['feedbackgiven'] = 'Feedback given'; @@ -228,7 +228,6 @@ $string['verbalfeedback:view'] = 'View verbal feedback'; $string['verbalfeedback:viewanalysepage'] = 'View verbal feedback analysis'; $string['verbalfeedback:view_all_reports'] = 'View verbal feedback reports of all students'; -$string['verbalfeedbacksettings'] = 'Verbal feedback settings'; $string['verbalfeedbacklanguages'] = 'Verbal feedback languages'; $string['verbalfeedbacksettings'] = 'Verbal feedback settings'; $string['viewfeedbackforuser'] = 'View feedback for user'; diff --git a/lang/fr/verbalfeedback.php b/lang/fr/verbalfeedback.php index 988f245..eac68cf 100644 --- a/lang/fr/verbalfeedback.php +++ b/lang/fr/verbalfeedback.php @@ -26,8 +26,8 @@ defined('MOODLE_INTERNAL') || die(); $string['activity'] = 'Activité'; -$string['additem'] = 'Ajouter un nouveau élément'; $string['addanewquestion'] = 'Ajouter une nouvelle question'; +$string['additem'] = 'Ajouter un nouveau élément'; $string['allowundodecline'] = 'Permettre aux étudiant-e-s d\'annuler les commentaires refusés'; $string['allparticipants'] = 'Tout-e-s les participant-e-s'; $string['anonymous'] = 'Anonyme'; @@ -42,8 +42,8 @@ $string['closebeforeopen'] = 'Vous avez indiqué une date de fermeture antérieure à la date d\'ouverture.'; $string['commentfromuser'] = '{$a->comment} ({$a->fromuser})'; $string['comments'] = 'Commentaires'; -$string['confirmquestiondeletion'] = 'Etes-vous sûr de vouloir supprimer cette question ?'; $string['confirmfinaliseanonymousfeedback'] = 'Ceci rendra vos réponses anonymes sur votre feedback pour {$a->nom}. Vous ne pourrez plus modifier vos réponses une fois que cela aura été fait. Poursuivre ?'; +$string['confirmquestiondeletion'] = 'Etes-vous sûr de vouloir supprimer cette question ?'; $string['course'] = 'Cours'; $string['criteria'] = 'Critères'; $string['criterion'] = 'Critère'; @@ -73,7 +73,6 @@ $string['enableselfreview'] = 'Activer l\'autorévision'; $string['entercomment'] = 'Entrez votre commentaire ici'; $string['enterquestion'] = 'Saisir le texte de la question...'; -$string['errorverbalfeedbacknotfound'] = 'Feedback verbal non trouvé'; $string['errorblankquestion'] = 'Requis'; $string['errorblankdeclinereason'] = 'Requis'; $string['errorcannotadditem'] = 'Impossible d\'ajouter l\'élément feedback.'; @@ -81,8 +80,8 @@ $string['errorcannotrespond'] = 'Vous ne pouvez pas répondre à cette activité de feedback verbal'; $string['errorcannotupdateitem'] = 'Impossible de mettre à jour l\'élément de feedback verbal'; $string['errorcannotviewallreports'] = 'Vous ne pouvez pas afficher les résultats des autres participants.'; -$string['erroritemnotfound'] = 'L\'élément n\'a pas été trouvé.'; $string['errorinvalidstatus'] = 'Statut invalide'; +$string['erroritemnotfound'] = 'L\'élément n\'a pas été trouvé.'; $string['errornocaptoedititems'] = 'Désolé, mais vous n\'avez pas la possibilité de modifier les éléments de feedback verbal'; $string['errornotenrolled'] = 'Vous devez être inscrit à ce cours pour pouvoir participer à cette activité de feedback verbal'; $string['errornotingroup'] = 'Vous devez être dans un groupe pour pouvoir participer à cette activité de feedback verbal. Veuillez contacter votre administrateur de cours.'; @@ -91,6 +90,7 @@ $string['errorreportnotavailable'] = 'Votre rapport de feedback n\'est pas encore disponible'; $string['errorresponsesavefailed'] = 'Une erreur s\'est produite lors de la sauvegarde des réponses. Veuillez réessayer plus tard.'; $string['errorroleconflict'] = 'L\'utilisateur actuel est à la fois élève et professeur pour cette instance, ce qui n\'est pas autorisé'; +$string['errorverbalfeedbacknotfound'] = 'Feedback verbal non trouvé'; $string['factor'] = 'Facteur'; $string['feedbacksurvey'] = 'Questionnaire feedback pour {$a}'; $string['feedbackgiven'] = 'Feedback donné'; diff --git a/language_edit.php b/language_edit.php index 6bd5ffa..530d206 100644 --- a/language_edit.php +++ b/language_edit.php @@ -102,7 +102,7 @@ function language_to_view_model(language $language) { * @param object $viewmodel The language model * @return language The language object */ -function view_model_to_language($viewmodel) : language { +function view_model_to_language($viewmodel): language { $language = new language(); if (isset($viewmodel->id)) { $language->set_id($viewmodel->id); diff --git a/lib.php b/lib.php index f6ae3f4..d157a43 100644 --- a/lib.php +++ b/lib.php @@ -47,7 +47,7 @@ * @param stdClass $object * @return instance The verbal feedback instance */ -function mod_verbalfeedback_view_model_to_instance(stdClass $object) : instance { +function mod_verbalfeedback_view_model_to_instance(stdClass $object): instance { $templaterepository = new template_repository(); if (!isset($object->course) || !is_numeric($object->course)) { diff --git a/locallib.php b/locallib.php index 1cf2892..dd1fbb4 100644 --- a/locallib.php +++ b/locallib.php @@ -68,7 +68,7 @@ function template_category_to_view_model(template_category $templatecategory) { * @return template_category The template category * @throws Exception */ -function view_model_to_template_category($viewmodel) : template_category { +function view_model_to_template_category($viewmodel): template_category { $templatecategory = new template_category(); if ($viewmodel->id == null) { $viewmodel->id = 0; @@ -169,7 +169,7 @@ function template_criterion_to_view_model(template_criterion $templatecriterion) * @return template_criterion The template criterion * @throws Exception */ -function view_model_to_template_criterion($viewmodel) : template_criterion { +function view_model_to_template_criterion($viewmodel): template_criterion { $languagerepository = new language_repository(); $templatecriterionmodel = new template_criterion(); if (isset($viewmodel->id)) { @@ -296,7 +296,7 @@ function template_to_view_model(template $template) { * @param object $viewmodel The view model * @return template The template */ -function view_model_to_template($viewmodel) : template { +function view_model_to_template($viewmodel): template { $template = new template(); $template->set_id($viewmodel->id); $template->set_name($viewmodel->name); diff --git a/tests/externallib_test.php b/tests/externallib_test.php index 154e810..439e15c 100644 --- a/tests/externallib_test.php +++ b/tests/externallib_test.php @@ -38,7 +38,7 @@ * @copyright 2022 Luca Bösch * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class externallib_test extends \externallib_advanced_testcase { +final class externallib_test extends \externallib_advanced_testcase { /** @var core_course_category */ protected $category; /** @var stdClass */ @@ -61,7 +61,9 @@ public function setUp(): void { $this->setUser($this->teacher); } - /** Creating 10 students and 1 teacher. */ + /** + * Creating 10 students and 1 teacher. + */ protected function create_and_enrol_users() { $this->students = []; for ($i = 0; $i < 10; $i++) { @@ -76,7 +78,7 @@ protected function create_and_enrol_users() { * * @covers ::mod_verbalfeedback_view_model_to_instance */ - public function test_mod_verbalfeedback_view_model_to_instance() { + public function test_mod_verbalfeedback_view_model_to_instance(): void { $this->resetAfterTest(); $instance = mod_verbalfeedback_view_model_to_instance((object)['course' => $this->course->id]); diff --git a/tests/generator/lib.php b/tests/generator/lib.php index 07f5298..57dc45f 100644 --- a/tests/generator/lib.php +++ b/tests/generator/lib.php @@ -14,6 +14,10 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see . +// Let codechecker ignore the sniff for this file for nullable types since the super method of +// create_instance is not yet rewritten and mod_attendance_generator::create_instance must have an identical signature. +// phpcs:disable PHPCompatibility.FunctionDeclarations.RemovedImplicitlyNullableParam.Deprecated + /** * mod_verbalfeedback data generator. * diff --git a/tests/generator_test.php b/tests/generator_test.php index 4bbaaf5..6fc6d85 100644 --- a/tests/generator_test.php +++ b/tests/generator_test.php @@ -31,7 +31,7 @@ * @copyright 2021 Luca Bösch * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class generator_test extends \advanced_testcase { +final class generator_test extends \advanced_testcase { /** * Test the verbalfeedback test data generator * @@ -39,7 +39,7 @@ class generator_test extends \advanced_testcase { * @throws coding_exception * @throws dml_exception */ - public function test_generator() { + public function test_generator(): void { global $DB; $this->resetAfterTest(true); diff --git a/tests/repository/import_data_test.php b/tests/repository/import_data_test.php index 433953d..81012fd 100644 --- a/tests/repository/import_data_test.php +++ b/tests/repository/import_data_test.php @@ -44,7 +44,7 @@ /** * A PHPunit test class to test data import */ -class import_data_test extends \advanced_testcase { +final class import_data_test extends \advanced_testcase { /** * Tests data import @@ -64,7 +64,7 @@ public function test_import(): void { $templaterepo = new template_repository(); // Test dallgoot/yaml. - $importdata = helper::parseYamlFile('./mod/verbalfeedback/db/default.yaml'); + $importdata = helper::parseyamlfile('./mod/verbalfeedback/db/default.yaml'); foreach ($importdata->languages as $yamllang) { if ($yamllang->id == null) { $lang = new language(null, $yamllang->language); diff --git a/tests/repository/language_repository_test.php b/tests/repository/language_repository_test.php index aad3693..efa4d36 100644 --- a/tests/repository/language_repository_test.php +++ b/tests/repository/language_repository_test.php @@ -36,7 +36,7 @@ /** * Verbal feedback language repository test class */ -class language_repository_test extends \advanced_testcase { +final class language_repository_test extends \advanced_testcase { /** @var language_repository A language repository */ protected $repo; @@ -95,7 +95,7 @@ public function save_provider(): array { * @throws coding_exception * @throws dml_exception */ - public function test_get_all() { + public function test_get_all(): void { global $DB; $this->resetAfterTest(); @@ -136,7 +136,7 @@ public function get_all_provider(): array { * * @covers \mod_verbalfeedback\repository\language_repository::get_by_id */ - public function test_get_by_id() { + public function test_get_by_id(): void { $this->resetAfterTest(); $language = new language(null, 'en'); @@ -155,7 +155,7 @@ public function test_get_by_id() { * @throws coding_exception * @throws dml_exception */ - public function test_delete_by_id() { + public function test_delete_by_id(): void { global $DB; $this->resetAfterTest(); $languages = [ diff --git a/tests/verbalfeedback_test.php b/tests/verbalfeedback_test.php index e86da78..d0d06a0 100644 --- a/tests/verbalfeedback_test.php +++ b/tests/verbalfeedback_test.php @@ -39,7 +39,7 @@ * @copyright 2021 Luca Bösch * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -class verbalfeedback_test extends \advanced_testcase { +final class verbalfeedback_test extends \advanced_testcase { /** * @var core_course_category Course category used for testing @@ -94,8 +94,10 @@ public function setUp(): void { $this->create_and_enrol_users(); } - /** Creating 10 students and 1 teacher. */ - protected function create_and_enrol_users() { + /** + * Creating 10 students and 1 teacher. + */ + protected function create_and_enrol_users(): void { $this->students = []; for ($i = 0; $i < 10; $i++) { $this->students[] = $this->getDataGenerator()->create_and_enrol($this->course, 'student'); @@ -109,7 +111,7 @@ protected function create_and_enrol_users() { * * @covers \mod_verbalfeedback\model\instance */ - public function test_verbalfeedback() { + public function test_verbalfeedback(): void { $this->resetAfterTest(); $this->assertEquals('Verbal feedback 1', $this->verbalfeedback->name); } @@ -121,7 +123,7 @@ public function test_verbalfeedback() { * @throws coding_exception * @throws dml_exception */ - public function test_verbalfeedback_get_user_grade() { + public function test_verbalfeedback_get_user_grade(): void { $this->resetAfterTest(); $this->assertEquals([], verbalfeedback_get_user_grades($this->verbalfeedback)); }