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
 * Multiclass test indicator.
19
 *
20
 * @package   core_analytics
21
 * @copyright 2019 Vlad Apetrei
22
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
defined('MOODLE_INTERNAL') || die();
26
 
27
/**
28
 * Multiclass test indicator.
29
 *
30
 * @package   core_analytics
31
 * @copyright 2019 Vlad Apetrei
32
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
34
class test_indicator_multiclass extends \core_analytics\local\indicator\linear {
35
 
36
    /**
37
     * Returns a lang_string object representing the name for the indicator.
38
     *
39
     * Used as column identificator.
40
     *
41
     * If there is a corresponding '_help' string this will be shown as well.
42
     *
43
     * @return \lang_string
44
     */
45
    public static function get_name(): \lang_string {
46
        // Using a string that exists and contains a corresponding '_help' string.
47
        return new \lang_string('allowstealthmodules');
48
    }
49
 
50
    /**
51
     * include_averages
52
     *
53
     * @return bool
54
     */
55
    protected static function include_averages() {
56
        return false;
57
    }
58
 
59
    /**
60
     * required_sample_data
61
     *
62
     * @return string[]
63
     */
64
    public static function required_sample_data() {
65
        return array('course');
66
    }
67
 
68
    /**
69
     * calculate_sample
70
     *
71
     * @param int $sampleid
72
     * @param string $samplesorigin
73
     * @param int $starttime
74
     * @param int $endtime
75
     * @return float
76
     */
77
    protected function calculate_sample($sampleid, $samplesorigin, $starttime, $endtime) {
78
 
79
        $course = $this->retrieve('course', $sampleid);
80
 
81
        $firstchar = substr($course->fullname, 0, 1);
82
        if ($firstchar === 'a') {
83
            return 1;
84
        } else if ($firstchar === 'b') {
85
            return -1;
86
        } else if ($firstchar === 'c') {
87
            return 1;
88
        } else {
89
            return self::MAX_VALUE;
90
        }
91
    }
92
}