Merge branch 'MDL-73863-master' of https://github.com/mihailges/moodle

This commit is contained in:
Sara Arjona 2022-03-17 11:33:58 +01:00
commit dbb63cfffc
15 changed files with 203 additions and 20 deletions

View file

@ -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);
}
}

View 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),
];
}
}