Moodle

Bulk user enrol hard-codes the student role id as 5 and incorrectly shows teachers as enrolled

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0.8
  • Component/s: Administration
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

This was checked in as MDL-15449.

This is BAD. The code should look for the role in the database according to some condition, for example shortname = 'student' or having capability legacy/student, with appropriate error handling.

Issue Links

Activity

Hide
Tim Hunt added a comment -

It also shows teachers as if they were already enrolled, however this is misleading as they are enrolled as teachers, and this page only lets you enrol people as students.

Show
Tim Hunt added a comment - It also shows teachers as if they were already enrolled, however this is misleading as they are enrolled as teachers, and this page only lets you enrol people as students.
Hide
Anthony Borrow added a comment -

Yep, hard coding the role id ~ line 93:

if( role_unassign(5, $ids[0], 0, $context->id) ) {

is not pretty although I confess doing something similar on one of my servers just because it was a quick/easy way to do it without having to look up the id.

Show
Anthony Borrow added a comment - Yep, hard coding the role id ~ line 93: if( role_unassign(5, $ids[0], 0, $context->id) ) { is not pretty although I confess doing something similar on one of my servers just because it was a quick/easy way to do it without having to look up the id.
Hide
Eloy Lafuente (stronk7) added a comment -

Looks really horrible, yup. Perhaps we could use $CFG->defaultcourseroleid as the role to be used when using that bulk operation? Both when detecting current enrolments and when assigning them.

Though it's possible that this will be changed in 2.0 new enrolments... I think it's better to have it working properly (at least "old behaviour") since now, yup?

Show
Eloy Lafuente (stronk7) added a comment - Looks really horrible, yup. Perhaps we could use $CFG->defaultcourseroleid as the role to be used when using that bulk operation? Both when detecting current enrolments and when assigning them. Though it's possible that this will be changed in 2.0 new enrolments... I think it's better to have it working properly (at least "old behaviour") since now, yup?

People

Vote (3)
Watch (9)

Dates

  • Created:
    Updated: