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
/**
19
 * Course competency override grade element.
20
 *
21
 * @package   tool_lp
22
 * @copyright 2022 Matthew Hilton <matthewhilton@catalyst-au.net>
23
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
24
 */
25
 
26
defined('MOODLE_INTERNAL') || die();
27
 
28
global $CFG;
29
 
30
require_once($CFG->libdir . '/form/advcheckbox.php');
31
 
32
/**
33
 * Course competency override grade element.
34
 *
35
 * @package   tool_lp
36
 * @copyright 2022 Matthew Hilton <matthewhilton@catalyst-au.net>
37
 * @license   http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
38
 */
39
class tool_lp_course_competency_overridegrade_form_element extends MoodleQuickForm_advcheckbox {
40
 
41
    /**
42
     * Constructor
43
     *
44
     * @param string $elementname Element name
45
     * @param mixed $elementlabel Label(s) for an element
46
     * @param array $options Options to control the element's display
47
     */
48
    public function __construct($elementname=null, $elementlabel=null, $options=[]) {
49
        if ($elementname == null) {
50
            // This is broken quickforms messing with the constructors.
51
            return;
52
        }
53
 
54
        if (!empty($options['cmid'])) {
55
            $cmid = $options['cmid'];
56
 
57
            $current = \core_competency\api::list_course_module_competencies_in_course_module($cmid);
58
 
59
            // Note: We just pick the override grade value set on the first course_module_competency.
60
            // Because in the UI we force them to be the same for all.
61
            if (!empty($current)) {
62
                $one = array_pop($current);
63
                $this->setValue($one->get('overridegrade'));
64
            }
65
        }
66
 
67
        parent::__construct($elementname, $elementlabel);
68
    }
69
}