Skip to content

Commit

Permalink
Merge branch 'MDL-68586-format_topics_code_prechecks' of https://gitl…
Browse files Browse the repository at this point in the history
  • Loading branch information
junpataleta committed Jul 22, 2020
2 parents a03e9e0 + ca864e0 commit 0ea341f
Show file tree
Hide file tree
Showing 10 changed files with 205 additions and 157 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Specialised restore for format_topics
* Specialised restore for Topics course format.
*
* @package format_topics
* @category backup
Expand All @@ -26,9 +26,9 @@
defined('MOODLE_INTERNAL') || die();

/**
* Specialised restore for format_topics
* Specialised restore for Topics course format.
*
* Processes 'numsections' from the old backup files and hides sections that used to be "orphaned"
* Processes 'numsections' from the old backup files and hides sections that used to be "orphaned".
*
* @package format_topics
* @category backup
Expand All @@ -53,7 +53,7 @@ protected function need_restore_numsections() {
}

/**
* Creates a dummy path element in order to be able to execute code after restore
* Creates a dummy path element in order to be able to execute code after restore.
*
* @return restore_path_element[]
*/
Expand All @@ -76,16 +76,20 @@ public function define_course_plugin_structure() {
}

/**
* Dummy process method
* Dummy process method.
*
* @return void
*/
public function process_dummy_course() {

}

/**
* Executed after course restore is complete
* Executed after course restore is complete.
*
* This method is only executed if course configuration was overridden.
*
* This method is only executed if course configuration was overridden
* @return void
*/
public function after_restore_course() {
global $DB;
Expand Down
15 changes: 11 additions & 4 deletions course/format/topics/classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,36 @@
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Privacy Subsystem implementation for format_topics.
* Privacy Subsystem implementation for Topics course format.
*
* @package format_topics
* @copyright 2018 Carlos Escobedo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace format_topics\privacy;

defined('MOODLE_INTERNAL') || die();

use core_privacy\local\metadata\null_provider;

/**
* Privacy Subsystem for format_topics implementing null_provider.
* Privacy Subsystem for Topics course format implementing null_provider.
*
* @copyright 2018 Carlos Escobedo <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {
class provider implements null_provider {

/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
6 changes: 3 additions & 3 deletions course/format/topics/db/upgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Upgrade scripts for course format "Topics"
* Upgrade scripts for Topics course format.
*
* @package format_topics
* @copyright 2017 Marina Glancy
Expand All @@ -25,9 +25,9 @@
defined('MOODLE_INTERNAL') || die();

/**
* Upgrade script for format_topics
* Upgrade script for Topics course format.
*
* @param int $oldversion the version we are upgrading from
* @param int|float $oldversion the version we are upgrading from
* @return bool result
*/
function xmldb_format_topics_upgrade($oldversion) {
Expand Down
42 changes: 20 additions & 22 deletions course/format/topics/format.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// Javascript functions for Topics course format
// Javascript functions for Topics course format.

M.course = M.course || {};

M.course.format = M.course.format || {};

/**
* Get sections config for this format
* Get sections config for this format.
*
* The section structure is:
* <ul class="topics">
Expand All @@ -18,50 +18,48 @@ M.course.format = M.course.format || {};
*/
M.course.format.get_config = function() {
return {
container_node : 'ul',
container_class : 'topics',
section_node : 'li',
section_class : 'section'
container_node: 'ul',
container_class: 'topics',
section_node: 'li',
section_class: 'section'
};
}
};

/**
* Swap section
* Swap section.
*
* @param {YUI} Y YUI3 instance
* @param {string} node1 node to swap to
* @param {string} node2 node to swap with
* @return {NodeList} section list
*/
M.course.format.swap_sections = function(Y, node1, node2) {
var CSS = {
COURSECONTENT : 'course-content',
SECTIONADDMENUS : 'section_add_menus'
COURSECONTENT: 'course-content',
SECTIONADDMENUS: 'section_add_menus'
};

var sectionlist = Y.Node.all('.'+CSS.COURSECONTENT+' '+M.course.format.get_section_selector(Y));
var sectionlist = Y.Node.all('.' + CSS.COURSECONTENT + ' ' + M.course.format.get_section_selector(Y));
// Swap the non-ajax menus, noting these are not always present (depends on theme and user prefs).
if (sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS)) {
sectionlist.item(node1).one('.'+CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.'+CSS.SECTIONADDMENUS));
if (sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS)) {
sectionlist.item(node1).one('.' + CSS.SECTIONADDMENUS).swap(sectionlist.item(node2).one('.' + CSS.SECTIONADDMENUS));
}
}
};

