Skip to content
Snippets Groups Projects
Unverified Commit b9447abd authored by Justus Dieckmann's avatar Justus Dieckmann Committed by GitHub
Browse files

Merge pull request #171 from PhMemmel/MBS-7377-Fix_workflowoverview_for_big_instances

Fix workflowoverview for big instances
parents 03188000 ab2138c0
Branches
No related tags found
No related merge requests found
......@@ -34,6 +34,10 @@ $string['config_delay_duration'] = 'Standardlänge eines Kursausschlusses';
$string['config_delay_duration_desc'] = 'Diese Einstellung definiert den Standardlänge einer Kursausschlusses in einem Workflow
falls ein Prozess des Workflows zurückgesetzt oder beendigt wird. Die Länge des Kursausschlusses besagt, wie lange es dauert, bis
der Kurs wieder vom Workflow bearbeitet wird.';
$string['config_showcoursecounts'] = 'Zeige Anzahl der Kurse, die getriggert werden';
$string['config_showcoursecounts_desc'] = 'Die Workflow-Konfigurationsseite zeigt normalerweise die Anzahl an Kursen, die durch
die konfigurierten Trigger getriggert werden, was Performance-Probleme verursachen kann. Bei Performance-Problemen kann dies hiermit
deaktiviert werden';
$string['find_course_list_header'] = 'Kurse finden';
$string['adminsettings_heading'] = 'Workflow-Einstellungen';
$string['active_manual_workflows_heading'] = 'Aktive manuelle Workflows';
......
......@@ -38,6 +38,10 @@ The delay duration determines how long a course will be excepted from being proc
$string['config_backup_path'] = 'Path of the lifecycle backup folder';
$string['config_backup_path_desc'] = 'This settings defines the storage location of the backups created by the backup step.
The path has to be specified as an absolute path on your server.';
$string['config_showcoursecounts'] = 'Show amount of courses which will be triggered';
$string['config_showcoursecounts_desc'] = 'The workflow overview page by default shows the amount of courses which will be
triggered by the configured triggers which can be load heavy. Disable this option if you experience issues loading the workflow
overview.';
$string['find_course_list_header'] = 'Find courses';
$string['adminsettings_heading'] = 'Workflow settings';
$string['active_manual_workflows_heading'] = 'Active manual workflows';
......
......@@ -42,6 +42,11 @@ if ($hassiteconfig) {
get_string('config_backup_path_desc', 'tool_lifecycle'),
$CFG->dataroot . DIRECTORY_SEPARATOR . 'lifecycle_backups'));
$settings->add(new admin_setting_configcheckbox('tool_lifecycle/showcoursecounts',
get_string('config_showcoursecounts', 'tool_lifecycle'),
get_string('config_showcoursecounts_desc', 'tool_lifecycle'),
1));
$ADMIN->add('lifecycle_category', new admin_externalpage('tool_lifecycle_workflow_drafts',
get_string('workflow_drafts_header', 'tool_lifecycle'),
new moodle_url(\tool_lifecycle\urls::WORKFLOW_DRAFTS)));
......
......@@ -84,12 +84,14 @@
<div class="mt-5 mb-3">{{{addinstance}}}</div>
<div class="wf-trigger-block workflow-item">
<h5 class="my-2">{{#str}} trigger, tool_lifecycle{{/str}} {{{triggerhelp}}}</h5>
{{#showcoursecounts}}
{{#automatic}}
<div class="mb-2 mx-2">
{{#str}} courses_will_be_triggered_total, tool_lifecycle, {{coursestriggered}} {{/str}}<br>
{{#str}} courses_will_be_excluded_total, tool_lifecycle, {{coursesexcluded}} {{/str}}<br>
</div>
{{/automatic}}
{{/showcoursecounts}}
<div class="workflow wf-trigger-wrapper">
{{#trigger}}
<div class="workflow-trigger">
......@@ -103,10 +105,12 @@
</div>
</div>
<div class="wf-content">
{{#showcoursecounts}}
{{#automatic}}
<span>{{#str}} courses_will_be_triggered, tool_lifecycle, {{triggeredcourses}} {{/str}}</span><br>
<span>{{#str}} courses_will_be_excluded, tool_lifecycle, {{excludedcourses}} {{/str}}</span>
{{/automatic}}
{{/showcoursecounts}}
</div>
</div>
{{/trigger}}
......
......@@ -87,8 +87,15 @@ $str = [
'move_down' => get_string('move_down', 'tool_lifecycle')
];
$showcoursecounts = get_config('tool_lifecycle', 'showcoursecounts');
if ($showcoursecounts) {
// On moodle instances with many courses the following call can be fatal, because each trigger
// check function will be called for every single course of the instance to determine how many
// courses will be triggered by the workflow/the specific trigger. This count is only being
// used to show the admin how many courses will be triggered, it has no functional aspect.
$amounts = (new \tool_lifecycle\processor())->get_count_of_courses_to_trigger_for_workflow($workflow->id);
$displaytotaltriggered = !empty($triggers);
}
foreach ($triggers as $trigger) {
// The array from the DB Function uses ids as keys.
......@@ -108,6 +115,7 @@ foreach ($triggers as $trigger) {
);
}
$trigger->actionmenu = $OUTPUT->render($actionmenu);
if ($showcoursecounts) {
$trigger->automatic = $amounts[$trigger->sortindex]->automatic;
$displaytotaltriggered &= $trigger->automatic;
if ($trigger->automatic) {
......@@ -115,6 +123,7 @@ foreach ($triggers as $trigger) {
$trigger->excludedcourses = $amounts[$trigger->sortindex]->excluded;
}
}
}
foreach ($steps as $step) {
$ncourses = $DB->count_records('tool_lifecycle_process',
......@@ -176,15 +185,18 @@ $data = [
'finishdelay' => format_time($workflow->finishdelay),
'delayglobally' => $workflow->delayforallworkflows,
'trigger' => array_values($triggers),
'automatic' => $displaytotaltriggered,
'coursestriggered' => $amounts['all']->triggered,
'coursesexcluded' => $amounts['all']->excluded,
'coursesetsize' => $amounts['all']->coursesetsize,
'showcoursecounts' => $showcoursecounts,
'steps' => array_values($steps),
'listofcourses' => $arrayofcourses,
'nosteplink' => $nosteplink,
'table' => $out
];
if ($showcoursecounts) {
$data['automatic'] = $displaytotaltriggered;
$data['coursestriggered'] = $amounts['all']->triggered;
$data['coursesexcluded'] = $amounts['all']->excluded;
$data['coursesetsize'] = $amounts['all']->coursesetsize;
}
echo $renderer->header();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment