From d06a34e8f7856f72ce2ae8a41c90cff94371c4ae Mon Sep 17 00:00:00 2001 From: Myriam Delaruelle <myriam.delaruelle@univ-lorraine.fr> Date: Thu, 17 Oct 2024 08:55:51 +0200 Subject: [PATCH] fix moodle44 --- classes/output/courseformat/content.php | 2 +- format.js | 50 ------------------------- format.php | 27 +------------ lib.php | 6 ++- renderer.php | 1 - 5 files changed, 8 insertions(+), 78 deletions(-) diff --git a/classes/output/courseformat/content.php b/classes/output/courseformat/content.php index 198cbf8..acceba7 100644 --- a/classes/output/courseformat/content.php +++ b/classes/output/courseformat/content.php @@ -46,7 +46,7 @@ class content extends content_base { */ public function export_for_template(\renderer_base $output) { global $CFG, $COURSE, $USER; - + $data=parent::export_for_template($output); //$section_entity = new course_format_iena_sections(); diff --git a/format.js b/format.js index e657204..26435a8 100644 --- a/format.js +++ b/format.js @@ -23,57 +23,7 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -M.course = M.course || {}; -M.course.format = M.course.format || {}; - -M.course.format.get_config = function() { - return { - container_node: 'ul', - container_class: 'buttons', - section_node: 'li', - section_class: 'section' - }; -}; - -M.course.format.swap_sections = function(Y, node1, node2) { - var CSS = { - COURSECONTENT: 'course-content', - SECTIONADDMENUS: 'section_add_menus' - }; - var sectionlist = Y.Node.all('.' + CSS.COURSECONTENT + ' ' + M.course.format.get_section_selector(Y)); - // Swap the non-ajax menus, noting these are not always present (depends on theme and user prefs). - if (sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS)) { - sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.' + CSS.SECTIONADDMENUS)); - } -}; - -M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) { - var CSS = { - SECTIONNAME: 'sectionname' - }, - SELECTORS = { - SECTIONLEFTSIDE: '.left .section-handle img' - }; - if (response.action == 'move') { - if (sectionfrom > sectionto) { - var temp = sectionto; - sectionto = sectionfrom; - sectionfrom = temp; - } - var ele, str, stridx, newstr; - for (var i = sectionfrom; i <= sectionto; i++) { - var content = Y.Node.create('<span>' + response.sectiontitles[i] + '</span>'); - sectionlist.item(i).all('.' + CSS.SECTIONNAME).setHTML(content); - ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE); - str = ele.getAttribute('alt'); - stridx = str.lastIndexOf(' '); - newstr = str.substr(0, stridx + 1) + i; - ele.setAttribute('alt', newstr); - ele.setAttribute('title', newstr); - } - } -}; (function () { $(".iena-description .description-inner").each(function(index){ diff --git a/format.php b/format.php index 4a23a59..39dfe76 100644 --- a/format.php +++ b/format.php @@ -41,29 +41,6 @@ require_once($CFG->libdir . '/completionlib.php'); $PAGE->requires->js('/course/format/iena/js/jquery.min.js'); $PAGE->requires->js('/course/format/iena/format.js'); -/*if ($topic = optional_param('topic', 0, PARAM_INT)) { - $url = $PAGE->url; - $url->param('section', $topic); - debugging('Outdated topic param passed to course/view.php', DEBUG_DEVELOPER); - redirect($url); -} -$context = context_course::instance($course->id); -if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) { - $course->marker = $marker; - course_set_marker($course->id, $marker); -} -$course = course_get_format($course)->get_course(); -course_create_sections_if_missing($course, 0); -$renderer = $PAGE->get_renderer('format_iena'); -if (!empty($displaysection)) { - - $renderer->print_single_section_page($course, null, null, null, null, $displaysection); -} else { - $renderer->switch_mode($course); -}*/ - - - // Horrible backwards compatible parameter aliasing. if ($topic = optional_param('topic', 0, PARAM_INT)) { @@ -89,8 +66,8 @@ if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context course_create_sections_if_missing($course, 0); $renderer = $PAGE->get_renderer('format_iena'); -if (!empty($displaysection)) { - $format->set_section_number($displaysection); +if (!is_null($displaysection)) { + $format->set_sectionnum($displaysection); } $outputclass = $format->get_output_classname('content'); $widget = new $outputclass($format); diff --git a/lib.php b/lib.php index ad4fcd6..069bb0e 100644 --- a/lib.php +++ b/lib.php @@ -36,6 +36,7 @@ class format_iena extends format_topics { global $PAGE; static $courseformatoptions = false; if ($courseformatoptions === false) { + $courseformatoptions=array(); $courseformatoptions['allmodulesbreadcrum'] = array( 'default' => 0, 'type' => PARAM_INT, @@ -341,7 +342,10 @@ class format_iena extends format_topics { $url->param('section', $sectionno); } else { if (empty($CFG->linkcoursesections) && !empty($options['navigation'])) { - return null; + $sectioninfo = $this->get_section($sectionno); + //return new moodle_url('/course/section.php', ['id' => $sectioninfo->id]); + $url->set_anchor('section-' . $sectionno); + return $url; } $url->set_anchor('section-' . $sectionno); } diff --git a/renderer.php b/renderer.php index bdb75f0..41f71b4 100644 --- a/renderer.php +++ b/renderer.php @@ -21,7 +21,6 @@ defined('MOODLE_INTERNAL') || die(); -require_once($CFG->dirroot . '/course/format/topics/renderer.php'); /** * format_iena_renderer -- GitLab