Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
6 ariadna 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
 * A form to edit reactions and difficulty tracks settings per-activity, displayed within the block.
19
 *
20
 * @package    block_point_view
21
 * @copyright  2023 Astor Bizard
22
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
23
 */
24
 
25
namespace block_point_view;
26
 
27
defined('MOODLE_INTERNAL') || die();
28
 
29
global $CFG;
30
require_once($CFG->libdir . '/formslib.php');
31
 
32
/**
33
 * In-block, per-activity form to edit reactions and difficulty tracks settings definition.
34
 *
35
 * @copyright  2023 Astor Bizard
36
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
37
 */
38
class module_form extends \moodleform {
39
    /**
40
     * {@inheritDoc}
41
     * @see \moodleform::definition()
42
     */
43
    public function definition() {
44
        $mform = $this->_form;
45
 
46
        $cmid = $this->_customdata['cmid'];
47
        $blockconfig = $this->_customdata['blockconfig'];
48
 
49
        $mform->addElement('hidden', 'cmid', $cmid);
50
        $mform->setType('cmid', PARAM_INT);
51
 
52
        $mform->addElement('hidden', 'returnurl', $this->_customdata['returnurl']);
53
        $mform->setType('returnurl', PARAM_RAW);
54
 
55
        $mform->addElement('hidden', 'blockinstanceid', $this->_customdata['blockinstanceid']);
56
        $mform->setType('blockinstanceid', PARAM_INT);
57
 
58
        $group = [];
59
 
60
        if (!empty($blockconfig->enable_point_views)) {
61
            // Checkbox for reactions.
62
            $group[] =& $mform->createElement( 'advcheckbox', 'enablereactions',
63
                    get_string('reactions', 'block_point_view'), null,
64
                    );
65
        }
66
 
67
        if (!empty($blockconfig->enable_difficultytracks)) {
68
            // Difficulty track.
69
            $group[] =& $mform->createElement( 'html',
70
                    '<span id="track_' . $cmid . '" class="block_point_view track selecttrack"></span>' );
71
 
72
            // Difficulty track select.
73
            $group[] =& $mform->createElement( 'select', 'difficultytrack', '',
74
                    [
75
                            get_string('nonetrack', 'block_point_view'),
76
                            get_string('greentrack', 'block_point_view'),
77
                            get_string('bluetrack', 'block_point_view'),
78
                            get_string('redtrack', 'block_point_view'),
79
                            get_string('blacktrack', 'block_point_view'),
80
                    ],
81
                    [ 'class' => 'moduletrackselect', 'data-id' => $cmid ]
82
                    );
83
        }
84
 
85
        if (!empty($group)) {
86
            $mform->addGroup( $group, 'point_view_for_module', '', '', false );
87
            $this->add_action_buttons(true, get_string('save'));
88
        }
89
    }
90
}