Permalink
Browse files

MDL-34917 course: Jump to section navigation for 'One section per page'.

  • Loading branch information...
gjb2048 committed Mar 23, 2013
1 parent 373a8e0 commit d46e26f6827d9c50eb8dac901a58833718b754b5
Showing with 37 additions and 4 deletions.
  1. +36 −3 course/format/renderer.php
  2. +1 −1 lang/en/moodle.php
View
@@ -562,6 +562,39 @@ protected function section_hidden($sectionno) {
return $o;
}
+ /**
+ * Generate the html for the 'Jump to' menu on a single section page.
+ *
+ * @param stdClass $course The course entry from DB
+ * @param array $sections The course_sections entries from the DB
+ * @param $displaysection the current displayed section number.
+ *
+ * @return string HTML to output.
+ */
+ protected function section_nav_selection($course, $sections, $displaysection) {
+ global $CFG;
+ $o = '';
+ $sectionmenu = array();
+ $sectionmenu[course_get_url($course)->out(false)] = get_string('maincoursepage');
+ $modinfo = get_fast_modinfo($course);
+ $section = 1;
+ while ($section <= $course->numsections) {
+ $thissection = $modinfo->get_section_info($section);
+ $showsection = $thissection->uservisible or !$course->hiddensections;
+ if (($showsection) && ($section != $displaysection) && ($url = course_get_url($course, $section))) {
+ $sectionmenu[$url->out(false)] = get_section_name($course, $section);
+ }
+ $section++;
+ }
+
+ $select = new url_select($sectionmenu, '', array('' => get_string('jumpto')));
+ $select->class = 'jumpmenu';
+ $select->formid = 'sectionmenu';
+ $o .= $this->output->render($select);
+
+ return $o;
+ }
+
/**
* Output the html for a single section page .
*
@@ -642,16 +675,16 @@ public function print_single_section_page($course, $sections, $mods, $modnames,
echo $this->end_section_list();
// Display section bottom navigation.
- $courselink = html_writer::link(course_get_url($course), get_string('returntomaincoursepage'));
$sectionbottomnav = '';
$sectionbottomnav .= html_writer::start_tag('div', array('class' => 'section-navigation mdl-bottom'));
$sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['previous'], array('class' => 'mdl-left'));
$sectionbottomnav .= html_writer::tag('span', $sectionnavlinks['next'], array('class' => 'mdl-right'));
- $sectionbottomnav .= html_writer::tag('div', $courselink, array('class' => 'mdl-align'));
+ $sectionbottomnav .= html_writer::tag('div', $this->section_nav_selection($course, $sections, $displaysection),
+ array('class' => 'mdl-align'));
$sectionbottomnav .= html_writer::end_tag('div');
echo $sectionbottomnav;
- // close single-section div.
+ // Close single-section div.
echo html_writer::end_tag('div');
}
View
@@ -973,6 +973,7 @@
$string['mailadmins'] = 'Inform admins';
$string['mailstudents'] = 'Inform students';
$string['mailteachers'] = 'Inform teachers';
+$string['maincoursepage'] = 'Main course page';
$string['makeafolder'] = 'Create folder';
$string['makeeditable'] = 'If you make \'{$a}\' editable by the web server process (eg apache) then you could edit this file directly from this page';
$string['makethismyhome'] = 'Make this my default home page';
@@ -1419,7 +1420,6 @@
$string['restoreusersprecheckerror'] = 'Some problems were detected when checking user data';
$string['restricted'] = 'Restricted';
$string['returningtosite'] = 'Returning to this web site?';
-$string['returntomaincoursepage'] = 'Return to main course page';
$string['returntooriginaluser'] = 'Return to {$a}';
$string['revert'] = 'Revert';
$string['role'] = 'Role';

0 comments on commit d46e26f

Please sign in to comment.