-
Notifications
You must be signed in to change notification settings - Fork 0
/
renderer.php
55 lines (40 loc) · 2.08 KB
/
renderer.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<?php
/**
* ReportBadges report renderer.
*
* @package report_reportbadges
* @copyright 2014 Andraž Prinčič <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die;
class report_reportbadges_renderer extends plugin_renderer_base {
protected function render_report_reportbadges(report_reportbadges $reportbadges) {
$this->report_selector_form($reportbadges);
}
/**
* This function is used to generate and display selector form
*
* @param report_reportbadges $reportbadges reportbadges report.
*/
public function report_selector_form(report_reportbadges $reportbadges) {
global $DB;
$yearsDB = $DB->get_records_sql('SELECT DISTINCT YEAR(FROM_UNIXTIME(d.dateissued)) as yearissued FROM {badge_issued} AS d JOIN {badge} AS b ON d.badgeid = b.id', array('courseid' => $reportbadges->courseid));
$years[] = get_string('selecallyears', 'report_reportbadges');
foreach ($yearsDB as $value) {
$years[$value->yearissued] = $value->yearissued;
}
echo html_writer::start_tag('form',
array('class' => 'reportbadgesselecform', 'action' => $reportbadges->url, 'method' => 'get'));
echo html_writer::start_div();
echo html_writer::empty_tag('input',
array('type' => 'hidden', 'name' => 'id', 'value' => $reportbadges->courseid));
echo html_writer::label(get_string('selectreporttype', 'report_reportbadges'), 'menureader', false);
echo html_writer::select($reportbadges->getAvailablereports(), 'reporttype', $reportbadges->reporttype, false);
echo html_writer::label(get_string('selectreportyear', 'report_reportbadges'), 'menureader', false);
echo html_writer::select($years, 'reportyear', $reportbadges->reportyear, false);
echo html_writer::empty_tag('input',
array('type' => 'submit', 'value' => get_string('showreport', 'report_reportbadges')));
echo html_writer::end_div();
echo html_writer::end_tag('form');
}
}