From 09e401dedec6a951d6402e8d21c691db79344c66 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Mon, 24 Apr 2023 13:02:43 +0100 Subject: [PATCH 01/31] V401.0.1 work in progress. --- lib.php | 12 ------------ version.php | 10 +++++----- 2 files changed, 5 insertions(+), 17 deletions(-) diff --git a/lib.php b/lib.php index 6d6aceb..996b9ce 100644 --- a/lib.php +++ b/lib.php @@ -1712,18 +1712,6 @@ public function can_delete_section($section) { return true; } - private function get_context() { - global $SITE; - - if ($SITE->id == $this->courseid) { - // Use the context of the page which should be the course category. - global $PAGE; - return $PAGE->context; - } else { - return context_course::instance($this->courseid); - } - } - /** * Prepares the templateable object to display section name. * diff --git a/version.php b/version.php index 2ef7547..5a6afe4 100644 --- a/version.php +++ b/version.php @@ -33,9 +33,9 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2022112601; -$plugin->maturity = MATURITY_STABLE; -$plugin->requires = 2022112800.00; // 4.1 (Build: 20221128). -$plugin->supported = array(401, 401); +$plugin->version = 2023042400; +$plugin->maturity = MATURITY_RC; +$plugin->requires = 2023042400.00; // 4.2 (Build: 20230424). +$plugin->supported = array(402, 402); $plugin->component = 'format_topcoll'; -$plugin->release = '401.1.0'; +$plugin->release = '402.0.1'; From a90e8abd1b60d84a8fcc0cad8a740c61139012bf Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Mon, 24 Apr 2023 13:18:38 +0100 Subject: [PATCH 02/31] Update CI --- .github/workflows/ci.yml | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c55cc39..cc0b96a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -7,14 +7,6 @@ jobs: runs-on: ubuntu-22.04 services: - postgres: - image: postgres:13.0 - env: - POSTGRES_USER: 'postgres' - POSTGRES_HOST_AUTH_METHOD: 'trust' - ports: - - 5432:5432 - options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 3 mariadb: image: mariadb:10.6 env: @@ -30,17 +22,8 @@ jobs: fail-fast: false matrix: include: - - php: 7.4 - moodle-branch: 'MOODLE_401_STABLE' - database: pgsql - - php: 7.4 - moodle-branch: 'MOODLE_401_STABLE' - database: mariadb - - php: 8.0 - moodle-branch: 'MOODLE_401_STABLE' - database: pgsql - php: 8.0 - moodle-branch: 'MOODLE_401_STABLE' + moodle-branch: 'MOODLE_402_STABLE' database: mariadb steps: From 2fa98d1bf71447bd94d4dd00d57a6a911758ca28 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Mon, 24 Apr 2023 20:19:50 +0100 Subject: [PATCH 03/31] Removed duplicate section functionality as core has its own version. --- Changes.md | 4 + .../content/section/controlmenu.php | 14 -- duplicate.php | 178 ------------------ lang/en/format_topcoll.php | 10 - lib.php | 22 ++- 5 files changed, 25 insertions(+), 203 deletions(-) delete mode 100644 duplicate.php diff --git a/Changes.md b/Changes.md index 5760f1b..d496581 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,10 @@ Version Information =================== +Version 4021.0.1 - TBR +-------------------------- +1. Removed duplicate section functionality as core has its own version. + Version 401.1.0 - 01/04/23 -------------------------- 1. Content component improvements. diff --git a/classes/output/courseformat/content/section/controlmenu.php b/classes/output/courseformat/content/section/controlmenu.php index 8bb4498..60f5ebb 100644 --- a/classes/output/courseformat/content/section/controlmenu.php +++ b/classes/output/courseformat/content/section/controlmenu.php @@ -85,20 +85,6 @@ public function export_for_template(\renderer_base $output): stdClass { $menu->add($al); } - $course = $this->format->get_course(); - $coursecontext = context_course::instance($course->id); - if (has_capability('moodle/course:manageactivities', $coursecontext)) { - $duplicatestr = get_string('duplicate', 'format_topcoll'); - $duplicateurl = new moodle_url('/course/format/topcoll/duplicate.php', - array('courseid' => $course->id, 'sectionno' => $section->section, 'sesskey' => sesskey())); - $link = new \action_link($duplicateurl, ' '.$duplicatestr, null, - array('class' => 'menu-action', 'role' => 'menuitem'), - new \pix_icon('t/copy', $duplicatestr)); - $link->add_action(new \confirm_action(get_string('duplicateconfirm', 'format_topcoll'), null, - $duplicatestr)); - $menu->add_secondary_action($link); - } - $data = (object)[ 'menu' => $output->render($menu), 'hasmenu' => true, diff --git a/duplicate.php b/duplicate.php deleted file mode 100644 index ba10602..0000000 --- a/duplicate.php +++ /dev/null @@ -1,178 +0,0 @@ -. - -/** - * Duplicate resources on a section as a new section adapted from code written by: - * @copyright 2015 David Herney Bernal - cirano - in format_onetopic. - * - * @package format_topcoll - * @version See the value of '$plugin->version' in version.php. - * @copyright © 2020-onwards G J Barnard. - * @author G J Barnard - gjbarnard at gmail dot com and {@link http://moodle.org/user/profile.php?id=442195} - * @link http://docs.moodle.org/en/Collapsed_Topics_course_format - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later - */ - -define('NO_OUTPUT_BUFFERING', true); - -require_once('../../../config.php'); -require_once($CFG->dirroot.'/course/lib.php'); - -$courseid = required_param('courseid', PARAM_INT); -$sectionno = required_param('sectionno', PARAM_INT); -$course = $DB->get_record('course', array('id' => $courseid), '*', MUST_EXIST); - -$PAGE->set_url('/course/format/topcoll/duplicate.php', array('courseid' => $courseid, 'sectionno' => $sectionno)); - -// Authorization checks. -require_login($course); -$context = context_course::instance($course->id); -require_capability('moodle/course:update', $context); -require_capability('moodle/course:manageactivities', $context); -require_sesskey(); - -$courseformat = course_get_format($course); -$course = $courseformat->get_course(); -$modinfo = get_fast_modinfo($course); -$sectioninfo = $modinfo->get_section_info($sectionno); -$numnewsection = null; - -$PAGE->set_pagelayout('course'); -$PAGE->set_heading($course->fullname); - -$PAGE->set_title(get_string('coursetitle', 'moodle', array('course' => $course->fullname))); - -echo $OUTPUT->header(); - -if (!empty($sectioninfo)) { - $pbar = new progress_bar('topcoll_duplicate_bar', 500, true); - $pbar->update_full(1, get_string('duplicating', 'format_topcoll')); - - $lastsectionnum = $DB->get_field('course_sections', 'MAX(section)', array('course' => $courseid), MUST_EXIST); - - $numnewsection = $lastsectionnum + 1; - - $pbar->update_full(5, get_string('creatingsection', 'format_topcoll')); - - // Assign same section info. - $data = new stdClass(); - $data->course = $sectioninfo->course; - $data->section = $numnewsection; - // The name is not duplicated. - $data->summary = $sectioninfo->summary; - $data->summaryformat = $sectioninfo->summaryformat; - $data->visible = $sectioninfo->visible; - $data->availability = $sectioninfo->availability; - - $newsectionid = $DB->insert_record('course_sections', $data, true); - - // Update 'numsections'. - $courseformatdata = array('numsections' => $numnewsection); - $courseformat->update_course_format_options($courseformatdata); - - try { - $fs = get_file_storage(); - $files = $fs->get_area_files($context->id, 'course', 'section', $sectioninfo->id); - - if ($files && is_array($files)) { - $fileinfo = array( - 'component' => 'course', - 'filearea' => 'section' - ); - foreach ($files as $file) { - $fileinfo['contextid'] = $context->id; - $fileinfo['itemid'] = $newsectionid; - - $fs->create_file_from_storedfile($fileinfo, $file); - } - } - } catch (Exception $e) { - debugging('Error copying section files.'.$e->getMessage(), DEBUG_DEVELOPER); - } - - $moved = move_section_to($course, $numnewsection, $sectionno + 1); - if ($moved) { - $numnewsection = $sectionno + 1; - } - - $formatoptions = $courseformat->get_format_options($sectionno); - if (is_array($formatoptions) && count($formatoptions) > 0) { - $formatoptions['id'] = $newsectionid; - $courseformat->update_section_format_options($formatoptions); - } - - // Trigger an event for course section update. - $event = \core\event\course_section_updated::create( - array( - 'objectid' => $newsectionid, - 'courseid' => $course->id, - 'context' => $context, - 'other' => array('sectionnum' => $numnewsection) - ) - ); - $event->trigger(); - - $course = course_get_format($course)->get_course(); - $modinfo = get_fast_modinfo($course); - - $pbar->update_full(10, get_string('rebuildcoursecache', 'format_topcoll')); - $newsectioninfo = $modinfo->get_section_info($numnewsection); - $modules = array(); - - if (is_object($modinfo) && isset($modinfo->sections[$sectionno])) { - $sectionmods = $modinfo->sections[$sectionno]; - - if (is_array($sectionmods)) { - $progressbarelements = count($sectionmods); - $dataprogress = new stdClass(); - $dataprogress->current = 0; - $dataprogress->size = $progressbarelements; - $k = 0; - $pbar->update_full(40, get_string('progresscounter', 'format_topcoll', $dataprogress)); - foreach ($sectionmods as $modnumber) { - $k++; - $mod = $modinfo->cms[$modnumber]; - $cm = get_coursemodule_from_id('', $mod->id, 0, true, MUST_EXIST); - - $modcontext = context_module::instance($cm->id); - if (has_capability('moodle/course:manageactivities', $modcontext)) { - // Duplicate the module. - $newcm = duplicate_module($course, $cm); - - // Move new module to new section. - if ($newcm && is_object($newcm)) { - moveto_module($newcm, $newsectioninfo); - } - } - $dataprogress->current = $k; - $percent = 40 + ($k / $progressbarelements) * 60; - $pbar->update_full($percent, get_string('progresscounter', 'format_topcoll', $dataprogress)); - } - } - } else { - $pbar->update_full(100, get_string('progressfull', 'format_topcoll')); - } - - $sectiontogo = $numnewsection; -} else { - $sectiontogo = $sectionno; - echo get_string('errornosectioninfo', 'format_topcoll'); - echo $OUTPUT->continue_button(course_get_url($course, $sectionno)); - echo $OUTPUT->footer(); -} - -echo $OUTPUT->continue_button(course_get_url($course, $numnewsection)); -echo $OUTPUT->footer(); diff --git a/lang/en/format_topcoll.php b/lang/en/format_topcoll.php index 681fc41..3a31fab 100644 --- a/lang/en/format_topcoll.php +++ b/lang/en/format_topcoll.php @@ -446,16 +446,6 @@ $string['xsubmitted'] = '{$a->completed} submitted'; $string['xungraded'] = '{$a} ungraded'; -// Duplicate section. -$string['creatingsection'] = 'Creating new section'; -$string['duplicate'] = 'Duplicate'; -$string['duplicateconfirm'] = 'Are you sure you want to duplicate the current section? This can take a while depending on the amount of resources.'; -$string['duplicating'] = 'Duplicating'; -$string['errornosectioninfo'] = 'The indicated topic have not information'; -$string['progresscounter'] = 'Duplicating activities ({$a->current}/{$a->size})'; -$string['progressfull'] = 'Duplicating topic'; -$string['rebuildcoursecache'] = 'Rebuild course cache'; - // Readme. $string['readme_title'] = 'Collapsed Topics read-me'; $string['readme_desc'] = 'Please click on \'{$a->url}\' for lots more information about Collapsed Topics.'; diff --git a/lib.php b/lib.php index 996b9ce..7c8ecf9 100644 --- a/lib.php +++ b/lib.php @@ -56,7 +56,8 @@ protected function __construct($format, $courseid) { parent::__construct($format, $courseid); $section = optional_param('section', 0, PARAM_INT); - if ($section) { + $duplicatesection = optional_param('duplicatesection', 0, PARAM_INT); + if ($section && !$duplicatesection) { $this->coursedisplay = COURSE_DISPLAY_MULTIPAGE; } } @@ -1777,6 +1778,25 @@ public function section_action($section, $action, $sr) { return $rv; } + + /** + * Duplicate a section + * + * @param section_info $originalsection The section to be duplicated + * @return section_info The new duplicated section + * @since Moodle 4.2 + */ + public function duplicate_section(section_info $originalsection): section_info { + $retr = parent::duplicate_section($originalsection); + + // Update 'numsections'. + $newnumsections = $this->settings['numsections'] + 1; + $courseformatdata = array('numsections' => $newnumsections); + $this->update_course_format_options($courseformatdata); + + return $retr; + } + } /** From 993e360dd41c34fcaa5cb6339b2d07a42ef161e3 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Sun, 7 May 2023 18:58:26 +0100 Subject: [PATCH 04/31] First Moodle 4.2 release. --- Changes.md | 5 +++-- version.php | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Changes.md b/Changes.md index d496581..6308b63 100644 --- a/Changes.md +++ b/Changes.md @@ -1,9 +1,10 @@ Version Information =================== -Version 4021.0.1 - TBR +Version 402.1.0 - TBR -------------------------- -1. Removed duplicate section functionality as core has its own version. +1. First Moodle 4.2 release. +2. Removed duplicate section functionality as core has its own version. Version 401.1.0 - 01/04/23 -------------------------- diff --git a/version.php b/version.php index 5a6afe4..994817a 100644 --- a/version.php +++ b/version.php @@ -34,8 +34,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->version = 2023042400; -$plugin->maturity = MATURITY_RC; +$plugin->maturity = MATURITY_STABLE; $plugin->requires = 2023042400.00; // 4.2 (Build: 20230424). $plugin->supported = array(402, 402); $plugin->component = 'format_topcoll'; -$plugin->release = '402.0.1'; +$plugin->release = '402.1.0'; From b52c50ee584754544f052c0d1b79eb576f6ac067 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Sun, 7 May 2023 21:10:18 +0100 Subject: [PATCH 05/31] V402.1.0 --- Changes.md | 2 +- Readme.md | 12 ++++++------ Support.md | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Changes.md b/Changes.md index 6308b63..fdb22f1 100644 --- a/Changes.md +++ b/Changes.md @@ -1,7 +1,7 @@ Version Information =================== -Version 402.1.0 - TBR +Version 402.1.0 - 07/05/23 -------------------------- 1. First Moodle 4.2 release. 2. Removed duplicate section functionality as core has its own version. diff --git a/Readme.md b/Readme.md index a84bbc0..33298fc 100644 --- a/Readme.md +++ b/Readme.md @@ -3,29 +3,29 @@ Topic based course format with an individual 'toggle' for each topic except 0. This file contains general information about the format. If you're reading this as an educator then you can learn about the format -from the documentation on http://docs.moodle.org/401/en/Collapsed_Topics_course_format. If you get stuck and your Moodle support +from the documentation on http://docs.moodle.org/402/en/Collapsed_Topics_course_format. If you get stuck and your Moodle support are unable to help / not sure what to do, then please go to https://moodle.org/mod/forum/view.php?id=47. If you like the format, then please do spread the word to other educators. The main page for the format is https://moodle.org/plugins/format_topcoll. Required version of Moodle ========================== -This version works with Moodle 4.1 version 2022112800.00 (Build: 20221128) and above within the MOODLE_401_STABLE branch until the +This version works with Moodle 4.2 version 2023042400.00 (Build: 20230424) and above within the MOODLE_402_STABLE branch until the next release. -Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/401/en/Installing_Moodle)'. +Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/402/en/Installing_Moodle)'. Downloads and documentation =========================== The primary source for downloading this branch of the format is https://moodle.org/plugins/view.php?plugin=format_topcoll -with 'Select Moodle version:' set at 'Moodle 4.1'. +with 'Select Moodle version:' set at 'Moodle 4.2'. -The secondary source is a tagged version with the V401 prefix on https://github.com/gjb2048/moodle-format_topcoll/tags +The secondary source is a tagged version with the V402 prefix on https://github.com/gjb2048/moodle-format_topcoll/tags If you download from the development area - https://github.com/gjb2048/moodle-format_topcoll/ - consider that the code is unstable and not for use in production environments. This is because I develop the next version in stages and use GitHub as a means of backup. Therefore the code is not finished, subject to alteration and requires testing. -Documented on http://docs.moodle.org/401/en/Collapsed_Topics_course_format +Documented on http://docs.moodle.org/402/en/Collapsed_Topics_course_format Free software ============= diff --git a/Support.md b/Support.md index a2f20e3..d37e8be 100644 --- a/Support.md +++ b/Support.md @@ -49,10 +49,10 @@ benefits. Required version of Moodle ========================== -This version works with Moodle 4.1 version 2022112800.00 (Build: 20221128) and above within the MOODLE_401_STABLE branch until the +This version works with Moodle 4.2 version 2023042400.00 (Build: 20230424) and above within the MOODLE_402_STABLE branch until the next release. -Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/401/en/Installing_Moodle)'. +Please ensure that your hardware and software complies with 'Requirements' in '[Installing Moodle](https://docs.moodle.org/402/en/Installing_Moodle)'. Reporting issues ================ From f3c47e7d6e7a07657ef15f02f6aa0e7e302c7f21 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Tue, 9 May 2023 17:18:49 +0100 Subject: [PATCH 06/31] V402.1.1 --- Changes.md | 3 +++ version.php | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Changes.md b/Changes.md index fdb22f1..787516f 100644 --- a/Changes.md +++ b/Changes.md @@ -1,6 +1,9 @@ Version Information =================== +Version 402.1.1 - TBR +-------------------------- + Version 402.1.0 - 07/05/23 -------------------------- 1. First Moodle 4.2 release. diff --git a/version.php b/version.php index 994817a..1c4588b 100644 --- a/version.php +++ b/version.php @@ -33,9 +33,9 @@ */ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2023042400; +$plugin->version = 2023042401; $plugin->maturity = MATURITY_STABLE; $plugin->requires = 2023042400.00; // 4.2 (Build: 20230424). $plugin->supported = array(402, 402); $plugin->component = 'format_topcoll'; -$plugin->release = '402.1.0'; +$plugin->release = '402.1.1'; From b41b0ecce3c8ea68c5ed7fff636a7afc87627d72 Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Tue, 9 May 2023 17:20:22 +0100 Subject: [PATCH 07/31] Fix 'section_activity_summary' method. --- Changes.md | 1 + classes/output/format_renderer_migration_toolbox.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Changes.md b/Changes.md index 787516f..e6a0db2 100644 --- a/Changes.md +++ b/Changes.md @@ -3,6 +3,7 @@ Version 402.1.1 - TBR -------------------------- +1. Fix 'section_activity_summary' method. Version 402.1.0 - 07/05/23 -------------------------- diff --git a/classes/output/format_renderer_migration_toolbox.php b/classes/output/format_renderer_migration_toolbox.php index cf56f7f..21634e4 100644 --- a/classes/output/format_renderer_migration_toolbox.php +++ b/classes/output/format_renderer_migration_toolbox.php @@ -54,7 +54,7 @@ trait format_renderer_migration_toolbox { protected function section_activity_summary($section, $course, $mods) { $widgetclass = $this->courseformat->get_output_classname('content\\section\\cmsummary'); $widget = new $widgetclass($this->courseformat, $section); - $this->render($widget); + return $this->render($widget); } /** From 4dad508ebbf422dd5fe44f8d1c742451b57e543c Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Tue, 9 May 2023 18:15:00 +0100 Subject: [PATCH 08/31] Single section navigation fixes. --- Changes.md | 1 + templates/singlesection.mustache | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/Changes.md b/Changes.md index e6a0db2..d74008d 100644 --- a/Changes.md +++ b/Changes.md @@ -4,6 +4,7 @@ Version 402.1.1 - TBR -------------------------- 1. Fix 'section_activity_summary' method. +2. Single section navigation fixes. Version 402.1.0 - 07/05/23 -------------------------- diff --git a/templates/singlesection.mustache b/templates/singlesection.mustache index c9c6ee7..c877bf5 100644 --- a/templates/singlesection.mustache +++ b/templates/singlesection.mustache @@ -77,17 +77,9 @@ {{/sectionzero}}
{{{sectionnavlinks}}} - {{{sectiontitle}}} -
- {{{sectionnavlinksprevious}}} -
{{{sectionnavselection}}}
- {{{sectionnavlinksnext}}} -
+ {{{sectionnavselection}}}
From f147db96fea60043276aa56f2458b6f3008f05ba Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Tue, 9 May 2023 19:14:46 +0100 Subject: [PATCH 09/31] Improve single section navigation appearance. --- Changes.md | 1 + .../content/sectionnavigation.php | 45 ++++++++++++++++ .../courseformat/content/sectionselector.php | 46 ++++++++++++++++ styles.css | 10 ++++ .../local/content/sectionnavigation.mustache | 47 ++++++++++++++++ .../local/content/sectionselector.mustache | 53 +++++++++++++++++++ 6 files changed, 202 insertions(+) create mode 100644 classes/output/courseformat/content/sectionnavigation.php create mode 100644 classes/output/courseformat/content/sectionselector.php create mode 100644 templates/local/content/sectionnavigation.mustache create mode 100644 templates/local/content/sectionselector.mustache diff --git a/Changes.md b/Changes.md index d74008d..1c32836 100644 --- a/Changes.md +++ b/Changes.md @@ -5,6 +5,7 @@ Version 402.1.1 - TBR -------------------------- 1. Fix 'section_activity_summary' method. 2. Single section navigation fixes. +3. Improve single section navigation appearance. Version 402.1.0 - 07/05/23 -------------------------- diff --git a/classes/output/courseformat/content/sectionnavigation.php b/classes/output/courseformat/content/sectionnavigation.php new file mode 100644 index 0000000..daf4d75 --- /dev/null +++ b/classes/output/courseformat/content/sectionnavigation.php @@ -0,0 +1,45 @@ +. + +/** + * Collapsed Topics + * + * Contains the default section controls output class. + * + * @package format_topcoll + * @version See the value of '$plugin->version' in version.php. + * @copyright © 2023-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} + * @copyright 2020 Ferran Recio + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace format_topcoll\output\courseformat\content; + +/** + * Base class to render a course add section navigation. + */ +class sectionnavigation extends \core_courseformat\output\local\content\sectionnavigation { + /** + * Get the name of the template to use for this templatable. + * + * @param \renderer_base $renderer The renderer requesting the template name + * @return string + */ + public function get_template_name(\renderer_base $renderer): string { + return 'format_topcoll/local/content/sectionnavigation'; + } +} diff --git a/classes/output/courseformat/content/sectionselector.php b/classes/output/courseformat/content/sectionselector.php new file mode 100644 index 0000000..ca952ca --- /dev/null +++ b/classes/output/courseformat/content/sectionselector.php @@ -0,0 +1,46 @@ +. + +/** + * Collapsed Topics + * + * Contains the default section controls output class. + * Contains the default section selector. + * + * @package format_topcoll + * @version See the value of '$plugin->version' in version.php. + * @copyright © 2023-onwards G J Barnard in respect to modifications of standard topics format. + * @author G J Barnard - {@link http://moodle.org/user/profile.php?id=442195} + * @copyright 2020 Ferran Recio + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + */ + +namespace format_topcoll\output\courseformat\content; + +/** + * Represents the section selector. + */ +class sectionselector extends \core_courseformat\output\local\content\sectionselector { + /** + * Get the name of the template to use for this templatable. + * + * @param \renderer_base $renderer The renderer requesting the template name + * @return string + */ + public function get_template_name(\renderer_base $renderer): string { + return 'format_topcoll/local/content/sectionselector'; + } +} diff --git a/styles.css b/styles.css index bd73e8d..be1f047 100644 --- a/styles.css +++ b/styles.css @@ -959,6 +959,16 @@ element.style { z-index: 500; } +.tcjumptocontainer { + left: 0; + position: absolute; + right: 0; +} + +.tcjumptocontainer .tcjumpto { + text-align: center; +} + /* Print styles. */ @media print { body.jsenabled .toggledsection { diff --git a/templates/local/content/sectionnavigation.mustache b/templates/local/content/sectionnavigation.mustache new file mode 100644 index 0000000..d15a4e1 --- /dev/null +++ b/templates/local/content/sectionnavigation.mustache @@ -0,0 +1,47 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template format_topcoll/local/content/sectionnavigation + + Displays the course section navigation. + + Example context (json): + { + "hasprevious": true, + "previousurl": "#", + "previousname": "Section 6", + "hasnext": true, + "nexturl": "#", + "nextname": "Section 8" + } +}} + diff --git a/templates/local/content/sectionselector.mustache b/templates/local/content/sectionselector.mustache new file mode 100644 index 0000000..e9b9a8b --- /dev/null +++ b/templates/local/content/sectionselector.mustache @@ -0,0 +1,53 @@ +{{! + This file is part of Moodle - http://moodle.org/ + + Moodle is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + Moodle is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Moodle. If not, see . +}} +{{! + @template format_topcoll/local/content/sectionselector + + Displays the course section navigation. + + Example context (json): + { + "hasprevious": true, + "previousurl": "#", + "previousname": "Section 6", + "hasnext": true, + "nexturl": "#", + "nextname": "Section 8", + "selector": "" + } +}} +
+
+ {{#hasprevious}} + + {{{previousname}}} + + {{/hasprevious}} +
+
+
+ {{{selector}}} +
+
+
+ {{#hasnext}} + + {{{nextname}}} + + {{/hasnext}} +
+
From bc242ac8561a178c7d83a1f6abc4004c90182ccd Mon Sep 17 00:00:00 2001 From: Gareth Barnard <1058419+gjb2048@users.noreply.github.com> Date: Wed, 10 May 2023 16:40:06 +0100 Subject: [PATCH 10/31] Improved single section navigation. --- styles.css | 25 ++++++++++++++----- .../local/content/sectionnavigation.mustache | 6 ++--- .../local/content/sectionselector.mustache | 12 ++++----- 3 files changed, 27 insertions(+), 16 deletions(-) diff --git a/styles.css b/styles.css index be1f047..5f1b702 100644 --- a/styles.css +++ b/styles.css @@ -959,14 +959,27 @@ element.style { z-index: 500; } -.tcjumptocontainer { - left: 0; - position: absolute; - right: 0; +/* Single section navigation */ +.course-content .single-section .section-navigation.tc-selection-selector-container { + align-items: center; + display: flex; } -.tcjumptocontainer .tcjumpto { - text-align: center; +.course-content .single-section .section-navigation .tc-selection-selector-item { + display: flex; + flex: 1 0 0%; +} + +.tc-selection-selector-item.prevsection { + justify-content: flex-start; +} + +.tc-selection-selector-item.jumpto { + justify-content: center; +} + +.tc-selection-selector-item.nextsection { + justify-content: flex-end; } /* Print styles. */ diff --git a/templates/local/content/sectionnavigation.mustache b/templates/local/content/sectionnavigation.mustache index d15a4e1..fb7790e 100644 --- a/templates/local/content/sectionnavigation.mustache +++ b/templates/local/content/sectionnavigation.mustache @@ -29,15 +29,15 @@ "nextname": "Section 8" } }} -