Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MDL-26477 Added a setting to display course sections as links within …

…the navigation
  • Loading branch information...
commit ad4700977a99d2fd342b4b3ed54987d4a13e8937 1 parent 4a47631
@samhemelryk samhemelryk authored skodak committed
View
1  admin/settings/appearance.php
@@ -91,6 +91,7 @@
$temp->add(new admin_setting_configcheckbox('navshowcategories', get_string('navshowcategories', 'admin'), get_string('confignavshowcategories', 'admin'), 1));
$temp->add(new admin_setting_configcheckbox('navshowallcourses', get_string('navshowallcourses', 'admin'), get_string('confignavshowallcourses', 'admin'), 0));
$temp->add(new admin_setting_configtext('navcourselimit',get_string('navcourselimit','admin'),get_string('confignavcourselimit', 'admin'),20,PARAM_INT));
+ $temp->add(new admin_setting_configcheckbox('navlinkcoursesections', get_string('navlinkcoursesections', 'admin'), get_string('navlinkcoursesections_help', 'admin'), 0));
$ADMIN->add('appearance', $temp);
View
11 course/format/topics/lib.php
@@ -90,3 +90,14 @@ function callback_topics_ajax_support() {
$ajaxsupport->testedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111, 'Safari' => 531, 'Chrome' => 6.0);
return $ajaxsupport;
}
+
+/**
+ * Returns a URL to arrive directly at a section
+ *
+ * @param int $courseid The id of the course to get the link for
+ * @param int $sectionnum The section number to jump to
+ * @return moodle_url
+ */
+function callback_topics_get_section_url($courseid, $sectionnum) {
+ return new moodle_url('/course/view.php', array('id' => $courseid, 'topic' => $sectionnum));
+}
View
11 course/format/weeks/lib.php
@@ -112,3 +112,14 @@ function callback_weeks_ajax_support() {
$ajaxsupport->testedbrowsers = array('MSIE' => 6.0, 'Gecko' => 20061111, 'Safari' => 531, 'Chrome' => 6.0);
return $ajaxsupport;
}
+
+/**
+ * Returns a URL to arrive directly at a section
+ *
+ * @param int $courseid The id of the course to get the link for
+ * @param int $sectionnum The section number to jump to
+ * @return moodle_url
+ */
+function callback_weeks_get_section_url($courseid, $sectionnum) {
+ return new moodle_url('/course/view.php', array('id' => $courseid, 'week' => $sectionnum));
+}
View
2  lang/en/admin.php
@@ -732,6 +732,8 @@
$string['mysql416required'] = 'MySQL 4.1.16 is the minimum version required for Moodle 1.6 in order to guarantee that all data can be converted to UTF-8 in the future.';
$string['navigationupgrade'] = 'This upgrade introduces two new navigation blocks that will replace these blocks: Administration, Courses, Activities and Participants. If you had set any special permissions on those blocks you should check to make sure everything is behaving as you want it.';
$string['navcourselimit'] = 'Course limit';
+$string['navlinkcoursesections'] = 'Link course sections';
+$string['navlinkcoursesections_help'] = 'If enabled course sections will be shown as links within the navigation.';
$string['navshowallcourses'] = 'Show all courses';
$string['navshowcategories'] = 'Show course categories';
$string['neverdeleteruns'] = 'Never delete runs';
View
22 lib/navigationlib.php
@@ -1635,9 +1635,20 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
$namingfunction = 'callback_'.$courseformat.'_get_section_name';
$namingfunctionexists = (function_exists($namingfunction));
- $activesection = course_get_display($course->id);
+
$viewhiddensections = has_capability('moodle/course:viewhiddensections', $this->page->context);
+ $urlfunction = 'callback_'.$courseformat.'_get_section_url';
+ if (empty($CFG->navlinkcoursesections) || !function_exists($urlfunction)) {
+ $urlfunction = null;
+ }
+
+ $keyfunction = 'callback_'.$courseformat.'_request_key';
+ $key = course_get_display($course->id);
+ if (defined('AJAX_SCRIPT') && AJAX_SCRIPT == '0' && function_exists($keyfunction) && $this->page->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
+ $key = optional_param($keyfunction(), $key, PARAM_INT);
+ }
+
$navigationsections = array();
foreach ($sections as $sectionid => $section) {
$section = clone($section);
@@ -1652,13 +1663,16 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
} else {
$sectionname = get_string('section').' '.$section->section;
}
- //$url = new moodle_url('/course/view.php', array('id'=>$course->id));
+
$url = null;
+ if (!empty($urlfunction)) {
+ $url = $urlfunction($course->id, $section->section);
+ }
$sectionnode = $coursenode->add($sectionname, $url, navigation_node::TYPE_SECTION, null, $section->id);
$sectionnode->nodetype = navigation_node::NODETYPE_BRANCH;
$sectionnode->hidden = (!$section->visible);
- if ($this->page->context->contextlevel != CONTEXT_MODULE && $section->hasactivites && ($sectionnode->isactive || ($activesection && $section->section == $activesection))) {
- $sectionnode->force_open();
+ if ($key != '0' && $section->section != '0' && $section->section == $key && $this->page->context->contextlevel != CONTEXT_MODULE && $section->hasactivites) {
+ $sectionnode->make_active();
$this->load_section_activities($sectionnode, $section->section, $activities);
}
$section->sectionnode = $sectionnode;
Please sign in to comment.
Something went wrong with that request. Please try again.