Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
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 <http://www.gnu.org/licenses/>.
16
 
17
namespace core_course\output;
18
 
19
use core\output\select_menu;
20
use core_completion\manager;
21
use moodle_url;
22
use renderable;
23
use renderer_base;
24
use templatable;
25
use url_select;
26
 
27
/**
28
 * Renderable class for the action bar elements in the course completion pages.
29
 *
30
 * @package    core_course
31
 * @copyright  2022 Mihail Geshoski <mihail@moodle.com>
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
34
class completion_action_bar implements templatable, renderable {
35
 
36
    /** @var int $courseid The course id. */
37
    private $courseid;
38
 
39
    /** @var moodle_url $currenturl The URL of the current page. */
40
    private $currenturl;
41
 
42
    /**
43
     * The class constructor.
44
     *
45
     * @param int $courseid The course id.
46
     * @param moodle_url $pageurl The URL of the current page.
47
     */
48
    public function __construct(int $courseid, moodle_url $pageurl) {
49
        $this->courseid = $courseid;
50
        $this->currenturl = $pageurl;
51
    }
52
 
53
    /**
54
     * Export the data for the mustache template.
55
     *
56
     * @param renderer_base $output renderer to be used to render the action bar elements.
57
     * @return array The array which contains the data required to output the tertiary navigation selector for the course
58
     *               completion pages.
59
     */
60
    public function export_for_template(renderer_base $output): array {
61
        $selectmenu = new select_menu(
62
            'coursecompletionnavigation',
63
            manager::get_available_completion_options($this->courseid),
64
            $this->currenturl->out(false)
65
        );
66
        $selectmenu->set_label(
67
            get_string('coursecompletionnavigation', 'completion'),
68
            ['class' => 'sr-only']
69
        );
70
 
71
        return [
72
            'navigation' => $selectmenu->export_for_template($output),
73
        ];
74
    }
75
}