MDL-70821 course: Activity information fixes

* Make sure the activity is visible to the user (cm_info::uservisible)
before showing the activity completion information.
* Add to-do status for overridden automatic completion
This commit is contained in:
Jun Pataleta 2021-03-27 13:21:53 +08:00
parent 15a9b2c51c
commit a5e6df51a7
3 changed files with 21 additions and 13 deletions

View file

@ -138,6 +138,9 @@ class activity_information implements renderable, templatable {
$data->withavailability = !empty($CFG->enableavailability) && info::completion_value_used($course, $this->cminfo->id);
}
// Whether this activity is visible to the user. If not, completion information will not be shown.
$data->uservisible = $this->cminfo->uservisible;
// Build automatic completion details.
$details = [];
foreach ($this->cmcompletion->get_details() as $key => $detail) {
@ -153,7 +156,8 @@ class activity_information implements renderable, templatable {
'condition' => $detail->description,
'setby' => $data->overrideby,
];
$detail->accessibledescription = get_string('completion_setby:auto', 'course', $setbydata);
$overridestatus = $detail->statuscomplete ? 'done' : 'todo';
$detail->accessibledescription = get_string('completion_setby:auto:' . $overridestatus, 'course', $setbydata);
}
// We don't need the status in the template.