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
/**
18
 * Provides rendering functionality for the forum summary report subplugin.
19
 *
20
 * @package   forumreport_summary
21
 * @copyright 2019 Michael Hawkins <michaelh@moodle.com>
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
use forumreport_summary\summary_table;
28
 
29
/**
30
 * Renderer for the forum summary report.
31
 *
32
 * @copyright  2019 Michael Hawkins <michaelh@moodle.com>
33
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
34
 */
35
class forumreport_summary_renderer extends plugin_renderer_base {
36
 
37
    /**
38
     * Render the filters available for the forum summary report.
39
     *
40
     * @param stdClass $course The course object.
41
     * @param array $cms Array of course module objects.
42
     * @param moodle_url $actionurl The form action URL.
43
     * @param array $filters Optional array of currently applied filter values.
44
     * @return string The filter form HTML.
45
     */
46
    public function render_filters_form(stdClass $course, array $cms, moodle_url $actionurl, array $filters = []): string {
47
        $renderable = new \forumreport_summary\output\filters($course, $cms, $actionurl, $filters);
48
        $templatecontext = $renderable->export_for_template($this);
49
 
50
        return $this->render_from_template('forumreport_summary/filters', $templatecontext);
51
    }
52
 
53
    /**
54
     * Render the summary report table.
55
     *
56
     * @param summary_table $table The summary table to be rendered.
57
     * @return string The report table HTML.
58
     */
59
    public function render_summary_table(summary_table $table): string {
60
        // Buffer so calling script can output the report as required.
61
        ob_start();
62
 
63
        // Render table.
64
        $table->out($table->get_perpage(), false);
65
 
66
        $tablehtml = ob_get_contents();
67
 
68
        ob_end_clean();
69
 
70
        return $this->render_from_template('forumreport_summary/report', ['tablehtml' => $tablehtml]);
71
    }
72
}