MDL-81780 tool_task : Adhoc task improvements

Added fail delay column in the adhock task table on the admin page,
Added a new column for a delete action for the adhoc tasks on and
Wrote delete_adhoctask.php for delete functionality of adhoc tasks.
Wrote behat test for the delete functionality. Also there was a
logical error in the previous code where it was checking if the task
is due or not and it was just showing Never or ASAP instead of
actual time so fixed that as well.
This commit is contained in:
waleedhassan
2025-01-16 12:16:04 +00:00
parent f4f166695c
commit c0572a0423
7 changed files with 150 additions and 15 deletions
+22 -3
View File
@@ -507,11 +507,17 @@ class manager {
* This function load the adhoc tasks for a given classname.
*
* @param string $classname
* @param bool $failedonly
* @param bool $skiprunning do not return tasks that are in the running state
* @param bool $failedonly Return only failed tasks
* @param bool $skiprunning Do not return tasks that are in the running state
* @param bool $dueonly Return only tasks that are due to run (nextruntime < now)
* @return array
*/
public static function get_adhoc_tasks(string $classname, bool $failedonly = false, bool $skiprunning = false): array {
public static function get_adhoc_tasks(
string $classname,
bool $failedonly = false,
bool $skiprunning = false,
bool $dueonly = false
): array {
global $DB;
$conds[] = 'classname = ?';
@@ -519,6 +525,8 @@ class manager {
if ($failedonly) {
$conds[] = 'faildelay > 0';
} else if ($dueonly) {
$conds[] = 'faildelay = 0';
}
if ($skiprunning) {
$conds[] = 'timestarted IS NULL';
@@ -950,6 +958,17 @@ class manager {
return null;
}
/**
* This function will delete an adhoc task by id. The task will be removed
* from the database.
*
* @param int $taskid
*/
public static function delete_adhoc_task(int $taskid): void {
global $DB;
$DB->delete_records('task_adhoc', ['id' => $taskid]);
}
/**
* This function will set locks on the task.
*