MDL-67211 Tasks: Add cron_enabled setting.

Co-authored-by: Sam Marshall <s.marshall@open.ac.uk>
This commit is contained in:
Mikhail Golenkov 2020-08-25 16:49:20 +10:00
parent 45875f6f7b
commit d7342dc239
12 changed files with 193 additions and 9 deletions

View file

@ -39,6 +39,7 @@ $string['classname'] = 'Class name';
$string['clearfaildelay_confirm'] = 'Are you sure you want to clear the fail delay for task \'{$a}\'? After clearing the delay, the task will run according to its normal schedule.';
$string['component'] = 'Component';
$string['corecomponent'] = 'Core';
$string['crondisabled'] = 'Cron is disabled. No new tasks will be started. The system will not operate properly until it is enabled again.';
$string['cronok'] = 'Cron is running frequently';
$string['default'] = 'Default';
$string['defaultx'] = 'Default: {$a}';

View file

@ -261,6 +261,16 @@ class tool_task_renderer extends plugin_renderer_base {
return $cell;
}
/**
* Displays a warning on the page if cron is disabled.
*
* @return string HTML code for information about cron being disabled
* @throws moodle_exception
*/
public function cron_disabled(): string {
return $this->output->notification(get_string('crondisabled', 'tool_task'), 'warning');
}
/**
* Renders a link back to the scheduled tasks page (used from the 'run now' screen).
*

View file

@ -39,6 +39,11 @@ admin_externalpage_setup('runningtasks');
echo $OUTPUT->header();
if (!get_config('core', 'cron_enabled')) {
$renderer = $PAGE->get_renderer('tool_task');
echo $renderer->cron_disabled();
}
$table = new \tool_task\running_tasks_table();
$table->baseurl = $pageurl;
$table->out(100, false);

View file

@ -95,6 +95,9 @@ if ($mform && ($mform->is_cancelled() || !empty($CFG->preventscheduledtaskchange
} else {
echo $OUTPUT->header();
if (!get_config('core', 'cron_enabled')) {
echo $renderer->cron_disabled();
}
$tasks = core\task\manager::get_all_scheduled_tasks();
echo $renderer->scheduled_tasks_table($tasks, $lastchanged);
echo $OUTPUT->footer();

View file

@ -0,0 +1,20 @@
@tool @tool_task
Feature: See warning message if cron is disabled
In order to manage scheduled tasks
As a Moodle Administrator
I need to be able to view a warning message if cron is disabled
Background:
Given I log in as "admin"
Scenario: If cron is disabled, I should see the message
When the following config values are set as admin:
| cron_enabled | 0 |
And I navigate to "Server > Tasks > Scheduled tasks" in site administration
Then I should see "Cron is disabled"
Scenario: If cron is enabled, I should not see the message
When the following config values are set as admin:
| cron_enabled | 1 |
And I navigate to "Server > Tasks > Scheduled tasks" in site administration
Then I should not see "Cron is disabled"