mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Merge branch 'MDL-66712-master-selfautounenrol' of git://github.com/mudrd8mz/moodle
This commit is contained in:
commit
a05b402c12
@ -450,8 +450,9 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
$userid = $instance->userid;
|
||||
unset($instance->userid);
|
||||
$this->unenrol_user($instance, $userid);
|
||||
$days = $instance->customint2 / 60*60*24;
|
||||
$trace->output("unenrolling user $userid from course $instance->courseid as they have did not log in for at least $days days", 1);
|
||||
$days = $instance->customint2 / DAYSECS;
|
||||
$trace->output("unenrolling user $userid from course $instance->courseid " .
|
||||
"as they did not log in for at least $days days", 1);
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
@ -467,8 +468,9 @@ class enrol_self_plugin extends enrol_plugin {
|
||||
$userid = $instance->userid;
|
||||
unset($instance->userid);
|
||||
$this->unenrol_user($instance, $userid);
|
||||
$days = $instance->customint2 / 60*60*24;
|
||||
$trace->output("unenrolling user $userid from course $instance->courseid as they have did not access course for at least $days days", 1);
|
||||
$days = $instance->customint2 / DAYSECS;
|
||||
$trace->output("unenrolling user $userid from course $instance->courseid " .
|
||||
"as they did not access the course for at least $days days", 1);
|
||||
}
|
||||
$rs->close();
|
||||
|
||||
|
@ -61,7 +61,7 @@ class enrol_self_testcase extends advanced_testcase {
|
||||
|
||||
$now = time();
|
||||
|
||||
$trace = new null_progress_trace();
|
||||
$trace = new progress_trace_buffer(new text_progress_trace(), false);
|
||||
|
||||
// Prepare some data.
|
||||
|
||||
@ -133,18 +133,32 @@ class enrol_self_testcase extends advanced_testcase {
|
||||
// Execute sync - this is the same thing used from cron.
|
||||
|
||||
$selfplugin->sync($trace, $course2->id);
|
||||
$output = $trace->get_buffer();
|
||||
$trace->reset_buffer();
|
||||
$this->assertEquals(10, $DB->count_records('user_enrolments'));
|
||||
|
||||
$this->assertStringContainsString('No expired enrol_self enrolments detected', $output);
|
||||
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$instance1->id, 'userid'=>$user1->id)));
|
||||
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$instance1->id, 'userid'=>$user2->id)));
|
||||
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$instance3->id, 'userid'=>$user1->id)));
|
||||
$this->assertTrue($DB->record_exists('user_enrolments', array('enrolid'=>$instance3->id, 'userid'=>$user3->id)));
|
||||
|
||||
$selfplugin->sync($trace, null);
|
||||
$output = $trace->get_buffer();
|
||||
$trace->reset_buffer();
|
||||
$this->assertEquals(6, $DB->count_records('user_enrolments'));
|
||||
$this->assertFalse($DB->record_exists('user_enrolments', array('enrolid'=>$instance1->id, 'userid'=>$user1->id)));
|
||||
$this->assertFalse($DB->record_exists('user_enrolments', array('enrolid'=>$instance1->id, 'userid'=>$user2->id)));
|
||||
$this->assertFalse($DB->record_exists('user_enrolments', array('enrolid'=>$instance3->id, 'userid'=>$user1->id)));
|
||||
$this->assertFalse($DB->record_exists('user_enrolments', array('enrolid'=>$instance3->id, 'userid'=>$user3->id)));
|
||||
$this->assertStringContainsString('unenrolling user ' . $user1->id . ' from course ' . $course1->id .
|
||||
' as they did not log in for at least 14 days', $output);
|
||||
$this->assertStringContainsString('unenrolling user ' . $user1->id . ' from course ' . $course3->id .
|
||||
' as they did not log in for at least 50 days', $output);
|
||||
$this->assertStringContainsString('unenrolling user ' . $user2->id . ' from course ' . $course1->id .
|
||||
' as they did not access the course for at least 14 days', $output);
|
||||
$this->assertStringContainsString('unenrolling user ' . $user3->id . ' from course ' . $course3->id .
|
||||
' as they did not access the course for at least 50 days', $output);
|
||||
$this->assertStringNotContainsString('unenrolling user ' . $user4->id, $output);
|
||||
|
||||
$this->assertEquals(6, $DB->count_records('role_assignments'));
|
||||
$this->assertEquals(4, $DB->count_records('role_assignments', array('roleid'=>$studentrole->id)));
|
||||
|
Loading…
x
Reference in New Issue
Block a user