Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lang/en/format_learningmap.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
$string['completionrequired'] = 'Completion tracking needs to be enabled to use this course format';
$string['error_nolearningmap'] = 'This course is not ready yet.';
$string['hidefromothers'] = 'hide';
$string['hidesecondarynavforstudents'] = 'Hide secondary navigation for students';
$string['mainlearningmap'] = 'Main learningmap';
$string['newsection'] = 'New section';
$string['nolearningmap'] = 'No learningmap in the course';
Expand Down
27 changes: 27 additions & 0 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,15 @@ public function page_set_cm(moodle_page $page) {

parent::page_set_cm($page);

$options = $this->get_format_options();
if (
!empty($options['hidesecondarynavforstudents']) &&
!(has_capability('moodle/course:manageactivities', context_module::instance($page->cm->id)) ||
has_capability('moodle/course:manageactivities', context_course::instance($this->courseid)))
) {
$page->set_secondary_navigation(false);
}

if ($PAGE == $page && $PAGE->has_set_url()) {
$this->set_singleactivity_navigation($page);
}
Expand Down Expand Up @@ -251,6 +260,24 @@ public function supports_ajax() {
$ajaxsupport->capable = true;
return $ajaxsupport;
}

/**
* Defines the course format options.
*
* @param boolean $foreditform whether the options are for the course edit form
* @return array the list of options
*/
public function course_format_options($foreditform = false) {
$options = parent::course_format_options($foreditform);
$options['hidesecondarynavforstudents'] = [
'label' => get_string('hidesecondarynavforstudents', 'format_learningmap'),
'type' => PARAM_BOOL,
'element_type' => 'advcheckbox',
'default' => 0,
];

return $options;
}
}

/**
Expand Down
Loading