Skip to content

Commit

Permalink
version update
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Sep 14, 2024
1 parent 7d7c6a0 commit 8866373
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ Stable

[![Build Status](https://github.com/ewallah/moodle-enrol_coursecompleted/workflows/Tests/badge.svg)](https://github.com/ewallah/moodle-enrol_coursecompleted/actions)
[![Coverage Status](https://coveralls.io/repos/github/ewallah/moodle-enrol_coursecompleted/badge.svg?branch=main)](https://coveralls.io/github/ewallah/moodle-enrol_coursecompleted?branch=main)
![Mutation score](https://badgen.net/badge/Mutation%20Score%20Indicator/85)
![Mutation score](https://badgen.net/badge/Mutation%20Score%20Indicator/87)

## Copyright

Expand Down
5 changes: 2 additions & 3 deletions classes/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,7 @@ public function edit_instance_form($instance, \MoodleQuickForm $mform, $context)
$mform->addElement('date_time_selector', 'enrolstartdate', get_string('enrolstartdate', 'enrol_coursecompleted'), $arr);
$mform->addHelpButton('enrolstartdate', 'enrolstartdate', 'enrol_coursecompleted');

$duration = intval(get_config('moodlecourse', 'courseduration')) ?? YEARSECS;
$arr['defaulttime'] = $start + $duration;
$arr['defaulttime'] = $start + get_config('moodlecourse', 'courseduration');
$mform->addElement('date_time_selector', 'enrolenddate', get_string('enrolenddate', 'enrol_coursecompleted'), $arr);
$mform->addHelpButton('enrolenddate', 'enrolenddate', 'enrol_coursecompleted');
}
Expand Down Expand Up @@ -464,7 +463,7 @@ public function edit_instance_validation($data, $files, $instance, $context): ar
$errors = [];
if (!empty($data['enrolenddate'])) {
// Minimum duration of a course is one hour.
if ($data['enrolenddate'] < $data['enrolstartdate'] + 3600) {
if ($data['enrolenddate'] <= $data['enrolstartdate'] + HOURSECS) {
$errors['enrolenddate'] = get_string('enrolenddaterror', 'enrol_fee');
}
}
Expand Down
2 changes: 2 additions & 0 deletions tests/enrol_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,9 @@ public function test_form(): void {
$html = ob_get_clean();
$cleaned = preg_replace('/\s+/', '', $html);
$this->assertStringContainsString('<optionvalue="1">No</option></select>', $cleaned);
$this->assertStringContainsString('optionvalue="86400"selected', $cleaned);
$this->assertStringContainsString('<optionvalue="0">No</option>', $cleaned);
$this->assertStringContainsString('d="id_enrolstartdate_enabled"value="1">Enable</label>', $cleaned);
$this->assertStringContainsString('cols="60"rows="8"', $cleaned);
$this->assertStringContainsString('name="customint3"class="form-check-input"value="1"id="id_customint3"', $cleaned);
$this->assertStringContainsString(
Expand Down
10 changes: 9 additions & 1 deletion tests/hook_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,16 @@ public function test_delete(): void {
'customint1' => $this->course2->id,
]
);
$this->plugin->add_instance(
$this->course1,
[
'status' => ENROL_INSTANCE_ENABLED,
'roleid' => 5,
'customint1' => $this->course1->id,
]
);
$this->event->trigger();
$this->assertEquals(1, $DB->count_records('enrol', ['enrol' => 'coursecompleted']));
$this->assertEquals(2, $DB->count_records('enrol', ['enrol' => 'coursecompleted']));
$this->assertEquals(4, $DB->count_records('course', []));
delete_course($this->course1, false);
$this->assertEquals(3, $DB->count_records('course', []));
Expand Down
6 changes: 6 additions & 0 deletions tests/other_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,12 @@ public function test_disabled(): void {
$plugin->update_status($instance, ENROL_INSTANCE_ENABLED);
$observer->enroluser($compevent);
$this->assertEquals(5, $DB->count_records('user_enrolments', []));
$recs = $DB->get_records_select('task_adhoc', "component = :component AND $sqllike", $params);
foreach ($recs as $rec) {
$this->assertEquals($rec->component, 'enrol_coursecompleted');
$this->assertEquals($rec->userid, $student1);
$this->assertEquals($rec->faildelay, 0);
}
$this->assertEquals(1, $DB->count_records_select('task_adhoc', "component = :component AND $sqllike", $params));
$data = new stdClass();
$data->status = ENROL_INSTANCE_DISABLED;
Expand Down
4 changes: 2 additions & 2 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@
$plugin->requires = 2024042200;
$plugin->maturity = MATURITY_STABLE;
$plugin->supported = [404, 404];
$plugin->release = 'v4.4.3';
$plugin->version = 2024070200;
$plugin->release = 'v4.4.4';
$plugin->version = 2024091400;

0 comments on commit 8866373

Please sign in to comment.