-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmod_form.php
More file actions
114 lines (96 loc) · 4.14 KB
/
Copy pathmod_form.php
File metadata and controls
114 lines (96 loc) · 4.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
// This file is part of the Lessonspace plugin for Moodle - https://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <https://www.gnu.org/licenses/>.
/**
* The main mod_lessonspace configuration form.
*
* @package mod_lessonspace
* @copyright 2021 Lessonspace, Inc
* @license https://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
defined('MOODLE_INTERNAL') || die();
require_once $CFG->dirroot.'/course/moodleform_mod.php';
/**
* Module instance settings form.
*
* @package mod_lessonspace
* @copyright 2021 Lessonspace (Pty) Ptd
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class mod_lessonspace_mod_form extends moodleform_mod
{
/**
* Defines forms elements
*/
public function definition()
{
global $CFG;
$mform = $this->_form;
// Adding the "general" fieldset, where all the common settings are shown.
$mform->addElement('header', 'general', get_string('general', 'form'));
// Adding the standard "name" field
$mform->addElement('text', 'name', get_string('activityname', 'mod_lessonspace'), array('size' => '64'));
$mform->setType('name', PARAM_TEXT);
$mform->addRule('name', null, 'required', null, 'client');
$mform->addRule('name', get_string('maximumchars', '', 300), 'maxlength', 300, 'client');
// Adding the standard "name" field.
$mform->addElement('text', 'space_id', get_string('spaceid', 'mod_lessonspace'), array('size' => '64'));
$mform->setType('space_id', PARAM_TEXT);
$mform->addRule('space_id', null, 'required', null, 'client');
$mform->addRule('space_id', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');
$mform->addHelpButton('space_id', 'spaceid', 'mod_lessonspace');
// Adding the standard "intro" and "introformat" fields.
if ($CFG->branch >= 29) {
$this->standard_intro_elements();
} else {
$this->add_intro_editor();
}
$mform->addElement('advcheckbox', 'add_lock', get_string('addlock', 'mod_lessonspace'));
$mform->addHelpButton('add_lock', 'addlock', 'mod_lessonspace');
// Add date/time.
$mform->addElement('date_time_selector', 'start_time', get_string('starttime', 'mod_lessonspace'));
$mform->disabledIf('start_time', 'add_lock', 'notchecked');
$mform->addHelpButton('start_time', 'starttime', 'mod_lessonspace');
// Add duration.
$mform->addElement('duration', 'duration', get_string('duration', 'mod_lessonspace'));
$mform->setDefault('duration', array('number' => 0, 'timeunit' => 3600));
$mform->disabledIf('duration', 'add_lock', 'notchecked');
$mform->addHelpButton('duration', 'duration', 'mod_lessonspace');
$mform->addElement(
'html',
'<div style="margin-bottom: 20px; font-weight: bold;">'.get_string('extrasettings', 'mod_lessonspace').'</div>'
);
// Add standard grading elements.
$this->standard_grading_coursemodule_elements();
$mform->setDefault('grade', false);
// Add standard elements, common to all modules.
$this->standard_coursemodule_elements();
$this->apply_admin_defaults();
// Add standard buttons, common to all modules.
$this->add_action_buttons();
}
/**
* Enforce validation rules here
*
* @param object $data Post data to validate
*
* @return array
**/
public function validation($data, $files)
{
$errors = parent::validation($data, $files);
return $errors;
}
}