From 8866373f7f417a095d29596dbfec55a69bfa059e Mon Sep 17 00:00:00 2001 From: Renaat Debleu Date: Sat, 14 Sep 2024 19:50:54 +0000 Subject: [PATCH] version update --- README.md | 2 +- classes/plugin.php | 5 ++--- tests/enrol_test.php | 2 ++ tests/hook_test.php | 10 +++++++++- tests/other_test.php | 6 ++++++ version.php | 4 ++-- 6 files changed, 22 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 0721153..1a435b1 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/classes/plugin.php b/classes/plugin.php index ea07d3b..dbd399d 100644 --- a/classes/plugin.php +++ b/classes/plugin.php @@ -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'); } @@ -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'); } } diff --git a/tests/enrol_test.php b/tests/enrol_test.php index ba56cca..4777c2f 100644 --- a/tests/enrol_test.php +++ b/tests/enrol_test.php @@ -432,7 +432,9 @@ public function test_form(): void { $html = ob_get_clean(); $cleaned = preg_replace('/\s+/', '', $html); $this->assertStringContainsString('No', $cleaned); + $this->assertStringContainsString('optionvalue="86400"selected', $cleaned); $this->assertStringContainsString('No', $cleaned); + $this->assertStringContainsString('d="id_enrolstartdate_enabled"value="1">Enable', $cleaned); $this->assertStringContainsString('cols="60"rows="8"', $cleaned); $this->assertStringContainsString('name="customint3"class="form-check-input"value="1"id="id_customint3"', $cleaned); $this->assertStringContainsString( diff --git a/tests/hook_test.php b/tests/hook_test.php index dd5e16b..be190cc 100644 --- a/tests/hook_test.php +++ b/tests/hook_test.php @@ -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', [])); diff --git a/tests/other_test.php b/tests/other_test.php index c27bf24..0b2f034 100644 --- a/tests/other_test.php +++ b/tests/other_test.php @@ -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; diff --git a/version.php b/version.php index f7ec1fe..0466f40 100644 --- a/version.php +++ b/version.php @@ -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;