mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 08:56:36 +02:00
MDL-70821 course: Render activity information only when necessary
Render the activity information output component in the course homepage only if either completion details or activity dates are to be displayed. This can help reduce the number of files being included when loading the course homepage (e.g. the activity information template for each activity in the course homepage).
This commit is contained in:
parent
24b48fd2e7
commit
c9e92d1f5e
1 changed files with 18 additions and 3 deletions
|
@ -943,9 +943,24 @@ class core_course_renderer extends plugin_renderer_base {
|
|||
$output .= html_writer::div($modicons, 'actions');
|
||||
}
|
||||
|
||||
$completiondetails = \core_completion\cm_completion_details::get_instance($mod, $USER->id);
|
||||
$activitydates = \core\activity_dates::get_dates_for_module($mod, $USER->id);
|
||||
$output .= $this->output->activity_information($mod, $completiondetails, $activitydates);
|
||||
// Fetch completion details.
|
||||
$showcompletionconditions = $course->showcompletionconditions == COMPLETION_SHOW_CONDITIONS;
|
||||
$completiondetails = \core_completion\cm_completion_details::get_instance($mod, $USER->id, $showcompletionconditions);
|
||||
$ismanualcompletion = $completiondetails->has_completion() && !$completiondetails->is_automatic();
|
||||
|
||||
// Fetch activity dates.
|
||||
$activitydates = [];
|
||||
if ($course->showactivitydates) {
|
||||
$activitydates = \core\activity_dates::get_dates_for_module($mod, $USER->id);
|
||||
}
|
||||
|
||||
// Show the activity information if:
|
||||
// - The course's showcompletionconditions setting is enabled; or
|
||||
// - The activity tracks completion manually; or
|
||||
// - There are activity dates to be shown.
|
||||
if ($showcompletionconditions || $ismanualcompletion || $activitydates) {
|
||||
$output .= $this->output->activity_information($mod, $completiondetails, $activitydates);
|
||||
}
|
||||
|
||||
// Show availability info (if module is not available).
|
||||
$output .= $this->course_section_cm_availability($mod, $displayoptions);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue