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 tool_brickfield\output\checktyperesults; 18 19 use core\chart_pie as chart_pie; 20 use core\chart_series as chart_series; 21 use tool_brickfield\accessibility; 22 use tool_brickfield\local\tool\filter; 23 use tool_brickfield\manager; 24 25 /** 26 * tool_brickfield/checktyperesults renderer 27 * 28 * @package tool_brickfield 29 * @copyright 2020 onward: Brickfield Education Labs, https://www.brickfield.ie 30 * @author Mike Churchward 31 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later 32 */ 33 class renderer extends \tool_brickfield\output\renderer { 34 /** 35 * Render the page containing the Checktype results report. 36 * @param \stdClass $data 37 * @param filter $filter 38 * @return bool|string 39 * @throws \coding_exception 40 * @throws \dml_exception 41 * @throws \moodle_exception 42 */ 43 public function display(\stdClass $data, filter $filter): string { 44 $templatedata = new \stdClass(); 45 46 // Set up the page information for the external renderer. 47 $templatedata->title = accessibility::get_title($filter, $data->countdata); 48 $templatedata->chartdesc = get_string('pagedesc:checktype', manager::PLUGINNAME); 49 $templatedata->chartdesctitle = get_string('pagedesctitle:checktype', manager::PLUGINNAME); 50 51 // Set up a table of data for the template. 52 $noerrorsfound = true; 53 $grouperrors = []; 54 $labels = []; 55 $count = 0; 56 for ($i = 1; (($count < $data->data[0]->groupcount) && ($i < 10)); $i++) { 57 if (isset($data->data[0]->{'componentlabel' . $i})) { 58 $grouperrors[] = $data->data[0]->{'errorsvalue' . $i}; 59 if ($data->data[0]->{'errorsvalue' . $i} > 0) { 60 $noerrorsfound = false; 61 } 62 $labels[] = $data->data[0]->{'componentlabel' . $i}; 63 $count++; 64 } 65 } 66 67 if ($noerrorsfound) { 68 $templatedata->pagetitle = $templatedata->title; 69 $templatedata->noerrorsfound = get_string('noerrorsfound', manager::PLUGINNAME); 70 return $this->render_from_template(manager::PLUGINNAME . '/norecords', $templatedata); 71 } 72 73 $chart = new chart_pie(); 74 $chart->set_doughnut(true); 75 $series1 = new chart_series(get_string('totalerrors', manager::PLUGINNAME), $grouperrors); 76 $chart->add_series($series1); 77 $chart->set_labels($labels); 78 $chart->set_title(get_string('totalgrouperrors', manager::PLUGINNAME)); 79 80 $templatedata->chart = $this->render($chart); 81 return $this->render_from_template(manager::PLUGINNAME . '/chartsingle', $templatedata); 82 } 83 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body