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
defined('MOODLE_INTERNAL') || die;
18
 
19
/**
20
 * Definition of the summary report class
21
 *
22
 * @package   gradereport_summary
23
 * @copyright 2022 Ilya Tregubov <ilya@moodle.com>
24
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
25
 */
26
 
27
require_once($CFG->dirroot . '/grade/report/lib.php');
28
 
29
/**
30
 * Class providing an API for the summary report building.
31
 *
32
 * @package   gradereport_summary
33
 * @uses      grade_report
34
 * @copyright 2022 Ilya Tregubov <ilya@moodle.com>
35
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
36
 */
37
class grade_report_summary extends grade_report {
38
 
39
    /**
40
     * Capability check caching
41
     *
42
     * @var boolean $canviewhidden
43
     */
44
    public $canviewhidden;
45
 
46
    /**
47
     * Constructor. Sets local copies of user preferences and initialises grade_tree.
48
     *
49
     * @param int $courseid
50
     * @param object $gpr grade plugin return tracking object
51
     * @param context_course $context
52
     */
53
    public function __construct($courseid, $gpr, $context) {
54
        parent::__construct($courseid, $gpr, $context);
55
 
56
        $this->canviewhidden = has_capability('moodle/grade:viewhidden', $context);
57
        $this->setup_groups();
58
    }
59
 
60
    /**
61
     * Processes a single action against a category, grade_item or grade. Not used in summary report.
62
     *
63
     * @param string $target eid ({type}{id}, e.g. c4 for category4)
64
     * @param string $action Which action to take (edit, delete etc...)
65
     */
66
    public function process_action($target, $action) {
67
    }
68
 
69
    /**
70
     * Handles form data sent by this report for this report. Not used in summary report.
71
     *
72
     * @param array $data
73
     */
74
    public function process_data($data) {
75
    }
76
 
77
    /**
78
     * To check if we only need to include active enrolments.
79
     *
80
     * @return bool
81
     */
82
    public function show_only_active(): bool {
83
 
84
        // Limit to users with an active enrolment.
85
        $defaultgradeshowactiveenrol = !empty($CFG->grade_report_showonlyactiveenrol);
86
        $showonlyactiveenrol = get_user_preferences('grade_report_showonlyactiveenrol', $defaultgradeshowactiveenrol);
87
        return $showonlyactiveenrol ||
88
            !has_capability('moodle/course:viewsuspendedusers', $this->context);
89
    }
90
}