mirror of
https://github.com/moodle/moodle.git
synced 2025-08-06 01:16:44 +02:00
Merge branch 'MDL-73863-master' of https://github.com/mihailges/moodle
This commit is contained in:
commit
dbb63cfffc
15 changed files with 203 additions and 20 deletions
|
@ -69,9 +69,11 @@ $renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion');
|
|||
|
||||
// Print the form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('bulkactivitycompletion', 'completion'));
|
||||
|
||||
echo $renderer->navigation($course, 'bulkcompletion');
|
||||
$actionbar = new \core_course\output\completion_action_bar($course->id, $PAGE->url);
|
||||
echo $renderer->render_course_completion_action_bar($actionbar);
|
||||
|
||||
echo $OUTPUT->heading(get_string('bulkactivitycompletion', 'completion'));
|
||||
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['theform']);
|
||||
|
||||
|
|
|
@ -38,11 +38,16 @@ class core_course_bulk_activity_completion_renderer extends plugin_renderer_base
|
|||
/**
|
||||
* Render the navigation tabs for the completion page.
|
||||
*
|
||||
* @deprecated since Moodle 4.0
|
||||
* @param int|stdClass $courseorid the course object or id.
|
||||
* @param String $page the tab to focus.
|
||||
* @return string html
|
||||
*/
|
||||
public function navigation($courseorid, $page) {
|
||||
debugging('navigation() has been deprecated as the tabs navigation structure in the completion page ' .
|
||||
'has been replaced with tertiary navigation. Please use render_course_completion_action_bar() instead.',
|
||||
DEBUG_DEVELOPER);
|
||||
|
||||
$tabs = core_completion\manager::get_available_completion_tabs($courseorid);
|
||||
if (count($tabs) > 1) {
|
||||
return $this->tabtree($tabs, $page);
|
||||
|
@ -112,4 +117,15 @@ class core_course_bulk_activity_completion_renderer extends plugin_renderer_base
|
|||
];
|
||||
return parent::render_from_template('core_course/editdefaultcompletion', $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Renders the course completion action bar.
|
||||
*
|
||||
* @param \core_course\output\completion_action_bar $actionbar
|
||||
* @return string The HTML output
|
||||
*/
|
||||
public function render_course_completion_action_bar(\core_course\output\completion_action_bar $actionbar): string {
|
||||
$data = $actionbar->export_for_template($this->output);
|
||||
return $this->output->render_from_template('core_course/completion_action_bar', $data);
|
||||
}
|
||||
}
|
||||
|
|
68
course/classes/output/completion_action_bar.php
Normal file
68
course/classes/output/completion_action_bar.php
Normal file
|
@ -0,0 +1,68 @@
|
|||
<?php
|
||||
// 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
namespace core_course\output;
|
||||
|
||||
use core_completion\manager;
|
||||
use moodle_url;
|
||||
use renderable;
|
||||
use renderer_base;
|
||||
use templatable;
|
||||
use url_select;
|
||||
|
||||
/**
|
||||
* Renderable class for the action bar elements in the course completion pages.
|
||||
*
|
||||
* @package core_course
|
||||
* @copyright 2022 Mihail Geshoski <mihail@moodle.com>
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class completion_action_bar implements templatable, renderable {
|
||||
|
||||
/** @var int $courseid The course id. */
|
||||
private $courseid;
|
||||
|
||||
/** @var moodle_url $currenturl The URL of the current page. */
|
||||
private $currenturl;
|
||||
|
||||
/**
|
||||
* The class constructor.
|
||||
*
|
||||
* @param int $courseid The course id.
|
||||
* @param moodle_url $pageurl The URL of the current page.
|
||||
*/
|
||||
public function __construct(int $courseid, moodle_url $pageurl) {
|
||||
$this->courseid = $courseid;
|
||||
$this->currenturl = $pageurl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Export the data for the mustache template.
|
||||
*
|
||||
* @param renderer_base $output renderer to be used to render the action bar elements.
|
||||
* @return array The array which contains the data required to output the tertiary navigation selector for the course
|
||||
* completion pages.
|
||||
*/
|
||||
public function export_for_template(renderer_base $output): array {
|
||||
$urlselect = new url_select(manager::get_available_completion_options($this->courseid),
|
||||
$this->currenturl->out(false), null, 'coursecompletionactionselect');
|
||||
$urlselect->set_label(get_string('coursecompletionnavigation', 'completion'), ['class' => 'sr-only']);
|
||||
|
||||
return [
|
||||
'urlselect' => $urlselect->export_for_template($output),
|
||||
];
|
||||
}
|
||||
}
|
|
@ -57,8 +57,9 @@ if ($id) {
|
|||
if (!has_capability('moodle/course:update', $context)) {
|
||||
// User is not allowed to modify course completion.
|
||||
// Check if they can see default completion or edit bulk completion and redirect there.
|
||||
if ($tabs = core_completion\manager::get_available_completion_tabs($course)) {
|
||||
redirect($tabs[0]->link);
|
||||
if ($options = core_completion\manager::get_available_completion_options($course->id)) {
|
||||
// Redirect to the first available completion page.
|
||||
redirect(array_key_first($options));
|
||||
} else {
|
||||
require_capability('moodle/course:update', $context);
|
||||
}
|
||||
|
@ -161,9 +162,11 @@ $renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion');
|
|||
|
||||
// Print the form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('editcoursecompletionsettings', 'core_completion'));
|
||||
|
||||
echo $renderer->navigation($course, 'completion');
|
||||
$actionbar = new \core_course\output\completion_action_bar($course->id, $PAGE->url);
|
||||
echo $renderer->render_course_completion_action_bar($actionbar);
|
||||
|
||||
echo $OUTPUT->heading(get_string('editcoursecompletionsettings', 'core_completion'));
|
||||
|
||||
$form->display();
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ if ($id) {
|
|||
// Set up the page.
|
||||
navigation_node::override_active_url(new moodle_url('/course/completion.php', array('id' => $course->id)));
|
||||
$PAGE->set_course($course);
|
||||
$PAGE->set_url('/course/bulkcompletion.php', array('id' => $course->id));
|
||||
$PAGE->set_url('/course/defaultcompletion.php', array('id' => $course->id));
|
||||
$PAGE->set_title($course->shortname);
|
||||
$PAGE->set_heading($course->fullname);
|
||||
$PAGE->set_pagelayout('admin');
|
||||
|
@ -64,9 +64,11 @@ $renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion');
|
|||
|
||||
// Print the form.
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('defaultcompletion', 'completion'));
|
||||
|
||||
echo $renderer->navigation($course, 'defaultcompletion');
|
||||
$actionbar = new \core_course\output\completion_action_bar($course->id, $PAGE->url);
|
||||
echo $renderer->render_course_completion_action_bar($actionbar);
|
||||
|
||||
echo $OUTPUT->heading(get_string('defaultcompletion', 'completion'));
|
||||
|
||||
$PAGE->requires->js_call_amd('core_form/changechecker', 'watchFormById', ['theform']);
|
||||
|
||||
|
|
|
@ -67,9 +67,8 @@ if ($form->is_cancelled()) {
|
|||
$renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('bulkactivitycompletion', 'completion'));
|
||||
|
||||
echo $renderer->navigation($course, 'bulkcompletion');
|
||||
echo $OUTPUT->heading(get_string('bulkactivitycompletion', 'completion'));
|
||||
|
||||
echo $renderer->edit_bulk_completion($form, $manager->get_activities(array_keys($cms)));
|
||||
|
||||
|
|
|
@ -65,9 +65,8 @@ if ($form->is_cancelled()) {
|
|||
$renderer = $PAGE->get_renderer('core_course', 'bulk_activity_completion');
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->heading(get_string('defaultcompletion', 'completion'));
|
||||
|
||||
echo $renderer->navigation($course, 'defaultcompletion');
|
||||
echo $OUTPUT->heading(get_string('defaultcompletion', 'completion'));
|
||||
|
||||
echo $renderer->edit_default_completion($form, $modules);
|
||||
|
||||
|
|
|
@ -4125,12 +4125,11 @@ function course_get_user_administration_options($course, $context) {
|
|||
global $CFG;
|
||||
$isfrontpage = $course->id == SITEID;
|
||||
$completionenabled = $CFG->enablecompletion && $course->enablecompletion;
|
||||
$hascompletiontabs = count(core_completion\manager::get_available_completion_tabs($course, $context)) > 0;
|
||||
$hascompletionoptions = count(core_completion\manager::get_available_completion_options($course->id)) > 0;
|
||||
$options = new stdClass;
|
||||
$options->update = has_capability('moodle/course:update', $context);
|
||||
$options->editcompletion = $CFG->enablecompletion &&
|
||||
$course->enablecompletion &&
|
||||
($options->update || $hascompletiontabs);
|
||||
$options->editcompletion = $CFG->enablecompletion && $course->enablecompletion &&
|
||||
($options->update || $hascompletionoptions);
|
||||
$options->filters = has_capability('moodle/filter:manage', $context) &&
|
||||
count(filter_get_available_in_context($context)) > 0;
|
||||
$options->reports = has_capability('moodle/site:viewreports', $context);
|
||||
|
|
53
course/templates/completion_action_bar.mustache
Normal file
53
course/templates/completion_action_bar.mustache
Normal file
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
}}
|
||||
{{!
|
||||
@template core_course/completion_action_bar
|
||||
|
||||
Actions bar in the course completion pages.
|
||||
|
||||
Context variables required for this template:
|
||||
* urlselect - The data object containing the required properties to render core/url_select.
|
||||
|
||||
Example context (json):
|
||||
{
|
||||
"urlselect": {
|
||||
"id": "url_select_test",
|
||||
"action": "https://example.com/post",
|
||||
"formid": "url_select_form",
|
||||
"sesskey": "sesskey",
|
||||
"classes": "urlselect",
|
||||
"label": "",
|
||||
"helpicon": false,
|
||||
"showbutton": null,
|
||||
"options": [
|
||||
{
|
||||
"name": "Some name",
|
||||
"value": "/mod/data/someurl.php",
|
||||
"selected": false
|
||||
}
|
||||
],
|
||||
"disabled": false,
|
||||
"title": null
|
||||
}
|
||||
}
|
||||
}}
|
||||
<div class="container-fluid tertiary-navigation">
|
||||
<div class="row">
|
||||
{{#urlselect}}
|
||||
<div class="navitem">
|
||||
{{>core/url_select}}
|
||||
</div>
|
||||
{{/urlselect}}
|
||||
</div>
|
||||
</div>
|
|
@ -89,6 +89,9 @@ course formats don't have their own renderer.
|
|||
category pages.
|
||||
* New core_course_category::get_nearest_editable_subcategory():
|
||||
- Return the core_course_category object for the first subcategory that the current user has the permission on it.
|
||||
* The method navigation() in the core_course_bulk_activity_completion_renderer class has been deprecated as the tabs navigation
|
||||
structure in the course competency pages has been replaced with tertiary navigation. To render the navigation, please
|
||||
render_course_completion_action_bar() instead.
|
||||
|
||||
=== 3.11 ===
|
||||
* A new callback xxx_coursemodule_definition_after_data that allows plugins to extend activity forms after the data is set.
|
||||
|
@ -102,6 +105,7 @@ course formats don't have their own renderer.
|
|||
- activity_dates_information_in_activity_should_not_exist()
|
||||
- Given the activity date information in "<ActivityName>" should not exist
|
||||
* A user preference usemodchooser has been removed and the activities/resources (non-ajax) activity chooser has been deprecated and will be removed in the future.
|
||||
|
||||
=== 3.10 ===
|
||||
|
||||
* The function make_categories_options() has now been deprecated. Please use \core_course_category::make_categories_list() instead.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue