Skip to content

Commit

Permalink
issue_#39
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Sep 12, 2024
1 parent 8c51993 commit 7d7c6a0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
4 changes: 2 additions & 2 deletions classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,13 +234,13 @@ public function enrol_user(
context_course::instance($instance->customint1, IGNORE_MISSING) &&
context_course::instance($instance->courseid, IGNORE_MISSING)
) {
$timestart = 0;
$timestart = time();
$timeend = 0;
if (isset($instance->customint4) && $instance->customint4 > 0) {
$timestart = $instance->customint4;
}
if (isset($instance->enrolperiod) && $instance->enrolperiod > 0) {
$timeend = max(time(), $timestart) + $instance->enrolperiod;
$timeend = $timestart + $instance->enrolperiod;
}
parent::enrol_user($instance, $userid, $roleid, $timestart, $timeend, $status, $recovergrades);
} else {
Expand Down
9 changes: 3 additions & 6 deletions tests/enrol_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,8 @@ public function test_library_functions(): void {
$this->assertEquals($icons[0]->attributes['title'], 'After completing course: Test course 1');
$icons = $this->plugin->get_action_icons($this->instance);
$this->assertCount(2, $icons);
$this->assertStringContainsString('icon fa fa-cog fa-fw iconsmall', $icons[0]);
$this->assertStringContainsString('icon fa fa-user-plus fa-fw iconsmall', $icons[1]);
$this->assertStringContainsString('icon fa fa-', $icons[0]);
$this->assertStringContainsString('icon fa fa-', $icons[1]);
$this->assertStringContainsString(
'<a href="https://www.example.com/moodle/enrol/editinstance.php?courseid=' . $this->course2->id,
$icons[0]
Expand Down Expand Up @@ -459,10 +459,7 @@ public function test_form(): void {
'Enddate',
];
foreach ($arr as $value) {
$this->assertStringContainsString(
'<iclass="iconfafa-question-circletext-infofa-fw"title="Helpwith' . $value . '"role="img"',
$cleaned
);
$this->assertStringContainsString('title="Helpwith' . $value . '"role="img"', $cleaned);
}
$strm = get_string_manager();
$arr = ['compcourse', 'customwelcome', 'enrolenddate', 'enrolstartdate', 'group'];
Expand Down
4 changes: 2 additions & 2 deletions tests/time_enrolled_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,10 @@ public function test_time_enrolled(): void {
$this->assertTrue(is_enrolled(context_course::instance($course2->id), $student->id));
$this->assertCount(1, $manager1->get_user_enrolments($student->id));
$ueinstance = $DB->get_record('user_enrolments', ['enrolid' => $id1, 'userid' => $student->id]);
$this->assertEquals(0, $ueinstance->timestart);
$this->assertNotEquals(0, $ueinstance->timestart);
$this->assertEquals(0, $ueinstance->timeend);
$ueinstance = $DB->get_record('user_enrolments', ['enrolid' => $id2, 'userid' => $student->id]);
$this->assertEquals(0, $ueinstance->timestart);
$this->assertNotEquals(0, $ueinstance->timestart);
$this->assertGreaterThan(time(), $ueinstance->timeend);
sleep(1);
$trace = new \null_progress_trace();
Expand Down

0 comments on commit 7d7c6a0

Please sign in to comment.