|
87 | 87 | 'move_down' => get_string('move_down', 'tool_lifecycle') |
88 | 88 | ]; |
89 | 89 |
|
90 | | -$amounts = (new \tool_lifecycle\processor())->get_count_of_courses_to_trigger_for_workflow($workflow->id); |
91 | | -$displaytotaltriggered = !empty($triggers); |
| 90 | +$showcoursecounts = get_config('tool_lifecycle', 'showcoursecounts'); |
| 91 | +if ($showcoursecounts) { |
| 92 | + // On moodle instances with many courses the following call can be fatal, because each trigger |
| 93 | + // check function will be called for every single course of the instance to determine how many |
| 94 | + // courses will be triggered by the workflow/the specific trigger. This count is only being |
| 95 | + // used to show the admin how many courses will be triggered, it has no functional aspect. |
| 96 | + $amounts = (new \tool_lifecycle\processor())->get_count_of_courses_to_trigger_for_workflow($workflow->id); |
| 97 | + $displaytotaltriggered = !empty($triggers); |
| 98 | +} |
92 | 99 |
|
93 | 100 | foreach ($triggers as $trigger) { |
94 | 101 | // The array from the DB Function uses ids as keys. |
|
108 | 115 | ); |
109 | 116 | } |
110 | 117 | $trigger->actionmenu = $OUTPUT->render($actionmenu); |
111 | | - $trigger->automatic = $amounts[$trigger->sortindex]->automatic; |
112 | | - $displaytotaltriggered &= $trigger->automatic; |
113 | | - if ($trigger->automatic) { |
114 | | - $trigger->triggeredcourses = $amounts[$trigger->sortindex]->triggered; |
115 | | - $trigger->excludedcourses = $amounts[$trigger->sortindex]->excluded; |
| 118 | + if ($showcoursecounts) { |
| 119 | + $trigger->automatic = $amounts[$trigger->sortindex]->automatic; |
| 120 | + $displaytotaltriggered &= $trigger->automatic; |
| 121 | + if ($trigger->automatic) { |
| 122 | + $trigger->triggeredcourses = $amounts[$trigger->sortindex]->triggered; |
| 123 | + $trigger->excludedcourses = $amounts[$trigger->sortindex]->excluded; |
| 124 | + } |
116 | 125 | } |
117 | 126 | } |
118 | 127 |
|
|
176 | 185 | 'finishdelay' => format_time($workflow->finishdelay), |
177 | 186 | 'delayglobally' => $workflow->delayforallworkflows, |
178 | 187 | 'trigger' => array_values($triggers), |
179 | | - 'automatic' => $displaytotaltriggered, |
180 | | - 'coursestriggered' => $amounts['all']->triggered, |
181 | | - 'coursesexcluded' => $amounts['all']->excluded, |
182 | | - 'coursesetsize' => $amounts['all']->coursesetsize, |
| 188 | + 'showcoursecounts' => $showcoursecounts, |
183 | 189 | 'steps' => array_values($steps), |
184 | 190 | 'listofcourses' => $arrayofcourses, |
185 | 191 | 'nosteplink' => $nosteplink, |
186 | 192 | 'table' => $out |
187 | 193 | ]; |
| 194 | +if ($showcoursecounts) { |
| 195 | + $data['automatic'] = $displaytotaltriggered; |
| 196 | + $data['coursestriggered'] = $amounts['all']->triggered; |
| 197 | + $data['coursesexcluded'] = $amounts['all']->excluded; |
| 198 | + $data['coursesetsize'] = $amounts['all']->coursesetsize; |
| 199 | +} |
188 | 200 |
|
189 | 201 | echo $renderer->header(); |
190 | 202 |
|
|
0 commit comments