Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Merge branch 'MDL-31122-m22' of git://github.com/sammarshallou/moodle…

… into MOODLE_22_STABLE
  • Loading branch information...
commit b292cea475d1d0a3a2b7dbf67cd56782b14f0230 2 parents fe3130a + 54b1dc4
Eloy Lafuente (stronk7) stronk7 authored

Showing 1 changed file with 25 additions and 4 deletions. Show diff stats Hide diff stats

  1. +25 4 lib/navigationlib.php
29 lib/navigationlib.php
@@ -127,6 +127,8 @@ class navigation_node implements renderable {
127 127 protected static $fullmeurl = null;
128 128 /** @var bool toogles auto matching of active node */
129 129 public static $autofindactive = true;
  130 + /** @var mixed If set to an int, that section will be included even if it has no activities */
  131 + public $includesectionnum = false;
130 132
131 133 /**
132 134 * Constructs a new navigation_node
@@ -1172,13 +1174,29 @@ public function initialise() {
1172 1174 }
1173 1175
1174 1176 $this->add_course_essentials($coursenode, $course);
  1177 +
  1178 + // Get section number from $cm (if provided) - we need this
  1179 + // before loading sections in order to tell it to load this section
  1180 + // even if it would not normally display (=> it contains only
  1181 + // a label, which we are now editing)
  1182 + $sectionnum = isset($cm->sectionnum) ? $cm->sectionnum : 0;
  1183 + if ($sectionnum) {
  1184 + // This value has to be stored in a member variable because
  1185 + // otherwise we would have to pass it through a public API
  1186 + // to course formats and they would need to change their
  1187 + // functions to pass it along again...
  1188 + $this->includesectionnum = $sectionnum;
  1189 + } else {
  1190 + $this->includesectionnum = false;
  1191 + }
  1192 +
1175 1193 // Load the course sections into the page
1176 1194 $sections = $this->load_course_sections($course, $coursenode);
1177 1195 if ($course->id != SITEID) {
1178 1196 // Find the section for the $CM associated with the page and collect
1179 1197 // its section number.
1180   - if (isset($cm->sectionnum)) {
1181   - $cm->sectionnumber = $cm->sectionnum;
  1198 + if ($sectionnum) {
  1199 + $cm->sectionnumber = $sectionnum;
1182 1200 } else {
1183 1201 foreach ($sections as $section) {
1184 1202 if ($section->id == $cm->section) {
@@ -1629,7 +1647,9 @@ protected function generate_sections_and_activities(stdClass $course) {
1629 1647 }
1630 1648 }
1631 1649 $activities[$cmid] = $activity;
1632   - $sections[$key]->hasactivites = true;
  1650 + if ($activity->display) {
  1651 + $sections[$key]->hasactivites = true;
  1652 + }
1633 1653 }
1634 1654 }
1635 1655 $this->cache->set('course_sections_'.$course->id, $sections);
@@ -1677,7 +1697,8 @@ public function load_generic_course_sections(stdClass $course, navigation_node $
1677 1697 if ($course->id == SITEID) {
1678 1698 $this->load_section_activities($coursenode, $section->section, $activities);
1679 1699 } else {
1680   - if ((!$viewhiddensections && !$section->visible) || (!$this->showemptysections && !$section->hasactivites)) {
  1700 + if ((!$viewhiddensections && !$section->visible) || (!$this->showemptysections &&
  1701 + !$section->hasactivites && $this->includesectionnum !== $section->section)) {
1681 1702 continue;
1682 1703 }
1683 1704 if ($namingfunctionexists) {

0 comments on commit b292cea

Please sign in to comment.
Something went wrong with that request. Please try again.