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 report_progress\output;
|
|
|
18 |
|
|
|
19 |
use single_select;
|
|
|
20 |
use plugin_renderer_base;
|
|
|
21 |
use html_writer;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Renderer for report progress.
|
|
|
25 |
*
|
|
|
26 |
* @package report_progress
|
|
|
27 |
* @copyright 2021 The Open University
|
|
|
28 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL Juv3 or later
|
|
|
29 |
*/
|
|
|
30 |
class renderer extends plugin_renderer_base {
|
|
|
31 |
/**
|
|
|
32 |
* Render include activity single select box.
|
|
|
33 |
*
|
|
|
34 |
* @param \moodle_url $url The base url.
|
|
|
35 |
* @param array $activitytypes The activity type options.
|
|
|
36 |
* @param string $activityinclude The current selected option.
|
|
|
37 |
* @return string HTML
|
|
|
38 |
* @throws \coding_exception
|
|
|
39 |
*/
|
|
|
40 |
public function render_include_activity_select(\moodle_url $url, array $activitytypes,
|
|
|
41 |
string $activityinclude): string {
|
|
|
42 |
$includeurl = fullclone($url);
|
|
|
43 |
$includeurl->remove_params(['page', 'activityinclude']);
|
|
|
44 |
$activityincludeselect = new single_select(
|
|
|
45 |
$url, 'activityinclude',
|
|
|
46 |
$activitytypes, $activityinclude, null, 'include-activity-select-report'
|
|
|
47 |
);
|
|
|
48 |
$activityincludeselect->set_label(get_string('include', 'report_progress'));
|
|
|
49 |
return \html_writer::div($this->output->render($activityincludeselect),
|
|
|
50 |
'include-activity-selector d-inline-block mr-3' );
|
|
|
51 |
}
|
|
|
52 |
|
|
|
53 |
/**
|
|
|
54 |
* Render activity order single select box.
|
|
|
55 |
*
|
|
|
56 |
* @param \moodle_url $url The base url.
|
|
|
57 |
* @param string $activityorder The current selected option.
|
|
|
58 |
* @return string HTML
|
|
|
59 |
* @throws \coding_exception
|
|
|
60 |
*/
|
|
|
61 |
public function render_activity_order_select(\moodle_url $url, string $activityorder): string {
|
|
|
62 |
$activityorderurl = fullclone($url);
|
|
|
63 |
$activityorderurl->remove_params(['activityorder']);
|
|
|
64 |
$options = ['orderincourse' => get_string('orderincourse', 'report_progress'),
|
|
|
65 |
'alphabetical' => get_string('alphabetical', 'report_progress')];
|
|
|
66 |
$sorttable = new single_select(
|
|
|
67 |
$activityorderurl, 'activityorder',
|
|
|
68 |
$options, $activityorder, null, 'activity-order-select-report'
|
|
|
69 |
);
|
|
|
70 |
$sorttable->set_label(get_string('activityorder', 'report_progress'));
|
|
|
71 |
return \html_writer::div($this->output->render($sorttable),
|
|
|
72 |
'activity-order-selector include-activity-selector d-inline-block');
|
|
|
73 |
}
|
|
|
74 |
|
|
|
75 |
/**
|
|
|
76 |
* Render groups single select box.
|
|
|
77 |
*
|
|
|
78 |
* @param \moodle_url $url The base url.
|
|
|
79 |
* @param \stdClass $course Current course.
|
|
|
80 |
* @return string HTML
|
|
|
81 |
*/
|
|
|
82 |
public function render_groups_select(\moodle_url $url, \stdClass $course): string {
|
|
|
83 |
$groupurl = fullclone($url);
|
|
|
84 |
$groupurl->remove_params(['page', 'group']);
|
|
|
85 |
$groupoutput = groups_print_course_menu($course, $groupurl, true);
|
|
|
86 |
|
|
|
87 |
if (empty($groupoutput)) {
|
|
|
88 |
return $groupoutput;
|
|
|
89 |
}
|
|
|
90 |
|
|
|
91 |
return \html_writer::div($groupoutput, 'd-inline-block mr-3');
|
|
|
92 |
}
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* Render activity section single select box.
|
|
|
96 |
*
|
|
|
97 |
* @param \moodle_url $url The base url.
|
|
|
98 |
* @param string $activitysection The current selected section.
|
|
|
99 |
* @param array $sections An array containing all sections of the course
|
|
|
100 |
* @return string HTML
|
|
|
101 |
* @throws \coding_exception
|
|
|
102 |
*/
|
|
|
103 |
public function render_activity_section_select(\moodle_url $url, string $activitysection, array $sections): string {
|
|
|
104 |
$activitysectionurl = fullclone($url);
|
|
|
105 |
$activitysectionurl->remove_params(['activitysection']);
|
|
|
106 |
$options = $sections;
|
|
|
107 |
$options[-1] = get_string('no_filter_by_section', 'report_progress');
|
|
|
108 |
$sorttable = new single_select(
|
|
|
109 |
$activitysectionurl, 'activitysection',
|
|
|
110 |
$options, $activitysection, null, 'activity-section-select-report'
|
|
|
111 |
);
|
|
|
112 |
$sorttable->set_label(get_string('activitysection', 'report_progress'));
|
|
|
113 |
return \html_writer::div($this->output->render($sorttable),
|
|
|
114 |
'activity-section-selector include-activity-selector d-inline-block ml-3');
|
|
|
115 |
}
|
|
|
116 |
|
|
|
117 |
/**
|
|
|
118 |
* Render download buttons.
|
|
|
119 |
*
|
|
|
120 |
* @param \moodle_url $url The base url.
|
|
|
121 |
* @return string HTML
|
|
|
122 |
* @throws \coding_exception
|
|
|
123 |
*/
|
|
|
124 |
public function render_download_buttons(\moodle_url $url): string {
|
|
|
125 |
$downloadurl = fullclone($url);
|
|
|
126 |
$downloadurl->remove_params(['page']);
|
|
|
127 |
$downloadurl->param('format', 'csv');
|
|
|
128 |
$downloadhtml = html_writer::start_tag('ul', ['class' => 'progress-actions']);
|
|
|
129 |
$downloadhtml .= html_writer::tag('li', html_writer::link($downloadurl, get_string('csvdownload', 'completion')));
|
|
|
130 |
$downloadurl->param('format', 'excelcsv');
|
|
|
131 |
$downloadhtml .= html_writer::tag('li', html_writer::link($downloadurl, get_string('excelcsvdownload', 'completion')));
|
|
|
132 |
$downloadhtml .= html_writer::end_tag('ul');
|
|
|
133 |
|
|
|
134 |
return $downloadhtml;
|
|
|
135 |
}
|
|
|
136 |
}
|