Skip to content

Commit

Permalink
Fixed: conflict in section number
Browse files Browse the repository at this point in the history
  • Loading branch information
davidherney committed Jul 13, 2024
1 parent 15c68ab commit e4ce0f0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 13 deletions.
7 changes: 4 additions & 3 deletions classes/output/courseformat/content.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ public function get_template_name(\renderer_base $renderer): string {
/**
* Export this data so it can be used as the context for a mustache template (core/inplace_editable).
*
* @param renderer_base $output typically, the renderer that's calling this function
* @param \renderer_base $output typically, the renderer that's calling this function
* @return stdClass data context for a mustache template
*/
public function export_for_template(\renderer_base $output) {
global $PAGE;
$format = $this->format;
$course = $format->get_course();

$currentsection = \format_menutopic::$displaysection;
$currentsection = $format->get_section_number();

// If the section 0 is above the menu remove from the list.
$sections = $this->export_sections($output);
Expand Down Expand Up @@ -187,7 +187,8 @@ protected function export_sections(\renderer_base $output): array {
*/
private function get_sections_to_display(course_modinfo $modinfo): array {

$sections = [$modinfo->get_section_info(\format_menutopic::$displaysection)];
$format = $this->format;
$sections = [$modinfo->get_section_info($format->get_section_number())];

return $sections;
}
Expand Down
2 changes: 1 addition & 1 deletion classes/output/edition.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function export_for_template(renderer_base $output) {

$msgs = [];

$displaysection = \format_menutopic::$displaysection;
$displaysection = $format->get_section_number();

if (!($formatdata = $DB->get_record('format_menutopic', ['course' => $this->course->id]))) {
$formatdata = new \stdClass();
Expand Down
10 changes: 1 addition & 9 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,12 @@ class format_menutopic extends core_courseformat\base {
/** @var \stdClass Local format data */
public static $formatdata;

/** @var \stdClass Reference to current course */
private static $localcourse;

/** @var array Messages to display */
public static $formatmsgs = [];

/** @var bool Edit menu mode */
public static $editmenumode = false;

/** @var bool Current section to display */
public static $displaysection = 0;

/** @var array Modules used in template */
public $tplcmsused = [];

Expand Down Expand Up @@ -117,7 +111,6 @@ protected function __construct($format, $courseid) {
$displaysection = $displaysection === 0 && $firstsection == 1 ? 1 : $displaysection;

$this->set_section_number($displaysection);
self::$displaysection = $displaysection;
$USER->display[$courseid] = $displaysection;
}
}
Expand Down Expand Up @@ -285,7 +278,7 @@ public function extend_course_navigation($navigation, navigation_node $node) {
global $PAGE;
// If section is specified in course/view.php, make sure it is expanded in navigation.
if ($navigation->includesectionnum === false) {
$selectedsection = self::$displaysection;
$selectedsection = $this->get_section_number();
if ($selectedsection !== null && (!defined('AJAX_SCRIPT') || AJAX_SCRIPT == '0') &&
$PAGE->url->compare(new moodle_url('/course/view.php'), URL_MATCH_BASE)) {
$navigation->includesectionnum = $selectedsection;
Expand Down Expand Up @@ -799,7 +792,6 @@ public function load_formatdata() {
$section++;
}

self::$localcourse = $course;
self::$formatdata[$course->id] = $formatdata;

return $formatdata;
Expand Down

0 comments on commit e4ce0f0

Please sign in to comment.