Skip to content

Commit 1622eb7

Browse files
committed
add new cover annotations
1 parent fec5eb3 commit 1622eb7

File tree

10 files changed

+166
-163
lines changed

10 files changed

+166
-163
lines changed

CHANGES.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
CHANGELOG
22
=========
33

4-
v5.0-r1 (2025-07-02)
4+
v5.0-r1 (2025-07-02)
55
------------------
6-
- [FIX] Issue #322
7-
- Moves classes from `locallib.php` to own class files.
6+
- [FIX] Issue [#322}(https://github.com/learnweb/moodle-mod_ratingallocate/issues/322)

classes/ratingallocate.php

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ private function process_action_start_distribution() {
211211
raise_memory_limit(MEMORY_EXTRA);
212212
core_php_time_limit::raise();
213213
// Distribute choices.
214-
$timeneeded = $this->distrubute_choices();
214+
$timeneeded = $this->distribute_choices();
215215

216216
// Logging.
217217
$event = distribution_triggered::create_simple(
@@ -1352,7 +1352,7 @@ public function get_ratings_for_rateable_choices() {
13521352
* distribution of choices for each user
13531353
* take care about max_execution_time and memory_limit
13541354
*/
1355-
public function distrubute_choices() {
1355+
public function distribute_choices() {
13561356
require_capability('mod/ratingallocate:start_distribution', $this->context);
13571357

13581358
// Set algorithm status to running.
@@ -1455,11 +1455,8 @@ public function synchronize_allocation_and_grouping() {
14551455
$groupids = $this->db->get_record(this_db\ratingallocate_ch_gengroups::TABLE,
14561456
['choiceid' => $choiceid],
14571457
'groupid');
1458-
if ($groupid = $groupids->groupid) {
1459-
$group = groups_get_group($groupid);
1460-
if ($group) {
1461-
groups_add_member($group, $userid);
1462-
}
1458+
if (($groupid = $groupids->groupid) && ($group = groups_get_group($groupid))) {
1459+
groups_add_member($group, $userid);
14631460
}
14641461
}
14651462
// Invalidate the grouping cache for the course.

classes/task/cron_task.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public function execute() {
8080
// Clear eventually scheduled distribution of unallocated users.
8181
$ratingallocate->clear_distribute_unallocated_tasks();
8282
// Run allocation.
83-
$ratingallocate->distrubute_choices();
83+
$ratingallocate->distribute_choices();
8484
}
8585
}
8686
return true;

tests/backup_restore_test.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
* @group mod_ratingallocate
3737
* @copyright usener
3838
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
39-
* @covers \mod_ratingallocate\backup_ratingallocate_activity_structure_step
39+
* @covers \mod_ratingallocate\backup_ratingallocate_activity_structure_step (This is deprecated from phpunit 12 onwards)
4040
*/
4141
#[CoversClass(backup_ratingallocate_activity_structure_step::class)]
4242
final class backup_restore_test extends \advanced_testcase {

tests/cron_test.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
use mod_ratingallocate\db as this_db;
2525
use mod_ratingallocate\task\cron_task;
2626
use PHPUnit\Framework\Attributes\CoversClass;
27+
use PHPUnit\Framework\Attributes\CoversFunction;
2728

2829
/**
2930
* mod_ratingallocate cron tests
@@ -39,6 +40,7 @@
3940
* @covers \mod_ratingallocate\task\cron_task
4041
*/
4142
#[CoversClass(cron_task::class)]
43+
#[CoversFunction('execute')]
4244
final class cron_test extends \advanced_testcase {
4345

4446
/** @var $teacher */
@@ -131,7 +133,7 @@ private function run_cron() {
131133
/**
132134
* Assert, that the algorithm status is not_started and the algorithm has created no allocation.
133135
*/
134-
private function assert_not_started() {
136+
private function assert_not_started(): void {
135137
global $DB;
136138
$record = $DB->get_record(this_db\ratingallocate::TABLE, []);
137139
$ratingallocate = \mod_ratingallocate_generator::get_ratingallocate_for_user($this, $record, $this->teacher);
@@ -143,7 +145,7 @@ private function assert_not_started() {
143145
/**
144146
* Assert, that the algorithm status is running and the algorithm has created no allocation.
145147
*/
146-
private function assert_running() {
148+
private function assert_running(): void {
147149
global $DB;
148150
$record = $DB->get_record(this_db\ratingallocate::TABLE, []);
149151
$ratingallocate = \mod_ratingallocate_generator::get_ratingallocate_for_user($this, $record, $this->teacher);
@@ -155,7 +157,7 @@ private function assert_running() {
155157
/**
156158
* Assert, that the algorithm status is failure and the algorithm has created no allocation.
157159
*/
158-
private function assert_failure() {
160+
private function assert_failure(): void {
159161
global $DB;
160162
$record = $DB->get_record(this_db\ratingallocate::TABLE, []);
161163
$ratingallocate = \mod_ratingallocate_generator::get_ratingallocate_for_user($this, $record, $this->teacher);
@@ -167,7 +169,7 @@ private function assert_failure() {
167169
/**
168170
* Assert, that the algorithm status is finished and the algorithm has created 4 allocations.
169171
*/
170-
private function assert_finish() {
172+
private function assert_finish(): void {
171173
global $DB;
172174
$record = $DB->get_record(this_db\ratingallocate::TABLE, []);
173175
$ratingallocate = \mod_ratingallocate_generator::get_ratingallocate_for_user($this, $record, $this->teacher);
@@ -179,7 +181,7 @@ private function assert_finish() {
179181
/**
180182
* Assert, that the algorithm status is still finished and the algorithm has created no allocation.
181183
*/
182-
private function assert_already_finish() {
184+
private function assert_already_finish(): void {
183185
global $DB;
184186
$record = $DB->get_record(this_db\ratingallocate::TABLE, []);
185187
$ratingallocate = \mod_ratingallocate_generator::get_ratingallocate_for_user($this, $record, $this->teacher);
@@ -195,7 +197,7 @@ private function assert_already_finish() {
195197
* @param int $algorithmstarttime the start time of the algorithm.
196198
*/
197199
private function create_ratingallocate($ratingperiodended,
198-
$algorithmstatus = algorithm_status::NOTSTARTED, $algorithmstarttime = null) {
200+
$algorithmstatus = algorithm_status::NOTSTARTED, $algorithmstarttime = null): void {
199201
global $DB;
200202

201203
$this->resetAfterTest();

tests/generator/lib.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,7 @@ public function __construct(advanced_testcase $tc, $moduledata = null, $choiceda
423423
// Allocate choices.
424424
$ratingallocate = mod_ratingallocate_generator::get_ratingallocate_for_user($tc,
425425
$this->moddb, $this->teacher);
426-
$timeneeded = $ratingallocate->distrubute_choices();
426+
$timeneeded = $ratingallocate->distribute_choices();
427427
$tc->assertGreaterThan(0, $timeneeded);
428428
$tc->assertLessThan(2.0, $timeneeded, 'Allocation is very slow');
429429
$this->allocations = $ratingallocate->get_allocations();

0 commit comments

Comments
 (0)