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
  * HTML rendering methods are defined here
19
  *
20
  * @category output
21
  * @package report_overviewstats
22
  * @copyright 2023 DualCube <admin@dualcube.com>
23
  * @copyright based on work by 2013 David Mudrak <david@moodle.com>
24
  * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
  */
26
 
27
 /**
28
  * Overview statistics renderer
29
  *
30
  * @category output
31
  * @package report_overviewstats
32
  * @copyright 2023 DualCube <admin@dualcube.com>
33
  * @copyright based on work by 2013 David Mudrak <david@moodle.com>
34
  * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
35
  */
36
class report_overviewstats_renderer extends plugin_renderer_base {
37
 
38
    /**
39
     * Render the report charts
40
     *
41
     * @see report_overviewstats_chart::get_content() for the expected structure
42
     * @param array $charts list of {@link report_overviewstats_chart} instances
43
     * @return string
44
     */
45
    public function charts($course) {
46
        $chartsdata = [];
47
        if (is_null($course)) {
48
            $chartsdata[] = report_overviewstats_chart::report_overviewstats_chart_logins();
49
            $chartsdata[] = report_overviewstats_chart::report_overviewstats_chart_countries();
50
            $chartsdata[] = report_overviewstats_chart::report_overviewstats_chart_langs();
51
            $chartsdata[] = report_overviewstats_chart::report_overviewstats_chart_courses();
52
        } else {
53
            $chartsdata[] = report_overviewstats_chart::report_overviewstats_chart_enrolments($course);
54
        }
55
 
56
        $outlist = '';
57
        $outbody = '';
58
 
59
        $counter = 0;
60
        foreach ($chartsdata as $chart) {
61
            foreach ($chart as $title => $content) {
62
                $counter++;
63
                $outlist .= html_writer::tag('li', html_writer::link('#chart_seq_' . $counter, s($title)));
64
                $outbody .= html_writer::start_div('chart', ['id' => 'chart_seq_' . $counter]);
65
                $outbody .= $this->output->heading($title, 2);
66
                if (is_array($content)) {
67
                    foreach ($content as $subtitle => $subcontent) {
68
                        $outbody .= html_writer::start_div('subchart');
69
                        $outbody .= $this->output->heading($subtitle, 3);
70
                        $outbody .= $subcontent;
71
                        $outbody .= html_writer::end_div();
72
                    }
73
                } else {
74
                    $outbody .= $content;
75
                }
76
                $outbody .= html_writer::end_div();
77
            }
78
        }
79
 
80
        $out = $this->output->header();
81
        $out .= html_writer::start_tag('ul', ['class' => 'chartslist']);
82
        $out .= $outlist;
83
        $out .= html_writer::end_tag('ul');
84
        $out .= html_writer::div($outbody, 'charts');
85
        $out .= $this->output->footer();
86
 
87
        return $out;
88
    }
89
}