diff --git a/public/mod/assign/tests/courseformat/overview_test.php b/public/mod/assign/tests/courseformat/overview_test.php
index 9f6aac92698..41a1ed313e1 100644
--- a/public/mod/assign/tests/courseformat/overview_test.php
+++ b/public/mod/assign/tests/courseformat/overview_test.php
@@ -161,34 +161,32 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array The data provider array.
+ * @return \Generator The data provider array.
*/
- public static function provider_get_actions_overview(): array {
- return [
- 'No groups - No team submission' => [
- 'groupmode' => NOGROUPS,
- 'teamsubmission' => false,
- ],
- 'No groups - Team submission' => [
- 'groupmode' => NOGROUPS,
- 'teamsubmission' => true,
- ],
- 'Visible groups - No team submission' => [
- 'groupmode' => VISIBLEGROUPS,
- 'teamsubmission' => false,
- ],
- 'Visible groups - Team submission' => [
- 'groupmode' => VISIBLEGROUPS,
- 'teamsubmission' => true,
- ],
- 'Separate groups - No team submission' => [
- 'groupmode' => SEPARATEGROUPS,
- 'teamsubmission' => false,
- ],
- 'Separate groups - Team submission' => [
- 'groupmode' => SEPARATEGROUPS,
- 'teamsubmission' => true,
- ],
+ public static function provider_get_actions_overview(): \Generator {
+ yield 'No groups - No team submission' => [
+ 'groupmode' => NOGROUPS,
+ 'teamsubmission' => false,
+ ];
+ yield 'No groups - Team submission' => [
+ 'groupmode' => NOGROUPS,
+ 'teamsubmission' => true,
+ ];
+ yield 'Visible groups - No team submission' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'teamsubmission' => false,
+ ];
+ yield 'Visible groups - Team submission' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'teamsubmission' => true,
+ ];
+ yield 'Separate groups - No team submission' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'teamsubmission' => false,
+ ];
+ yield 'Separate groups - Team submission' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'teamsubmission' => true,
];
}
@@ -231,19 +229,17 @@ final class overview_test extends \advanced_testcase {
/**
* Provider for get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_due_date_overview_provider(): array {
- return [
- 'no_due' => [
- 'timeincrement' => null,
- ],
- 'past_due' => [
- 'timeincrement' => -1 * (4 * DAYSECS),
- ],
- 'future_due' => [
- 'timeincrement' => (4 * DAYSECS),
- ],
+ public static function get_due_date_overview_provider(): \Generator {
+ yield 'no_due' => [
+ 'timeincrement' => null,
+ ];
+ yield 'past_due' => [
+ 'timeincrement' => -1 * (4 * DAYSECS),
+ ];
+ yield 'future_due' => [
+ 'timeincrement' => (4 * DAYSECS),
];
}
diff --git a/public/mod/bigbluebuttonbn/tests/courseformat/overview_test.php b/public/mod/bigbluebuttonbn/tests/courseformat/overview_test.php
index ce0922e371a..f7d2c822728 100644
--- a/public/mod/bigbluebuttonbn/tests/courseformat/overview_test.php
+++ b/public/mod/bigbluebuttonbn/tests/courseformat/overview_test.php
@@ -143,22 +143,20 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_date_data(): array {
- return [
- 'tomorrow' => [
- 'timeincrement' => DAYSECS,
- ],
- 'yesterday' => [
- 'timeincrement' => -1 * DAYSECS,
- ],
- 'today' => [
- 'timeincrement' => 0,
- ],
- 'No date' => [
- 'timeincrement' => null,
- ],
+ public static function get_extra_date_data(): \Generator {
+ yield 'tomorrow' => [
+ 'timeincrement' => DAYSECS,
+ ];
+ yield 'yesterday' => [
+ 'timeincrement' => -1 * DAYSECS,
+ ];
+ yield 'today' => [
+ 'timeincrement' => 0,
+ ];
+ yield 'No date' => [
+ 'timeincrement' => null,
];
}
@@ -192,22 +190,20 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_room_type_overview_data(): array {
- return [
- 'All' => [
- 'roomtype' => instance::TYPE_ALL,
- 'expectedtype' => get_string('instance_type_default', 'bigbluebuttonbn'),
- ],
- 'Room Only' => [
- 'roomtype' => instance::TYPE_ROOM_ONLY,
- 'expectedtype' => get_string('instance_type_room_only', 'bigbluebuttonbn'),
- ],
- 'Recording Only' => [
- 'roomtype' => instance::TYPE_RECORDING_ONLY,
- 'expectedtype' => get_string('instance_type_recording_only', 'bigbluebuttonbn'),
- ],
+ public static function get_extra_room_type_overview_data(): \Generator {
+ yield 'All' => [
+ 'roomtype' => instance::TYPE_ALL,
+ 'expectedtype' => get_string('instance_type_default', 'bigbluebuttonbn'),
+ ];
+ yield 'Room Only' => [
+ 'roomtype' => instance::TYPE_ROOM_ONLY,
+ 'expectedtype' => get_string('instance_type_room_only', 'bigbluebuttonbn'),
+ ];
+ yield 'Recording Only' => [
+ 'roomtype' => instance::TYPE_RECORDING_ONLY,
+ 'expectedtype' => get_string('instance_type_recording_only', 'bigbluebuttonbn'),
];
}
@@ -249,19 +245,16 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_studentsattempted_overview and test_get_extra_totalattempts_overview
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_recordings_overview_data(): array {
-
- return [
- 'with recordings' => [
- 'activityname' => 'withrecordings',
- 'recordingcount' => 2,
- ],
- 'without recordings' => [
- 'activityname' => 'withoutrecordings',
- 'recordingcount' => 0,
- ],
+ public static function get_extra_recordings_overview_data(): \Generator {
+ yield 'with recordings' => [
+ 'activityname' => 'withrecordings',
+ 'recordingcount' => 2,
+ ];
+ yield 'without recordings' => [
+ 'activityname' => 'withoutrecordings',
+ 'recordingcount' => 0,
];
}
@@ -320,9 +313,9 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_studentsattempted_overview and test_get_extra_totalattempts_overview
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_recordings_overview_with_groups_data(): array {
+ public static function get_extra_recordings_overview_with_groups_data(): \Generator {
// The setup is as follows:
// - T1 is in group but is editing teacher so can see recordings from group g1 and g2.
// - T2 is not in any group but is editing teacher so can see recordings from group g1 and g2.
@@ -333,39 +326,37 @@ final class overview_test extends \advanced_testcase {
// We have 3 recordings in total (all processed:
// - 2 recordings in group g1.
// - 1 recording in group g2.
- return [
- 'With separate groups' => [
- 'activityname' => 'withrecordings',
- 'groupmode' => SEPARATEGROUPS,
- 'recordingcounts' => [
- 't1' => 4, // T1 is in group g1 and can see recordings from group g2 (as has all access as editing teacher).
- 't2' => 4, // T2 is not in any group but can see recordings from group g1 and g2 as editing teacher.
- 't3' => 2, // T3 is in group g1 so can see recordings from group g1.
- 't4' => null, // T4 is not in any group so should not see any recording.
- 't5' => 1, // T5 is in group g2 and can see recordings from group g2.
- ],
+ yield 'With separate groups' => [
+ 'activityname' => 'withrecordings',
+ 'groupmode' => SEPARATEGROUPS,
+ 'recordingcounts' => [
+ 't1' => 4, // T1 is in group g1 and can see recordings from group g2 (as has all access as editing teacher).
+ 't2' => 4, // T2 is not in any group but can see recordings from group g1 and g2 as editing teacher.
+ 't3' => 2, // T3 is in group g1 so can see recordings from group g1.
+ 't4' => null, // T4 is not in any group so should not see any recording.
+ 't5' => 1, // T5 is in group g2 and can see recordings from group g2.
],
- 'With no groups' => [
- 'activityname' => 'withrecordings',
- 'groupmode' => NOGROUPS,
- 'recordingcounts' => [
- 't1' => 4,
- 't2' => 4,
- 't3' => 4,
- 't4' => 4,
- 't5' => 4,
- ],
+ ];
+ yield 'With no groups' => [
+ 'activityname' => 'withrecordings',
+ 'groupmode' => NOGROUPS,
+ 'recordingcounts' => [
+ 't1' => 4,
+ 't2' => 4,
+ 't3' => 4,
+ 't4' => 4,
+ 't5' => 4,
],
- 'With visible groups' => [
- 'activityname' => 'withrecordings',
- 'groupmode' => VISIBLEGROUPS,
- 'recordingcounts' => [
- 't1' => 4,
- 't2' => 4,
- 't3' => 4,
- 't4' => 4,
- 't5' => 4,
- ],
+ ];
+ yield 'With visible groups' => [
+ 'activityname' => 'withrecordings',
+ 'groupmode' => VISIBLEGROUPS,
+ 'recordingcounts' => [
+ 't1' => 4,
+ 't2' => 4,
+ 't3' => 4,
+ 't4' => 4,
+ 't5' => 4,
],
];
}
diff --git a/public/mod/choice/tests/courseformat/overview_test.php b/public/mod/choice/tests/courseformat/overview_test.php
index f49dfdccddc..099acdcd3d6 100644
--- a/public/mod/choice/tests/courseformat/overview_test.php
+++ b/public/mod/choice/tests/courseformat/overview_test.php
@@ -56,22 +56,20 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_status_for_user.
*
- * @return array
+ * @return \Generator
*/
- public static function data_provider_get_extra_status_for_user(): array {
- return [
- 'teacher view answered' => [
- 'user' => 't1',
- 'answered' => null, // Teacher can not see the status column.
- ],
- 'student view answered' => [
- 'user' => 's1',
- 'answered' => true,
- ],
- 'student view not answered' => [
- 'user' => 's2',
- 'answered' => false,
- ],
+ public static function data_provider_get_extra_status_for_user(): \Generator {
+ yield 'teacher view answered' => [
+ 'user' => 't1',
+ 'answered' => null, // Teacher can not see the status column.
+ ];
+ yield 'student view answered' => [
+ 'user' => 's1',
+ 'answered' => true,
+ ];
+ yield 'student view not answered' => [
+ 'user' => 's2',
+ 'answered' => false,
];
}
@@ -110,22 +108,20 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function data_provider_get_due_date_overview(): array {
- return [
- 'tomorrow' => [
- 'timeincrement' => 1 * DAYSECS,
- ],
- 'yesterday' => [
- 'timeincrement' => -1 * DAYSECS,
- ],
- 'today' => [
- 'timeincrement' => 0,
- ],
- 'No date' => [
- 'timeincrement' => null,
- ],
+ public static function data_provider_get_due_date_overview(): \Generator {
+ yield 'tomorrow' => [
+ 'timeincrement' => 1 * DAYSECS,
+ ];
+ yield 'yesterday' => [
+ 'timeincrement' => -1 * DAYSECS,
+ ];
+ yield 'today' => [
+ 'timeincrement' => 0,
+ ];
+ yield 'No date' => [
+ 'timeincrement' => null,
];
}
@@ -157,18 +153,16 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array the data provider array
+ * @return \Generator the data provider array
*/
- public static function provider_test_get_actions_overview(): array {
- return [
- 'Student' => [
- 'username' => 's1',
- 'expectedcount' => null,
- ],
- 'Teacher' => [
- 'username' => 't1',
- 'expectedcount' => 3,
- ],
+ public static function provider_test_get_actions_overview(): \Generator {
+ yield 'Student' => [
+ 'username' => 's1',
+ 'expectedcount' => null,
+ ];
+ yield 'Teacher' => [
+ 'username' => 't1',
+ 'expectedcount' => 3,
];
}
@@ -236,125 +230,123 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_students_who_responded.
*
- * @return array the data provider array
+ * @return \Generator the data provider array
*/
- public static function provider_get_extra_students_who_responded(): array {
- return [
- 'Student' => [
- 'currentuser' => 's1',
- 'expectedcount' => null,
- ],
- // No groups.
- 'No groups - Teacher - With answers - No multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => false,
- 'withanswers' => true,
- 'groupmode' => NOGROUPS,
- 'expectedcount' => 3,
- ],
- 'No groups - Teacher - Without answers - No multiple' => [
- 'currentuser' => 't2',
- 'withanswers' => false,
- 'groupmode' => NOGROUPS,
- 'expectedcount' => 0,
- ],
- 'No groups - Teacher - With answers - Multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => true,
- 'withanswers' => true,
- 'groupmode' => NOGROUPS,
- 'expectedcount' => 3,
- ],
- 'No groups - Teacher - Without answers - Multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => true,
- 'withanswers' => false,
- 'groupmode' => NOGROUPS,
- 'expectedcount' => 0,
- ],
- // Visible groups.
- 'Visible groups - Teacher - With answers - No multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => false,
- 'withanswers' => true,
- 'groupmode' => VISIBLEGROUPS,
- 'expectedcount' => 3,
- ],
- 'Visible groups - Teacher - Without answers - No multiple' => [
- 'currentuser' => 't2',
- 'withanswers' => false,
- 'groupmode' => VISIBLEGROUPS,
- 'expectedcount' => 0,
- ],
- 'Visible groups - Teacher - With answers - Multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => true,
- 'withanswers' => true,
- 'groupmode' => VISIBLEGROUPS,
- 'expectedcount' => 3,
- ],
- 'Visible groups - Teacher - Without answers - Multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => true,
- 'withanswers' => false,
- 'groupmode' => VISIBLEGROUPS,
- 'expectedcount' => 0,
- ],
- // Separate groups.
- 'Separate groups - Editing teacher - With answers - No multiple' => [
- 'currentuser' => 't1',
- 'allowmultiple' => false,
- 'withanswers' => true,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 3,
- ],
- 'Separate groups - Editing teacher - Without answers - No multiple' => [
- 'currentuser' => 't1',
- 'withanswers' => false,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 0,
- ],
- 'Separate groups - Editing teacher - With answers - Multiple' => [
- 'currentuser' => 't1',
- 'allowmultiple' => true,
- 'withanswers' => true,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 3,
- ],
- 'Separate groups - Editing teacher - Without answers - Multiple' => [
- 'currentuser' => 't1',
- 'allowmultiple' => true,
- 'withanswers' => false,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 0,
- ],
- 'Separate groups - Non-editing teacher - With answers - No multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => false,
- 'withanswers' => true,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 1,
- ],
- 'Separate groups - Non-editing teacher - Without answers - No multiple' => [
- 'currentuser' => 't2',
- 'withanswers' => false,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 0,
- ],
- 'Separate groups - Non-editing teacher - With answers - Multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => true,
- 'withanswers' => true,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 1,
- ],
- 'Separate groups - Non-editing teacher - Without answers - Multiple' => [
- 'currentuser' => 't2',
- 'allowmultiple' => true,
- 'withanswers' => false,
- 'groupmode' => SEPARATEGROUPS,
- 'expectedcount' => 0,
- ],
+ public static function provider_get_extra_students_who_responded(): \Generator {
+ yield 'Student' => [
+ 'currentuser' => 's1',
+ 'expectedcount' => null,
+ ];
+ // No groups.
+ yield 'No groups - Teacher - With answers - No multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => false,
+ 'withanswers' => true,
+ 'groupmode' => NOGROUPS,
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Teacher - Without answers - No multiple' => [
+ 'currentuser' => 't2',
+ 'withanswers' => false,
+ 'groupmode' => NOGROUPS,
+ 'expectedcount' => 0,
+ ];
+ yield 'No groups - Teacher - With answers - Multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => true,
+ 'withanswers' => true,
+ 'groupmode' => NOGROUPS,
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Teacher - Without answers - Multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => true,
+ 'withanswers' => false,
+ 'groupmode' => NOGROUPS,
+ 'expectedcount' => 0,
+ ];
+ // Visible groups.
+ yield 'Visible groups - Teacher - With answers - No multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => false,
+ 'withanswers' => true,
+ 'groupmode' => VISIBLEGROUPS,
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Teacher - Without answers - No multiple' => [
+ 'currentuser' => 't2',
+ 'withanswers' => false,
+ 'groupmode' => VISIBLEGROUPS,
+ 'expectedcount' => 0,
+ ];
+ yield 'Visible groups - Teacher - With answers - Multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => true,
+ 'withanswers' => true,
+ 'groupmode' => VISIBLEGROUPS,
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Teacher - Without answers - Multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => true,
+ 'withanswers' => false,
+ 'groupmode' => VISIBLEGROUPS,
+ 'expectedcount' => 0,
+ ];
+ // Separate groups.
+ yield 'Separate groups - Editing teacher - With answers - No multiple' => [
+ 'currentuser' => 't1',
+ 'allowmultiple' => false,
+ 'withanswers' => true,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 3,
+ ];
+ yield 'Separate groups - Editing teacher - Without answers - No multiple' => [
+ 'currentuser' => 't1',
+ 'withanswers' => false,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 0,
+ ];
+ yield 'Separate groups - Editing teacher - With answers - Multiple' => [
+ 'currentuser' => 't1',
+ 'allowmultiple' => true,
+ 'withanswers' => true,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 3,
+ ];
+ yield 'Separate groups - Editing teacher - Without answers - Multiple' => [
+ 'currentuser' => 't1',
+ 'allowmultiple' => true,
+ 'withanswers' => false,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 0,
+ ];
+ yield 'Separate groups - Non-editing teacher - With answers - No multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => false,
+ 'withanswers' => true,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 1,
+ ];
+ yield 'Separate groups - Non-editing teacher - Without answers - No multiple' => [
+ 'currentuser' => 't2',
+ 'withanswers' => false,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 0,
+ ];
+ yield 'Separate groups - Non-editing teacher - With answers - Multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => true,
+ 'withanswers' => true,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 1,
+ ];
+ yield 'Separate groups - Non-editing teacher - Without answers - Multiple' => [
+ 'currentuser' => 't2',
+ 'allowmultiple' => true,
+ 'withanswers' => false,
+ 'groupmode' => SEPARATEGROUPS,
+ 'expectedcount' => 0,
];
}
diff --git a/public/mod/data/tests/courseformat/overview_test.php b/public/mod/data/tests/courseformat/overview_test.php
index 1fa543ce847..33fe98a6e2b 100644
--- a/public/mod/data/tests/courseformat/overview_test.php
+++ b/public/mod/data/tests/courseformat/overview_test.php
@@ -92,51 +92,49 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_actions_overview(): array {
- return [
- 'Student' => [
- 'role' => 'student',
- 'needsapproval' => false,
- 'entries' => [1, 0],
- 'expected' => null,
+ public static function provider_test_get_actions_overview(): \Generator {
+ yield 'Student' => [
+ 'role' => 'student',
+ 'needsapproval' => false,
+ 'entries' => [1, 0],
+ 'expected' => null,
+ ];
+ yield 'Teacher with entries (non-require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => false,
+ 'entries' => [1, 0],
+ 'expected' => [
+ 'link' => get_string('view', 'moodle'),
+ 'value' => 0,
],
- 'Teacher with entries (non-require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => false,
- 'entries' => [1, 0],
- 'expected' => [
- 'link' => get_string('view', 'moodle'),
- 'value' => 0,
- ],
+ ];
+ yield 'Teacher without entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [],
+ 'expected' => [
+ 'link' => get_string('view', 'moodle'),
+ 'value' => 0,
],
- 'Teacher without entries (require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [],
- 'expected' => [
- 'link' => get_string('view', 'moodle'),
- 'value' => 0,
- ],
+ ];
+ yield 'Teacher with entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [1, 0],
+ 'expected' => [
+ 'link' => get_string('approve', 'data'),
+ 'value' => 1,
],
- 'Teacher with entries (require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [1, 0],
- 'expected' => [
- 'link' => get_string('approve', 'data'),
- 'value' => 1,
- ],
- ],
- 'Teacher with approved entries (require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [1, 1],
- 'expected' => [
- 'link' => get_string('view', 'moodle'),
- 'value' => 0,
- ],
+ ];
+ yield 'Teacher with approved entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [1, 1],
+ 'expected' => [
+ 'link' => get_string('view', 'moodle'),
+ 'value' => 0,
],
];
}
@@ -218,69 +216,67 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test entry related extras.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_entries_overview(): array {
- return [
- 'Student not needing approval' => [
- 'role' => 'student',
- 'needsapproval' => false,
- 'entries' => [1, 0],
- 'myentries' => [1, 0],
- 'expected' => [
- 'myentries' => 2,
- 'totalentries' => 4,
- ],
+ public static function provider_test_get_entries_overview(): \Generator {
+ yield 'Student not needing approval' => [
+ 'role' => 'student',
+ 'needsapproval' => false,
+ 'entries' => [1, 0],
+ 'myentries' => [1, 0],
+ 'expected' => [
+ 'myentries' => 2,
+ 'totalentries' => 4,
],
- 'Student needing approval' => [
- 'role' => 'student',
- 'needsapproval' => true,
- 'entries' => [1, 0],
- 'myentries' => [1, 0],
- 'expected' => [
- 'myentries' => 2,
- 'totalentries' => 2,
- ],
+ ];
+ yield 'Student needing approval' => [
+ 'role' => 'student',
+ 'needsapproval' => true,
+ 'entries' => [1, 0],
+ 'myentries' => [1, 0],
+ 'expected' => [
+ 'myentries' => 2,
+ 'totalentries' => 2,
],
- 'Teacher with entries (non-require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => false,
- 'entries' => [1, 0],
- 'myentries' => [1, 0],
- 'expected' => [
- 'myentries' => null,
- 'totalentries' => 4,
- ],
+ ];
+ yield 'Teacher with entries (non-require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => false,
+ 'entries' => [1, 0],
+ 'myentries' => [1, 0],
+ 'expected' => [
+ 'myentries' => null,
+ 'totalentries' => 4,
],
- 'Teacher without entries (require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [],
- 'myentries' => [],
- 'expected' => [
- 'myentries' => null,
- 'totalentries' => 0,
- ],
+ ];
+ yield 'Teacher without entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [],
+ 'myentries' => [],
+ 'expected' => [
+ 'myentries' => null,
+ 'totalentries' => 0,
],
- 'Teacher with entries (require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [1, 0],
- 'myentries' => [1, 0],
- 'expected' => [
- 'myentries' => null,
- 'totalentries' => 4,
- ],
+ ];
+ yield 'Teacher with entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [1, 0],
+ 'myentries' => [1, 0],
+ 'expected' => [
+ 'myentries' => null,
+ 'totalentries' => 4,
],
- 'Teacher with approved entries (require approval)' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [1, 1],
- 'myentries' => [1, 1],
- 'expected' => [
- 'myentries' => null,
- 'totalentries' => 4,
- ],
+ ];
+ yield 'Teacher with approved entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [1, 1],
+ 'myentries' => [1, 1],
+ 'expected' => [
+ 'myentries' => null,
+ 'totalentries' => 4,
],
];
}
@@ -446,82 +442,80 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test comments extras.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_comments_overview(): array {
- return [
- 'Student not needing approval with no comments' => [
- 'role' => 'student',
- 'needsapproval' => false,
- 'entries' => [
+ public static function provider_test_get_comments_overview(): \Generator {
+ yield 'Student not needing approval with no comments' => [
+ 'role' => 'student',
+ 'needsapproval' => false,
+ 'entries' => [
['approved' => 1, 'comments' => false],
['approved' => 0, 'comments' => false],
],
'expected' => 0,
+ ];
+ yield 'Student not needing approval with comments' => [
+ 'role' => 'student',
+ 'needsapproval' => false,
+ 'entries' => [
+ ['approved' => 1, 'comments' => true],
+ ['approved' => 0, 'comments' => true],
],
- 'Student not needing approval with comments' => [
- 'role' => 'student',
- 'needsapproval' => false,
- 'entries' => [
- ['approved' => 1, 'comments' => true],
- ['approved' => 0, 'comments' => true],
- ],
- 'expected' => 1,
+ 'expected' => 1,
+ ];
+ yield 'Student needing approval with no comments' => [
+ 'role' => 'student',
+ 'needsapproval' => true,
+ 'entries' => [
+ ['approved' => 1, 'comments' => false],
+ ['approved' => 0, 'comments' => false],
],
- 'Student needing approval with no comments' => [
- 'role' => 'student',
- 'needsapproval' => true,
- 'entries' => [
- ['approved' => 1, 'comments' => false],
- ['approved' => 0, 'comments' => false],
- ],
- 'expected' => 0,
+ 'expected' => 0,
+ ];
+ yield 'Student needing approval with comments' => [
+ 'role' => 'student',
+ 'needsapproval' => true,
+ 'entries' => [
+ ['approved' => 1, 'comments' => true],
+ ['approved' => 0, 'comments' => true],
],
- 'Student needing approval with comments' => [
- 'role' => 'student',
- 'needsapproval' => true,
- 'entries' => [
- ['approved' => 1, 'comments' => true],
- ['approved' => 0, 'comments' => true],
- ],
- 'expected' => 1,
+ 'expected' => 1,
+ ];
+ yield 'Teacher not needing approval with no comments' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => false,
+ 'entries' => [
+ ['approved' => 1, 'comments' => false],
+ ['approved' => 0, 'comments' => false],
],
- 'Teacher not needing approval with no comments' => [
- 'role' => 'editingteacher',
- 'needsapproval' => false,
- 'entries' => [
- ['approved' => 1, 'comments' => false],
- ['approved' => 0, 'comments' => false],
- ],
- 'expected' => 0,
+ 'expected' => 0,
+ ];
+ yield 'Teacher not needing approval with comments' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => false,
+ 'entries' => [
+ ['approved' => 1, 'comments' => true],
+ ['approved' => 0, 'comments' => true],
],
- 'Teacher not needing approval with comments' => [
- 'role' => 'editingteacher',
- 'needsapproval' => false,
- 'entries' => [
- ['approved' => 1, 'comments' => true],
- ['approved' => 0, 'comments' => true],
- ],
- 'expected' => 2,
+ 'expected' => 2,
+ ];
+ yield 'Teacher needing approval with no comments' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [
+ ['approved' => 1, 'comments' => false],
+ ['approved' => 0, 'comments' => false],
],
- 'Teacher needing approval with no comments' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [
- ['approved' => 1, 'comments' => false],
- ['approved' => 0, 'comments' => false],
- ],
- 'expected' => 0,
- ],
- 'Teacher needing approval with comments' => [
- 'role' => 'editingteacher',
- 'needsapproval' => true,
- 'entries' => [
- ['approved' => 1, 'comments' => true],
- ['approved' => 0, 'comments' => true],
- ],
- 'expected' => 2,
+ 'expected' => 0,
+ ];
+ yield 'Teacher needing approval with comments' => [
+ 'role' => 'editingteacher',
+ 'needsapproval' => true,
+ 'entries' => [
+ ['approved' => 1, 'comments' => true],
+ ['approved' => 0, 'comments' => true],
],
+ 'expected' => 2,
];
}
}
diff --git a/public/mod/feedback/tests/courseformat/overview_test.php b/public/mod/feedback/tests/courseformat/overview_test.php
index 102add8ac56..4be1121da20 100644
--- a/public/mod/feedback/tests/courseformat/overview_test.php
+++ b/public/mod/feedback/tests/courseformat/overview_test.php
@@ -73,20 +73,18 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_actions_overview(): array {
- return [
- 'Student' => [
- 'role' => 'student',
- 'expected' => null,
- ],
- 'Teacher' => [
- 'role' => 'editingteacher',
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => get_string('view'),
- ],
+ public static function provider_test_get_actions_overview(): \Generator {
+ yield 'Student' => [
+ 'role' => 'student',
+ 'expected' => null,
+ ];
+ yield 'Teacher' => [
+ 'role' => 'editingteacher',
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => get_string('view'),
],
];
}
@@ -126,26 +124,24 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_due_date_overview(): array {
- return [
- 'Teacher with due date' => [
- 'user' => 'teacher',
- 'hasduedate' => true,
- ],
- 'Student with due date' => [
- 'user' => 'student',
- 'hasduedate' => true,
- ],
- 'Teacher without due date' => [
- 'user' => 'teacher',
- 'hasduedate' => false,
- ],
- 'Student without due date' => [
- 'user' => 'student',
- 'hasduedate' => false,
- ],
+ public static function provider_test_get_due_date_overview(): \Generator {
+ yield 'Teacher with due date' => [
+ 'user' => 'teacher',
+ 'hasduedate' => true,
+ ];
+ yield 'Student with due date' => [
+ 'user' => 'student',
+ 'hasduedate' => true,
+ ];
+ yield 'Teacher without due date' => [
+ 'user' => 'teacher',
+ 'hasduedate' => false,
+ ];
+ yield 'Student without due date' => [
+ 'user' => 'student',
+ 'hasduedate' => false,
];
}
@@ -208,30 +204,28 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for get_extra_responses_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_get_extra_responses_overview(): array {
- return [
- 'Teacher with responses' => [
- 'user' => 'teacher',
- 'expectnull' => false,
- 'hasresponses' => true,
- ],
- 'Student with responses' => [
- 'user' => 'student',
- 'expectnull' => true,
- 'hasresponses' => true,
- ],
- 'Teacher without responses' => [
- 'user' => 'teacher',
- 'expectnull' => false,
- 'hasresponses' => false,
- ],
- 'Student without responses' => [
- 'user' => 'student',
- 'expectnull' => true,
- 'hasresponses' => false,
- ],
+ public static function provider_get_extra_responses_overview(): \Generator {
+ yield 'Teacher with responses' => [
+ 'user' => 'teacher',
+ 'expectnull' => false,
+ 'hasresponses' => true,
+ ];
+ yield 'Student with responses' => [
+ 'user' => 'student',
+ 'expectnull' => true,
+ 'hasresponses' => true,
+ ];
+ yield 'Teacher without responses' => [
+ 'user' => 'teacher',
+ 'expectnull' => false,
+ 'hasresponses' => false,
+ ];
+ yield 'Student without responses' => [
+ 'user' => 'student',
+ 'expectnull' => true,
+ 'hasresponses' => false,
];
}
@@ -349,100 +343,98 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for feedback_get_extra_responses_overview_with_groups.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_feedback_get_extra_responses_overview_with_groups(): array {
- return [
- 'Separate groups - Editing teacher' => [
- 'groupmode' => SEPARATEGROUPS,
- 'currentuser' => 'teacher1',
- 'expectedcount' => 3,
- ],
- 'Separate groups - Non-editing teacher (groupa)' => [
- 'groupmode' => SEPARATEGROUPS,
- 'currentuser' => 'teacher2',
- 'expectedcount' => 2,
- ],
- 'Separate groups - Non-editing teacher (groupb)' => [
- 'groupmode' => SEPARATEGROUPS,
- 'currentuser' => 'teacher3',
- 'expectedcount' => 1,
- ],
- 'Separate groups - Non-editing teacher (groupc)' => [
- 'groupmode' => SEPARATEGROUPS,
- 'currentuser' => 'teacher4',
- 'expectedcount' => 0,
- ],
- 'Separate groups - Non-editing teacher (no group)' => [
- 'groupmode' => SEPARATEGROUPS,
- 'currentuser' => 'teacher5',
- 'expectedcount' => 3, // Although the expected count should be 0, this information will never be shown to the user.
- ],
- 'Separate groups - Editing teacher (no group)' => [
- 'groupmode' => SEPARATEGROUPS,
- 'currentuser' => 'teacher6',
- 'expectedcount' => 3,
- ],
- 'Visible groups - Editing teacher' => [
- 'groupmode' => VISIBLEGROUPS,
- 'currentuser' => 'teacher1',
- 'expectedcount' => 3,
- ],
- 'Visible groups - Non-editing teacher (groupa)' => [
- 'groupmode' => VISIBLEGROUPS,
- 'currentuser' => 'teacher2',
- 'expectedcount' => 3,
- ],
- 'Visible groups - Non-editing teacher (groupb)' => [
- 'groupmode' => VISIBLEGROUPS,
- 'currentuser' => 'teacher3',
- 'expectedcount' => 3,
- ],
- 'Visible groups - Non-editing teacher (groupc)' => [
- 'groupmode' => VISIBLEGROUPS,
- 'currentuser' => 'teacher4',
- 'expectedcount' => 3,
- ],
- 'Visible groups - Non-editing teacher (no group)' => [
- 'groupmode' => VISIBLEGROUPS,
- 'currentuser' => 'teacher5',
- 'expectedcount' => 3,
- ],
- 'Visible groups - Editing teacher (no group)' => [
- 'groupmode' => VISIBLEGROUPS,
- 'currentuser' => 'teacher6',
- 'expectedcount' => 3,
- ],
- 'No groups - Editing teacher' => [
- 'groupmode' => NOGROUPS,
- 'currentuser' => 'teacher1',
- 'expectedcount' => 3,
- ],
- 'No groups - Non-editing teacher (groupa)' => [
- 'groupmode' => NOGROUPS,
- 'currentuser' => 'teacher2',
- 'expectedcount' => 3,
- ],
- 'No groups - Non-editing teacher (groupb)' => [
- 'groupmode' => NOGROUPS,
- 'currentuser' => 'teacher3',
- 'expectedcount' => 3,
- ],
- 'No groups - Non-editing teacher (groupc)' => [
- 'groupmode' => NOGROUPS,
- 'currentuser' => 'teacher4',
- 'expectedcount' => 3,
- ],
- 'No groups - Non-editing teacher (no group)' => [
- 'groupmode' => NOGROUPS,
- 'currentuser' => 'teacher5',
- 'expectedcount' => 3,
- ],
- 'No groups - Editing teacher (no group)' => [
- 'groupmode' => NOGROUPS,
- 'currentuser' => 'teacher6',
- 'expectedcount' => 3,
- ],
+ public static function provider_feedback_get_extra_responses_overview_with_groups(): \Generator {
+ yield 'Separate groups - Editing teacher' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'currentuser' => 'teacher1',
+ 'expectedcount' => 3,
+ ];
+ yield 'Separate groups - Non-editing teacher (groupa)' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'currentuser' => 'teacher2',
+ 'expectedcount' => 2,
+ ];
+ yield 'Separate groups - Non-editing teacher (groupb)' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'currentuser' => 'teacher3',
+ 'expectedcount' => 1,
+ ];
+ yield 'Separate groups - Non-editing teacher (groupc)' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'currentuser' => 'teacher4',
+ 'expectedcount' => 0,
+ ];
+ yield 'Separate groups - Non-editing teacher (no group)' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'currentuser' => 'teacher5',
+ 'expectedcount' => 3, // Although the expected count should be 0, this information will never be shown to the user.
+ ];
+ yield 'Separate groups - Editing teacher (no group)' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'currentuser' => 'teacher6',
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Editing teacher' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'currentuser' => 'teacher1',
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Non-editing teacher (groupa)' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'currentuser' => 'teacher2',
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Non-editing teacher (groupb)' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'currentuser' => 'teacher3',
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Non-editing teacher (groupc)' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'currentuser' => 'teacher4',
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Non-editing teacher (no group)' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'currentuser' => 'teacher5',
+ 'expectedcount' => 3,
+ ];
+ yield 'Visible groups - Editing teacher (no group)' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'currentuser' => 'teacher6',
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Editing teacher' => [
+ 'groupmode' => NOGROUPS,
+ 'currentuser' => 'teacher1',
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Non-editing teacher (groupa)' => [
+ 'groupmode' => NOGROUPS,
+ 'currentuser' => 'teacher2',
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Non-editing teacher (groupb)' => [
+ 'groupmode' => NOGROUPS,
+ 'currentuser' => 'teacher3',
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Non-editing teacher (groupc)' => [
+ 'groupmode' => NOGROUPS,
+ 'currentuser' => 'teacher4',
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Non-editing teacher (no group)' => [
+ 'groupmode' => NOGROUPS,
+ 'currentuser' => 'teacher5',
+ 'expectedcount' => 3,
+ ];
+ yield 'No groups - Editing teacher (no group)' => [
+ 'groupmode' => NOGROUPS,
+ 'currentuser' => 'teacher6',
+ 'expectedcount' => 3,
];
}
@@ -502,30 +494,28 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_submitted_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_extra_submitted_overview(): array {
- return [
- 'Teacher with responses' => [
- 'user' => 'teacher',
- 'expectnull' => true,
- 'hasresponses' => true,
- ],
- 'Student with responses' => [
- 'user' => 'student',
- 'expectnull' => false,
- 'hasresponses' => true,
- ],
- 'Teacher without responses' => [
- 'user' => 'teacher',
- 'expectnull' => true,
- 'hasresponses' => false,
- ],
- 'Student without responses' => [
- 'user' => 'student',
- 'expectnull' => false,
- 'hasresponses' => false,
- ],
+ public static function provider_test_get_extra_submitted_overview(): \Generator {
+ yield 'Teacher with responses' => [
+ 'user' => 'teacher',
+ 'expectnull' => true,
+ 'hasresponses' => true,
+ ];
+ yield 'Student with responses' => [
+ 'user' => 'student',
+ 'expectnull' => false,
+ 'hasresponses' => true,
+ ];
+ yield 'Teacher without responses' => [
+ 'user' => 'teacher',
+ 'expectnull' => true,
+ 'hasresponses' => false,
+ ];
+ yield 'Student without responses' => [
+ 'user' => 'student',
+ 'expectnull' => false,
+ 'hasresponses' => false,
];
}
}
diff --git a/public/mod/forum/tests/courseformat/overview_test.php b/public/mod/forum/tests/courseformat/overview_test.php
index 3cdee75d660..6935cb9f7ff 100644
--- a/public/mod/forum/tests/courseformat/overview_test.php
+++ b/public/mod/forum/tests/courseformat/overview_test.php
@@ -147,19 +147,17 @@ final class overview_test extends \advanced_testcase {
/**
* Provider for get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_due_date_overview_provider(): array {
- return [
- 'no_due' => [
- 'timeincrement' => null,
- ],
- 'past_due' => [
- 'timeincrement' => -1 * (4 * DAYSECS),
- ],
- 'future_due' => [
- 'timeincrement' => (4 * DAYSECS),
- ],
+ public static function get_due_date_overview_provider(): \Generator {
+ yield 'no_due' => [
+ 'timeincrement' => null,
+ ];
+ yield 'past_due' => [
+ 'timeincrement' => -1 * (4 * DAYSECS),
+ ];
+ yield 'future_due' => [
+ 'timeincrement' => (4 * DAYSECS),
];
}
@@ -214,34 +212,32 @@ final class overview_test extends \advanced_testcase {
/**
* Provider for get_extra_forumtype_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_forumtype_overview_provider(): array {
- return [
- 'General' => [
- 'forumtype' => 'general',
- 'expected' => get_string('generalforum', 'forum'),
- ],
- 'Single discussion' => [
- 'forumtype' => 'single',
- 'expected' => get_string('singleforum', 'forum'),
- ],
- 'Each user' => [
- 'forumtype' => 'eachuser',
- 'expected' => get_string('eachuserforum', 'forum'),
- ],
- 'Question&Answer' => [
- 'forumtype' => 'qanda',
- 'expected' => get_string('qandaforum', 'forum'),
- ],
- 'Blog' => [
- 'forumtype' => 'blog',
- 'expected' => get_string('blogforum', 'forum'),
- ],
- 'News' => [
- 'forumtype' => 'news',
- 'expected' => get_string('namenews', 'forum'),
- ],
+ public static function get_extra_forumtype_overview_provider(): \Generator {
+ yield 'General' => [
+ 'forumtype' => 'general',
+ 'expected' => get_string('generalforum', 'forum'),
+ ];
+ yield 'Single discussion' => [
+ 'forumtype' => 'single',
+ 'expected' => get_string('singleforum', 'forum'),
+ ];
+ yield 'Each user' => [
+ 'forumtype' => 'eachuser',
+ 'expected' => get_string('eachuserforum', 'forum'),
+ ];
+ yield 'Question&Answer' => [
+ 'forumtype' => 'qanda',
+ 'expected' => get_string('qandaforum', 'forum'),
+ ];
+ yield 'Blog' => [
+ 'forumtype' => 'blog',
+ 'expected' => get_string('blogforum', 'forum'),
+ ];
+ yield 'News' => [
+ 'forumtype' => 'news',
+ 'expected' => get_string('namenews', 'forum'),
];
}
@@ -306,112 +302,110 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_track_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_track_overview_provider(): array {
- return [
- // Student role tests.
- 'Student. Tracking optional' => [
- 'forumtype' => FORUM_TRACKING_OPTIONAL,
- 'tracked' => 1,
- 'disabled' => false,
- ],
- 'Student. Tracking forced off' => [
- 'forumtype' => FORUM_TRACKING_OFF,
- 'tracked' => 0,
- 'disabled' => true,
- ],
- 'Student. Tracking forced on' => [
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 1,
- 'disabled' => true,
- ],
- 'Student. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 1,
- 'disabled' => false,
- 'allowforced' => false,
- ],
- 'Student. $USER->trackforums disabled. Tracking optional. ' => [
- 'forumtype' => FORUM_TRACKING_OPTIONAL,
- 'tracked' => 0,
- 'disabled' => true,
- 'trackforums' => 0,
- ],
- 'Student. $USER->trackforums disabled. Tracking forced off' => [
- 'forumtype' => FORUM_TRACKING_OFF,
- 'tracked' => 0,
- 'disabled' => true,
- 'trackforums' => 0,
- ],
- 'Student. $USER->trackforums disabled. Tracking forced on' => [
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 1,
- 'disabled' => true,
- 'trackforums' => 0,
- ],
- 'Student. $USER->trackforums disabled. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 0,
- 'disabled' => true,
- 'allowforced' => false,
- 'trackforums' => 0,
- ],
- // Teacher role tests.
- 'Teacher. Tracking optional' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_OPTIONAL,
- 'tracked' => 1,
- 'disabled' => false,
- ],
- 'Teacher. Tracking forced off' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_OFF,
- 'tracked' => 0,
- 'disabled' => true,
- ],
- 'Teacher. Tracking forced on' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 1,
- 'disabled' => true,
- ],
- 'Teacher. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 1,
- 'disabled' => false,
- 'allowforced' => false,
- ],
- 'Teacher. $USER->trackforums disabled. Tracking optional' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_OPTIONAL,
- 'tracked' => 0,
- 'disabled' => true,
- 'trackforums' => 0,
- ],
- 'Teacher. $USER->trackforums disabled. Tracking forced off' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_OFF,
- 'tracked' => 0,
- 'disabled' => true,
- 'trackforums' => 0,
- ],
- 'Teacher. $USER->trackforums disabled. Tracking forced on' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 1,
- 'disabled' => true,
- 'trackforums' => 0,
- ],
- 'Teacher. $USER->trackforums disabled. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_TRACKING_FORCED,
- 'tracked' => 0,
- 'disabled' => true,
- 'allowforced' => false,
- 'trackforums' => 0,
- ],
+ public static function get_extra_track_overview_provider(): \Generator {
+ // Student role tests.
+ yield 'Student. Tracking optional' => [
+ 'forumtype' => FORUM_TRACKING_OPTIONAL,
+ 'tracked' => 1,
+ 'disabled' => false,
+ ];
+ yield 'Student. Tracking forced off' => [
+ 'forumtype' => FORUM_TRACKING_OFF,
+ 'tracked' => 0,
+ 'disabled' => true,
+ ];
+ yield 'Student. Tracking forced on' => [
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 1,
+ 'disabled' => true,
+ ];
+ yield 'Student. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 1,
+ 'disabled' => false,
+ 'allowforced' => false,
+ ];
+ yield 'Student. $USER->trackforums disabled. Tracking optional. ' => [
+ 'forumtype' => FORUM_TRACKING_OPTIONAL,
+ 'tracked' => 0,
+ 'disabled' => true,
+ 'trackforums' => 0,
+ ];
+ yield 'Student. $USER->trackforums disabled. Tracking forced off' => [
+ 'forumtype' => FORUM_TRACKING_OFF,
+ 'tracked' => 0,
+ 'disabled' => true,
+ 'trackforums' => 0,
+ ];
+ yield 'Student. $USER->trackforums disabled. Tracking forced on' => [
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 1,
+ 'disabled' => true,
+ 'trackforums' => 0,
+ ];
+ yield 'Student. $USER->trackforums disabled. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 0,
+ 'disabled' => true,
+ 'allowforced' => false,
+ 'trackforums' => 0,
+ ];
+ // Teacher role tests.
+ yield 'Teacher. Tracking optional' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_OPTIONAL,
+ 'tracked' => 1,
+ 'disabled' => false,
+ ];
+ yield 'Teacher. Tracking forced off' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_OFF,
+ 'tracked' => 0,
+ 'disabled' => true,
+ ];
+ yield 'Teacher. Tracking forced on' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 1,
+ 'disabled' => true,
+ ];
+ yield 'Teacher. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 1,
+ 'disabled' => false,
+ 'allowforced' => false,
+ ];
+ yield 'Teacher. $USER->trackforums disabled. Tracking optional' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_OPTIONAL,
+ 'tracked' => 0,
+ 'disabled' => true,
+ 'trackforums' => 0,
+ ];
+ yield 'Teacher. $USER->trackforums disabled. Tracking forced off' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_OFF,
+ 'tracked' => 0,
+ 'disabled' => true,
+ 'trackforums' => 0,
+ ];
+ yield 'Teacher. $USER->trackforums disabled. Tracking forced on' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 1,
+ 'disabled' => true,
+ 'trackforums' => 0,
+ ];
+ yield 'Teacher. $USER->trackforums disabled. Tracking forced on, with $CFG->forum_allowforcedreadtracking disabled' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_TRACKING_FORCED,
+ 'tracked' => 0,
+ 'disabled' => true,
+ 'allowforced' => false,
+ 'trackforums' => 0,
];
}
@@ -468,56 +462,54 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for get_extra_subscribed_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_subscribed_overview_provider(): array {
- return [
- // Student role tests.
- 'Student. Tracking forced on' => [
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'subscribed' => 1,
- 'disabled' => true,
- ],
- 'Student. Tracking forced off' => [
- 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
- 'subscribed' => 0,
- 'disabled' => true,
- ],
- 'Student. Tracking choose' => [
- 'forumtype' => FORUM_CHOOSESUBSCRIBE,
- 'subscribed' => 0,
- 'disabled' => false,
- ],
- 'Student. Tracking initial on' => [
- 'forumtype' => FORUM_INITIALSUBSCRIBE,
- 'subscribed' => 1,
- 'disabled' => false,
- ],
- // Teacher role tests.
- 'Teacher. Tracking forced on' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'subscribed' => 1,
- 'disabled' => true,
- ],
- 'Teacher. Tracking forced off' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
- 'subscribed' => 0,
- 'disabled' => false,
- ],
- 'Teacher. Tracking choose' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_CHOOSESUBSCRIBE,
- 'subscribed' => 0,
- 'disabled' => false,
- ],
- 'Teacher. Tracking initial on' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_INITIALSUBSCRIBE,
- 'subscribed' => 1,
- 'disabled' => false,
- ],
+ public static function get_extra_subscribed_overview_provider(): \Generator {
+ // Student role tests.
+ yield 'Student. Tracking forced on' => [
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'subscribed' => 1,
+ 'disabled' => true,
+ ];
+ yield 'Student. Tracking forced off' => [
+ 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
+ 'subscribed' => 0,
+ 'disabled' => true,
+ ];
+ yield 'Student. Tracking choose' => [
+ 'forumtype' => FORUM_CHOOSESUBSCRIBE,
+ 'subscribed' => 0,
+ 'disabled' => false,
+ ];
+ yield 'Student. Tracking initial on' => [
+ 'forumtype' => FORUM_INITIALSUBSCRIBE,
+ 'subscribed' => 1,
+ 'disabled' => false,
+ ];
+ yield // Teacher role tests.
+ 'Teacher. Tracking forced on' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'subscribed' => 1,
+ 'disabled' => true,
+ ];
+ yield 'Teacher. Tracking forced off' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
+ 'subscribed' => 0,
+ 'disabled' => false,
+ ];
+ yield 'Teacher. Tracking choose' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_CHOOSESUBSCRIBE,
+ 'subscribed' => 0,
+ 'disabled' => false,
+ ];
+ yield 'Teacher. Tracking initial on' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_INITIALSUBSCRIBE,
+ 'subscribed' => 1,
+ 'disabled' => false,
];
}
@@ -591,70 +583,68 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for get_extra_emaildigest_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_emaildigest_overview_provider(): array {
- return [
- // Student role tests.
- 'Student. Tracking forced on. No digest' => [
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- ],
- 'Student. Tracking forced off' => [
- 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
- 'emaildigestvalue' => '-',
- ],
- 'Student. Tracking choose' => [
- 'forumtype' => FORUM_CHOOSESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- ],
- 'Student. Tracking initial on' => [
- 'forumtype' => FORUM_INITIALSUBSCRIBE,
- 'emaildigestvalue' => 'default',
- ],
- 'Student. Complete' => [
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- 'usermaildigest' => 1,
- ],
- 'Student. Subjects' => [
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- 'usermaildigest' => 2,
- ],
- // Teacher role tests.
- 'Teacher. Tracking forced on. No digest' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- ],
- 'Teacher. Tracking forced off' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
- 'emaildigestvalue' => 'default',
- ],
- 'Teacher. Tracking choose' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_CHOOSESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- ],
- 'Teacher. Tracking initial on' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_INITIALSUBSCRIBE,
- 'emaildigestvalue' => 'default',
- ],
- 'Teacher. Complete' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- 'usermaildigest' => 1,
- ],
- 'Teacher. Subjects' => [
- 'role' => 'teacher',
- 'forumtype' => FORUM_FORCESUBSCRIBE,
- 'emaildigestvalue' => 'default',
- 'usermaildigest' => 2,
- ],
+ public static function get_extra_emaildigest_overview_provider(): \Generator {
+ // Student role tests.
+ yield 'Student. Tracking forced on. No digest' => [
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ ];
+ yield 'Student. Tracking forced off' => [
+ 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
+ 'emaildigestvalue' => '-',
+ ];
+ yield 'Student. Tracking choose' => [
+ 'forumtype' => FORUM_CHOOSESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ ];
+ yield 'Student. Tracking initial on' => [
+ 'forumtype' => FORUM_INITIALSUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ ];
+ yield 'Student. Complete' => [
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ 'usermaildigest' => 1,
+ ];
+ yield 'Student. Subjects' => [
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ 'usermaildigest' => 2,
+ ];
+ // Teacher role tests.
+ yield 'Teacher. Tracking forced on. No digest' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ ];
+ yield 'Teacher. Tracking forced off' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_DISALLOWSUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ ];
+ yield 'Teacher. Tracking choose' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_CHOOSESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ ];
+ yield 'Teacher. Tracking initial on' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_INITIALSUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ ];
+ yield 'Teacher. Complete' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ 'usermaildigest' => 1,
+ ];
+ yield 'Teacher. Subjects' => [
+ 'role' => 'teacher',
+ 'forumtype' => FORUM_FORCESUBSCRIBE,
+ 'emaildigestvalue' => 'default',
+ 'usermaildigest' => 2,
];
}
diff --git a/public/mod/glossary/tests/courseformat/overview_test.php b/public/mod/glossary/tests/courseformat/overview_test.php
index 8b87f9a4f93..7b2652f42e9 100644
--- a/public/mod/glossary/tests/courseformat/overview_test.php
+++ b/public/mod/glossary/tests/courseformat/overview_test.php
@@ -100,45 +100,43 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_actions_overview(): array {
- return [
- 'Student' => [
- 'role' => 'student',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => null,
+ public static function provider_test_get_actions_overview(): \Generator {
+ yield 'Student' => [
+ 'role' => 'student',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => null,
+ ];
+ yield 'Teacher with entries (non-require approval)' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => 0,
+ 'content' => get_string('view'),
],
- 'Teacher with entries (non-require approval)' => [
- 'role' => 'editingteacher',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => 0,
- 'content' => get_string('view'),
- ],
+ ];
+ yield 'Teacher without entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => true,
+ 'hasentries' => false,
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => 0,
+ 'content' => get_string('view'),
],
- 'Teacher without entries (require approval)' => [
- 'role' => 'editingteacher',
- 'requireapproval' => true,
- 'hasentries' => false,
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => 0,
- 'content' => get_string('view'),
- ],
- ],
- 'Teacher with entries (require approval)' => [
- 'role' => 'editingteacher',
- 'requireapproval' => true,
- 'hasentries' => true,
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => 2,
- 'content' => get_string('approve', 'mod_glossary'),
- ],
+ ];
+ yield 'Teacher with entries (require approval)' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => true,
+ 'hasentries' => true,
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => 2,
+ 'content' => get_string('approve', 'mod_glossary'),
],
];
}
@@ -252,46 +250,44 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_comments_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_extra_comments_overview(): array {
- return [
- 'Teacher without responses' => [
- 'role' => 'editingteacher',
- 'requireapproval' => false,
- 'hasentries' => false,
- 'expected' => '0',
- ],
- 'Teacher with responses (non-require approval)' => [
- 'role' => 'editingteacher',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => '5',
- ],
- 'Teacher with responses (require approval)' => [
- 'role' => 'editingteacher',
- 'requireapproval' => true,
- 'hasentries' => true,
- 'expected' => '5',
- ],
- 'Student without responses' => [
- 'role' => 'student',
- 'requireapproval' => false,
- 'hasentries' => false,
- 'expected' => '0',
- ],
- 'Student with responses (non-require approval)' => [
- 'role' => 'student',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => '5',
- ],
- 'Student with responses (require approval)' => [
- 'role' => 'student',
- 'requireapproval' => true,
- 'hasentries' => true,
- 'expected' => '4', // One comment is from an unapproved entry created by a different user.
- ],
+ public static function provider_test_get_extra_comments_overview(): \Generator {
+ yield 'Teacher without responses' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => false,
+ 'hasentries' => false,
+ 'expected' => '0',
+ ];
+ yield 'Teacher with responses (non-require approval)' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => '5',
+ ];
+ yield 'Teacher with responses (require approval)' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => true,
+ 'hasentries' => true,
+ 'expected' => '5',
+ ];
+ yield 'Student without responses' => [
+ 'role' => 'student',
+ 'requireapproval' => false,
+ 'hasentries' => false,
+ 'expected' => '0',
+ ];
+ yield 'Student with responses (non-require approval)' => [
+ 'role' => 'student',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => '5',
+ ];
+ yield 'Student with responses (require approval)' => [
+ 'role' => 'student',
+ 'requireapproval' => true,
+ 'hasentries' => true,
+ 'expected' => '4', // One comment is from an unapproved entry created by a different user.
];
}
@@ -334,30 +330,28 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_comments_overview_with_comments_disabled.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_extra_comments_overview_with_comments_disabled(): array {
- return [
- 'Use comments disabled, allow comments disabled' => [
- 'usecomments' => false,
- 'allowcomments' => false,
- 'expected' => '-',
- ],
- 'Use comments enabled, allow comments disabled' => [
- 'usecomments' => true,
- 'allowcomments' => false,
- 'expected' => '-',
- ],
- 'Use comments disabled, allow comments enabled' => [
- 'usecomments' => false,
- 'allowcomments' => true,
- 'expected' => '-',
- ],
- 'Use comments enabled, allow comments enabled' => [
- 'usecomments' => true,
- 'allowcomments' => true,
- 'expected' => '0',
- ],
+ public static function provider_test_get_extra_comments_overview_with_comments_disabled(): \Generator {
+ yield 'Use comments disabled, allow comments disabled' => [
+ 'usecomments' => false,
+ 'allowcomments' => false,
+ 'expected' => '-',
+ ];
+ yield 'Use comments enabled, allow comments disabled' => [
+ 'usecomments' => true,
+ 'allowcomments' => false,
+ 'expected' => '-',
+ ];
+ yield 'Use comments disabled, allow comments enabled' => [
+ 'usecomments' => false,
+ 'allowcomments' => true,
+ 'expected' => '-',
+ ];
+ yield 'Use comments enabled, allow comments enabled' => [
+ 'usecomments' => true,
+ 'allowcomments' => true,
+ 'expected' => '0',
];
}
@@ -433,45 +427,43 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_submitted_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_extra_totalentries_overview(): array {
- return [
- 'Teacher with entries (non-require approval)' => [
- 'role' => 'editingteacher',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => [
- 'name' => get_string('entries', 'mod_glossary'),
- 'value' => 4,
- ],
+ public static function provider_test_get_extra_totalentries_overview(): \Generator {
+ yield 'Teacher with entries (non-require approval)' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => [
+ 'name' => get_string('entries', 'mod_glossary'),
+ 'value' => 4,
],
- 'Student without entries' => [
- 'role' => 'student',
- 'requireapproval' => false,
- 'hasentries' => false,
- 'expected' => [
- 'name' => get_string('totalentries', 'mod_glossary'),
- 'value' => 0,
- ],
+ ];
+ yield 'Student without entries' => [
+ 'role' => 'student',
+ 'requireapproval' => false,
+ 'hasentries' => false,
+ 'expected' => [
+ 'name' => get_string('totalentries', 'mod_glossary'),
+ 'value' => 0,
],
- 'Student with entries (non-require approval)' => [
- 'role' => 'student',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => [
- 'name' => get_string('totalentries', 'mod_glossary'),
- 'value' => 4,
- ],
+ ];
+ yield 'Student with entries (non-require approval)' => [
+ 'role' => 'student',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => [
+ 'name' => get_string('totalentries', 'mod_glossary'),
+ 'value' => 4,
],
- 'Student with entries (require approval)' => [
- 'role' => 'student',
- 'requireapproval' => true,
- 'hasentries' => true,
- 'expected' => [
- 'name' => get_string('totalentries', 'mod_glossary'),
- 'value' => 3,
- ],
+ ];
+ yield 'Student with entries (require approval)' => [
+ 'role' => 'student',
+ 'requireapproval' => true,
+ 'hasentries' => true,
+ 'expected' => [
+ 'name' => get_string('totalentries', 'mod_glossary'),
+ 'value' => 3,
],
];
}
@@ -553,42 +545,40 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_submitted_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_extra_myentries_overview(): array {
- return [
- 'Teacher' => [
- 'role' => 'editingteacher',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => null,
+ public static function provider_test_get_extra_myentries_overview(): \Generator {
+ yield 'Teacher' => [
+ 'role' => 'editingteacher',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => null,
+ ];
+ yield 'Student without responses' => [
+ 'role' => 'student',
+ 'requireapproval' => false,
+ 'hasentries' => false,
+ 'expected' => [
+ 'name' => get_string('myentries', 'mod_glossary'),
+ 'value' => 0,
],
- 'Student without responses' => [
- 'role' => 'student',
- 'requireapproval' => false,
- 'hasentries' => false,
- 'expected' => [
- 'name' => get_string('myentries', 'mod_glossary'),
- 'value' => 0,
- ],
+ ];
+ yield 'Student with responses (non-require approval)' => [
+ 'role' => 'student',
+ 'requireapproval' => false,
+ 'hasentries' => true,
+ 'expected' => [
+ 'name' => get_string('myentries', 'mod_glossary'),
+ 'value' => 1,
],
- 'Student with responses (non-require approval)' => [
- 'role' => 'student',
- 'requireapproval' => false,
- 'hasentries' => true,
- 'expected' => [
- 'name' => get_string('myentries', 'mod_glossary'),
- 'value' => 1,
- ],
- ],
- 'Student with responses (require approval)' => [
- 'role' => 'student',
- 'requireapproval' => true,
- 'hasentries' => true,
- 'expected' => [
- 'name' => get_string('myentries', 'mod_glossary'),
- 'value' => 1,
- ],
+ ];
+ yield 'Student with responses (require approval)' => [
+ 'role' => 'student',
+ 'requireapproval' => true,
+ 'hasentries' => true,
+ 'expected' => [
+ 'name' => get_string('myentries', 'mod_glossary'),
+ 'value' => 1,
],
];
}
diff --git a/public/mod/h5pactivity/tests/courseformat/overview_test.php b/public/mod/h5pactivity/tests/courseformat/overview_test.php
index 62d5f470a89..de366b0013e 100644
--- a/public/mod/h5pactivity/tests/courseformat/overview_test.php
+++ b/public/mod/h5pactivity/tests/courseformat/overview_test.php
@@ -46,8 +46,6 @@ final class overview_test extends \advanced_testcase {
$teacher = $this->getDataGenerator()->create_and_enrol($course, 'editingteacher');
$student = $this->getDataGenerator()->create_and_enrol($course, 'student');
- $this->getDataGenerator()->get_plugin_generator('mod_h5pactivity');
-
// Students have no action column.
$this->setUser($student);
$this->assertNull(overviewfactory::create($cm)->get_actions_overview());
@@ -120,25 +118,23 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test h5p type overview extra.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_extra_h5type_overview(): array {
- return [
- 'Basic package' => [
- 'h5pfile' => 'basic_essay.h5p',
- 'iscorrect' => true,
- 'expected' => 'Essay',
- ],
- 'No json file' => [
- 'h5pfile' => 'no-json-file.h5p',
- 'iscorrect' => false,
- 'expected' => get_string('unknowntype', 'mod_h5pactivity'),
- ],
- 'Unzippable package' => [
- 'h5pfile' => 'unzippable.h5p',
- 'iscorrect' => false,
- 'expected' => get_string('unknowntype', 'mod_h5pactivity'),
- ],
+ public static function provider_test_get_extra_h5type_overview(): \Generator {
+ yield 'Basic package' => [
+ 'h5pfile' => 'basic_essay.h5p',
+ 'iscorrect' => true,
+ 'expected' => 'Essay',
+ ];
+ yield 'No json file' => [
+ 'h5pfile' => 'no-json-file.h5p',
+ 'iscorrect' => false,
+ 'expected' => get_string('unknowntype', 'mod_h5pactivity'),
+ ];
+ yield 'Unzippable package' => [
+ 'h5pfile' => 'unzippable.h5p',
+ 'iscorrect' => false,
+ 'expected' => get_string('unknowntype', 'mod_h5pactivity'),
];
}
diff --git a/public/mod/lesson/tests/courseformat/overview_test.php b/public/mod/lesson/tests/courseformat/overview_test.php
index 28e775f6dcd..fbc365313aa 100644
--- a/public/mod/lesson/tests/courseformat/overview_test.php
+++ b/public/mod/lesson/tests/courseformat/overview_test.php
@@ -87,19 +87,17 @@ final class overview_test extends \advanced_testcase {
/**
* Provider for test_get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_due_date_overview(): array {
- return [
- 'no_due' => [
- 'timeincrement' => null,
- ],
- 'past_due' => [
- 'timeincrement' => -1 * (4 * DAYSECS),
- ],
- 'future_due' => [
- 'timeincrement' => (4 * DAYSECS),
- ],
+ public static function provider_test_get_due_date_overview(): \Generator {
+ yield 'no_due' => [
+ 'timeincrement' => null,
+ ];
+ yield 'past_due' => [
+ 'timeincrement' => -1 * (4 * DAYSECS),
+ ];
+ yield 'future_due' => [
+ 'timeincrement' => (4 * DAYSECS),
];
}
@@ -141,20 +139,18 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_actions_overview(): array {
- return [
- 'Student' => [
- 'role' => 'student',
- 'expected' => null,
- ],
- 'Teacher' => [
- 'role' => 'editingteacher',
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => '',
- ],
+ public static function provider_test_get_actions_overview(): \Generator {
+ yield 'Student' => [
+ 'role' => 'student',
+ 'expected' => null,
+ ];
+ yield 'Teacher' => [
+ 'role' => 'editingteacher',
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => '',
],
];
}
diff --git a/public/mod/quiz/tests/courseformat/overview_test.php b/public/mod/quiz/tests/courseformat/overview_test.php
index ce0e5178ab4..36623b108ac 100644
--- a/public/mod/quiz/tests/courseformat/overview_test.php
+++ b/public/mod/quiz/tests/courseformat/overview_test.php
@@ -65,19 +65,17 @@ final class overview_test extends \advanced_testcase {
/**
* Provider for test_get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_due_date_overview(): array {
- return [
- 'no_due' => [
- 'timeincrement' => null,
- ],
- 'past_due' => [
- 'timeincrement' => -1 * (4 * DAYSECS),
- ],
- 'future_due' => [
- 'timeincrement' => (4 * DAYSECS),
- ],
+ public static function provider_test_get_due_date_overview(): \Generator {
+ yield 'no_due' => [
+ 'timeincrement' => null,
+ ];
+ yield 'past_due' => [
+ 'timeincrement' => -1 * (4 * DAYSECS),
+ ];
+ yield 'future_due' => [
+ 'timeincrement' => (4 * DAYSECS),
];
}
@@ -115,27 +113,25 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_actions_overview(): array {
- return [
- 'Student' => [
- 'currentuser' => 's1',
- 'expected' => null,
+ public static function provider_test_get_actions_overview(): \Generator {
+ yield 'Student' => [
+ 'currentuser' => 's1',
+ 'expected' => null,
+ ];
+ yield 'Editing Teacher' => [
+ 'currentuser' => 't1',
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => '',
],
- 'Editing Teacher' => [
- 'currentuser' => 't1',
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => '',
- ],
- ],
- 'Non editing Teacher' => [
- 'currentuser' => 't2',
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => '',
- ],
+ ];
+ yield 'Non editing Teacher' => [
+ 'currentuser' => 't2',
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => '',
],
];
}
@@ -182,33 +178,31 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for provider_test_get_total_attempts_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_total_attempts_overview(): array {
- return [
- 'Without groups' => [
- 'groupmode' => NOGROUPS,
- 'expected' => [
- 't1' => 5, // Count all attempts (even teacher's attempts).
- 't2' => 5,
- 's1' => null,
- ],
+ public static function provider_test_get_total_attempts_overview(): \Generator {
+ yield 'Without groups' => [
+ 'groupmode' => NOGROUPS,
+ 'expected' => [
+ 't1' => 5, // Count all attempts (even teacher's attempts).
+ 't2' => 5,
+ 's1' => null,
],
- 'With separate groups' => [
- 'groupmode' => SEPARATEGROUPS,
- 'expected' => [
- 't1' => 5,
- 't2' => 3, // User 1 two attempts, teacher 2 one attempt (counted).
- 's1' => null,
- ],
+ ];
+ yield 'With separate groups' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'expected' => [
+ 't1' => 5,
+ 't2' => 3, // User 1 two attempts, teacher 2 one attempt (counted).
+ 's1' => null,
],
- 'With visible groups' => [
- 'groupmode' => VISIBLEGROUPS,
- 'expected' => [
- 't1' => 5,
- 't2' => 5,
- 's1' => null,
- ],
+ ];
+ yield 'With visible groups' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'expected' => [
+ 't1' => 5,
+ 't2' => 5,
+ 's1' => null,
],
];
}
@@ -253,33 +247,31 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_students_who_attempted_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_students_who_attempted_overview(): array {
- return [
- 'With no groups' => [
- 'groupmode' => NOGROUPS,
- 'expected' => [
- 't1' => "3 of 4", // 3 students and one teacher out (not counted) of 4 made at least one attempt.
- 't2' => "3 of 4",
- 's1' => null,
- ],
+ public static function provider_test_get_students_who_attempted_overview(): \Generator {
+ yield 'With no groups' => [
+ 'groupmode' => NOGROUPS,
+ 'expected' => [
+ 't1' => "3 of 4", // 3 students and one teacher out (not counted) of 4 made at least one attempt.
+ 't2' => "3 of 4",
+ 's1' => null,
],
- 'With separate groups' => [
- 'groupmode' => SEPARATEGROUPS,
- 'expected' => [
- 't1' => "3 of 4", // Teacher 1 can see all groups.
- 't2' => "1 of 1", // Only student 1 in group 1 made at least one attempt.
- 's1' => null,
- ],
+ ];
+ yield 'With separate groups' => [
+ 'groupmode' => SEPARATEGROUPS,
+ 'expected' => [
+ 't1' => "3 of 4", // Teacher 1 can see all groups.
+ 't2' => "1 of 1", // Only student 1 in group 1 made at least one attempt.
+ 's1' => null,
],
- 'With visible groups' => [
- 'groupmode' => VISIBLEGROUPS,
- 'expected' => [
- 't1' => "3 of 4", // 3 students and one teacher out (not counted) of 4 made at least one attempt.
- 't2' => "3 of 4",
- 's1' => null,
- ],
+ ];
+ yield 'With visible groups' => [
+ 'groupmode' => VISIBLEGROUPS,
+ 'expected' => [
+ 't1' => "3 of 4", // 3 students and one teacher out (not counted) of 4 made at least one attempt.
+ 't2' => "3 of 4",
+ 's1' => null,
],
];
}
diff --git a/public/mod/scorm/tests/courseformat/overview_test.php b/public/mod/scorm/tests/courseformat/overview_test.php
index 363ad017715..f3057c92c90 100644
--- a/public/mod/scorm/tests/courseformat/overview_test.php
+++ b/public/mod/scorm/tests/courseformat/overview_test.php
@@ -77,22 +77,20 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_due_date_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function get_due_date_overview_data(): array {
- return [
- 'tomorrow' => [
- 'timeincrement' => DAYSECS,
- ],
- 'yesterday' => [
- 'timeincrement' => -1 * DAYSECS,
- ],
- 'today' => [
- 'timeincrement' => 0,
- ],
- 'No date' => [
- 'timeincrement' => null,
- ],
+ public static function get_due_date_overview_data(): \Generator {
+ yield 'tomorrow' => [
+ 'timeincrement' => DAYSECS,
+ ];
+ yield 'yesterday' => [
+ 'timeincrement' => -1 * DAYSECS,
+ ];
+ yield 'today' => [
+ 'timeincrement' => 0,
+ ];
+ yield 'No date' => [
+ 'timeincrement' => null,
];
}
@@ -248,181 +246,179 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_studentsattempted_overview and test_get_extra_totalattempts_overview
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_overview_items_data(): array {
+ public static function get_extra_overview_items_data(): \Generator {
// Here we intentionally just test the case where course mode is set to NOGROUPS as groups are is not
// yet supported by the overview page for SCORM module. This will be followed up in a future issue (MDL-85852).
- return [
- 'teacher 1 - no groups with attempts' => [
- 'username' => 't1',
- 'activity' => 'withattempts',
- 'groupmode' => NOGROUPS,
- 'expected' => [
- 'attempted' => [
- 'value' => 2,
- 'content' => '2 of 4',
- ],
- 'totalattempts' => [
- 'value' => 2,
- 'items' => [
- [
- 'label' => 'Grading method',
- 'value' => 'Highest attempt',
- ],
- [
- 'label' => 'Allowed attempts per student',
- 'value' => 'Unlimited',
- ],
- [
- 'label' => 'Average attempts per student',
- 'value' => '1',
- ],
- ],
-
- ],
-
+ yield 'teacher 1 - no groups with attempts' => [
+ 'username' => 't1',
+ 'activity' => 'withattempts',
+ 'groupmode' => NOGROUPS,
+ 'expected' => [
+ 'attempted' => [
+ 'value' => 2,
+ 'content' => '2 of 4',
],
- ],
- 'teacher 1 - no groups without attempts' => [
- 'username' => 't1',
- 'activity' => 'withoutattempts',
- 'groupmode' => NOGROUPS,
- 'expected' => [
- 'attempted' => [
- 'value' => 0,
- 'content' => '0 of 4',
- ],
- 'totalattempts' => [
- 'value' => 0,
- 'items' => [
- [
- 'label' => 'Grading method',
- 'value' => 'Highest attempt',
- ],
- [
- 'label' => 'Allowed attempts per student',
- 'value' => 'Unlimited',
- ],
- [
- 'label' => 'Average attempts per student',
- 'value' => '0',
- ],
+ 'totalattempts' => [
+ 'value' => 2,
+ 'items' => [
+ [
+ 'label' => 'Grading method',
+ 'value' => 'Highest attempt',
+ ],
+ [
+ 'label' => 'Allowed attempts per student',
+ 'value' => 'Unlimited',
+ ],
+ [
+ 'label' => 'Average attempts per student',
+ 'value' => '1',
],
],
],
+
],
- 'teacher 2 - no groups' => [
- 'username' => 't2',
- 'activity' => 'withattempts',
- 'groupmode' => NOGROUPS,
- 'expected' => [
- 'attempted' => [
- 'value' => 2,
- 'content' => '2 of 4',
+ ];
+ yield 'teacher 1 - no groups without attempts' => [
+ 'username' => 't1',
+ 'activity' => 'withoutattempts',
+ 'groupmode' => NOGROUPS,
+ 'expected' => [
+ 'attempted' => [
+ 'value' => 0,
+ 'content' => '0 of 4',
+ ],
+ 'totalattempts' => [
+ 'value' => 0,
+ 'items' => [
+ [
+ 'label' => 'Grading method',
+ 'value' => 'Highest attempt',
+ ],
+ [
+ 'label' => 'Allowed attempts per student',
+ 'value' => 'Unlimited',
+ ],
+ [
+ 'label' => 'Average attempts per student',
+ 'value' => '0',
+ ],
],
- 'totalattempts' => [
- 'value' => 2,
- 'items' => [
- [
- 'label' => 'Grading method',
- 'value' => 'Highest attempt',
- ],
- [
- 'label' => 'Allowed attempts per student',
- 'value' => 'Unlimited',
- ],
- [
- 'label' => 'Average attempts per student',
- 'value' => '1',
- ],
+ ],
+
+ ],
+ ];
+ yield 'teacher 2 - no groups' => [
+ 'username' => 't2',
+ 'activity' => 'withattempts',
+ 'groupmode' => NOGROUPS,
+ 'expected' => [
+ 'attempted' => [
+ 'value' => 2,
+ 'content' => '2 of 4',
+ ],
+ 'totalattempts' => [
+ 'value' => 2,
+ 'items' => [
+ [
+ 'label' => 'Grading method',
+ 'value' => 'Highest attempt',
+ ],
+ [
+ 'label' => 'Allowed attempts per student',
+ 'value' => 'Unlimited',
+ ],
+ [
+ 'label' => 'Average attempts per student',
+ 'value' => '1',
],
],
],
],
- 'teacher 1 - separate group' => [
- 'username' => 't1',
- 'activity' => 'withattempts',
- 'groupmode' => SEPARATEGROUPS,
- 'expected' => [
- 'attempted' => [
- 'value' => 1,
- 'content' => '1 of 2', // Teacher can also attempt, so s1 and t1 are counted.
- ],
- 'totalattempts' => [
- 'value' => 1, // Attempt from s1 only.
- 'items' => [
- [
- 'label' => 'Grading method',
- 'value' => 'Highest attempt',
- ],
- [
- 'label' => 'Allowed attempts per student',
- 'value' => 'Unlimited',
- ],
- [
- 'label' => 'Average attempts per student',
- 'value' => '1',
- ],
+ ];
+ yield 'teacher 1 - separate group' => [
+ 'username' => 't1',
+ 'activity' => 'withattempts',
+ 'groupmode' => SEPARATEGROUPS,
+ 'expected' => [
+ 'attempted' => [
+ 'value' => 1,
+ 'content' => '1 of 2', // Teacher can also attempt, so s1 and t1 are counted.
+ ],
+ 'totalattempts' => [
+ 'value' => 1, // Attempt from s1 only.
+ 'items' => [
+ [
+ 'label' => 'Grading method',
+ 'value' => 'Highest attempt',
+ ],
+ [
+ 'label' => 'Allowed attempts per student',
+ 'value' => 'Unlimited',
+ ],
+ [
+ 'label' => 'Average attempts per student',
+ 'value' => '1',
],
],
],
],
- // Teacher 2 is not in any group, so no attempt can be counted and the overview will return an error.
- // But still the attempts can be counted if we call directly the manager methods, so we just skip the test here.
- 'teacher 1 - visible group' => [
- 'username' => 't1',
- 'activity' => 'withattempts',
- 'groupmode' => VISIBLEGROUPS,
- 'expected' => [
- 'attempted' => [
- 'value' => 2,
- 'content' => '2 of 4',
- ],
- 'totalattempts' => [
- 'value' => 2,
- 'items' => [
- [
- 'label' => 'Grading method',
- 'value' => 'Highest attempt',
- ],
- [
- 'label' => 'Allowed attempts per student',
- 'value' => 'Unlimited',
- ],
- [
- 'label' => 'Average attempts per student',
- 'value' => '1',
- ],
+ ];
+ // Teacher 2 is not in any group, so no attempt can be counted and the overview will return an error.
+ // But still the attempts can be counted if we call directly the manager methods, so we just skip the test here.
+ yield 'teacher 1 - visible group' => [
+ 'username' => 't1',
+ 'activity' => 'withattempts',
+ 'groupmode' => VISIBLEGROUPS,
+ 'expected' => [
+ 'attempted' => [
+ 'value' => 2,
+ 'content' => '2 of 4',
+ ],
+ 'totalattempts' => [
+ 'value' => 2,
+ 'items' => [
+ [
+ 'label' => 'Grading method',
+ 'value' => 'Highest attempt',
+ ],
+ [
+ 'label' => 'Allowed attempts per student',
+ 'value' => 'Unlimited',
+ ],
+ [
+ 'label' => 'Average attempts per student',
+ 'value' => '1',
],
],
],
],
- 'teacher 2 - visible group' => [
- 'username' => 't2',
- 'activity' => 'withattempts',
- 'groupmode' => VISIBLEGROUPS,
- 'expected' => [
- 'attempted' => [
- 'value' => 2,
- 'content' => '2 of 4',
- ],
- 'totalattempts' => [
- 'value' => 2,
- 'items' => [
- [
- 'label' => 'Grading method',
- 'value' => 'Highest attempt',
- ],
- [
- 'label' => 'Allowed attempts per student',
- 'value' => 'Unlimited',
- ],
- [
- 'label' => 'Average attempts per student',
- 'value' => '1',
- ],
+ ];
+ yield 'teacher 2 - visible group' => [
+ 'username' => 't2',
+ 'activity' => 'withattempts',
+ 'groupmode' => VISIBLEGROUPS,
+ 'expected' => [
+ 'attempted' => [
+ 'value' => 2,
+ 'content' => '2 of 4',
+ ],
+ 'totalattempts' => [
+ 'value' => 2,
+ 'items' => [
+ [
+ 'label' => 'Grading method',
+ 'value' => 'Highest attempt',
+ ],
+ [
+ 'label' => 'Allowed attempts per student',
+ 'value' => 'Unlimited',
+ ],
+ [
+ 'label' => 'Average attempts per student',
+ 'value' => '1',
],
],
],
diff --git a/public/mod/wiki/tests/courseformat/overview_test.php b/public/mod/wiki/tests/courseformat/overview_test.php
index 0eb810cd785..191f82003bd 100644
--- a/public/mod/wiki/tests/courseformat/overview_test.php
+++ b/public/mod/wiki/tests/courseformat/overview_test.php
@@ -32,13 +32,11 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for wiki modes.
*
- * @return array
+ * @return \Generator
*/
- public static function get_wiki_mode_provider(): array {
- return [
- 'collaborative' => ['mode' => wiki_mode::COLLABORATIVE],
- 'individual' => ['mode' => wiki_mode::INDIVIDUAL],
- ];
+ public static function get_wiki_mode_provider(): \Generator {
+ yield 'collaborative' => ['mode' => wiki_mode::COLLABORATIVE];
+ yield 'individual' => ['mode' => wiki_mode::INDIVIDUAL];
}
/**
@@ -67,14 +65,12 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for get_extra_my_entries.
*
- * @return array
+ * @return \Generator
*/
- public static function get_extra_my_entries_provider(): array {
- return [
- 'student 1' => ['s1', 1],
- 'student 2' => ['s2', 1],
- 'teacher 1' => ['t1', null], // Teacher 1 does not have any entries.
- ];
+ public static function get_extra_my_entries_provider(): \Generator {
+ yield 'student 1' => ['s1', 1];
+ yield 'student 2' => ['s2', 1];
+ yield 'teacher 1' => ['t1', null]; // Teacher 1 does not have any entries.
}
/**
diff --git a/public/mod/workshop/tests/courseformat/overview_test.php b/public/mod/workshop/tests/courseformat/overview_test.php
index 0ea29fce9d9..024ebc0c22a 100644
--- a/public/mod/workshop/tests/courseformat/overview_test.php
+++ b/public/mod/workshop/tests/courseformat/overview_test.php
@@ -143,28 +143,26 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_grade_item_names.
*
- * @return array
+ * @return \Generator
*/
- public static function data_provider_get_grade_item_names(): array {
- return [
- 'student with submissions' => [
- 'user' => 'student',
- 'expectempty' => false,
- 'hassubmission' => true,
- 'hasassesment' => false,
- ],
- 'student with assessments' => [
- 'user' => 'student',
- 'expectempty' => false,
- 'hassubmission' => true,
- 'hasassesment' => true,
- ],
- 'teacher' => [
- 'user' => 'teacher',
- 'expectempty' => true,
- 'hassubmission' => false,
- 'hasassesment' => false,
- ],
+ public static function data_provider_get_grade_item_names(): \Generator {
+ yield 'student with submissions' => [
+ 'user' => 'student',
+ 'expectempty' => false,
+ 'hassubmission' => true,
+ 'hasassesment' => false,
+ ];
+ yield 'student with assessments' => [
+ 'user' => 'student',
+ 'expectempty' => false,
+ 'hassubmission' => true,
+ 'hasassesment' => true,
+ ];
+ yield 'teacher' => [
+ 'user' => 'teacher',
+ 'expectempty' => true,
+ 'hassubmission' => false,
+ 'hasassesment' => false,
];
}
@@ -208,50 +206,48 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_phase_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function data_provider_get_extra_phase_overview(): array {
- return [
- 'teacher setup phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_SETUP,
- ],
- 'student setup phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_SETUP,
- ],
- 'teacher submission phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- ],
- 'student submission phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- ],
- 'teacher assessment phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- ],
- 'student assessment phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- ],
- 'teacher evaluation phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- ],
- 'student evaluation phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- ],
- 'teacher closed phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- ],
- 'student closed phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_CLOSED,
- ],
+ public static function data_provider_get_extra_phase_overview(): \Generator {
+ yield 'teacher setup phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ ];
+ yield 'student setup phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ ];
+ yield 'teacher submission phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ ];
+ yield 'student submission phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ ];
+ yield 'teacher assessment phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ ];
+ yield 'student assessment phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ ];
+ yield 'teacher evaluation phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ ];
+ yield 'student evaluation phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ ];
+ yield 'teacher closed phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ ];
+ yield 'student closed phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_CLOSED,
];
}
@@ -316,82 +312,80 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_phase_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function data_provider_get_extra_deadline_overview(): array {
+ public static function data_provider_get_extra_deadline_overview(): \Generator {
$submissionend = 3600;
$assessmentend = 7200;
- return [
- 'teacher setup phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_SETUP,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => null,
- ],
- 'student setup phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_SETUP,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => null,
- ],
- 'teacher submission phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => $submissionend,
- ],
- 'student submission phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => $submissionend,
- ],
- 'teacher assessment phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => $assessmentend,
- ],
- 'student assessment phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => $assessmentend,
- ],
- 'teacher evaluation phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => null,
- ],
- 'student evaluation phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => null,
- ],
- 'teacher closed phase' => [
- 'user' => 'teacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => null,
- ],
- 'student closed phase' => [
- 'user' => 'student',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'submissionend' => $submissionend,
- 'assessmentend' => $assessmentend,
- 'expectedincrement' => null,
- ],
+ yield 'teacher setup phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => null,
+ ];
+ yield 'student setup phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => null,
+ ];
+ yield 'teacher submission phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => $submissionend,
+ ];
+ yield 'student submission phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => $submissionend,
+ ];
+ yield 'teacher assessment phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => $assessmentend,
+ ];
+ yield 'student assessment phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => $assessmentend,
+ ];
+ yield 'teacher evaluation phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => null,
+ ];
+ yield 'student evaluation phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => null,
+ ];
+ yield 'teacher closed phase' => [
+ 'user' => 'teacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => null,
+ ];
+ yield 'student closed phase' => [
+ 'user' => 'student',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'submissionend' => $submissionend,
+ 'assessmentend' => $assessmentend,
+ 'expectedincrement' => null,
];
}
@@ -520,208 +514,206 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_extra_submissions_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function data_provider_get_extra_submissions_overview(): array {
- return [
- 'teacher setup phase without activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_SETUP,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => false,
- 'expected' => ['submissions' => 0, 'assessments' => 0],
- ],
- 'student setup phase without activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_SETUP,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => true,
- ],
- 'teacher submission phase without activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => false,
- 'expected' => ['submissions' => 0, 'assessments' => 0],
- ],
- 'student submission phase without activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => true,
- ],
- 'teacher assessment phase without activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => false,
- 'expected' => ['submissions' => 0, 'assessments' => 0],
- ],
- 'student assessment phase without activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => true,
- ],
- 'teacher evaluation phase without activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => false,
- 'expected' => ['submissions' => 0, 'assessments' => 0],
- ],
- 'student evaluation phase without activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => true,
- ],
- 'teacher closed phase without activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => false,
- 'expected' => ['submissions' => 0, 'assessments' => 0],
- ],
- 'student closed phase without activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => false,
- 'expectnull' => true,
- ],
- // Tests with assessments.
- 'teacher setup phase with activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_SETUP,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'student setup phase with activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_SETUP,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => true,
- ],
- 'teacher submission phase with activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'student submission phase with activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_SUBMISSION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => true,
- ],
- 'teacher assessment phase with activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'student assessment phase with activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_ASSESSMENT,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => true,
- ],
- 'teacher evaluation phase with activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'student evaluation phase with activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_EVALUATION,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => true,
- ],
- 'teacher closed phase with activity' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'student closed phase with activity' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => NOGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => true,
- ],
- // Group mode tests.
- 'teacher closed phase with group activity (separate groups)' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => SEPARATEGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'non-editing teacher closed phase with group activity (separate groups)' => [
- 'role' => 'teacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => SEPARATEGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 1, 'assessments' => 1],
- ],
- 'student closed phase with group activity (separate groups)' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => SEPARATEGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => true,
- ],
- 'teacher closed phase with group activity (visible groups)' => [
- 'role' => 'editingteacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => VISIBLEGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'non-editing teacher closed phase with group activity (visible groups)' => [
- 'role' => 'teacher',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => VISIBLEGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => false,
- 'expected' => ['submissions' => 2, 'assessments' => 3],
- ],
- 'student closed phase with group activity (visible groups)' => [
- 'role' => 'student',
- 'currentphase' => \workshop::PHASE_CLOSED,
- 'groupmode' => VISIBLEGROUPS,
- 'hasstudentactivity' => true,
- 'expectnull' => true,
- ],
+ public static function data_provider_get_extra_submissions_overview(): \Generator {
+ yield 'teacher setup phase without activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 0, 'assessments' => 0],
+ ];
+ yield 'student setup phase without activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => true,
+ ];
+ yield 'teacher submission phase without activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 0, 'assessments' => 0],
+ ];
+ yield 'student submission phase without activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => true,
+ ];
+ yield 'teacher assessment phase without activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 0, 'assessments' => 0],
+ ];
+ yield 'student assessment phase without activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => true,
+ ];
+ yield 'teacher evaluation phase without activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 0, 'assessments' => 0],
+ ];
+ yield 'student evaluation phase without activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => true,
+ ];
+ yield 'teacher closed phase without activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 0, 'assessments' => 0],
+ ];
+ yield 'student closed phase without activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => false,
+ 'expectnull' => true,
+ ];
+ // Tests with assessments.
+ yield 'teacher setup phase with activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'student setup phase with activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_SETUP,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => true,
+ ];
+ yield 'teacher submission phase with activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'student submission phase with activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_SUBMISSION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => true,
+ ];
+ yield 'teacher assessment phase with activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'student assessment phase with activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_ASSESSMENT,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => true,
+ ];
+ yield 'teacher evaluation phase with activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'student evaluation phase with activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_EVALUATION,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => true,
+ ];
+ yield 'teacher closed phase with activity' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'student closed phase with activity' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => NOGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => true,
+ ];
+ // Group mode tests.
+ yield 'teacher closed phase with group activity (separate groups)' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => SEPARATEGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'non-editing teacher closed phase with group activity (separate groups)' => [
+ 'role' => 'teacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => SEPARATEGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 1, 'assessments' => 1],
+ ];
+ yield 'student closed phase with group activity (separate groups)' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => SEPARATEGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => true,
+ ];
+ yield 'teacher closed phase with group activity (visible groups)' => [
+ 'role' => 'editingteacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => VISIBLEGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'non-editing teacher closed phase with group activity (visible groups)' => [
+ 'role' => 'teacher',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => VISIBLEGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => false,
+ 'expected' => ['submissions' => 2, 'assessments' => 3],
+ ];
+ yield 'student closed phase with group activity (visible groups)' => [
+ 'role' => 'student',
+ 'currentphase' => \workshop::PHASE_CLOSED,
+ 'groupmode' => VISIBLEGROUPS,
+ 'hasstudentactivity' => true,
+ 'expectnull' => true,
];
}
@@ -762,27 +754,25 @@ final class overview_test extends \advanced_testcase {
/**
* Data provider for test_get_actions_overview.
*
- * @return array
+ * @return \Generator
*/
- public static function provider_test_get_actions_overview(): array {
- return [
- 'Student' => [
- 'role' => 'student',
- 'expected' => null,
+ public static function provider_test_get_actions_overview(): \Generator {
+ yield 'Student' => [
+ 'role' => 'student',
+ 'expected' => null,
+ ];
+ yield 'Editing teacher' => [
+ 'role' => 'editingteacher',
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => get_string('view'),
],
- 'Editing teacher' => [
- 'role' => 'editingteacher',
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => get_string('view'),
- ],
- ],
- 'Teacher' => [
- 'role' => 'teacher',
- 'expected' => [
- 'name' => get_string('actions'),
- 'value' => get_string('view'),
- ],
+ ];
+ yield 'Teacher' => [
+ 'role' => 'teacher',
+ 'expected' => [
+ 'name' => get_string('actions'),
+ 'value' => get_string('view'),
],
];
}