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 tool_brickfield\local\tool;
|
|
|
18 |
|
|
|
19 |
use tool_brickfield\sitedata;
|
|
|
20 |
|
|
|
21 |
/**
|
|
|
22 |
* Class checktyperesults.
|
|
|
23 |
*
|
|
|
24 |
* @package tool_brickfield
|
|
|
25 |
* @copyright 2020 onward: Brickfield Education Labs, www.brickfield.ie
|
|
|
26 |
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
|
|
27 |
*/
|
|
|
28 |
class checktyperesults extends tool {
|
|
|
29 |
|
|
|
30 |
/**
|
|
|
31 |
* Provide a name for this tool, suitable for display on pages.
|
|
|
32 |
* @return mixed|string
|
|
|
33 |
* @throws \coding_exception
|
|
|
34 |
*/
|
|
|
35 |
public static function toolname(): string {
|
|
|
36 |
return get_string('checktyperesults:toolname', 'tool_brickfield');
|
|
|
37 |
}
|
|
|
38 |
|
|
|
39 |
/**
|
|
|
40 |
* Provide a short name for this tool, suitable for menus and selectors.
|
|
|
41 |
* @return mixed|string
|
|
|
42 |
* @throws \coding_exception
|
|
|
43 |
*/
|
|
|
44 |
public static function toolshortname(): string {
|
|
|
45 |
return get_string('checktyperesults:toolshortname', 'tool_brickfield');
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* Provide a lowercase name identifying this plugin. Should really be the same as the directory name.
|
|
|
50 |
* @return string
|
|
|
51 |
*/
|
|
|
52 |
public function pluginname(): string {
|
|
|
53 |
return 'checktyperesults';
|
|
|
54 |
}
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Return the data for renderer / template display.
|
|
|
58 |
* @return \stdClass
|
|
|
59 |
* @throws \coding_exception
|
|
|
60 |
* @throws \dml_exception
|
|
|
61 |
*/
|
|
|
62 |
protected function fetch_data(): \stdClass {
|
|
|
63 |
$filter = $this->get_filter();
|
|
|
64 |
if (!$filter->validate_filters()) {
|
|
|
65 |
return (object)[
|
|
|
66 |
'valid' => false,
|
|
|
67 |
'error' => $filter->get_errormessage(),
|
|
|
68 |
];
|
|
|
69 |
|
|
|
70 |
}
|
|
|
71 |
$data = (object)[
|
|
|
72 |
'valid' => true,
|
|
|
73 |
'error' => '',
|
|
|
74 |
'data' => (new sitedata())->get_checkgroup_data($filter),
|
|
|
75 |
];
|
|
|
76 |
if ($filter->categoryid != 0) {
|
|
|
77 |
$data->countdata = count($filter->courseids);
|
|
|
78 |
} else {
|
|
|
79 |
$data->countdata = sitedata::get_total_courses_checked();
|
|
|
80 |
}
|
|
|
81 |
|
|
|
82 |
return $data;
|
|
|
83 |
}
|
|
|
84 |
}
|