Moodle

Student cannot unenrol self via button on profile page

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Duplicate
  • Affects Version/s: 1.8.2
  • Fix Version/s: None
  • Component/s: Course
  • Labels:
    None
  • Environment:
    Doesn't matter
  • Database:
    MySQL
  • Affected Branches:
    MOODLE_18_STABLE

Description

moodle/role:unassignself has been allowed for students so students can unenrol from any course.

It works when student clicks on the link in administration field on course view page. However, when trying to unenrol via the button on profile page an error message appears. Apparently student must have moodle/role:assign allowed

Reason for bug:
if ($userid) on line 31 of file course/unenrol.php always evaluates to true when the script is called via the button on profile page. So the script thinks someone else is about to be unenrolled.

Fix of bug:
Replacing

if ($userid) {

by

if ($userid && $userid != $USER->id) {

on lines 31, 42, and 66 in file course/unenrol.php fixes the bug.

Issue Links

Activity

Hide
Dan Poltawski added a comment -

This is a duplicate of MDL-10241 which was fixed recently

Show
Dan Poltawski added a comment - This is a duplicate of MDL-10241 which was fixed recently

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: