├── composer.json
├── lang
└── en
│ └── deprecated.txt
├── templates
├── local
│ ├── subsectionmodes
│ │ ├── summary.mustache
│ │ ├── list.mustache
│ │ └── collapsible.mustache
│ ├── activity_dateinline.mustache
│ ├── content
│ │ ├── cm.mustache
│ │ ├── section
│ │ │ └── content.mustache
│ │ └── section.mustache
│ └── content.mustache
├── courseformat
│ ├── content
│ │ ├── cminlinecompletion.mustache
│ │ ├── cm
│ │ │ ├── badgesinline.mustache
│ │ │ ├── cmiconinline.mustache
│ │ │ ├── availabilityinline.mustache
│ │ │ ├── cmnameinline.mustache
│ │ │ ├── activityinline.mustache
│ │ │ └── cmhelpinfo.mustache
│ │ └── cminline.mustache
│ └── tabtree.mustache
├── footer.mustache
└── header.mustache
├── format.js
├── classes
├── courseformat
│ └── stateactions.php
├── local
│ ├── hooks
│ │ └── output
│ │ │ └── before_http_headers.php
│ ├── formelement_background.php
│ └── clilib.php
├── privacy
│ └── provider.php
├── output
│ ├── courseformat
│ │ ├── content
│ │ │ ├── delegatedsection.php
│ │ │ ├── sectionselector.php
│ │ │ ├── section.php
│ │ │ ├── sectionnavigation.php
│ │ │ └── section
│ │ │ │ ├── cmlist.php
│ │ │ │ └── controlmenu.php
│ │ └── content.php
│ └── renderer.php
├── footer.php
├── singletab.php
└── tabstyles.php
├── db
├── upgrade.php
└── hooks.php
├── version.php
├── amd
├── build
│ ├── main.min.js
│ ├── onetopicbackground.min.js
│ ├── oneline.min.js
│ ├── main.min.js.map
│ ├── onetopicbackground.min.js.map
│ └── oneline.min.js.map
└── src
│ ├── main.js
│ ├── onetopicbackground.js
│ └── oneline.js
├── format.php
├── cli.php
├── tests
└── behat
│ ├── highlight_sections.feature
│ └── edit_delete_sections.feature
├── backup
└── moodle2
│ └── restore_format_onetopic_plugin.class.php
├── README.md
├── .github
└── workflows
│ └── moodle-ci.yml
├── changenumsections.php
├── styles.php
└── settings.php
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "davidherney/moodle-format_onetopic",
3 | "type": "moodle-format",
4 | "require": {
5 | "composer/installers": "~1.0"
6 | },
7 | "extra": {
8 | "installer-name": "onetopic"
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/lang/en/deprecated.txt:
--------------------------------------------------------------------------------
1 | disable,format_onetopic
2 | disableajax,format_onetopic
3 | disableajax_help,format_onetopic
4 | enable,format_onetopic
5 | utilities,format_onetopic
6 | duplicate,format_onetopic
7 | duplicate_confirm,format_onetopic
8 | duplicatesection,format_onetopic
9 | duplicatesection_help,format_onetopic
10 | duplicating,format_onetopic
11 | progress_counter,format_onetopic
12 | progress_full,format_onetopic
13 | rebuild_course_cache,format_onetopic
14 |
--------------------------------------------------------------------------------
/templates/local/subsectionmodes/summary.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/local/subsectionmodes/summary
19 |
20 | Default moodle summary template for subsection mode.
21 |
22 | Example context (json):
23 | {
24 | }
25 | }}
26 | {{> core_courseformat/local/content/delegatedsection }}
27 |
--------------------------------------------------------------------------------
/format.js:
--------------------------------------------------------------------------------
1 | // Javascript functions for onetopic course format
2 |
3 | M.course = M.course || {};
4 |
5 | M.course.format = M.course.format || {};
6 |
7 | M.course.format.showInfo = function(id) {
8 |
9 | new M.core.dialogue({
10 | draggable: true,
11 | headerContent: '' + M.util.get_string('info', 'moodle') + '',
12 | bodyContent: Y.Node.one('#' + id),
13 | centered: true,
14 | width: '480px',
15 | modal: true,
16 | visible: true
17 | });
18 |
19 | Y.Node.one('#' + id).show();
20 |
21 | };
22 |
23 | M.course.format.dialogueinitloaded = false;
24 |
25 | M.course.format.dialogueinit = function() {
26 |
27 | if (M.course.format.dialogueinitloaded) {
28 | return;
29 | }
30 |
31 | M.course.format.dialogueinitloaded = true;
32 | Y.all('[data-infoid]').each(function(node) {
33 | node.on('click', function(e) {
34 | e.preventDefault();
35 | M.course.format.showInfo(node.getAttribute('data-infoid'));
36 | });
37 | });
38 | };
39 |
--------------------------------------------------------------------------------
/templates/local/activity_dateinline.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/local/activity_date
19 |
20 | Template for displaying the activity's dates.
21 |
22 | Example context (json):
23 | {
24 | "label": "Opens:",
25 | "datestring": "6 April 2021, 6:46 PM"
26 | }
27 | }}
28 |
29 | {{label}} {{datestring}}
30 |
31 |
--------------------------------------------------------------------------------
/classes/courseformat/stateactions.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | namespace format_onetopic\courseformat;
18 |
19 | use format_topics\courseformat\stateactions as stateactions_format_topics;
20 |
21 | /**
22 | * Contains the core course state actions specific to topics format.
23 | *
24 | * @package format_onetopic
25 | * @copyright 2024 David Herney - cirano. https://bambuco.co
26 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 | */
28 | class stateactions extends stateactions_format_topics {
29 | }
30 |
--------------------------------------------------------------------------------
/db/upgrade.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Upgrade scripts for course format "onetopic"
19 | *
20 | * @package format_onetopic
21 | * @copyright 2018 David Herney Bernal - cirano
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 | */
24 |
25 | /**
26 | * Upgrade script for format_onetopic
27 | *
28 | * @param int $oldversion the version we are upgrading from
29 | * @return bool result
30 | */
31 | function xmldb_format_onetopic_upgrade($oldversion) {
32 | global $CFG, $DB;
33 |
34 | return true;
35 | }
36 |
--------------------------------------------------------------------------------
/db/hooks.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Hook callbacks for Onetopic format
19 | *
20 | * @package format_onetopic
21 | * @copyright 2024 2024 David Herney @ BambuCo
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 | */
24 |
25 | defined('MOODLE_INTERNAL') || die();
26 |
27 | $callbacks = [
28 |
29 | [
30 | 'hook' => core\hook\output\before_http_headers::class,
31 | 'callback' => 'format_onetopic\local\hooks\output\before_http_headers::callback',
32 | 'priority' => 0,
33 | ],
34 | ];
35 |
--------------------------------------------------------------------------------
/templates/courseformat/content/cminlinecompletion.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/content/cminlinecompletion
19 |
20 | Displays a course module instance inside a course section.
21 |
22 | Example context (json):
23 | {
24 | "completedclass": "complete"
25 | }
26 | }}
27 |
28 | {{$ format_onetopic/courseformat/content/cminline }}
29 | {{> format_onetopic/courseformat/content/cminline }}
30 | {{/ format_onetopic/courseformat/content/cminline }}
31 |
32 |
--------------------------------------------------------------------------------
/classes/local/hooks/output/before_http_headers.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | namespace format_onetopic\local\hooks\output;
18 |
19 | /**
20 | * Hook callbacks for format_onetopic
21 | *
22 | * @package format_onetopic
23 | * @copyright 2024 David Herney @ BambuCo
24 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25 | */
26 | class before_http_headers {
27 | /**
28 | * Moodle native lib/navigationlib.php calls this hook allowing us to override UI.
29 | *
30 | * @param \core\hook\output\before_http_headers $unused
31 | */
32 | public static function callback(\core\hook\output\before_http_headers $unused): void {
33 | global $PAGE;
34 | $PAGE->requires->css('/course/format/onetopic/styles.php');
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/templates/courseformat/content/cm/badgesinline.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/content/cm/badges
19 |
20 | Convenience mustache to displays if an activity is in hidden or stealth mode.
21 |
22 | Format plugins are free to implement an alternative inplace editable for activities.
23 |
24 | Example context (json):
25 | {
26 | "modhiddenfromstudents" : "1",
27 | "modstealth" : "1"
28 | }
29 | }}
30 | {{#modhiddenfromstudents}}
31 |
32 | {{#str}}hiddenfromstudents{{/str}}
33 |
34 | {{/modhiddenfromstudents}}
35 | {{#modstealth}}
36 |
37 | {{#str}}hiddenoncoursepage{{/str}}
38 |
39 | {{/modstealth}}
40 |
--------------------------------------------------------------------------------
/templates/courseformat/content/cm/cmiconinline.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/content/cm/cmiconinline
19 |
20 | Displays a course module icon.
21 |
22 | Example context (json):
23 | {
24 | "icon": "../../../pix/help.svg",
25 | "iconclass": "",
26 | "purpose": "content",
27 | "modname": "resource",
28 | "pluginname": "File",
29 | "showtooltip": 1
30 | }
31 | }}
32 |
33 |
41 |
42 |
--------------------------------------------------------------------------------
/classes/privacy/provider.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Privacy Subsystem implementation for format_onetopic.
19 | *
20 | * @package format_onetopic
21 | * @copyright 2019 David Herney Bernal - cirano
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 | */
24 |
25 | namespace format_onetopic\privacy;
26 |
27 | /**
28 | * Privacy Subsystem for format_onetopic implementing null_provider.
29 | *
30 | * @copyright 2019 David Herney Bernal - cirano
31 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 | */
33 | class provider implements \core_privacy\local\metadata\null_provider {
34 | /**
35 | * Get the language string identifier with the component's language
36 | * file to explain why this plugin stores no data.
37 | *
38 | * @return string
39 | */
40 | public static function get_reason(): string {
41 | return 'privacy:metadata';
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/templates/footer.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/footer
19 |
20 | Example context (json):
21 | {
22 | "uniqid": "course-1",
23 | "sectionreturn": 1,
24 | "hastopictabs": true,
25 | "testing": true
26 | }
27 | }}
28 |
29 | {{#testing}}
30 |
{{! Used in order to break the div wraped in output.course_content_footer }}
43 |
44 | {{! End of onetopic-tab-body box. }}
45 |
46 |
47 |
48 |
49 |
50 | {{#js}}
51 | require(['core_courseformat/local/content'], function(component) {
52 | component.init('#{{uniqid}}-course-format',
53 | {
54 | SECTION: `ul.onetopic [data-for='section']`,
55 | SECTION_CMLIST: `ul.onetopic [data-for='cmlist']`,
56 | CM: `ul.onetopic [data-for='cmitem']`,
57 | },
58 | {{sectionreturn}});
59 | });
60 | {{/js}}
61 |
--------------------------------------------------------------------------------
/templates/courseformat/content/cm/availabilityinline.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/content/cm/availabilityinline
19 |
20 | Displays a activity availability with inline tags.
21 |
22 | Example context (json):
23 | {
24 | "info": [
25 | {
26 | "classes": "",
27 | "text": "Not available unless:
It is on or after 8 June 2012
",
28 | "ishidden": 0,
29 | "isstealth": 0,
30 | "isrestricted": 1,
31 | "isfullinfo": 1
32 | }
33 | ],
34 | "hasmodavailability": true
35 | }
36 | }}
37 | {{#hasmodavailability}}
38 | {{#info}}
39 |
40 | {{^isrestricted}}
41 | {{{text}}}
42 | {{/isrestricted}}
43 | {{#isrestricted}}
44 |
45 | {{#pix}}t/unlock, core{{/pix}}
46 |
47 | {{/isrestricted}}
48 |
49 | {{/info}}
50 | {{/hasmodavailability}}
51 |
--------------------------------------------------------------------------------
/version.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Version details.
19 | *
20 | * Component releases:
21 | * Un recorderis de las Veredas de mi pueblo, en homenaje a los campesinos de mi tierra.
22 | *
23 | * Old releases: Guarango, Pantalio, Chalarca, Mazorcal, Chuscalito, Las Teresas, La Madera, Las Brisas, Buenavista,
24 | * San Juan, La Almería, Piedras Teherán, El Cardal, La Divisa, Las Acacias.
25 | *
26 | * Next releases: Santa Cruz, Vallejuelito, Fátima, La Cabaña, La Palmera, Las Colmenas, Minitas,
27 | * Quebrada Negra, San Francisco, San Miguel Abajo, San Miguel, La Concha.
28 | *
29 | * @package format_onetopic
30 | * @copyright 2015 David Herney - cirano. https://bambuco.co
31 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32 | */
33 |
34 | defined('MOODLE_INTERNAL') || die();
35 |
36 | $plugin->version = 2025021902.02; // The current plugin version (Date: YYYYMMDDXX).
37 | $plugin->requires = 2025021400; // Requires this Moodle version.
38 | $plugin->component = 'format_onetopic'; // Full name of the plugin (used for diagnostics).
39 | $plugin->maturity = MATURITY_STABLE;
40 | $plugin->release = '5.0.2(LaDivisa)';
41 | $plugin->dependencies = ['format_topics' => 2025041400];
42 | $plugin->supported = [500, 500];
43 |
--------------------------------------------------------------------------------
/classes/output/courseformat/content/delegatedsection.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Contains the delegated section course format output class.
19 | *
20 | * @package format_onetopic
21 | * @copyright 2025 David Herney - cirano. https://bambuco.co
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 | */
24 |
25 | namespace format_onetopic\output\courseformat\content;
26 |
27 | use core_courseformat\output\local\content\delegatedsection as delegatedsection_base;
28 |
29 | /**
30 | * Class to render a delegated section.
31 | *
32 | * @package format_onetopic
33 | * @copyright 2025 David Herney - cirano. https://bambuco.co
34 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35 | */
36 | class delegatedsection extends delegatedsection_base {
37 | /**
38 | * @var section The onetopic section output instance.
39 | */
40 | public $onesection;
41 |
42 | /**
43 | * Load the section according to the current format because the delegated class is not aware of the specific format.
44 | *
45 | */
46 | public function load_onesection() {
47 | $this->onesection = new \format_onetopic\output\courseformat\content\section($this->format, $this->section);
48 | $this->onesection->insection = true;
49 | }
50 |
51 | /**
52 | * Get the display mode of the delegated section.
53 | *
54 | * @return string
55 | */
56 | public function get_displaymode(): string {
57 | $options = $this->format->get_format_options($this->section);
58 |
59 | return $options['displaymode'] ?? 'list';
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/templates/courseformat/tabtree.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/tabtree
19 |
20 | Tab tree.
21 |
22 | Example context (json):
23 | {
24 | "tabs": [{
25 | "active": "true",
26 | "inactive": "false",
27 | "link": [{
28 | "link": "http://moodle.org"
29 | }],
30 | "title": "Moodle.org",
31 | "text": "Moodle community",
32 | "styles": "color: #ff00ff"
33 | }]
34 | }
35 | }}
36 |
58 |
--------------------------------------------------------------------------------
/amd/build/main.min.js:
--------------------------------------------------------------------------------
1 | define("format_onetopic/main",["exports","format_onetopic/oneline","jquery","core/modal_factory","core/str"],(function(_exports,OneLine,_jquery,_modal_factory,_str){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _getRequireWildcardCache(nodeInterop){if("function"!=typeof WeakMap)return null;var cacheBabelInterop=new WeakMap,cacheNodeInterop=new WeakMap;return(_getRequireWildcardCache=function(nodeInterop){return nodeInterop?cacheNodeInterop:cacheBabelInterop})(nodeInterop)}Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,OneLine=function(obj,nodeInterop){if(!nodeInterop&&obj&&obj.__esModule)return obj;if(null===obj||"object"!=typeof obj&&"function"!=typeof obj)return{default:obj};var cache=_getRequireWildcardCache(nodeInterop);if(cache&&cache.has(obj))return cache.get(obj);var newObj={},hasPropertyDescriptor=Object.defineProperty&&Object.getOwnPropertyDescriptor;for(var key in obj)if("default"!==key&&Object.prototype.hasOwnProperty.call(obj,key)){var desc=hasPropertyDescriptor?Object.getOwnPropertyDescriptor(obj,key):null;desc&&(desc.get||desc.set)?Object.defineProperty(newObj,key,desc):newObj[key]=obj[key]}newObj.default=obj,cache&&cache.set(obj,newObj);return newObj}
2 | /**
3 | * General format features.
4 | *
5 | * @module format_onetopic/main
6 | * @copyright 2021 David Herney Bernal - cirano
7 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
8 | */(OneLine),_jquery=_interopRequireDefault(_jquery),_modal_factory=_interopRequireDefault(_modal_factory);_exports.init=(formattype,icons)=>{2==formattype&&OneLine.load(icons);var infotitle=(0,_str.get_string)("aboutresource","format_onetopic");(0,_jquery.default)(".format-onetopic .onetopic .iconwithhelp[data-helpwindow]").each((function(){var $node=(0,_jquery.default)(this);$node.on("click",(function(e){e.preventDefault();var $content=(0,_jquery.default)("#hw-"+$node.data("helpwindow"));if($content.data("modal"))$content.data("modal").show();else{var title=$content.data("title");title||(title=infotitle),_modal_factory.default.create({title:title,body:""}).done((function(modal){var contenthtml=$content.html();contenthtml=contenthtml.replace(//g,(function(match,p1){return p1}));var $modalBody=modal.getBody();$modalBody.css("min-height","150px"),$modalBody.append(contenthtml),modal.show(),$content.data("modal",modal)}))}}))}))}}));
9 |
10 | //# sourceMappingURL=main.min.js.map
--------------------------------------------------------------------------------
/templates/courseformat/content/cm/cmnameinline.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/content/cm/cmnameinline
19 |
20 | Convenience mustache to displays a course module inplcae editable from the format renderer.
21 |
22 | Format plugins are free to implement an alternative inplace editable for activities.
23 |
24 | Example context (json):
25 | {
26 | "url": "#",
27 | "icon": "../../../pix/help.svg",
28 | "pluginname": "File",
29 | "textclasses": "",
30 | "purpose": "content",
31 | "modname": "resource",
32 | "activityname": {
33 | "displayvalue" : "Moodle",
34 | "value" : "Moodle",
35 | "itemid" : "1",
36 | "component" : "core_unknown",
37 | "itemtype" : "unknown",
38 | "edithint" : "Edit this",
39 | "editlabel" : "New name for this",
40 | "type" : "text",
41 | "options" : "",
42 | "linkeverything": 0
43 | }
44 | }
45 | }}
46 | {{#url}}
47 |
48 | {{^hideicons}}
49 | {{! Icon }}
50 | {{#activityicon}}
51 | {{$ format_onetopic/courseformat/content/cm/cmiconinline }}
52 | {{> format_onetopic/courseformat/content/cm/cmiconinline }}
53 | {{/ format_onetopic/courseformat/content/cm/cmiconinline }}
54 | {{/activityicon}}
55 | {{/hideicons}}
56 |
57 | {{#activityname}}
58 | {{{displayvalue}}}
59 | {{/activityname}}
60 |
61 |
62 | {{/url}}
63 |
--------------------------------------------------------------------------------
/amd/build/onetopicbackground.min.js:
--------------------------------------------------------------------------------
1 | define("format_onetopic/onetopicbackground",["exports","jquery","core/modal_factory","core/modal_save_cancel","core/modal_events"],(function(_exports,_jquery,_modal_factory,_modal_save_cancel,_modal_events){function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}
2 | /**
3 | * Onetopic background selector.
4 | *
5 | * @module format_onetopic/onetopicbackground
6 | * @copyright 2021 David Herney Bernal - cirano
7 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
8 | */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.init=void 0,_jquery=_interopRequireDefault(_jquery),_modal_factory=_interopRequireDefault(_modal_factory),_modal_save_cancel=_interopRequireDefault(_modal_save_cancel),_modal_events=_interopRequireDefault(_modal_events);_exports.init=controlid=>{var $controlinput=(0,_jquery.default)("#"+controlid),$control=$controlinput.parent(".backgroundpicker"),$controlwindow=$control.find(".backgroundpickerwindow"),$controlbutton=$control.find(".backgroundpickerselector"),$colorpickerinput=$controlwindow.find('input.form-control[type="text"]');$controlinput.on("change",(function(){var $color=$controlinput.val();$color?$controlinput.css("background",$color):$controlinput.css("background","")})),$controlinput.trigger("change");var title=$controlwindow.attr("title"),buttons=[];buttons.save=$controlwindow.data("savelabel");_modal_factory.default.create({title:title,body:$controlwindow,type:_modal_save_cancel.default.TYPE,large:!0,buttons:buttons}).done((function(modal){modal.getBody().append($controlwindow),$control.data("modal",modal),function(modal){modal.getRoot().on(_modal_events.default.cancel,(()=>{modal.hide()})),modal.getRoot().on(_modal_events.default.save,(()=>{var newcolor=$colorpickerinput.val(),val=$controlinput.val(),color=readColor(val);color?val=val.replace(color,newcolor):""===val.trim()?val=newcolor:val+=" "+newcolor,$controlinput.val(val),$controlinput.css("background",val),modal.hide()}))}(modal)})),$controlbutton.on("click",(function(e){e.preventDefault(),$controlwindow.removeClass("hidden");var currentval=$controlinput.val(),color=readColor(currentval);$colorpickerinput.val(color),$control.data("modal").show()}))};var readColor=function(text){var regexcolor=new RegExp(/#[0-9a-fA-F]{6}/.source+/|#[0-9a-fA-F]{3}/.source+/|rgba?\(\s*([0-9]{1,3}\s*,\s*){2}[0-9]{1,3}\s*(,\s*[0-9.]+\s*)?\)/.source+/|hsla?\(\s*([0-9]{1,3}\s*,\s*){2}[0-9]{1,3}\s*(,\s*[0-9.]+\s*)?\)/.source),color=text.match(regexcolor);return color&&(color=color[0]),color}}));
9 |
10 | //# sourceMappingURL=onetopicbackground.min.js.map
--------------------------------------------------------------------------------
/classes/footer.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * This file contains class for render the footer in the course format onetopic.
19 | *
20 | * @package format_onetopic
21 | * @copyright 2023 David Herney - https://bambuco.co
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 | */
24 |
25 | namespace format_onetopic;
26 |
27 | use core_courseformat\output\local\content as content_base;
28 | use course_modinfo;
29 |
30 | /**
31 | * Class used to render the footer content in each course page.
32 | *
33 | *
34 | * @package format_onetopic
35 | * @copyright 2016 David Herney - https://bambuco.co
36 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37 | */
38 | class footer implements \renderable, \templatable {
39 | /**
40 | * @var \format_onetopic
41 | */
42 | private $format;
43 |
44 | /**
45 | * Constructor.
46 | *
47 | * @param \format_onetopic $format Course format instance.
48 | */
49 | public function __construct(\format_onetopic $format) {
50 | global $COURSE;
51 |
52 | $this->format = $format;
53 | }
54 |
55 | /**
56 | * Export this data so it can be used as the context for a mustache template (core/inplace_editable).
57 | *
58 | * @param renderer_base $output typically, the renderer that's calling this function
59 | * @return stdClass data context for a mustache template
60 | */
61 | public function export_for_template(\renderer_base $output) {
62 |
63 | $format = $this->format;
64 | $currentsection = $this->format->get_sectionnum();
65 |
66 | $data = (object)[
67 | 'uniqid' => $format->uniqid,
68 | 'sectionreturn' => $currentsection ?? 0,
69 | 'hastopictabs' => $format->hastopictabs,
70 | 'hassecondrow' => $format->hassecondrow,
71 | ];
72 |
73 | return $data;
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/format.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Display the whole course as "tabs".
19 | *
20 | * It is based of the "topics" format.
21 | *
22 | * @since 2.0
23 | * @package format_onetopic
24 | * @copyright 2012 David Herney Bernal - cirano
25 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
26 | */
27 |
28 | defined('MOODLE_INTERNAL') || die();
29 |
30 | require_once($CFG->libdir . '/filelib.php');
31 | require_once($CFG->libdir . '/completionlib.php');
32 |
33 | // Horrible backwards compatible parameter aliasing.
34 | if ($topic = optional_param('topic', 0, PARAM_INT)) {
35 | $url = $PAGE->url;
36 | $url->param('section', $topic);
37 | debugging('Outdated topic param passed to course/view.php', DEBUG_DEVELOPER);
38 | redirect($url);
39 | }
40 | // End backwards-compatible aliasing.
41 |
42 | $context = context_course::instance($course->id);
43 | // Retrieve course format option fields and add them to the $course object.
44 | $course = course_get_format($course)->get_course();
45 |
46 | if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
47 | $course->marker = $marker;
48 | course_set_marker($course->id, $marker);
49 | }
50 |
51 | // Onetopic format is always multipage.
52 | $course->coursedisplay = COURSE_DISPLAY_MULTIPAGE;
53 |
54 | $renderer = $PAGE->get_renderer('format_onetopic');
55 |
56 | $disableajax = optional_param('onetopic_da', -1, PARAM_INT);
57 |
58 | if (!isset($USER->onetopic_da)) {
59 | $USER->onetopic_da = [];
60 | }
61 |
62 | if ($disableajax !== -1) {
63 | if ($disableajax === 0) {
64 | $USER->onetopic_da[$course->id] = false;
65 | } else {
66 | $USER->onetopic_da[$course->id] = true;
67 | }
68 | }
69 |
70 | if (!is_null($displaysection)) {
71 | $format->set_sectionnum($displaysection);
72 | }
73 |
74 | $outputclass = $format->get_output_classname('content');
75 | $widget = new $outputclass($format);
76 | echo $renderer->render($widget);
77 |
--------------------------------------------------------------------------------
/amd/build/oneline.min.js:
--------------------------------------------------------------------------------
1 | define("format_onetopic/oneline",["exports","jquery"],(function(_exports,_jquery){var obj;
2 | /**
3 | * Used to oneline tabs view.
4 | *
5 | * @module format_onetopic/oneline
6 | * @copyright 2021 David Herney Bernal - cirano
7 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
8 | */Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.load=void 0,_jquery=(obj=_jquery)&&obj.__esModule?obj:{default:obj};_exports.load=icons=>{(0,_jquery.default)(".format-onetopic .onelinetabs .tabs-wrapper").each((function(){var $container=(0,_jquery.default)(this),$menu=$container.find("> ul.nav.nav-tabs"),itemsLength=$menu.find("> li.nav-item").length,itemSize=$menu.find("> li.nav-item").outerWidth(!0),$leftarrow=(0,_jquery.default)('"),$rightarrow=(0,_jquery.default)('");$container.append($leftarrow),$container.append($rightarrow);var getMenuSize=function(){return itemsLength*itemSize},getMenuPosition=function(){return $menu.scrollLeft()},getMenuWrapperSize=function(){return $container.width()},hasScroll=function(){return $menu.get(0).scrollWidth>$menu.get(0).clientWidth},getInvisibleSize=function(){return menuSize-getMenuPosition()-menuWrapperSize};hasScroll()&&$container.addClass("hasscroll");var menuWrapperSize=getMenuWrapperSize(),wrapPadding=$container.outerWidth()-$container.width(),menuSize=getMenuSize(),menuInvisibleSize=getInvisibleSize();(0,_jquery.default)(window).on("resize",(function(){menuWrapperSize=getMenuWrapperSize(),menuSize=getMenuSize(),calcArrowVisible()}));var calcArrowVisible=function(){var menuPosition=getMenuPosition();menuInvisibleSize=getInvisibleSize();var maxScrollLeft=$menu.get(0).scrollWidth-$menu.get(0).clientWidth,menuEndOffset=menuInvisibleSize-20;hasScroll()?($container.addClass("hasscroll"),menuPosition<=20?($leftarrow.addClass("hidden"),$rightarrow.removeClass("hidden")):menuPosition=menuEndOffset&&($leftarrow.removeClass("hidden"),$rightarrow.addClass("hidden"))):($leftarrow.addClass("hidden"),$rightarrow.addClass("hidden"),$container.removeClass("hasscroll"))};$menu.on("scroll",(function(){calcArrowVisible()})),$rightarrow.on("click",(function(event){event.preventDefault();var newX=getMenuPosition()+.8*menuWrapperSize;$menu.animate({scrollLeft:newX},300)})),$leftarrow.on("click",(function(event){event.preventDefault();var newX=getMenuPosition()-.8*menuWrapperSize;$menu.animate({scrollLeft:newX},300)}));var $active=$container.find(".nav-link.active");if($active.length>0){var newX=$active.position().left-wrapPadding/2;$menu.animate({scrollLeft:newX},300)}calcArrowVisible()}))}}));
9 |
10 | //# sourceMappingURL=oneline.min.js.map
--------------------------------------------------------------------------------
/templates/local/content/cm.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/local/content/cm
19 |
20 | Displays a course module instance inside a course section.
21 |
22 | Example context (json):
23 | {
24 | "cmname": {
25 | "displayvalue" : "Activity example"
26 | },
27 | "hasname": "true",
28 | "afterlink": "30 unread messages",
29 | "hasextras": true,
30 | "extras": ["[extras]"],
31 | "activityinfo": {
32 | "hasmodavailability": true,
33 | "activityname": "Activity example",
34 | "hascompletion": true,
35 | "uservisible": true,
36 | "hasdates": true,
37 | "isautomatic": true,
38 | "istrackeduser": true,
39 | "activitydates": [
40 | {
41 | "label": "Opens:",
42 | "datestring": "6 April 2021, 6:46 PM"
43 | }
44 | ],
45 | "completiondetails": [
46 | {
47 | "statuscomplete": 1,
48 | "description": "Viewed"
49 | },
50 | {
51 | "statusincomplete": 1,
52 | "description": "Receive a grade"
53 | }
54 | ]
55 | },
56 | "modstealth": true
57 | }
58 | }}
59 |
62 | {{!
63 | Place the actual content of the activity-item in a separate template to make it easier for other formats to add
64 | additional content to the activity wrapper.
65 | }}
66 | {{$ core_courseformat/local/content/cm/activity }}
67 | {{> core_courseformat/local/content/cm/activity }}
68 | {{/ core_courseformat/local/content/cm/activity }}
69 |
70 |
--------------------------------------------------------------------------------
/templates/courseformat/content/cminline.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/content/cminline
19 |
20 | Displays a course module instance inside a course section.
21 |
22 | Example context (json):
23 | {
24 | "cmname": {
25 | "displayvalue" : "Activity example"
26 | },
27 | "hasname": "true",
28 | "afterlink": "30 unread messages",
29 | "hasextras": true,
30 | "extras": ["[extras]"],
31 | "activityinfo": {
32 | "hasmodavailability": true,
33 | "activityname": "Activity example",
34 | "hascompletion": true,
35 | "uservisible": true,
36 | "hasdates": true,
37 | "isautomatic": true,
38 | "istrackeduser": true,
39 | "activitydates": [
40 | {
41 | "label": "Opens:",
42 | "datestring": "6 April 2021, 6:46 PM"
43 | }
44 | ],
45 | "completiondetails": [
46 | {
47 | "statuscomplete": 1,
48 | "description": "Viewed"
49 | },
50 | {
51 | "statusincomplete": 1,
52 | "description": "Receive a grade"
53 | }
54 | ]
55 | },
56 | "modstealth": true
57 | }
58 | }}
59 |
62 | {{!
63 | Place the actual content of the activity-item in a separate template to make it easier for other formats to add
64 | additional content to the activity wrapper.
65 | }}
66 | {{$ format_onetopic/courseformat/content/cm/activityinline }}
67 | {{> format_onetopic/courseformat/content/cm/activityinline }}
68 | {{/ format_onetopic/courseformat/content/cm/activityinline }}
69 |
70 |
--------------------------------------------------------------------------------
/amd/src/main.js:
--------------------------------------------------------------------------------
1 | // This file is part of Moodle - http://moodle.org/
2 | //
3 | // Moodle is free software: you can redistribute it and/or modify
4 | // it under the terms of the GNU General Public License as published by
5 | // the Free Software Foundation, either version 3 of the License, or
6 | // (at your option) any later version.
7 | //
8 | // Moodle is distributed in the hope that it will be useful,
9 | // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 | // GNU General Public License for more details.
12 | //
13 | // You should have received a copy of the GNU General Public License
14 | // along with Moodle. If not, see .
15 |
16 | /**
17 | * General format features.
18 | *
19 | * @module format_onetopic/main
20 | * @copyright 2021 David Herney Bernal - cirano
21 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22 | */
23 |
24 | import * as OneLine from 'format_onetopic/oneline';
25 | import $ from 'jquery';
26 | import ModalFactory from 'core/modal_factory';
27 | import {get_string as getString} from 'core/str';
28 |
29 | /**
30 | * Component initialization.
31 | *
32 | * @method init
33 | * @param {string} formattype The course format type: 0: default, 1: vertical, 2: oneline.
34 | * @param {object} icons A list of usable icons: left arrow, right arrow.
35 | */
36 | export const init = (formattype, icons) => {
37 |
38 | if (formattype == 2) {
39 | OneLine.load(icons);
40 | }
41 |
42 | var infotitle = getString('aboutresource', 'format_onetopic');
43 |
44 | $('.format-onetopic .onetopic .iconwithhelp[data-helpwindow]').each(function() {
45 | var $node = $(this);
46 | $node.on('click', function(e) {
47 | e.preventDefault();
48 | var $content = $('#hw-' + $node.data('helpwindow'));
49 |
50 | if ($content.data('modal')) {
51 | $content.data('modal').show();
52 | return;
53 | }
54 |
55 | var title = $content.data('title');
56 |
57 | if (!title) {
58 | title = infotitle;
59 | }
60 |
61 | // Show the content in a modal window.
62 | ModalFactory.create({
63 | 'title': title,
64 | 'body': '',
65 | }).done(function(modal) {
66 |
67 | var contenthtml = $content.html();
68 |
69 | // Uncomment html in contenthtml. The comment is used in order to load content with tags not inline.
70 | contenthtml = contenthtml.replace(//g, function(match, p1) {
71 | return p1;
72 | });
73 |
74 | var $modalBody = modal.getBody();
75 | $modalBody.css('min-height', '150px');
76 | $modalBody.append(contenthtml);
77 | modal.show();
78 | $content.data('modal', modal);
79 | });
80 | });
81 | });
82 | };
83 |
--------------------------------------------------------------------------------
/templates/courseformat/content/cm/activityinline.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/courseformat/content/cm/activityinline
19 |
20 | Display the activity content of a cm.
21 |
22 | Example context (json):
23 | {
24 | "cmname": {
25 | "displayvalue" : "Activity example"
26 | },
27 | "hasname": "true",
28 | "afterlink": "30 unread messages",
29 | "hasextras": true,
30 | "extras": ["[extras]"],
31 | "activityinfo": {
32 | "hasmodavailability": true,
33 | "activityname": "Activity example",
34 | "hascompletion": true,
35 | "uservisible": true,
36 | "hasdates": true,
37 | "isautomatic": true,
38 | "istrackeduser": true,
39 | "activitydates": [
40 | {
41 | "label": "Opens:",
42 | "datestring": "6 April 2021, 6:46 PM"
43 | }
44 | ],
45 | "completiondetails": [
46 | {
47 | "statuscomplete": 1,
48 | "description": "Viewed"
49 | },
50 | {
51 | "statusincomplete": 1,
52 | "description": "Receive a grade"
53 | }
54 | ]
55 | },
56 | "modstealth": true
57 | }
58 | }}
59 |
60 | {{#cmname}}
61 | {{$ format_onetopic/courseformat/content/cm/cmnameinline }}
62 | {{> format_onetopic/courseformat/content/cm/cmnameinline }}
63 | {{/ format_onetopic/courseformat/content/cm/cmnameinline }}
64 | {{/cmname}}
65 | {{#afterlink}}
66 |
67 | {{{afterlink}}}
68 |
69 | {{/afterlink}}
70 |
71 | {{#showinlinehelp}}
72 | {{! Only show the icon if there is a name to display. }}
73 | {{#hasname}}
74 |
75 | {{#pix}} e/help, core, {{#str}} info {{/str}} {{/pix}}
76 |
77 | {{/hasname}}
78 | {{/showinlinehelp}}
79 |
80 |
--------------------------------------------------------------------------------
/cli.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * This file contains cli commands for the Onetopic course format.
19 | *
20 | * @package format_onetopic
21 | * @copyright 2025 David Herney @ BambuCo
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 | */
24 |
25 | define('CLI_SCRIPT', true);
26 |
27 | require(__DIR__ . '/../../../config.php');
28 | require_once($CFG->libdir . '/clilib.php'); // Cli only functions.
29 | require_once(__DIR__ . '/classes/local/clilib.php'); // Local cli functions.
30 |
31 | // Global options.
32 | $hr = "----------------------------------------\n";
33 |
34 | // Get cli options.
35 | [$options, $unrecognized] = cli_get_params(
36 | [
37 | 'help' => false,
38 | 'mstyles' => false,
39 | 'mslimit' => false,
40 | 'verbose' => false,
41 | ],
42 | [
43 | 'h' => 'help',
44 | 'ms' => 'mstyles',
45 | 'msl' => 'mslimit',
46 | 'v' => 'verbose',
47 | ]
48 | );
49 |
50 | $any = false;
51 | foreach ($options as $option) {
52 | if ($option) {
53 | $any = true;
54 | break;
55 | }
56 | }
57 |
58 | if (!$any) {
59 | $options['help'] = true;
60 | }
61 |
62 | if ($unrecognized) {
63 | $unrecognized = implode("\n ", $unrecognized);
64 | cli_error(get_string('cliunknowoption', 'admin', $unrecognized));
65 | }
66 |
67 | if ($options['help']) {
68 | echo get_string('cli_help', 'format_onetopic');
69 | die;
70 | }
71 |
72 | $cliverbose = $options['verbose'] ?? false;
73 | define('CLI_VERBOSE', $cliverbose);
74 |
75 | if ($options['mstyles']) {
76 | $action = $options['mstyles'];
77 |
78 | if ($action === true || !in_array($action, ['migrate', 'list'])) {
79 | $action = 'list';
80 | }
81 |
82 | $limit = isset($options['mslimit']) && is_number($options['mslimit']) ? (int)$options['mslimit'] : 100;
83 |
84 | echo get_string('cli_migratestylesstarttitle', 'format_onetopic') . "\n";
85 | echo $hr;
86 |
87 | if ($action === 'migrate') {
88 | echo get_string('cli_migratestylesstart', 'format_onetopic') . "\n";
89 | \format_onetopic\local\clilib::mstyles_migrate($limit);
90 | echo get_string('cli_migratestylesend', 'format_onetopic') . "\n";
91 | } else {
92 | \format_onetopic\local\clilib::mstyles_list($limit);
93 | }
94 | echo $hr;
95 |
96 | die;
97 | }
98 |
--------------------------------------------------------------------------------
/templates/local/subsectionmodes/list.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/local/subsectionmodes/list
19 |
20 | List template for subsection mode.
21 |
22 | Example context (json):
23 | {
24 | }
25 | }}
26 | {{< core_courseformat/local/content/delegatedsection }}
27 | {{$ core_courseformat/local/content/section/content }}
28 |
70 | {{/ core_courseformat/local/content/section/content }}
71 | {{/ core_courseformat/local/content/delegatedsection}}
72 |
--------------------------------------------------------------------------------
/tests/behat/highlight_sections.feature:
--------------------------------------------------------------------------------
1 | @format @format_onetopic
2 | Feature: Sections can be highlighted in Onetopic format
3 | In order to mark sections
4 | As a teacher
5 | I need to highlight and unhighlight sections
6 |
7 | Background:
8 | Given the following "users" exist:
9 | | username | firstname | lastname | email |
10 | | teacher1 | Teacher | 1 | teacher1@example.com |
11 | And the following "courses" exist:
12 | | fullname | shortname | format | coursedisplay | numsections |
13 | | Course 1 | C1 | onetopic | 0 | 5 |
14 | And the following "activities" exist:
15 | | activity | name | intro | course | idnumber | section |
16 | | assign | Test assignment name | Test assignment description | C1 | assign1 | 0 |
17 | | book | Test book name | Test book description | C1 | book1 | 1 |
18 | | lesson | Test lesson name | Test lesson description | C1 | lesson1 | 4 |
19 | | choice | Test choice name | Test choice description | C1 | choice1 | 5 |
20 | And the following "course enrolments" exist:
21 | | user | course | role |
22 | | teacher1 | C1 | editingteacher |
23 | And I log in as "teacher1"
24 |
25 | @javascript
26 | Scenario: Highlight a section in Onetopic format
27 | Given I am on "Course 1" course homepage with editing mode on
28 | When I click on "Topic 2" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
29 | And I open section "2" edit menu
30 | And I click on "Highlight" "link"
31 | Then I should see "Highlighted" in the "#page-content .course-section .course-section-header" "css_element"
32 |
33 | @javascript
34 | Scenario: Highlight a section when another section is already highlighted in Onetopic format
35 | Given I am on "Course 1" course homepage with editing mode on
36 | And I click on "Topic 3" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
37 | And I open section "3" edit menu
38 | And I click on "Highlight" "link"
39 | And I should see "Highlighted" in the "#page-content .course-section .course-section-header" "css_element"
40 | When I click on "Topic 2" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
41 | And I open section "2" edit menu
42 | And I click on "Highlight" "link"
43 | Then I should see "Highlighted" in the "#page-content .course-section .course-section-header" "css_element"
44 | When I click on "Topic 3" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
45 | And I should not see "Highlighted" in the "#page-content .course-section .course-section-header" "css_element"
46 |
47 | @javascript
48 | Scenario: Unhighlight a section in Onetopic format
49 | Given I am on "Course 1" course homepage with editing mode on
50 | And I click on "Topic 3" "link" in the "#page-content ul.nav.nav-tabs" "css_element"
51 | And I open section "3" edit menu
52 | And I click on "Highlight" "link"
53 | And I should see "Highlighted" in the "#page-content .course-section .course-section-header" "css_element"
54 | When I open section "3" edit menu
55 | And I click on "Unhighlight" "link"
56 | Then I should not see "Highlighted" in the "#page-content .course-section .course-section-header" "css_element"
57 |
--------------------------------------------------------------------------------
/templates/local/subsectionmodes/collapsible.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/local/subsectionmodes/collapsible
19 |
20 | List template for subsection mode.
21 |
22 | Example context (json):
23 | {
24 | }
25 | }}
26 | {{< core_courseformat/local/content/delegatedsection }}
27 | {{$ core_courseformat/local/content/section/content }}
28 |
70 | {{/ core_courseformat/local/content/section/content }}
71 | {{/ core_courseformat/local/content/delegatedsection}}
72 |
--------------------------------------------------------------------------------
/amd/build/main.min.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"file":"main.min.js","sources":["../src/main.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * General format features.\n *\n * @module format_onetopic/main\n * @copyright 2021 David Herney Bernal - cirano\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n */\n\nimport * as OneLine from 'format_onetopic/oneline';\nimport $ from 'jquery';\nimport ModalFactory from 'core/modal_factory';\nimport {get_string as getString} from 'core/str';\n\n/**\n * Component initialization.\n *\n * @method init\n * @param {string} formattype The course format type: 0: default, 1: vertical, 2: oneline.\n * @param {object} icons A list of usable icons: left arrow, right arrow.\n */\nexport const init = (formattype, icons) => {\n\n if (formattype == 2) {\n OneLine.load(icons);\n }\n\n var infotitle = getString('aboutresource', 'format_onetopic');\n\n $('.format-onetopic .onetopic .iconwithhelp[data-helpwindow]').each(function() {\n var $node = $(this);\n $node.on('click', function(e) {\n e.preventDefault();\n var $content = $('#hw-' + $node.data('helpwindow'));\n\n if ($content.data('modal')) {\n $content.data('modal').show();\n return;\n }\n\n var title = $content.data('title');\n\n if (!title) {\n title = infotitle;\n }\n\n // Show the content in a modal window.\n ModalFactory.create({\n 'title': title,\n 'body': '',\n }).done(function(modal) {\n\n var contenthtml = $content.html();\n\n // Uncomment html in contenthtml. The comment is used in order to load content with tags not inline.\n contenthtml = contenthtml.replace(//g, function(match, p1) {\n return p1;\n });\n\n var $modalBody = modal.getBody();\n $modalBody.css('min-height', '150px');\n $modalBody.append(contenthtml);\n modal.show();\n $content.data('modal', modal);\n });\n });\n });\n};\n"],"names":["formattype","icons","OneLine","load","infotitle","each","$node","this","on","e","preventDefault","$content","data","show","title","create","done","modal","contenthtml","html","replace","match","p1","$modalBody","getBody","css","append"],"mappings":";;;;;;;2HAmCoB,CAACA,WAAYC,SAEX,GAAdD,YACAE,QAAQC,KAAKF,WAGbG,WAAY,mBAAU,gBAAiB,uCAEzC,6DAA6DC,MAAK,eAC5DC,OAAQ,mBAAEC,MACdD,MAAME,GAAG,SAAS,SAASC,GACvBA,EAAEC,qBACEC,UAAW,mBAAE,OAASL,MAAMM,KAAK,kBAEjCD,SAASC,KAAK,SACdD,SAASC,KAAK,SAASC,gBAIvBC,MAAQH,SAASC,KAAK,SAErBE,QACDA,MAAQV,kCAICW,OAAO,OACPD,WACD,KACTE,MAAK,SAASC,WAETC,YAAcP,SAASQ,OAG3BD,YAAcA,YAAYE,QAAQ,sBAAsB,SAASC,MAAOC,WAC7DA,UAGPC,WAAaN,MAAMO,UACvBD,WAAWE,IAAI,aAAc,SAC7BF,WAAWG,OAAOR,aAClBD,MAAMJ,OACNF,SAASC,KAAK,QAASK"}
--------------------------------------------------------------------------------
/classes/output/courseformat/content/sectionselector.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Contains the default section selector.
19 | *
20 | * @package format_onetopic
21 | * @copyright 2022 David Herney Bernal - cirano. https://bambuco.co
22 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23 | */
24 |
25 | namespace format_onetopic\output\courseformat\content;
26 |
27 | use core\output\named_templatable;
28 | use core_courseformat\base as course_format;
29 | use core_courseformat\output\local\courseformat_named_templatable;
30 | use core_courseformat\output\local\content\sectionselector as sectionselector_base;
31 | use renderable;
32 | use stdClass;
33 | use url_select;
34 |
35 | /**
36 | * Represents the section selector.
37 | *
38 | * @package format_onetopic
39 | * @copyright 2022 David Herney Bernal - cirano. https://bambuco.co
40 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
41 | */
42 | class sectionselector extends sectionselector_base {
43 | /**
44 | * Export this data so it can be used as the context for a mustache template.
45 | *
46 | * @param renderer_base $output typically, the renderer that's calling this function
47 | * @return stdClass data context for a mustache template
48 | */
49 | public function export_for_template(\renderer_base $output): stdClass {
50 |
51 | $format = $this->format;
52 | $course = $format->get_course();
53 |
54 | $modinfo = $this->format->get_modinfo();
55 |
56 | $data = $this->navigation->export_for_template($output);
57 |
58 | $anchortotabstree = get_config('format_onetopic', 'anchortotabstree');
59 |
60 | $anchor = $anchortotabstree ? '#tabs-tree-start' : '';
61 |
62 | // Add the section selector.
63 | $sectionmenu = [];
64 | $section = ($course->realcoursedisplay == COURSE_DISPLAY_MULTIPAGE) ? 1 : 0;
65 | $numsections = $format->get_last_section_number();
66 | while ($section <= $numsections) {
67 | $thissection = $modinfo->get_section_info($section);
68 | $formatoptions = course_get_format($course)->get_format_options($thissection);
69 | $prefix = is_array($formatoptions) && $formatoptions['level'] > 0 ? ' ' : '';
70 |
71 | $url = course_get_url($course, $section);
72 | if ($thissection->uservisible && $url) {
73 | $sectionmenu[$url->out(false) . $anchor] = $prefix . get_section_name($course, $section);
74 | }
75 | $section++;
76 | }
77 |
78 | $select = new url_select($sectionmenu, '', ['' => get_string('jumpto')]);
79 | $select->class = 'jumpmenu';
80 | $select->formid = 'sectionmenu';
81 |
82 | $data->selector = $output->render($select);
83 | return $data;
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/backup/moodle2/restore_format_onetopic_plugin.class.php:
--------------------------------------------------------------------------------
1 | .
16 |
17 | /**
18 | * Specialised restore for format_onetopic
19 | *
20 | * @package format_onetopic
21 | * @category backup
22 | * @copyright 2018 David Herney Bernal - cirano
23 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24 | */
25 |
26 | defined('MOODLE_INTERNAL') || die();
27 |
28 | require_once($CFG->dirroot . '/course/format/topics/backup/moodle2/restore_format_topics_plugin.class.php');
29 |
30 | /**
31 | * Specialised restore for format_onetopic
32 | *
33 | * Processes 'numsections' from the old backup files and hides sections that used to be "orphaned"
34 | *
35 | * @package format_onetopic
36 | * @category backup
37 | * @copyright 2018 David Herney Bernal - cirano
38 | * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39 | */
40 | class restore_format_onetopic_plugin extends restore_format_topics_plugin {
41 | /**
42 | * Executed after course restore is complete
43 | *
44 | * This method is only executed if course configuration was overridden
45 | */
46 | public function after_restore_course() {
47 | global $DB;
48 |
49 | if (!$this->need_restore_numsections()) {
50 | // Backup file was made in Moodle 3.3 or later, we don't need to process 'numsecitons'.
51 | return;
52 | }
53 |
54 | $data = $this->connectionpoint->get_data();
55 | $backupinfo = $this->step->get_task()->get_info();
56 | if ($backupinfo->original_course_format !== 'onetopic' || !isset($data['tags']['numsections'])) {
57 | // Backup from another course format or backup file does not even have 'numsections'.
58 | return;
59 | }
60 |
61 | $numsections = (int)$data['tags']['numsections'];
62 | foreach ($backupinfo->sections as $key => $section) {
63 | // For each section from the backup file check if it was restored and if was "orphaned" in the original
64 | // course and mark it as hidden. This will leave all activities in it visible and available just as it was
65 | // in the original course.
66 | // Exception is when we restore with merging and the course already had a section with this section number,
67 | // in this case we don't modify the visibility.
68 | if ($this->step->get_task()->get_setting_value($key . '_included')) {
69 | $sectionnum = (int)$section->title;
70 | if ($sectionnum > $numsections && $sectionnum > $this->originalnumsections) {
71 | $DB->execute(
72 | "UPDATE {course_sections} SET visible = 0 WHERE course = ? AND section = ?",
73 | [$this->step->get_task()->get_courseid(), $sectionnum]
74 | );
75 | }
76 | }
77 | }
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/templates/local/content.mustache:
--------------------------------------------------------------------------------
1 | {{!
2 | This file is part of Moodle - http://moodle.org/
3 |
4 | Moodle is free software: you can redistribute it and/or modify
5 | it under the terms of the GNU General Public License as published by
6 | the Free Software Foundation, either version 3 of the License, or
7 | (at your option) any later version.
8 |
9 | Moodle is distributed in the hope that it will be useful,
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 | GNU General Public License for more details.
13 |
14 | You should have received a copy of the GNU General Public License
15 | along with Moodle. If not, see .
16 | }}
17 | {{!
18 | @template format_onetopic/local/content
19 |
20 | Displays the complete course format.
21 |
22 | Example context (json):
23 | {
24 | "sectionselector": {
25 | "hasprevious": true,
26 | "previousurl": "#",
27 | "larrow": "◄",
28 | "previousname": "Section 3",
29 | "hasnext": true,
30 | "rarrow": "►",
31 | "nexturl": "#",
32 | "nextname": "Section 5",
33 | "selector": ""
34 | },
35 | "singlesection": {
36 | "num": 1,
37 | "id": 35,
38 | "header": {
39 | "name": "Single Section Example",
40 | "url": "#"
41 | },
42 | "cmlist": {
43 | "cms": [
44 | {
45 | "cmitem": {
46 | "cmformat": {
47 | "cmname": "Assign example",
48 | "hasname": "true"
49 | },
50 | "cmid": 4,
51 | "id": 4,
52 | "anchor": "module-4",
53 | "module": "assign",
54 | "extraclasses": ""
55 | }
56 | }
57 | ],
58 | "hascms": true
59 | },
60 | "iscurrent": true,
61 | "summary": {
62 | "summarytext": "Summary text!"
63 | }
64 | }
65 | }
66 | }}
67 |
68 |