|
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
|
|
|
* Relationship's Cohort form definition |
|
19
|
|
|
* |
|
20
|
|
|
* @package local_relationship |
|
21
|
|
|
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later |
|
22
|
|
|
*/ |
|
23
|
|
|
|
|
24
|
|
|
namespace local_relationship\form; |
|
25
|
|
|
defined('MOODLE_INTERNAL') || die(); |
|
26
|
|
|
|
|
27
|
|
|
require_once($CFG->dirroot.'/lib/formslib.php'); |
|
28
|
|
|
|
|
29
|
|
|
class edit_cohort extends \moodleform { |
|
30
|
|
|
|
|
31
|
|
|
public function definition() { |
|
32
|
|
|
|
|
33
|
|
|
$mform = $this->_form; |
|
|
|
|
|
|
34
|
|
|
$relationshipcohort = $this->_customdata['data']; |
|
35
|
|
|
|
|
36
|
|
|
$cohorts = relationship_get_cohort_options($relationshipcohort->relationshipid); |
|
|
|
|
|
|
37
|
|
|
$relationshipcohorts = relationship_get_cohorts($relationshipcohort->relationshipid); |
|
38
|
|
|
foreach($relationshipcohorts AS $rc) { |
|
39
|
|
|
unset($cohorts[$rc->cohortid]); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
$mform->addElement('select', 'cohortid', get_string('cohort', 'cohort'), $cohorts); |
|
43
|
|
|
|
|
44
|
|
|
$roles = relationship_get_role_options(); |
|
45
|
|
|
foreach($relationshipcohorts AS $rc) { |
|
46
|
|
|
unset($roles[$rc->roleid]); |
|
47
|
|
|
} |
|
48
|
|
|
$mform->addElement('select', 'roleid', get_string('role'), $roles); |
|
49
|
|
|
|
|
50
|
|
|
if($relationshipcohort->id) { |
|
51
|
|
|
$mform->freeze('roleid'); |
|
52
|
|
|
$mform->freeze('cohortid'); |
|
53
|
|
|
} |
|
54
|
|
|
|
|
55
|
|
|
$mform->addElement('selectyesno', 'allowdupsingroups', get_string('allowdupsingroups', 'local_relationship')); |
|
56
|
|
|
$mform->addHelpButton('allowdupsingroups', 'allowdupsingroups', 'local_relationship'); |
|
57
|
|
|
|
|
58
|
|
|
$mform->addElement('selectyesno', 'uniformdistribution', get_string('uniformdistribute', 'local_relationship')); |
|
59
|
|
|
$mform->addHelpButton('uniformdistribution', 'uniformdistribute', 'local_relationship'); |
|
60
|
|
|
|
|
61
|
|
|
$mform->addElement('hidden', 'id'); |
|
62
|
|
|
$mform->setType('id', PARAM_INT); |
|
63
|
|
|
$mform->addElement('hidden', 'relationshipid'); |
|
64
|
|
|
$mform->setType('relationshipid', PARAM_INT); |
|
65
|
|
|
|
|
66
|
|
|
$this->add_action_buttons(); |
|
67
|
|
|
|
|
68
|
|
|
$this->set_data($relationshipcohort); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
public function validation($data, $files) { |
|
72
|
|
|
$errors = parent::validation($data, $files); |
|
73
|
|
|
return $errors; |
|
74
|
|
|
} |
|
75
|
|
|
|
|
76
|
|
|
} |
|
77
|
|
|
|
|
78
|
|
|
|
This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.
To visualize
will produce issues in the first and second line, while this second example
will produce no issues.