diff --git a/lang/en/format_learningmap.php b/lang/en/format_learningmap.php index 9918e5d..6e0e973 100644 --- a/lang/en/format_learningmap.php +++ b/lang/en/format_learningmap.php @@ -30,6 +30,8 @@ $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['hidesecondarynavforstudents_help'] = 'This will hide the navigation items above the activity content (e.g. "Grades") from the students.'; $string['mainlearningmap'] = 'Main learningmap'; $string['newsection'] = 'New section'; $string['nolearningmap'] = 'No learningmap in the course'; diff --git a/lib.php b/lib.php index 23b7172..3e96143 100644 --- a/lib.php +++ b/lib.php @@ -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); } @@ -251,6 +260,26 @@ 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' => new \lang_string('hidesecondarynavforstudents', 'format_learningmap'), + 'type' => PARAM_BOOL, + 'element_type' => 'advcheckbox', + 'default' => 0, + 'help' => 'hidesecondarynavforstudents', + 'help_component' => 'format_learningmap', + ]; + + return $options; + } } /**