mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-72413 lesson: Use the common module for setting the header
This commit is contained in:
parent
535bbed24e
commit
0705928b4a
@ -57,8 +57,11 @@ $mform->set_data($data);
|
||||
$PAGE->navbar->add($strimportquestions);
|
||||
$PAGE->set_title($strimportquestions);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->activityheader->set_attrs([
|
||||
'hidecompletion' => true,
|
||||
'description' => ''
|
||||
]);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(format_string($lesson->name), 2);
|
||||
echo $OUTPUT->heading_with_help($strimportquestions, 'importquestions', 'lesson', '', '', 3);
|
||||
|
||||
if ($data = $mform->get_data()) {
|
||||
|
@ -53,42 +53,30 @@ class mod_lesson_renderer extends plugin_renderer_base {
|
||||
$this->page->set_title($title);
|
||||
$this->page->set_heading($this->page->course->fullname);
|
||||
lesson_add_header_buttons($cm, $context, $extraeditbuttons, $lessonpageid);
|
||||
|
||||
$canmanage = has_capability('mod/lesson:manage', $context);
|
||||
$activityheader = $this->page->activityheader;
|
||||
$activitypage = new moodle_url('/mod/' . $this->page->activityname . '/view.php');
|
||||
$setactive = $activitypage->compare($this->page->url, URL_MATCH_BASE);
|
||||
if ($activityheader->is_title_allowed()) {
|
||||
$title = $canmanage && $setactive ?
|
||||
$this->output->heading_with_help($activityname, 'overview', 'lesson') :
|
||||
$activityname;
|
||||
$activityheader->set_title($title);
|
||||
}
|
||||
|
||||
// If we have the capability to manage the lesson but not within the view page,
|
||||
// there's no reason to show activity/completion information.
|
||||
if ($canmanage && !$setactive) {
|
||||
$activityheader->set_hidecompletion(true);
|
||||
}
|
||||
|
||||
$output = $this->output->header();
|
||||
|
||||
$cminfo = cm_info::create($cm);
|
||||
$completiondetails = \core_completion\cm_completion_details::get_instance($cminfo, $USER->id);
|
||||
$activitydates = \core\activity_dates::get_dates_for_module($cminfo, $USER->id);
|
||||
if (has_capability('mod/lesson:manage', $context)) {
|
||||
$activitypage = new moodle_url('/mod/' . $this->page->activityname . '/view.php');
|
||||
$setactive = $activitypage->compare($this->page->url, URL_MATCH_BASE);
|
||||
if ($setactive) {
|
||||
if (!$this->page->has_secondary_navigation()) {
|
||||
$output .= $this->output->heading_with_help($activityname, 'overview', 'lesson');
|
||||
}
|
||||
$output .= $this->output->activity_information($cminfo, $completiondetails, $activitydates);
|
||||
}
|
||||
|
||||
// Info box.
|
||||
if ($lesson->intro) {
|
||||
$output .= $this->output->box(format_module_intro('lesson', $lesson, $cm->id), 'generalbox', 'intro');
|
||||
}
|
||||
|
||||
if (!empty($currenttab) && !$this->page->has_secondary_navigation()) {
|
||||
ob_start();
|
||||
include($CFG->dirroot.'/mod/lesson/tabs.php');
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
} else {
|
||||
if (!$this->page->has_secondary_navigation()) {
|
||||
$output .= $this->output->heading($activityname);
|
||||
}
|
||||
$output .= $this->output->activity_information($cminfo, $completiondetails, $activitydates);
|
||||
|
||||
// Info box.
|
||||
if ($lesson->intro) {
|
||||
$output .= $this->output->box(format_module_intro('lesson', $lesson, $cm->id), 'generalbox', 'intro');
|
||||
}
|
||||
if ($canmanage && !empty($currenttab) && !$this->page->has_secondary_navigation()) {
|
||||
ob_start();
|
||||
include($CFG->dirroot.'/mod/lesson/tabs.php');
|
||||
$output .= ob_get_contents();
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
foreach ($lesson->messages as $message) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user