/**
* Process sections after ajax response
* Process sections after ajax response.
*
* @param {YUI} Y YUI3 instance
* @param {NodeList} sectionlist of sections
* @param {array} response ajax response
* @param {string} sectionfrom first affected section
* @param {string} sectionto last affected section
* @return void
*/
M.course.format.process_sections = function(Y, sectionlist, response, sectionfrom, sectionto) {
var CSS = {
SECTIONNAME : 'sectionname'
SECTIONNAME: 'sectionname'
},
SELECTORS = {
SECTIONLEFTSIDE : '.left .section-handle .icon'
SECTIONLEFTSIDE: '.left .section-handle .icon'
};

if (response.action == 'move') {
Expand All @@ -78,15 +76,15 @@ M.course.format.process_sections = function(Y, sectionlist, response, sectionfro
for (var i = sectionfrom; i <= sectionto; i++) {
// Update section title.
var content = Y.Node.create('<span>' + response.sectiontitles[i] + '</span>');
sectionlist.item(i).all('.'+CSS.SECTIONNAME).setHTML(content);
sectionlist.item(i).all('.' + CSS.SECTIONNAME).setHTML(content);
// Update the drag handle.
ele = sectionlist.item(i).one(SELECTORS.SECTIONLEFTSIDE).ancestor('.section-handle');
str = ele.getAttribute('title');
stridx = str.lastIndexOf(' ');
newstr = str.substr(0, stridx +1) + i;
newstr = str.substr(0, stridx + 1) + i;
ele.setAttribute('title', newstr);
// Update the aria-label for the section.
sectionlist.item(i).setAttribute('aria-label', content.get('innerText').trim());
}
}
}
};
10 changes: 5 additions & 5 deletions course/format/topics/format.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Topics course format. Display the whole course as "topics" made of modules.
* Topics course format. Display the whole course as "topics" made of modules.
*
* @package format_topics
* @copyright 2006 The Open University
Expand All @@ -28,20 +28,20 @@
require_once($CFG->libdir.'/filelib.php');
require_once($CFG->libdir.'/completionlib.php');

// Horrible backwards compatible parameter aliasing..
// Horrible backwards compatible parameter aliasing.
if ($topic = optional_param('topic', 0, PARAM_INT)) {
$url = $PAGE->url;
$url->param('section', $topic);
debugging('Outdated topic param passed to course/view.php', DEBUG_DEVELOPER);
redirect($url);
}
// End backwards-compatible aliasing..
// End backwards-compatible aliasing.

$context = context_course::instance($course->id);
// Retrieve course format option fields and add them to the $course object.
$course = course_get_format($course)->get_course();

if (($marker >=0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
if (($marker >= 0) && has_capability('moodle/course:setcurrentsection', $context) && confirm_sesskey()) {
$course->marker = $marker;
course_set_marker($course->id, $marker);
}
Expand All @@ -57,5 +57,5 @@
$renderer->print_multiple_section_page($course, null, null, null, null);
}

// Include course format js module
// Include course format js module.
$PAGE->requires->js('/course/format/topics/format.js');
3 changes: 1 addition & 2 deletions course/format/topics/lang/en/format_topics.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<?php

// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
Expand All @@ -16,7 +15,7 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

/**
* Strings for component 'format_topics', language 'en', branch 'MOODLE_20_STABLE'
* Strings for component Topics course format.
*
* @package format_topics
* @copyright 1999 onwards Martin Dougiamas {@link http://moodle.com}
Expand Down
Loading

0 comments on commit 0ea341f

Please sign in to comment.