From 3449816e7f2ef665bf9253db5d52e08342761d5e Mon Sep 17 00:00:00 2001 From: Sara Arjona Date: Fri, 6 Apr 2018 12:22:46 +0200 Subject: [PATCH] MDL-61736 user: Show correct status when enrol method is disabled When disabling an enrolment method, the user status will be displayed as "Not current" instead of "Active". --- user/classes/participants_table.php | 6 ++++-- user/tests/behat/view_participants.feature | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/user/classes/participants_table.php b/user/classes/participants_table.php index e05e0fd4ed3..1959b08910b 100644 --- a/user/classes/participants_table.php +++ b/user/classes/participants_table.php @@ -385,8 +385,10 @@ class participants_table extends \table_sql { case ENROL_USER_ACTIVE: $currentdate = new DateTime(); $now = $currentdate->getTimestamp(); - // If user enrolment status has not yet started/already ended. - if ($timestart > $now || ($timeend > 0 && $timeend < $now)) { + $isexpired = $timestart > $now || ($timeend > 0 && $timeend < $now); + $enrolmentdisabled = $ue->enrolmentinstance->status == ENROL_INSTANCE_DISABLED; + // If user enrolment status has not yet started/already ended or the enrolment instance is disabled. + if ($isexpired || $enrolmentdisabled) { $status = get_string('participationnotcurrent', 'enrol'); $statusval = status_field::STATUS_NOT_CURRENT; } diff --git a/user/tests/behat/view_participants.feature b/user/tests/behat/view_participants.feature index 5e1f44fff60..5c6d4f80cdb 100644 --- a/user/tests/behat/view_participants.feature +++ b/user/tests/behat/view_participants.feature @@ -265,3 +265,12 @@ Feature: View course participants # Suspended and non-current students should not be rendered. And I should not see "Student 10x" in the "participants" "table" And I should not see "Student 11x" in the "participants" "table" + + Scenario: Check status after disabling manual enrolment + Given I log in as "admin" + And I am on "Course 1" course homepage + And I navigate to course participants + When I navigate to "Enrolment methods" in current page administration + And I click on "Disable" "link" in the "Manual enrolments" "table_row" + Then I navigate to course participants + And I should see "Not current" in the "student0x" "table_row"