Skip to content

Commit

Permalink
WIP: fix for M4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
TamaroWalter committed May 24, 2024
1 parent 5e30a0d commit e665ab9
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 11 deletions.
11 changes: 2 additions & 9 deletions classes/external.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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])) {
Expand Down
4 changes: 2 additions & 2 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
1 change: 1 addition & 0 deletions tests/behat/behat_block_townsquare.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions tests/behat/block_townsquare_savepreferences.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e665ab9

Please sign in to comment.