MDL-86177 task: ensure tasks are runnable in indicator output.

Also fix case where task indicator progress data no longer exists,
which lead to exceptions when encountered, breaking the gradebook.
This commit is contained in:
Paul Holden
2025-08-29 15:51:25 +01:00
parent 3ca7c6bf32
commit 3597ec7916
3 changed files with 10 additions and 14 deletions
+5 -2
View File
@@ -98,6 +98,7 @@ class task_indicator implements renderable, templatable {
if (
array_key_exists('task', plugin_manager::instance()->get_present_plugins('tool'))
&& is_null($this->taskrecord->timestarted)
&& \core\task\manager::is_runnable()
&& has_capability('moodle/site:config', system::instance())
) {
$this->runurl = new url('/admin/tool/task/run_adhoctasks.php', ['id' => $this->taskrecord->id]);
@@ -124,13 +125,15 @@ class task_indicator implements renderable, templatable {
if ($this->taskrecord) {
$export['heading'] = $this->heading;
$export['message'] = $this->message;
$export['progress'] = $this->progressbar->export_for_template($output);
$export['icon'] = $this->icon ? $this->icon->export_for_template($output) : '';
$export['redirecturl'] = $this->redirecturl?->out();
$export['extraclasses'] = implode(' ', $this->extraclasses);
$export['runurl'] = $this->runurl?->out();
$export['runlabel'] = $this->runlabel;
$this->progressbar->init_js();
if ($this->progressbar !== null) {
$export['progress'] = $this->progressbar->export_for_template($output);
$this->progressbar->init_js();
}
}
return $export;
}