diff --git a/classes/external.php b/classes/external.php index a713182..691376e 100644 --- a/classes/external.php +++ b/classes/external.php @@ -22,7 +22,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ namespace block_townsquare; -use core_external\external_function_parameters; +use external_function_parameters; use Exception; use external_api; use external_value; @@ -82,20 +82,13 @@ public static function record_usersettings_returns(): external_value { public static function record_usersettings($userid, $timefilterpast, $timefilterfuture, $basicletter, $completionletter, $postletter): bool { global $DB, $CFG; - // Parameter validation. - /* if ($CFG->branch >= 402) { $params = self::validate_parameters(self::record_usersettings_parameters(), [ 'userid' => $userid, 'timefilterpast' => $timefilterpast, 'timefilterfuture' => $timefilterfuture, 'basicletter' => $basicletter, 'completionletter' => $completionletter, 'postletter' => $postletter, ]); - } else { - // TODO: delete this branch when Moodle 4.1 is no longer supported. - $params = [ - 'userid' => $userid, 'timefilterpast' => $timefilterpast, 'timefilterfuture' => $timefilterfuture, - 'basicletter' => $basicletter, 'completionletter' => $completionletter, 'postletter' => $postletter, ]; - }*/ + } // Check if the user already has a record in the database. if ($records = $DB->get_records('block_townsquare_preferences', ['userid' => $userid])) { diff --git a/locallib.php b/locallib.php index d3f8883..29048bf 100644 --- a/locallib.php +++ b/locallib.php @@ -26,10 +26,10 @@ * Function to get the color of a letter. * * @param string $lettertype The type of the letter that wants to retrieve its color setting. - * @return false|mixed The color of the letter. + * @return false|string The color of the letter. * @throws moodle_exception */ -function townsquare_get_colorsetting($lettertype) { +function townsquare_get_colorsetting($lettertype): string { switch ($lettertype) { case 'basicletter': return get_config('block_townsquare', 'basiclettercolor'); diff --git a/tests/behat/behat_block_townsquare.php b/tests/behat/behat_block_townsquare.php index 707daa0..ef75c69 100644 --- a/tests/behat/behat_block_townsquare.php +++ b/tests/behat/behat_block_townsquare.php @@ -68,6 +68,7 @@ public function i_add_an_townsquare_completion_event(string $coursename) { */ public function i_townsquare_debug() { global $DB; + //\block_townsquare\external::record_usersettings(1, 1, 1, 1, 1, 1); $record = $DB->get_records('block_townsquare_preferences'); var_dump($record); ob_flush(); diff --git a/tests/behat/block_townsquare_savepreferences.feature b/tests/behat/block_townsquare_savepreferences.feature index ce3672c..64d7412 100644 --- a/tests/behat/block_townsquare_savepreferences.feature +++ b/tests/behat/block_townsquare_savepreferences.feature @@ -29,6 +29,7 @@ Feature: In the townsquare block user can save their settings in a database. Then I should see "Test assign 2" in the "Town Square" "block" And I click on "Time filter" "text" And I click on "Next two days" "text" + And I townsquare debug When I click on "Save settings" "text" in the "Town Square" "block" Then I should not see "Test assign 2" in the "Town Square" "block" And I townsquare debug