Skip to content

Commit

Permalink
Update section control menu for Moodle 4.2
Browse files Browse the repository at this point in the history
  • Loading branch information
davidherney committed May 9, 2024
1 parent 31dee0b commit 565786c
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 248 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ Download zip package, extract the onetopic folder and upload this folder into co

## IN VERSION

### 2024050303:
* Update section control menu for Moodle 4.2

### 2024050301:
* Support bulk edit tools.

Expand Down
59 changes: 12 additions & 47 deletions classes/output/courseformat/content/section/controlmenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
namespace format_onetopic\output\courseformat\content\section;

use context_course;
use core_courseformat\output\local\content\section\controlmenu as controlmenu_base;
use format_topics\output\courseformat\content\section\controlmenu as controlmenu_format_topics;

/**
* Base class to render a course section menu.
Expand All @@ -34,7 +34,7 @@
* @copyright 2022 David Herney Bernal - cirano. https://bambuco.co
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class controlmenu extends controlmenu_base {
class controlmenu extends controlmenu_format_topics {

/** @var course_format the course format class */
protected $format;
Expand Down Expand Up @@ -69,35 +69,6 @@ public function section_control_items() {
$url->param('sesskey', sesskey());

$othercontrols = [];
if ($section->section && has_capability('moodle/course:setcurrentsection', $coursecontext)) {
if ($course->marker == $section->section) { // Show the "light globe" on/off.
$url->param('marker', 0);
$highlightoff = get_string('highlightoff');
$othercontrols['highlight'] = [
'url' => $url,
'icon' => 'i/marked',
'name' => $highlightoff,
'pixattr' => ['class' => ''],
'attr' => [
'class' => 'editing_highlight',
'data-action' => 'removemarker',
],
];
} else {
$url->param('marker', $section->section);
$highlight = get_string('highlight');
$othercontrols['highlight'] = [
'url' => $url,
'icon' => 'i/marker',
'name' => $highlight,
'pixattr' => ['class' => ''],
'attr' => [
'class' => 'editing_highlight',
'data-action' => 'setmarker',
],
];
}
}

$movecontrols = [];
if ($section->section && !$isstealth && has_capability('moodle/course:movesections', $coursecontext, $USER)) {
Expand Down Expand Up @@ -136,22 +107,6 @@ public function section_control_items() {
}
}

// Duplicate current section option.
if ($section->section && has_capability('moodle/course:manageactivities', $coursecontext)) {
$urlduplicate = new \moodle_url('/course/format/onetopic/duplicate.php',
['courseid' => $course->id, 'section' => $section->section, 'sesskey' => sesskey()]);

$othercontrols['duplicate'] = [
'url' => $urlduplicate,
'icon' => 'i/reload',
'name' => get_string('duplicate', 'format_onetopic'),
'pixattr' => ['class' => ''],
'attr' => [
'class' => 'editing_duplicate',
],
];
}

$parentcontrols = parent::section_control_items();

// ToDo: reload the page is a temporal solution. We need control the delete tab action with JS.
Expand All @@ -165,6 +120,16 @@ public function section_control_items() {
unset($parentcontrols['delete']['attr']['data-action']);
}

// Create the permalink according to the Onetopic format.
if (array_key_exists("permalink", $parentcontrols)) {
$sectionlink = new \moodle_url(
'/course/view.php',
['id' => $course->id, 'sectionid' => $section->id],
'tabs-tree-start');

$parentcontrols['permalink']['url'] = $sectionlink;
}

// If the edit key exists, we are going to insert our controls after it.
$merged = [];
$editcontrolexists = array_key_exists("edit", $parentcontrols);
Expand Down
200 changes: 0 additions & 200 deletions duplicate.php

This file was deleted.

2 changes: 1 addition & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

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

$plugin->version = 2024050302; // The current plugin version (Date: YYYYMMDDXX).
$plugin->version = 2024050302.01; // The current plugin version (Date: YYYYMMDDXX).
$plugin->requires = 2023041800; // Requires this Moodle version.
$plugin->component = 'format_onetopic'; // Full name of the plugin (used for diagnostics).
$plugin->maturity = MATURITY_STABLE;
Expand Down

0 comments on commit 565786c

Please sign in to comment.