forked from microsoft/moodle-block_microsoft
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathforms.php
More file actions
119 lines (104 loc) · 4.68 KB
/
forms.php
File metadata and controls
119 lines (104 loc) · 4.68 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
115
116
117
118
119
<?php
// This file is part of Moodle - http://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 <http://www.gnu.org/licenses/>.
/**
* Define forms used by the plugin.
*
* @package block_microsoft
* @author Lai Wei <lai.wei@enovation.ie>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @copyright (C) 2021 onwards Microsoft, Inc. (http://microsoft.com/)
*/
defined('MOODLE_INTERNAL') || die();
require_once($CFG->libdir . '/formslib.php');
require_once($CFG->dirroot . '/local/o365/lib.php');
/**
* Form to configure course sync options.
*/
class block_microsoft_course_sync_form extends moodleform {
/**
* Form definition.
*/
protected function definition() {
$mform = $this->_form;
$mform->addElement('hidden', 'course');
$mform->setType('course', PARAM_INT);
// Sync options.
$syncoptions = [
MICROSOFT365_COURSE_SYNC_NONE => get_string('course_sync_option_not_synced', 'block_microsoft'),
MICROSOFT365_COURSE_SYNC_GROUPS => get_string('course_sync_option_groups', 'block_microsoft'),
MICROSOFT365_COURSE_SYNC_TEAMS => get_string('course_sync_option_teams', 'block_microsoft'),
];
$mform->addElement('select', 'sync', get_string('course_sync_option', 'block_microsoft'), $syncoptions);
$mform->setDefault('sync', MICROSOFT365_COURSE_SYNC_NONE);
$this->add_action_buttons();
}
}
/**
* Form to configure course Team reset actions.
*/
class block_microsoft_course_configure_team_form extends moodleform {
/**
* Form definition.
*/
protected function definition() {
$mform = $this->_form;
$mform->addElement('hidden', 'course');
$mform->setType('course', PARAM_INT);
$resetoptions = [];
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
get_string('teams_reset_option_do_nothing', 'block_microsoft'), TEAMS_COURSE_RESET_SETTING_DO_NOTHING);
$createteams = get_config('local_o365', 'createteams');
if ($createteams == 'oncustom') {
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
get_string('teams_reset_option_disconnect_only', 'block_microsoft'),
TEAMS_COURSE_RESET_SETTING_DISCONNECT_ONLY);
}
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
get_string('teams_reset_option_disconnect', 'block_microsoft'), TEAMS_COURSE_RESET_SETTING_DISCONNECT_AND_CREATE_NEW);
$mform->addGroup($resetoptions, 'resetsettinggroup', get_string('course_reset_team_option', 'block_microsoft'),
'<br/>', false);
$mform->setDefault('reset_setting', TEAMS_COURSE_RESET_SETTING_DO_NOTHING);
$this->add_action_buttons();
}
}
/**
* Form to configure course group reset actions.
*/
class block_microsoft_course_configure_group_form extends moodleform {
/**
* Form definition.
*/
protected function definition() {
$mform = $this->_form;
$mform->addElement('hidden', 'course');
$mform->setType('course', PARAM_INT);
$resetoptions = [];
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
get_string('group_reset_option_do_nothing', 'block_microsoft'), GROUP_COURSE_RESET_SETTING_DO_NOTHING);
$createteams = get_config('local_o365', 'createteams');
if ($createteams == 'oncustom') {
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
get_string('group_reset_option_disconnect_only', 'block_microsoft'),
GROUP_COURSE_RESET_SETTING_DISCONNECT_ONLY);
}
$resetoptions[] = $mform->createElement('radio', 'reset_setting', '',
get_string('group_reset_option_disconnect', 'block_microsoft'), GROUP_COURSE_RESET_SETTING_DISCONNECT_AND_CREATE_NEW);
$mform->addGroup($resetoptions, 'resetsettinggroup', get_string('course_reset_group_option', 'block_microsoft'),
'<br/><br/>', false);
$mform->setDefault('reset_setting', GROUP_COURSE_RESET_SETTING_DO_NOTHING);
$this->add_action_buttons();
}
}