// Only allow the idnumber to be set if the user has permission and the idnumber is not already in use by
// another a group in the same course
$context = context_course::instance($data->courseid);
- if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
+ if (isset($data->idnumber) and has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
if (groups_get_group_by_idnumber($data->courseid, $data->idnumber)) {
unset($data->idnumber);
}
// Only allow the idnumber to be set if the user has permission and the idnumber is not already in use by
// another a grouping in the same course
$context = context_course::instance($data->courseid);
- if (has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
+ if (isset($data->idnumber) and has_capability('moodle/course:changeidnumber', $context, $this->task->get_userid())) {
if (groups_get_grouping_by_idnumber($data->courseid, $data->idnumber)) {
unset($data->idnumber);
}