1441 |
ariadna |
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_courseformat\output\local\overview;
|
|
|
18 |
|
|
|
19 |
use cm_info;
|
|
|
20 |
use core\output\named_templatable;
|
|
|
21 |
use core\output\renderable;
|
|
|
22 |
use core\output\renderer_base;
|
|
|
23 |
use core_courseformat\base as course_format;
|
|
|
24 |
use stdClass;
|
|
|
25 |
|
|
|
26 |
/**
|
|
|
27 |
* Class activityname
|
|
|
28 |
*
|
|
|
29 |
* @package core_courseformat
|
|
|
30 |
* @copyright 2025 Ferran Recio <ferran@moodle.com>
|
|
|
31 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
32 |
*/
|
|
|
33 |
class activityname implements renderable, named_templatable {
|
|
|
34 |
/**
|
|
|
35 |
* Constructor.
|
|
|
36 |
*
|
|
|
37 |
* @param cm_info $cm The course module.
|
|
|
38 |
*/
|
|
|
39 |
public function __construct(
|
|
|
40 |
/** @var cm_info The course module. */
|
|
|
41 |
protected cm_info $cm,
|
|
|
42 |
) {
|
|
|
43 |
}
|
|
|
44 |
|
|
|
45 |
/**
|
|
|
46 |
* Export this data so it can be used as the context for a mustache template.
|
|
|
47 |
*
|
|
|
48 |
* @param renderer_base $output Renderer base.
|
|
|
49 |
* @return stdClass
|
|
|
50 |
*/
|
|
|
51 |
public function export_for_template(renderer_base $output): stdClass {
|
|
|
52 |
$cm = $this->cm;
|
|
|
53 |
$section = $this->cm->get_section_info();
|
|
|
54 |
$course = $this->cm->get_course();
|
|
|
55 |
$format = course_format::instance($course);
|
|
|
56 |
|
|
|
57 |
$result = (object) [
|
|
|
58 |
'activityname' => \core_external\util::format_string($cm->name, $cm->context, true),
|
|
|
59 |
'activityurl' => $cm->url,
|
|
|
60 |
'hidden' => empty($cm->visible),
|
|
|
61 |
'stealth' => $cm->is_stealth(),
|
|
|
62 |
];
|
|
|
63 |
if ($format->uses_sections()) {
|
|
|
64 |
$result->sectiontitle = $format->get_section_name($section);
|
|
|
65 |
}
|
|
|
66 |
return $result;
|
|
|
67 |
}
|
|
|
68 |
|
|
|
69 |
/**
|
|
|
70 |
* Get the template name.
|
|
|
71 |
*
|
|
|
72 |
* @param renderer_base $renderer Renderer base.
|
|
|
73 |
* @return string
|
|
|
74 |
*/
|
|
|
75 |
public function get_template_name(renderer_base $renderer): string {
|
|
|
76 |
return 'core_courseformat/local/overview/activityname';
|
|
|
77 |
}
|
|
|
78 |
}
|