Skip to content

Commit

Permalink
fix: remove even more PARAM_RAWs
Browse files Browse the repository at this point in the history
  • Loading branch information
jmorrph committed Jul 5, 2024
1 parent f78eb41 commit 530bc86
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 28 deletions.
8 changes: 4 additions & 4 deletions classes/external/add_learning_goal.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ public static function execute_parameters(): external_function_parameters {
* @param int $courseid The ID of the course in which the goal is being created.
* @param int $duedate The due date timestamp for the goal.
* @param string $goalname The description of the new goal.
* @return string A message indicating the success of creating the new goal.
* @return bool Indicating the success of creating the new goal.
* @throws moodle_exception If the parameters or data validation fails.
* @throws dml_exception If there are database-related errors.
*/
public static function execute(int $courseid, int $duedate, string $goalname): string {
public static function execute(int $courseid, int $duedate, string $goalname): bool {
global $DB, $PAGE, $CFG, $USER;

self::validate_parameters(self::execute_parameters(), [
Expand All @@ -100,7 +100,7 @@ public static function execute(int $courseid, int $duedate, string $goalname): s
$goal->finished = 0;
learningdata::add_goal_to_database($goal);

return 'New goal successfully created.';
return true;
}

/**
Expand All @@ -109,6 +109,6 @@ public static function execute(int $courseid, int $duedate, string $goalname): s
* @return external_value jsonobj
*/
public static function execute_returns(): external_value {
return new external_value(PARAM_RAW);
return new external_value(PARAM_BOOL);
}
}
8 changes: 4 additions & 4 deletions classes/external/change_planner_view.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ public static function execute_parameters(): external_function_parameters {
* @param int $month
* @param int $year
* @param string $direction
* @return string
* @return bool
* @throws coding_exception
* @throws dml_exception
* @throws invalid_parameter_exception
* @throws Exception
*/
public static function execute(int $courseid, int $day, int $month, int $year, string $direction): string {
public static function execute(int $courseid, int $day, int $month, int $year, string $direction): bool {
global $DB, $PAGE, $CFG;

self::validate_parameters(self::execute_parameters(), [
Expand Down Expand Up @@ -111,7 +111,7 @@ public static function execute(int $courseid, int $day, int $month, int $year, s

planner::block_disealytics_change_month_display_in_database($day, $month, $year);

return 'Date changed.';
return true;
}

/**
Expand All @@ -120,6 +120,6 @@ public static function execute(int $courseid, int $day, int $month, int $year, s
* @return external_value jsonobj
*/
public static function execute_returns(): external_value {
return new external_value(PARAM_RAW);
return new external_value(PARAM_BOOL);
}
}
8 changes: 4 additions & 4 deletions classes/external/delete_learning_goal.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ public static function execute_parameters(): external_function_parameters {
*
*
* @param string $goalid the goal ID
* @return string $result
* @return bool $result
* @throws invalid_parameter_exception|dml_exception
*/
public static function execute(string $goalid): string {
public static function execute(string $goalid): bool {
global $CFG;
self::validate_parameters(self::execute_parameters(), ['goalid' => $goalid]);
require_once($CFG->dirroot . '/blocks/disealytics/classes/learningdata.php');
learningdata::delete_goal($goalid);
return 'Goal ID: ' . $goalid . ' deleted.';
return true;
}

/**
Expand All @@ -77,6 +77,6 @@ public static function execute(string $goalid): string {
* @return external_value jsonobj
*/
public static function execute_returns(): external_value {
return new external_value(PARAM_RAW);
return new external_value(PARAM_BOOL);
}
}
10 changes: 5 additions & 5 deletions classes/external/optional_input.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class optional_input extends external_api {
public static function execute_parameters(): external_function_parameters {
return new external_function_parameters([
'calltype' => new external_value(
PARAM_RAW,
PARAM_ALPHA,
'Defines the type calltype. Calltype might be adding, deleting or updating',
VALUE_REQUIRED
),
Expand Down Expand Up @@ -97,7 +97,7 @@ public static function execute_parameters(): external_function_parameters {
* @param int $currentpage last page that was read in the document
* @param int $lastpage last page of the document
* @param int $expenditureoftime expenditure of time
* @return string $result
* @return bool $result
* @throws invalid_parameter_exception
* @throws dml_exception
* @throws coding_exception
Expand All @@ -110,7 +110,7 @@ public static function execute(
int $currentpage = 0,
int $lastpage = 1,
int $expenditureoftime = 0
): string {
): bool {
global $DB, $PAGE, $CFG;
self::validate_parameters(self::execute_parameters(), ['calltype' => $calltype, 'id' => $id, 'name' => $name,
'currentpage' => $currentpage, 'lastpage' => $lastpage, 'courseid' => $courseid,
Expand Down Expand Up @@ -140,7 +140,7 @@ public static function execute(
} else if ($calltype === 'delete') {
learningdata::delete_optional_input($id);
}
return 'Executed optional input ' . $calltype;
return true;
}

/**
Expand All @@ -149,6 +149,6 @@ public static function execute(
* @return external_value jsonobj
*/
public static function execute_returns(): external_value {
return new external_value(PARAM_RAW);
return new external_value(PARAM_BOOL);
}
}
8 changes: 4 additions & 4 deletions classes/external/update_learning_goal.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ public static function execute_parameters(): external_function_parameters {
* @param int $duedate the goal ID
* @param string $goalname the goal name
* @param bool $finished finished target
* @return string $result
* @return bool $result
* @throws invalid_parameter_exception
* @throws dml_exception
*/
public static function execute(string $goalid, int $duedate, string $goalname, bool $finished): string {
public static function execute(string $goalid, int $duedate, string $goalname, bool $finished): bool {

global $CFG;

Expand All @@ -100,7 +100,7 @@ public static function execute(string $goalid, int $duedate, string $goalname, b
$goal->duedate = $duedate;
$goal->finished = $finished;
learningdata::update_goal($goal);
return 'Goal ID: ' . $goalid . ' updated name with: ' . $goalname . ' and due date ' . $duedate . '.';
return true;
}

/**
Expand All @@ -109,6 +109,6 @@ public static function execute(string $goalid, int $duedate, string $goalname, b
* @return external_value jsonobj
*/
public static function execute_returns(): external_value {
return new external_value(PARAM_RAW);
return new external_value(PARAM_BOOL);
}
}
8 changes: 4 additions & 4 deletions classes/external/update_planner_event.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static function execute_parameters(): external_function_parameters {
* @param string|null $location
* @param int|null $eventtype
* @param int|null $repetitions
* @return string
* @return bool
* @throws dml_exception
* @throws invalid_parameter_exception
*/
Expand All @@ -121,7 +121,7 @@ public static function execute(
?string $location = null,
?int $eventtype = null,
?int $repetitions = null
): string {
): bool {
global $USER;

self::validate_parameters(self::execute_parameters(), [
Expand Down Expand Up @@ -181,7 +181,7 @@ public static function execute(
planner::delete_date($dateid);
}

return 'Operation was successful.';
return true;
}

/**
Expand All @@ -190,6 +190,6 @@ public static function execute(
* @return external_value jsonobj
*/
public static function execute_returns(): external_value {
return new external_value(PARAM_RAW);
return new external_value(PARAM_BOOL);
}
}
4 changes: 2 additions & 2 deletions lang/de/block_disealytics.php
Original file line number Diff line number Diff line change
Expand Up @@ -428,8 +428,8 @@
$string['choice_no'] = 'Sie haben die Einwilligung abgelehnt';
$string['choice_yes'] = 'Sie haben die Einwilligung angenommen';

$string['messageprovider'] = 'Disea Message Provider';
$string['messageprovider:logdata_disea'] = 'Disea Message Provider';
$string['messageprovider'] = 'DiSEA Message Provider';
$string['messageprovider:logdata_disea'] = 'DiSEA Message Provider';

$string['download'] = 'Herunterladen';
$string['back'] = 'Zurück';
Expand Down
2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@

$plugin->component = 'block_disealytics';
$plugin->release = '0.2.4';
$plugin->version = 2024070102;
$plugin->version = 2024070500;
$plugin->requires = 2021051700;

0 comments on commit 530bc86

Please sign in to comment.