mirror of
https://github.com/moodle/moodle.git
synced 2025-04-21 00:12:56 +02:00
MDL-26477 Added a setting to display course sections as links within the navigation
This commit is contained in:
parent
4a47631fb4
commit
ad4700977a
@ -91,6 +91,7 @@ if ($hassiteconfig) { // speedup for non-admins, add all caps used on this page
|
||||
$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);
|
||||
|
||||
|
@ -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));
|
||||
}
|
@ -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));
|
||||
}
|
||||
|
@ -732,6 +732,8 @@ $string['mysql416bypassed'] = 'However, if your site is using iso-8859-1 (latin)
|
||||
$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';
|
||||
|
@ -1635,9 +1635,20 @@ class global_navigation extends 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 @@ class global_navigation extends 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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user