Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 11
Línea 49... Línea 49...
49
    public $extrastudents;
49
    public $extrastudents;
Línea 50... Línea 50...
50
 
50
 
51
    /** @var array */
51
    /** @var array */
Línea 52... Línea 52...
52
    public $extrasuspendedstudents;
52
    public $extrasuspendedstudents;
53
 
53
 
Línea 54... Línea 54...
54
    public function test_return_links() {
54
    public function test_return_links(): void {
55
        global $PAGE;
55
        global $PAGE;
Línea 63... Línea 63...
63
        $assign->register_return_link('RETURNACTION', ['param' => 1]);
63
        $assign->register_return_link('RETURNACTION', ['param' => 1]);
64
        $this->assertEquals('RETURNACTION', $assign->get_return_action());
64
        $this->assertEquals('RETURNACTION', $assign->get_return_action());
65
        $this->assertEquals(['param' => 1], $assign->get_return_params());
65
        $this->assertEquals(['param' => 1], $assign->get_return_params());
66
    }
66
    }
Línea 67... Línea 67...
67
 
67
 
68
    public function test_get_feedback_plugins() {
68
    public function test_get_feedback_plugins(): void {
69
        $this->resetAfterTest();
69
        $this->resetAfterTest();
70
        $course = $this->getDataGenerator()->create_course();
70
        $course = $this->getDataGenerator()->create_course();
Línea 71... Línea 71...
71
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
71
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 77... Línea 77...
77
        foreach ($assign->get_feedback_plugins() as $plugin) {
77
        foreach ($assign->get_feedback_plugins() as $plugin) {
78
            $this->assertContains($plugin->get_type(), $installedplugins, 'Feedback plugin not in list of installed plugins');
78
            $this->assertContains($plugin->get_type(), $installedplugins, 'Feedback plugin not in list of installed plugins');
79
        }
79
        }
80
    }
80
    }
Línea 81... Línea 81...
81
 
81
 
82
    public function test_get_submission_plugins() {
82
    public function test_get_submission_plugins(): void {
83
        $this->resetAfterTest();
83
        $this->resetAfterTest();
84
        $course = $this->getDataGenerator()->create_course();
84
        $course = $this->getDataGenerator()->create_course();
Línea 85... Línea 85...
85
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
85
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 91... Línea 91...
91
        foreach ($assign->get_submission_plugins() as $plugin) {
91
        foreach ($assign->get_submission_plugins() as $plugin) {
92
            $this->assertContains($plugin->get_type(), $installedplugins, 'Submission plugin not in list of installed plugins');
92
            $this->assertContains($plugin->get_type(), $installedplugins, 'Submission plugin not in list of installed plugins');
93
        }
93
        }
94
    }
94
    }
Línea 95... Línea 95...
95
 
95
 
96
    public function test_is_blind_marking() {
96
    public function test_is_blind_marking(): void {
97
        $this->resetAfterTest();
97
        $this->resetAfterTest();
98
        $course = $this->getDataGenerator()->create_course();
98
        $course = $this->getDataGenerator()->create_course();
99
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
99
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 178... Línea 178...
178
     *
178
     *
179
     * @dataProvider get_assign_perpage_provider
179
     * @dataProvider get_assign_perpage_provider
180
     * @param integer $maxperpage site config value
180
     * @param integer $maxperpage site config value
181
     * @param array $userprefs Array of user preferences and expected page sizes
181
     * @param array $userprefs Array of user preferences and expected page sizes
182
     */
182
     */
183
    public function test_get_assign_perpage($maxperpage, $userprefs) {
183
    public function test_get_assign_perpage($maxperpage, $userprefs): void {
184
        $this->resetAfterTest();
184
        $this->resetAfterTest();
185
        $course = $this->getDataGenerator()->create_course();
185
        $course = $this->getDataGenerator()->create_course();
186
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
186
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
187
        $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
187
        $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
Línea 202... Línea 202...
202
     * Test filter by requires grading.
202
     * Test filter by requires grading.
203
     *
203
     *
204
     * This is specifically checking an assignment with no grade to make sure we do not
204
     * This is specifically checking an assignment with no grade to make sure we do not
205
     * get an exception thrown when rendering the grading table for this type of assignment.
205
     * get an exception thrown when rendering the grading table for this type of assignment.
206
     */
206
     */
207
    public function test_gradingtable_filter_by_requiresgrading_no_grade() {
207
    public function test_gradingtable_filter_by_requiresgrading_no_grade(): void {
208
        global $PAGE;
208
        global $PAGE;
Línea 209... Línea 209...
209
 
209
 
Línea 210... Línea 210...
210
        $this->resetAfterTest();
210
        $this->resetAfterTest();
Línea 233... Línea 233...
233
 
233
 
234
 
234
 
235
    /**
235
    /**
236
     * Test submissions with extension date.
236
     * Test submissions with extension date.
237
     */
237
     */
Línea 238... Línea 238...
238
    public function test_gradingtable_extension_due_date() {
238
    public function test_gradingtable_extension_due_date(): void {
239
        global $PAGE;
239
        global $PAGE;
240
 
240
 
Línea 292... Línea 292...
292
    }
292
    }
Línea 293... Línea 293...
293
 
293
 
294
    /**
294
    /**
295
     * Test that late submissions with extension date calculate correctly.
295
     * Test that late submissions with extension date calculate correctly.
296
     */
296
     */
297
    public function test_gradingtable_extension_date_calculation_for_lateness() {
297
    public function test_gradingtable_extension_date_calculation_for_lateness(): void {
Línea 298... Línea 298...
298
        global $PAGE;
298
        global $PAGE;
299
 
299
 
300
        $this->resetAfterTest();
300
        $this->resetAfterTest();
Línea 355... Línea 355...
355
        $difftime = $submittedtime - $time;
355
        $difftime = $submittedtime - $time;
356
        $this->assertStringContainsString(get_string('submittedlateshort', 'assign', format_time((2 * DAYSECS) + $difftime)),
356
        $this->assertStringContainsString(get_string('submittedlateshort', 'assign', format_time((2 * DAYSECS) + $difftime)),
357
            $output);
357
            $output);
358
    }
358
    }
Línea 359... Línea 359...
359
 
359
 
360
    public function test_gradingtable_status_rendering() {
360
    public function test_gradingtable_status_rendering(): void {
Línea 361... Línea 361...
361
        global $PAGE;
361
        global $PAGE;
362
 
362
 
363
        $this->resetAfterTest();
363
        $this->resetAfterTest();
Línea 406... Línea 406...
406
 
406
 
407
    /**
407
    /**
408
     * Check that group submission information is rendered correctly in the
408
     * Check that group submission information is rendered correctly in the
409
     * grading table.
409
     * grading table.
410
     */
410
     */
411
    public function test_gradingtable_group_submissions_rendering() {
411
    public function test_gradingtable_group_submissions_rendering(): void {
Línea 412... Línea 412...
412
        global $PAGE;
412
        global $PAGE;
413
 
413
 
414
        $this->resetAfterTest();
414
        $this->resetAfterTest();
Línea 496... Línea 496...
496
        // Check comments can be made.
496
        // Check comments can be made.
497
        $this->assertEquals(1, $xpath->evaluate('count(//td[@id="' . $xpathuniqueidroot . '_r0_c10"]//textarea)'));
497
        $this->assertEquals(1, $xpath->evaluate('count(//td[@id="' . $xpathuniqueidroot . '_r0_c10"]//textarea)'));
498
        $this->assertEquals(1, $xpath->evaluate('count(//td[@id="' . $xpathuniqueidroot . '_r3_c10"]//textarea)'));
498
        $this->assertEquals(1, $xpath->evaluate('count(//td[@id="' . $xpathuniqueidroot . '_r3_c10"]//textarea)'));
499
    }
499
    }
Línea 500... Línea 500...
500
 
500
 
501
    public function test_show_intro() {
501
    public function test_show_intro(): void {
502
        $this->resetAfterTest();
502
        $this->resetAfterTest();
503
        $course = $this->getDataGenerator()->create_course();
503
        $course = $this->getDataGenerator()->create_course();
Línea 504... Línea 504...
504
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
504
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 522... Línea 522...
522
                'allowsubmissionsfromdate' => $yesterday,
522
                'allowsubmissionsfromdate' => $yesterday,
523
            ]);
523
            ]);
524
        $this->assertEquals(true, $assign->testable_show_intro());
524
        $this->assertEquals(true, $assign->testable_show_intro());
525
    }
525
    }
Línea 526... Línea 526...
526
 
526
 
527
    public function test_has_submissions_or_grades() {
527
    public function test_has_submissions_or_grades(): void {
528
        $this->resetAfterTest();
528
        $this->resetAfterTest();
529
        $course = $this->getDataGenerator()->create_course();
529
        $course = $this->getDataGenerator()->create_course();
530
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
530
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 557... Línea 557...
557
 
557
 
558
        // Now test again.
558
        // Now test again.
559
        $this->assertEquals(true, $assign->has_submissions_or_grades());
559
        $this->assertEquals(true, $assign->has_submissions_or_grades());
Línea 560... Línea 560...
560
    }
560
    }
561
 
561
 
562
    public function test_delete_grades() {
562
    public function test_delete_grades(): void {
563
        $this->resetAfterTest();
563
        $this->resetAfterTest();
564
        $course = $this->getDataGenerator()->create_course();
564
        $course = $this->getDataGenerator()->create_course();
Línea 583... Línea 583...
583
        $gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $assign->get_instance()->id);
583
        $gradinginfo = grade_get_grades($course->id, 'mod', 'assign', $assign->get_instance()->id);
Línea 584... Línea 584...
584
 
584
 
585
        $this->assertEquals(0, count($gradinginfo->items));
585
        $this->assertEquals(0, count($gradinginfo->items));
Línea 586... Línea 586...
586
    }
586
    }
587
 
587
 
588
    public function test_delete_instance() {
588
    public function test_delete_instance(): void {
589
        $this->resetAfterTest();
589
        $this->resetAfterTest();
590
        $course = $this->getDataGenerator()->create_course();
590
        $course = $this->getDataGenerator()->create_course();
Línea 606... Línea 606...
606
        // Now try and delete.
606
        // Now try and delete.
607
        $this->setUser($teacher);
607
        $this->setUser($teacher);
608
        $this->assertEquals(true, $assign->delete_instance());
608
        $this->assertEquals(true, $assign->delete_instance());
609
    }
609
    }
Línea 610... Línea 610...
610
 
610
 
611
    public function test_reset_userdata() {
611
    public function test_reset_userdata(): void {
Línea 612... Línea 612...
612
        global $DB;
612
        global $DB;
613
 
613
 
614
        $this->resetAfterTest();
614
        $this->resetAfterTest();
Línea 685... Línea 685...
685
        $this->assertEquals($assignduedate + (4 * DAYSECS), $instance->duedate);
685
        $this->assertEquals($assignduedate + (4 * DAYSECS), $instance->duedate);
686
        $instance2 = $DB->get_record('assign', array('id' => $assign2->get_instance()->id));
686
        $instance2 = $DB->get_record('assign', array('id' => $assign2->get_instance()->id));
687
        $this->assertEquals($assign2duedate + (4 * DAYSECS), $instance2->duedate);
687
        $this->assertEquals($assign2duedate + (4 * DAYSECS), $instance2->duedate);
688
    }
688
    }
Línea 689... Línea 689...
689
 
689
 
690
    public function test_plugin_settings() {
690
    public function test_plugin_settings(): void {
Línea 691... Línea 691...
691
        global $DB;
691
        global $DB;
Línea 692... Línea 692...
692
 
692
 
Línea 705... Línea 705...
705
 
705
 
706
        $plugin = $assign->get_submission_plugin_by_type('file');
706
        $plugin = $assign->get_submission_plugin_by_type('file');
707
        $this->assertEquals('12', $plugin->get_config('maxfilesubmissions'));
707
        $this->assertEquals('12', $plugin->get_config('maxfilesubmissions'));
Línea 708... Línea 708...
708
    }
708
    }
709
 
709
 
Línea 710... Línea 710...
710
    public function test_update_calendar() {
710
    public function test_update_calendar(): void {
Línea 711... Línea 711...
711
        global $DB;
711
        global $DB;
Línea 782... Línea 782...
782
 
782
 
Línea 783... Línea 783...
783
        $this->assertStringContainsString('Some text', $event->description);
783
        $this->assertStringContainsString('Some text', $event->description);
Línea 784... Línea 784...
784
 
784
 
785
    }
785
    }
Línea 786... Línea 786...
786
 
786
 
Línea 787... Línea 787...
787
    public function test_update_instance() {
787
    public function test_update_instance(): void {
Línea 805... Línea 805...
805
 
805
 
806
        $instance = $DB->get_record('assign', ['id' => $assign->get_instance()->id]);
806
        $instance = $DB->get_record('assign', ['id' => $assign->get_instance()->id]);
807
        $this->assertEquals($now, $instance->duedate);
807
        $this->assertEquals($now, $instance->duedate);
Línea 808... Línea 808...
808
    }
808
    }
809
 
809
 
Línea 810... Línea 810...
810
    public function test_cannot_submit_empty() {
810
    public function test_cannot_submit_empty(): void {
Línea 811... Línea 811...
811
        global $PAGE;
811
        global $PAGE;
Línea 824... Línea 824...
824
        $output = $assign->view_student_summary($student, true);
824
        $output = $assign->view_student_summary($student, true);
825
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'),
825
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'),
826
            $output, 'Can submit empty offline assignment');
826
            $output, 'Can submit empty offline assignment');
827
    }
827
    }
Línea 828... Línea 828...
828
 
828
 
829
    public function test_cannot_submit_empty_no_submission() {
829
    public function test_cannot_submit_empty_no_submission(): void {
Línea 830... Línea 830...
830
        global $PAGE;
830
        global $PAGE;
Línea 831... Línea 831...
831
 
831
 
Línea 846... Línea 846...
846
        $output = $assign->view_student_summary($student, true);
846
        $output = $assign->view_student_summary($student, true);
847
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'),
847
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'),
848
            $output, 'Cannot submit empty onlinetext assignment');
848
            $output, 'Cannot submit empty onlinetext assignment');
849
    }
849
    }
Línea 850... Línea 850...
850
 
850
 
851
    public function test_can_submit_with_submission() {
851
    public function test_can_submit_with_submission(): void {
Línea 852... Línea 852...
852
        global $PAGE;
852
        global $PAGE;
Línea 853... Línea 853...
853
 
853
 
Línea 881... Línea 881...
881
     *
881
     *
882
     * @dataProvider new_submission_empty_testcases
882
     * @dataProvider new_submission_empty_testcases
883
     * @param string $data The file submission data
883
     * @param string $data The file submission data
884
     * @param bool $expected The expected return value
884
     * @param bool $expected The expected return value
885
     */
885
     */
886
    public function test_new_submission_empty($data, $expected) {
886
    public function test_new_submission_empty($data, $expected): void {
887
        $this->resetAfterTest();
887
        $this->resetAfterTest();
Línea 888... Línea 888...
888
 
888
 
889
        $course = $this->getDataGenerator()->create_course();
889
        $course = $this->getDataGenerator()->create_course();
Línea 934... Línea 934...
934
                false
934
                false
935
            ]
935
            ]
936
        ];
936
        ];
937
    }
937
    }
Línea 938... Línea 938...
938
 
938
 
939
    public function test_list_participants() {
939
    public function test_list_participants(): void {
Línea 940... Línea 940...
940
        global $CFG;
940
        global $CFG;
Línea 941... Línea 941...
941
 
941
 
Línea 953... Línea 953...
953
        $assign = $this->create_instance($course, ['grade' => 100]);
953
        $assign = $this->create_instance($course, ['grade' => 100]);
Línea 954... Línea 954...
954
 
954
 
955
        $this->assertCount(10, $assign->list_participants(null, true));
955
        $this->assertCount(10, $assign->list_participants(null, true));
Línea 956... Línea 956...
956
    }
956
    }
957
 
957
 
Línea 958... Línea 958...
958
    public function test_list_participants_activeenrol() {
958
    public function test_list_participants_activeenrol(): void {
Línea 959... Línea 959...
959
        global $CFG, $DB;
959
        global $CFG, $DB;
Línea 978... Línea 978...
978
        $assign = $this->create_instance($course, ['grade' => 100]);
978
        $assign = $this->create_instance($course, ['grade' => 100]);
Línea 979... Línea 979...
979
 
979
 
980
        $this->assertCount(10, $assign->list_participants(null, true));
980
        $this->assertCount(10, $assign->list_participants(null, true));
Línea 981... Línea 981...
981
    }
981
    }
982
 
982
 
Línea 983... Línea 983...
983
    public function test_list_participants_with_group_restriction() {
983
    public function test_list_participants_with_group_restriction(): void {
Línea 984... Línea 984...
984
        global $CFG;
984
        global $CFG;
Línea 1005... Línea 1005...
1005
        groups_add_member($specialgroup, $student);
1005
        groups_add_member($specialgroup, $student);
1006
        groups_add_member($specialgroup, $otherstudent);
1006
        groups_add_member($specialgroup, $otherstudent);
1007
        $this->assertEquals(2, count($assign->list_participants(null, true)));
1007
        $this->assertEquals(2, count($assign->list_participants(null, true)));
1008
    }
1008
    }
Línea 1009... Línea 1009...
1009
 
1009
 
1010
    public function test_get_participant_user_not_exist() {
1010
    public function test_get_participant_user_not_exist(): void {
1011
        $this->resetAfterTest();
1011
        $this->resetAfterTest();
Línea 1012... Línea 1012...
1012
        $course = $this->getDataGenerator()->create_course();
1012
        $course = $this->getDataGenerator()->create_course();
1013
 
1013
 
1014
        $assign = $this->create_instance($course);
1014
        $assign = $this->create_instance($course);
Línea 1015... Línea 1015...
1015
        $this->assertNull($assign->get_participant('-1'));
1015
        $this->assertNull($assign->get_participant('-1'));
1016
    }
1016
    }
1017
 
1017
 
1018
    public function test_get_participant_not_enrolled() {
1018
    public function test_get_participant_not_enrolled(): void {
Línea 1019... Línea 1019...
1019
        $this->resetAfterTest();
1019
        $this->resetAfterTest();
1020
        $course = $this->getDataGenerator()->create_course();
1020
        $course = $this->getDataGenerator()->create_course();
1021
        $assign = $this->create_instance($course);
1021
        $assign = $this->create_instance($course);
Línea 1022... Línea 1022...
1022
 
1022
 
1023
        $user = $this->getDataGenerator()->create_user();
1023
        $user = $this->getDataGenerator()->create_user();
1024
        $this->assertNull($assign->get_participant($user->id));
1024
        $this->assertNull($assign->get_participant($user->id));
1025
    }
1025
    }
1026
 
1026
 
Línea 1036... Línea 1036...
1036
        $this->assertFalse($participant->submitted);
1036
        $this->assertFalse($participant->submitted);
1037
        $this->assertFalse($participant->requiregrading);
1037
        $this->assertFalse($participant->requiregrading);
1038
        $this->assertFalse($participant->grantedextension);
1038
        $this->assertFalse($participant->grantedextension);
1039
    }
1039
    }
Línea 1040... Línea 1040...
1040
 
1040
 
1041
    public function test_get_participant_granted_extension() {
1041
    public function test_get_participant_granted_extension(): void {
1042
        $this->resetAfterTest();
1042
        $this->resetAfterTest();
1043
        $course = $this->getDataGenerator()->create_course();
1043
        $course = $this->getDataGenerator()->create_course();
1044
        $assign = $this->create_instance($course);
1044
        $assign = $this->create_instance($course);
1045
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
1045
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 1053... Línea 1053...
1053
        $this->assertFalse($participant->submitted);
1053
        $this->assertFalse($participant->submitted);
1054
        $this->assertFalse($participant->requiregrading);
1054
        $this->assertFalse($participant->requiregrading);
1055
        $this->assertTrue($participant->grantedextension);
1055
        $this->assertTrue($participant->grantedextension);
1056
    }
1056
    }
Línea 1057... Línea 1057...
1057
 
1057
 
1058
    public function test_get_participant_with_ungraded_submission() {
1058
    public function test_get_participant_with_ungraded_submission(): void {
1059
        $this->resetAfterTest();
1059
        $this->resetAfterTest();
1060
        $course = $this->getDataGenerator()->create_course();
1060
        $course = $this->getDataGenerator()->create_course();
1061
        $assign = $this->create_instance($course);
1061
        $assign = $this->create_instance($course);
1062
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
1062
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 1075... Línea 1075...
1075
    }
1075
    }
Línea 1076... Línea 1076...
1076
 
1076
 
1077
    /**
1077
    /**
1078
     * Tests that if a student with no submission who can no longer submit is not a participant.
1078
     * Tests that if a student with no submission who can no longer submit is not a participant.
1079
     */
1079
     */
1080
    public function test_get_participant_with_no_submission_no_capability() {
1080
    public function test_get_participant_with_no_submission_no_capability(): void {
1081
        global $DB;
1081
        global $DB;
1082
        $this->resetAfterTest();
1082
        $this->resetAfterTest();
1083
        $course = self::getDataGenerator()->create_course();
1083
        $course = self::getDataGenerator()->create_course();
1084
        $coursecontext = \context_course::instance($course->id);
1084
        $coursecontext = \context_course::instance($course->id);
Línea 1096... Línea 1096...
1096
    }
1096
    }
Línea 1097... Línea 1097...
1097
 
1097
 
1098
    /**
1098
    /**
1099
     * Tests that if a student that has submitted but can no longer submit is a participant.
1099
     * Tests that if a student that has submitted but can no longer submit is a participant.
1100
     */
1100
     */
1101
    public function test_get_participant_with_submission_no_capability() {
1101
    public function test_get_participant_with_submission_no_capability(): void {
1102
        global $DB;
1102
        global $DB;
1103
        $this->resetAfterTest();
1103
        $this->resetAfterTest();
1104
        $course = self::getDataGenerator()->create_course();
1104
        $course = self::getDataGenerator()->create_course();
1105
        $coursecontext = \context_course::instance($course->id);
1105
        $coursecontext = \context_course::instance($course->id);
Línea 1122... Línea 1122...
1122
        self::assertTrue($participant->submitted);
1122
        self::assertTrue($participant->submitted);
1123
        self::assertTrue($participant->requiregrading);
1123
        self::assertTrue($participant->requiregrading);
1124
        self::assertFalse($participant->grantedextension);
1124
        self::assertFalse($participant->grantedextension);
1125
    }
1125
    }
Línea 1126... Línea 1126...
1126
 
1126
 
1127
    public function test_get_participant_with_graded_submission() {
1127
    public function test_get_participant_with_graded_submission(): void {
1128
        $this->resetAfterTest();
1128
        $this->resetAfterTest();
1129
        $course = $this->getDataGenerator()->create_course();
1129
        $course = $this->getDataGenerator()->create_course();
1130
        $assign = $this->create_instance($course);
1130
        $assign = $this->create_instance($course);
1131
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
1131
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 1150... Línea 1150...
1150
    }
1150
    }
Línea 1151... Línea 1151...
1151
 
1151
 
1152
    /**
1152
    /**
1153
     * No active group and non-group submissions disallowed => 2 groups.
1153
     * No active group and non-group submissions disallowed => 2 groups.
1154
     */
1154
     */
1155
    public function test_count_teams_no_active_non_group_allowed() {
1155
    public function test_count_teams_no_active_non_group_allowed(): void {
Línea 1156... Línea 1156...
1156
        $this->resetAfterTest();
1156
        $this->resetAfterTest();
1157
 
1157
 
1158
        $course = $this->getDataGenerator()->create_course();
1158
        $course = $this->getDataGenerator()->create_course();
Línea 1173... Línea 1173...
1173
    }
1173
    }
Línea 1174... Línea 1174...
1174
 
1174
 
1175
    /**
1175
    /**
1176
     * No active group and non group submissions allowed => 2 groups + the default one.
1176
     * No active group and non group submissions allowed => 2 groups + the default one.
1177
     */
1177
     */
1178
    public function test_count_teams_non_group_allowed() {
1178
    public function test_count_teams_non_group_allowed(): void {
Línea 1179... Línea 1179...
1179
        $this->resetAfterTest();
1179
        $this->resetAfterTest();
1180
 
1180
 
1181
        $course = $this->getDataGenerator()->create_course();
1181
        $course = $this->getDataGenerator()->create_course();
Línea 1209... Línea 1209...
1209
    }
1209
    }
Línea 1210... Línea 1210...
1210
 
1210
 
1211
    /**
1211
    /**
1212
     * Active group => just selected one.
1212
     * Active group => just selected one.
1213
     */
1213
     */
1214
    public function test_count_teams_no_active_group() {
1214
    public function test_count_teams_no_active_group(): void {
Línea 1215... Línea 1215...
1215
        $this->resetAfterTest();
1215
        $this->resetAfterTest();
1216
 
1216
 
1217
        $course = $this->getDataGenerator()->create_course();
1217
        $course = $this->getDataGenerator()->create_course();
Línea 1244... Línea 1244...
1244
    }
1244
    }
Línea 1245... Línea 1245...
1245
 
1245
 
1246
    /**
1246
    /**
1247
     * Active group => just selected one.
1247
     * Active group => just selected one.
1248
     */
1248
     */
1249
    public function test_count_teams_groups_only() {
1249
    public function test_count_teams_groups_only(): void {
Línea 1250... Línea 1250...
1250
        $this->resetAfterTest();
1250
        $this->resetAfterTest();
1251
 
1251
 
Línea 1277... Línea 1277...
1277
            'preventsubmissionnotingroup' => true,
1277
            'preventsubmissionnotingroup' => true,
1278
        ]);
1278
        ]);
1279
        $this->assertEquals(2, $assign->count_teams());
1279
        $this->assertEquals(2, $assign->count_teams());
1280
    }
1280
    }
Línea 1281... Línea 1281...
1281
 
1281
 
1282
    public function test_submit_to_default_group() {
1282
    public function test_submit_to_default_group(): void {
Línea 1283... Línea 1283...
1283
        global $DB, $SESSION;
1283
        global $DB, $SESSION;
Línea 1284... Línea 1284...
1284
 
1284
 
Línea 1313... Línea 1313...
1313
        // Set an active group.
1313
        // Set an active group.
1314
        $SESSION->activegroup[$course->id]['aag'][0] = (int) $group->id;
1314
        $SESSION->activegroup[$course->id]['aag'][0] = (int) $group->id;
1315
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1315
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1316
    }
1316
    }
Línea 1317... Línea 1317...
1317
 
1317
 
1318
    public function test_count_submissions_no_draft() {
1318
    public function test_count_submissions_no_draft(): void {
Línea 1319... Línea 1319...
1319
        $this->resetAfterTest();
1319
        $this->resetAfterTest();
1320
 
1320
 
1321
        $course = $this->getDataGenerator()->create_course();
1321
        $course = $this->getDataGenerator()->create_course();
Línea 1337... Línea 1337...
1337
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1337
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1338
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1338
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1339
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1339
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1340
    }
1340
    }
Línea 1341... Línea 1341...
1341
 
1341
 
1342
    public function test_count_submissions_draft() {
1342
    public function test_count_submissions_draft(): void {
Línea 1343... Línea 1343...
1343
        $this->resetAfterTest();
1343
        $this->resetAfterTest();
1344
 
1344
 
1345
        $course = $this->getDataGenerator()->create_course();
1345
        $course = $this->getDataGenerator()->create_course();
Línea 1361... Línea 1361...
1361
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1361
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1362
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1362
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1363
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1363
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1364
    }
1364
    }
Línea 1365... Línea 1365...
1365
 
1365
 
1366
    public function test_count_submissions_submitted() {
1366
    public function test_count_submissions_submitted(): void {
Línea 1367... Línea 1367...
1367
        global $SESSION;
1367
        global $SESSION;
Línea 1368... Línea 1368...
1368
 
1368
 
Línea 1387... Línea 1387...
1387
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1387
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1388
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1388
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1389
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1389
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1390
    }
1390
    }
Línea 1391... Línea 1391...
1391
 
1391
 
1392
    public function test_count_submissions_graded() {
1392
    public function test_count_submissions_graded(): void {
Línea 1393... Línea 1393...
1393
        $this->resetAfterTest();
1393
        $this->resetAfterTest();
1394
 
1394
 
1395
        $course = $this->getDataGenerator()->create_course();
1395
        $course = $this->getDataGenerator()->create_course();
Línea 1413... Línea 1413...
1413
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1413
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1414
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1414
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1415
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1415
        $this->assertEquals(0, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_REOPENED));
1416
    }
1416
    }
Línea 1417... Línea 1417...
1417
 
1417
 
1418
    public function test_count_submissions_graded_group() {
1418
    public function test_count_submissions_graded_group(): void {
Línea 1419... Línea 1419...
1419
        global $SESSION;
1419
        global $SESSION;
Línea 1420... Línea 1420...
1420
 
1420
 
Línea 1529... Línea 1529...
1529
        $this->assertEquals(5, $assign->count_submissions(true));
1529
        $this->assertEquals(5, $assign->count_submissions(true));
1530
        $this->assertEquals(3, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1530
        $this->assertEquals(3, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_SUBMITTED));
1531
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1531
        $this->assertEquals(1, $assign->count_submissions_with_status(ASSIGN_SUBMISSION_STATUS_DRAFT));
1532
    }
1532
    }
Línea 1533... Línea 1533...
1533
 
1533
 
1534
    public function test_get_grading_userid_list_only_active() {
1534
    public function test_get_grading_userid_list_only_active(): void {
Línea 1535... Línea 1535...
1535
        $this->resetAfterTest();
1535
        $this->resetAfterTest();
1536
 
1536
 
1537
        $course = $this->getDataGenerator()->create_course();
1537
        $course = $this->getDataGenerator()->create_course();
Línea 1544... Línea 1544...
1544
 
1544
 
1545
        $assign = $this->create_instance($course);
1545
        $assign = $this->create_instance($course);
1546
        $this->assertCount(1, $assign->testable_get_grading_userid_list());
1546
        $this->assertCount(1, $assign->testable_get_grading_userid_list());
Línea 1547... Línea 1547...
1547
    }
1547
    }
1548
 
1548
 
Línea 1549... Línea 1549...
1549
    public function test_get_grading_userid_list_all() {
1549
    public function test_get_grading_userid_list_all(): void {
1550
        $this->resetAfterTest();
1550
        $this->resetAfterTest();
1551
 
1551
 
Línea 1560... Línea 1560...
1560
 
1560
 
1561
        $assign = $this->create_instance($course);
1561
        $assign = $this->create_instance($course);
1562
        $this->assertCount(2, $assign->testable_get_grading_userid_list());
1562
        $this->assertCount(2, $assign->testable_get_grading_userid_list());
Línea 1563... Línea 1563...
1563
    }
1563
    }
1564
 
1564
 
1565
    public function test_cron() {
1565
    public function test_cron(): void {
Línea 1566... Línea 1566...
1566
        global $PAGE;
1566
        global $PAGE;
1567
        $this->resetAfterTest();
1567
        $this->resetAfterTest();
Línea 1603... Línea 1603...
1603
        $this->assertEquals($userpicture->get_url($PAGE)->out(false), $customdata->notificationiconurl);
1603
        $this->assertEquals($userpicture->get_url($PAGE)->out(false), $customdata->notificationiconurl);
1604
        $this->assertEquals(0, $customdata->uniqueidforuser);   // Not used in this case.
1604
        $this->assertEquals(0, $customdata->uniqueidforuser);   // Not used in this case.
1605
        $this->assertFalse($customdata->blindmarking);
1605
        $this->assertFalse($customdata->blindmarking);
1606
    }
1606
    }
Línea 1607... Línea 1607...
1607
 
1607
 
1608
    public function test_cron_without_notifications() {
1608
    public function test_cron_without_notifications(): void {
Línea 1609... Línea 1609...
1609
        $this->resetAfterTest();
1609
        $this->resetAfterTest();
1610
 
1610
 
1611
        // First run cron so there are no messages waiting to be sent (from other tests).
1611
        // First run cron so there are no messages waiting to be sent (from other tests).
Línea 1634... Línea 1634...
1634
        $messages = $sink->get_messages();
1634
        $messages = $sink->get_messages();
Línea 1635... Línea 1635...
1635
 
1635
 
1636
        $this->assertEquals(0, count($messages));
1636
        $this->assertEquals(0, count($messages));
Línea 1637... Línea 1637...
1637
    }
1637
    }
1638
 
1638
 
Línea 1639... Línea 1639...
1639
    public function test_cron_regraded() {
1639
    public function test_cron_regraded(): void {
1640
        $this->resetAfterTest();
1640
        $this->resetAfterTest();
1641
 
1641
 
Línea 1676... Línea 1676...
1676
    }
1676
    }
Línea 1677... Línea 1677...
1677
 
1677
 
1678
    /**
1678
    /**
1679
     * Test delivery of grade notifications as controlled by marking workflow.
1679
     * Test delivery of grade notifications as controlled by marking workflow.
1680
     */
1680
     */
1681
    public function test_markingworkflow_cron() {
1681
    public function test_markingworkflow_cron(): void {
Línea 1682... Línea 1682...
1682
        $this->resetAfterTest();
1682
        $this->resetAfterTest();
1683
 
1683
 
1684
        // First run cron so there are no messages waiting to be sent (from other tests).
1684
        // First run cron so there are no messages waiting to be sent (from other tests).
Línea 1728... Línea 1728...
1728
        $this->assertEquals(1, count($messages));
1728
        $this->assertEquals(1, count($messages));
1729
        $this->assertEquals(1, $messages[0]->notification);
1729
        $this->assertEquals(1, $messages[0]->notification);
1730
        $this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
1730
        $this->assertEquals($assign->get_instance()->name, $messages[0]->contexturlname);
1731
    }
1731
    }
Línea 1732... Línea 1732...
1732
 
1732
 
1733
    public function test_cron_message_includes_courseid() {
1733
    public function test_cron_message_includes_courseid(): void {
Línea 1734... Línea 1734...
1734
        $this->resetAfterTest();
1734
        $this->resetAfterTest();
1735
 
1735
 
1736
        // First run cron so there are no messages waiting to be sent (from other tests).
1736
        // First run cron so there are no messages waiting to be sent (from other tests).
Línea 1766... Línea 1766...
1766
        $this->assertInstanceOf('\core\event\notification_sent', $event);
1766
        $this->assertInstanceOf('\core\event\notification_sent', $event);
1767
        $this->assertEquals($assign->get_course()->id, $event->other['courseid']);
1767
        $this->assertEquals($assign->get_course()->id, $event->other['courseid']);
1768
        $sink->close();
1768
        $sink->close();
1769
    }
1769
    }
Línea 1770... Línea 1770...
1770
 
1770
 
1771
    public function test_is_graded() {
1771
    public function test_is_graded(): void {
Línea 1772... Línea 1772...
1772
        $this->resetAfterTest();
1772
        $this->resetAfterTest();
1773
 
1773
 
1774
        $course = $this->getDataGenerator()->create_course();
1774
        $course = $this->getDataGenerator()->create_course();
Línea 1785... Línea 1785...
1785
        $this->setUser($teacher);
1785
        $this->setUser($teacher);
1786
        $this->assertEquals(true, $assign->testable_is_graded($student->id));
1786
        $this->assertEquals(true, $assign->testable_is_graded($student->id));
1787
        $this->assertEquals(false, $assign->testable_is_graded($otherstudent->id));
1787
        $this->assertEquals(false, $assign->testable_is_graded($otherstudent->id));
1788
    }
1788
    }
Línea 1789... Línea 1789...
1789
 
1789
 
1790
    public function test_can_grade() {
1790
    public function test_can_grade(): void {
Línea 1791... Línea 1791...
1791
        global $DB;
1791
        global $DB;
Línea 1792... Línea 1792...
1792
 
1792
 
Línea 1815... Línea 1815...
1815
        $studentrole = $DB->get_record('role', array('shortname' => 'student'));
1815
        $studentrole = $DB->get_record('role', array('shortname' => 'student'));
1816
        assign_capability('mod/assign:viewgrades', CAP_ALLOW, $studentrole->id, $assign->get_context()->id);
1816
        assign_capability('mod/assign:viewgrades', CAP_ALLOW, $studentrole->id, $assign->get_context()->id);
1817
        $this->assertEquals(false, $assign->can_grade());
1817
        $this->assertEquals(false, $assign->can_grade());
1818
    }
1818
    }
Línea 1819... Línea 1819...
1819
 
1819
 
1820
    public function test_can_view_submission() {
1820
    public function test_can_view_submission(): void {
Línea 1821... Línea 1821...
1821
        global $DB;
1821
        global $DB;
Línea 1822... Línea 1822...
1822
 
1822
 
Línea 1857... Línea 1857...
1857
        $this->assertEquals(true, $assign->can_view_submission($otherstudent->id));
1857
        $this->assertEquals(true, $assign->can_view_submission($otherstudent->id));
1858
        $this->assertEquals(true, $assign->can_view_submission($teacher->id));
1858
        $this->assertEquals(true, $assign->can_view_submission($teacher->id));
1859
        $this->assertEquals(false, $assign->can_view_submission($suspendedstudent->id));
1859
        $this->assertEquals(false, $assign->can_view_submission($suspendedstudent->id));
1860
    }
1860
    }
Línea 1861... Línea 1861...
1861
 
1861
 
1862
    public function test_update_submission() {
1862
    public function test_update_submission(): void {
Línea 1863... Línea 1863...
1863
        $this->resetAfterTest();
1863
        $this->resetAfterTest();
1864
 
1864
 
1865
        $course = $this->getDataGenerator()->create_course();
1865
        $course = $this->getDataGenerator()->create_course();
Línea 1879... Línea 1879...
1879
 
1879
 
1880
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$student->id]));
1880
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$student->id]));
1881
        $this->assertEquals($student->id, $gradinginfo->items[0]->grades[$student->id]->usermodified);
1881
        $this->assertEquals($student->id, $gradinginfo->items[0]->grades[$student->id]->usermodified);
Línea 1882... Línea 1882...
1882
    }
1882
    }
1883
 
1883
 
Línea 1884... Línea 1884...
1884
    public function test_update_submission_team() {
1884
    public function test_update_submission_team(): void {
1885
        $this->resetAfterTest();
1885
        $this->resetAfterTest();
1886
 
1886
 
Línea 1921... Línea 1921...
1921
 
1921
 
1922
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$otherstudent->id]));
1922
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$otherstudent->id]));
1923
        $this->assertEquals($otherstudent->id, $gradinginfo->items[0]->grades[$otherstudent->id]->usermodified);
1923
        $this->assertEquals($otherstudent->id, $gradinginfo->items[0]->grades[$otherstudent->id]->usermodified);
Línea 1924... Línea 1924...
1924
    }
1924
    }
1925
 
1925
 
Línea 1926... Línea 1926...
1926
    public function test_update_submission_suspended() {
1926
    public function test_update_submission_suspended(): void {
1927
        $this->resetAfterTest();
1927
        $this->resetAfterTest();
1928
 
1928
 
Línea 1943... Línea 1943...
1943
 
1943
 
1944
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$student->id]));
1944
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$student->id]));
1945
        $this->assertEquals($student->id, $gradinginfo->items[0]->grades[$student->id]->usermodified);
1945
        $this->assertEquals($student->id, $gradinginfo->items[0]->grades[$student->id]->usermodified);
Línea 1946... Línea 1946...
1946
    }
1946
    }
1947
 
1947
 
Línea 1948... Línea 1948...
1948
    public function test_update_submission_blind() {
1948
    public function test_update_submission_blind(): void {
1949
        $this->resetAfterTest();
1949
        $this->resetAfterTest();
1950
 
1950
 
Línea 1966... Línea 1966...
1966
        // The usermodified is not set because this is blind marked.
1966
        // The usermodified is not set because this is blind marked.
1967
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$student->id]));
1967
        $this->assertTrue(isset($gradinginfo->items[0]->grades[$student->id]));
1968
        $this->assertNull($gradinginfo->items[0]->grades[$student->id]->usermodified);
1968
        $this->assertNull($gradinginfo->items[0]->grades[$student->id]->usermodified);
1969
    }
1969
    }
Línea 1970... Línea 1970...
1970
 
1970
 
1971
    public function test_group_submissions_submit_for_marking_requireallteammemberssubmit() {
1971
    public function test_group_submissions_submit_for_marking_requireallteammemberssubmit(): void {
Línea 1972... Línea 1972...
1972
        global $PAGE;
1972
        global $PAGE;
Línea 1973... Línea 1973...
1973
 
1973
 
Línea 2020... Línea 2020...
2020
        $assign->testable_update_submission($submission, $otherstudent->id, true, true);
2020
        $assign->testable_update_submission($submission, $otherstudent->id, true, true);
2021
        $output = $assign->view_submission_action_bar($assign->get_instance(), $otherstudent);
2021
        $output = $assign->view_submission_action_bar($assign->get_instance(), $otherstudent);
2022
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'), $output);
2022
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'), $output);
2023
    }
2023
    }
Línea 2024... Línea 2024...
2024
 
2024
 
2025
    public function test_group_submissions_submit_for_marking() {
2025
    public function test_group_submissions_submit_for_marking(): void {
Línea 2026... Línea 2026...
2026
        global $PAGE;
2026
        global $PAGE;
Línea 2027... Línea 2027...
2027
 
2027
 
Línea 2084... Línea 2084...
2084
        $assign->testable_update_submission($submission, $otherstudent->id, true, true);
2084
        $assign->testable_update_submission($submission, $otherstudent->id, true, true);
2085
        $output = $assign->view_submission_action_bar($assign->get_instance(), $otherstudent);
2085
        $output = $assign->view_submission_action_bar($assign->get_instance(), $otherstudent);
2086
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'), $output);
2086
        $this->assertStringNotContainsString(get_string('submitassignment', 'assign'), $output);
2087
    }
2087
    }
Línea 2088... Línea 2088...
2088
 
2088
 
2089
    public function test_submissions_open() {
2089
    public function test_submissions_open(): void {
Línea 2090... Línea 2090...
2090
        global $DB;
2090
        global $DB;
Línea 2091... Línea 2091...
2091
 
2091
 
Línea 2134... Línea 2134...
2134
 
2134
 
2135
        $this->setUser($teacher);
2135
        $this->setUser($teacher);
2136
        $this->assertEquals(false, $assign->testable_submissions_open($student->id));
2136
        $this->assertEquals(false, $assign->testable_submissions_open($student->id));
Línea 2137... Línea 2137...
2137
    }
2137
    }
2138
 
2138
 
Línea 2139... Línea 2139...
2139
    public function test_get_graders() {
2139
    public function test_get_graders(): void {
Línea 2140... Línea 2140...
2140
        global $DB;
2140
        global $DB;
Línea 2151... Línea 2151...
2151
        // Create an assignment with no groups.
2151
        // Create an assignment with no groups.
2152
        $assign = $this->create_instance($course);
2152
        $assign = $this->create_instance($course);
2153
        $this->assertCount(2, $assign->testable_get_graders($student->id));
2153
        $this->assertCount(2, $assign->testable_get_graders($student->id));
2154
    }
2154
    }
Línea 2155... Línea 2155...
2155
 
2155
 
2156
    public function test_get_graders_separate_groups() {
2156
    public function test_get_graders_separate_groups(): void {
Línea 2157... Línea 2157...
2157
        global $DB;
2157
        global $DB;
Línea 2158... Línea 2158...
2158
 
2158
 
Línea 2186... Línea 2186...
2186
        // Note the second student is in a group that is not in the grouping.
2186
        // Note the second student is in a group that is not in the grouping.
2187
        // This means that we get all graders that are not in a group in the grouping.
2187
        // This means that we get all graders that are not in a group in the grouping.
2188
        $this->assertCount(4, $assign->testable_get_graders($otherstudent->id));
2188
        $this->assertCount(4, $assign->testable_get_graders($otherstudent->id));
2189
    }
2189
    }
Línea 2190... Línea 2190...
2190
 
2190
 
2191
    public function test_get_notified_users() {
2191
    public function test_get_notified_users(): void {
Línea 2192... Línea 2192...
2192
        global $CFG, $DB;
2192
        global $CFG, $DB;
Línea 2193... Línea 2193...
2193
 
2193
 
Línea 2230... Línea 2230...
2230
        // Note the second student is in a group that is not in the grouping.
2230
        // Note the second student is in a group that is not in the grouping.
2231
        // This means that we get all graders that are not in a group in the grouping.
2231
        // This means that we get all graders that are not in a group in the grouping.
2232
        $this->assertCount(1, $assign->testable_get_notifiable_users($otherstudent->id));
2232
        $this->assertCount(1, $assign->testable_get_notifiable_users($otherstudent->id));
2233
    }
2233
    }
Línea 2234... Línea 2234...
2234
 
2234
 
2235
    public function test_get_notified_users_in_grouping() {
2235
    public function test_get_notified_users_in_grouping(): void {
Línea 2236... Línea 2236...
2236
        global $CFG, $DB;
2236
        global $CFG, $DB;
Línea 2237... Línea 2237...
2237
 
2237
 
Línea 2281... Línea 2281...
2281
        // This means that we get all graders that are not in a group in the grouping.
2281
        // This means that we get all graders that are not in a group in the grouping.
2282
        // Unfortunately there are no editing teachers who are not in a group.
2282
        // Unfortunately there are no editing teachers who are not in a group.
2283
        $this->assertCount(0, $assign->testable_get_notifiable_users($otherstudent->id));
2283
        $this->assertCount(0, $assign->testable_get_notifiable_users($otherstudent->id));
2284
    }
2284
    }
Línea 2285... Línea 2285...
2285
 
2285
 
2286
    public function test_group_members_only() {
2286
    public function test_group_members_only(): void {
Línea 2287... Línea 2287...
2287
        global $CFG;
2287
        global $CFG;
Línea 2288... Línea 2288...
2288
 
2288
 
Línea 2341... Línea 2341...
2341
        $this->assertCount(2, $participants);
2341
        $this->assertCount(2, $participants);
2342
        $this->assertTrue(isset($participants[$student->id]));
2342
        $this->assertTrue(isset($participants[$student->id]));
2343
        $this->assertTrue(isset($participants[$otherstudent->id]));
2343
        $this->assertTrue(isset($participants[$otherstudent->id]));
2344
    }
2344
    }
Línea 2345... Línea 2345...
2345
 
2345
 
2346
    public function test_get_uniqueid_for_user() {
2346
    public function test_get_uniqueid_for_user(): void {
Línea 2347... Línea 2347...
2347
        $this->resetAfterTest();
2347
        $this->resetAfterTest();
2348
 
2348
 
2349
        $course = $this->getDataGenerator()->create_course();
2349
        $course = $this->getDataGenerator()->create_course();
Línea 2361... Línea 2361...
2361
            $uniqueid = $assign->get_uniqueid_for_user($student->id);
2361
            $uniqueid = $assign->get_uniqueid_for_user($student->id);
2362
            $this->assertEquals($student->id, $assign->get_user_id_for_uniqueid($uniqueid));
2362
            $this->assertEquals($student->id, $assign->get_user_id_for_uniqueid($uniqueid));
2363
        }
2363
        }
2364
    }
2364
    }
Línea 2365... Línea 2365...
2365
 
2365
 
2366
    public function test_show_student_summary() {
2366
    public function test_show_student_summary(): void {
Línea 2367... Línea 2367...
2367
        global $CFG, $PAGE;
2367
        global $CFG, $PAGE;
Línea 2368... Línea 2368...
2368
 
2368
 
Línea 2425... Línea 2425...
2425
        $this->setUser($student);
2425
        $this->setUser($student);
2426
        $output = $assign->view_student_summary($student, true);
2426
        $output = $assign->view_student_summary($student, true);
2427
        $this->assertMatchesRegularExpression('/Feedback/', $output, 'Show feedback if there is a grade');
2427
        $this->assertMatchesRegularExpression('/Feedback/', $output, 'Show feedback if there is a grade');
2428
    }
2428
    }
Línea 2429... Línea 2429...
2429
 
2429
 
2430
    public function test_show_student_summary_with_feedback() {
2430
    public function test_show_student_summary_with_feedback(): void {
Línea 2431... Línea 2431...
2431
        global $CFG, $PAGE;
2431
        global $CFG, $PAGE;
Línea 2432... Línea 2432...
2432
 
2432
 
Línea 2498... Línea 2498...
2498
    }
2498
    }
Línea 2499... Línea 2499...
2499
 
2499
 
2500
    /**
2500
    /**
2501
     * Test reopen behavior when in "Manual" mode.
2501
     * Test reopen behavior when in "Manual" mode.
2502
     */
2502
     */
2503
    public function test_attempt_reopen_method_manual() {
2503
    public function test_attempt_reopen_method_manual(): void {
Línea 2504... Línea 2504...
2504
        global $PAGE;
2504
        global $PAGE;
2505
 
2505
 
2506
        $this->resetAfterTest();
2506
        $this->resetAfterTest();
Línea 2596... Línea 2596...
2596
    }
2596
    }
Línea 2597... Línea 2597...
2597
 
2597
 
2598
    /**
2598
    /**
2599
     * Test reopen behavior when in "Reopen until pass" mode.
2599
     * Test reopen behavior when in "Reopen until pass" mode.
2600
     */
2600
     */
2601
    public function test_attempt_reopen_method_untilpass() {
2601
    public function test_attempt_reopen_method_untilpass(): void {
Línea 2602... Línea 2602...
2602
        global $PAGE;
2602
        global $PAGE;
2603
 
2603
 
2604
        $this->resetAfterTest();
2604
        $this->resetAfterTest();
Línea 2670... Línea 2670...
2670
        $output = $assign->view_submission_action_bar($assign->get_instance(), $student);
2670
        $output = $assign->view_submission_action_bar($assign->get_instance(), $student);
2671
        $this->assertMatchesRegularExpression('/' . get_string('addnewattempt', 'assign') . '/', $output);
2671
        $this->assertMatchesRegularExpression('/' . get_string('addnewattempt', 'assign') . '/', $output);
2672
        $this->assertNotEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
2672
        $this->assertNotEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
2673
    }
2673
    }
Línea 2674... Línea 2674...
2674
 
2674
 
2675
    public function test_attempt_reopen_method_untilpass_passing() {
2675
    public function test_attempt_reopen_method_untilpass_passing(): void {
Línea 2676... Línea 2676...
2676
        global $PAGE;
2676
        global $PAGE;
2677
 
2677
 
2678
        $this->resetAfterTest();
2678
        $this->resetAfterTest();
Línea 2713... Línea 2713...
2713
        // Check that the student does not have a button for Add a new attempt.
2713
        // Check that the student does not have a button for Add a new attempt.
2714
        $output = $assign->view_student_summary($student, true);
2714
        $output = $assign->view_student_summary($student, true);
2715
        $this->assertEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
2715
        $this->assertEquals(false, strpos($output, get_string('addnewattempt', 'assign')));
2716
    }
2716
    }
Línea 2717... Línea 2717...
2717
 
2717
 
2718
    public function test_attempt_reopen_method_untilpass_no_passing_requirement() {
2718
    public function test_attempt_reopen_method_untilpass_no_passing_requirement(): void {
Línea 2719... Línea 2719...
2719
        global $PAGE;
2719
        global $PAGE;
2720
 
2720
 
2721
        $this->resetAfterTest();
2721
        $this->resetAfterTest();
Línea 2759... Línea 2759...
2759
    }
2759
    }
Línea 2760... Línea 2760...
2760
 
2760
 
2761
    /**
2761
    /**
2762
     * Test student visibility for each stage of the marking workflow.
2762
     * Test student visibility for each stage of the marking workflow.
2763
     */
2763
     */
2764
    public function test_markingworkflow() {
2764
    public function test_markingworkflow(): void {
Línea 2765... Línea 2765...
2765
        global $PAGE;
2765
        global $PAGE;
2766
 
2766
 
2767
        $this->resetAfterTest();
2767
        $this->resetAfterTest();
Línea 2861... Línea 2861...
2861
    }
2861
    }
Línea 2862... Línea 2862...
2862
 
2862
 
2863
    /**
2863
    /**
2864
     * Test that a student allocated a specific marker is only shown to that marker.
2864
     * Test that a student allocated a specific marker is only shown to that marker.
2865
     */
2865
     */
2866
    public function test_markerallocation() {
2866
    public function test_markerallocation(): void {
Línea 2867... Línea 2867...
2867
        global $PAGE;
2867
        global $PAGE;
2868
 
2868
 
2869
        $this->resetAfterTest();
2869
        $this->resetAfterTest();
Línea 2901... Línea 2901...
2901
    }
2901
    }
Línea 2902... Línea 2902...
2902
 
2902
 
2903
    /**
2903
    /**
2904
     * Ensure that a teacher cannot submit for students as standard.
2904
     * Ensure that a teacher cannot submit for students as standard.
2905
     */
2905
     */
2906
    public function test_teacher_submit_for_student() {
2906
    public function test_teacher_submit_for_student(): void {
Línea 2907... Línea 2907...
2907
        global $PAGE;
2907
        global $PAGE;
2908
 
2908
 
2909
        $this->resetAfterTest();
2909
        $this->resetAfterTest();
Línea 2933... Línea 2933...
2933
    }
2933
    }
Línea 2934... Línea 2934...
2934
 
2934
 
2935
    /**
2935
    /**
2936
     * Ensure that a teacher with the editothersubmission capability can submit on behalf of a student.
2936
     * Ensure that a teacher with the editothersubmission capability can submit on behalf of a student.
2937
     */
2937
     */
2938
    public function test_teacher_submit_for_student_with_capability() {
2938
    public function test_teacher_submit_for_student_with_capability(): void {
Línea 2939... Línea 2939...
2939
        global $PAGE;
2939
        global $PAGE;
2940
 
2940
 
2941
        $this->resetAfterTest();
2941
        $this->resetAfterTest();
Línea 3000... Línea 3000...
3000
    }
3000
    }
Línea 3001... Línea 3001...
3001
 
3001
 
3002
    /**
3002
    /**
3003
     * Ensure that disabling submit after the cutoff date works as expected.
3003
     * Ensure that disabling submit after the cutoff date works as expected.
3004
     */
3004
     */
3005
    public function test_disable_submit_after_cutoff_date() {
3005
    public function test_disable_submit_after_cutoff_date(): void {
Línea 3006... Línea 3006...
3006
        global $PAGE;
3006
        global $PAGE;
3007
 
3007
 
3008
        $this->resetAfterTest();
3008
        $this->resetAfterTest();
Línea 3053... Línea 3053...
3053
     * @dataProvider submission_plugin_settings_provider
3053
     * @dataProvider submission_plugin_settings_provider
3054
     * @param   bool    $globalenabled
3054
     * @param   bool    $globalenabled
3055
     * @param   array   $instanceconfig
3055
     * @param   array   $instanceconfig
3056
     * @param   bool    $isenabled
3056
     * @param   bool    $isenabled
3057
     */
3057
     */
3058
    public function test_submission_comment_plugin_settings($globalenabled, $instanceconfig, $isenabled) {
3058
    public function test_submission_comment_plugin_settings($globalenabled, $instanceconfig, $isenabled): void {
3059
        global $CFG;
3059
        global $CFG;
Línea 3060... Línea 3060...
3060
 
3060
 
3061
        $this->resetAfterTest();
3061
        $this->resetAfterTest();
Línea 3111... Línea 3111...
3111
    }
3111
    }
Línea 3112... Línea 3112...
3112
 
3112
 
3113
    /**
3113
    /**
3114
     * Testing for comment inline settings
3114
     * Testing for comment inline settings
3115
     */
3115
     */
3116
    public function test_feedback_comment_commentinline() {
3116
    public function test_feedback_comment_commentinline(): void {
Línea 3117... Línea 3117...
3117
        global $CFG, $USER;
3117
        global $CFG, $USER;
3118
 
3118
 
3119
        $this->resetAfterTest();
3119
        $this->resetAfterTest();
Línea 3191... Línea 3191...
3191
     *
3191
     *
3192
     * @dataProvider feedback_plugin_settings_provider
3192
     * @dataProvider feedback_plugin_settings_provider
3193
     * @param   array   $instanceconfig
3193
     * @param   array   $instanceconfig
3194
     * @param   bool    $isenabled
3194
     * @param   bool    $isenabled
3195
     */
3195
     */
3196
    public function test_feedback_plugin_settings($instanceconfig, $isenabled) {
3196
    public function test_feedback_plugin_settings($instanceconfig, $isenabled): void {
3197
        $this->resetAfterTest();
3197
        $this->resetAfterTest();
3198
        $course = $this->getDataGenerator()->create_course();
3198
        $course = $this->getDataGenerator()->create_course();
Línea 3199... Línea 3199...
3199
 
3199
 
3200
        $assign = $this->create_instance($course, $instanceconfig);
3200
        $assign = $this->create_instance($course, $instanceconfig);
Línea 3224... Línea 3224...
3224
    }
3224
    }
Línea 3225... Línea 3225...
3225
 
3225
 
3226
    /**
3226
    /**
3227
     * Testing if gradebook feedback plugin is enabled.
3227
     * Testing if gradebook feedback plugin is enabled.
3228
     */
3228
     */
3229
    public function test_is_gradebook_feedback_enabled() {
3229
    public function test_is_gradebook_feedback_enabled(): void {
3230
        $this->resetAfterTest();
3230
        $this->resetAfterTest();
3231
        $course = $this->getDataGenerator()->create_course();
3231
        $course = $this->getDataGenerator()->create_course();
3232
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3232
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 3249... Línea 3249...
3249
    }
3249
    }
Línea 3250... Línea 3250...
3250
 
3250
 
3251
    /**
3251
    /**
3252
     * Testing if gradebook feedback plugin is disabled.
3252
     * Testing if gradebook feedback plugin is disabled.
3253
     */
3253
     */
3254
    public function test_is_gradebook_feedback_disabled() {
3254
    public function test_is_gradebook_feedback_disabled(): void {
3255
        $this->resetAfterTest();
3255
        $this->resetAfterTest();
3256
        $course = $this->getDataGenerator()->create_course();
3256
        $course = $this->getDataGenerator()->create_course();
3257
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3257
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 3272... Línea 3272...
3272
    }
3272
    }
Línea 3273... Línea 3273...
3273
 
3273
 
3274
    /**
3274
    /**
3275
     * Testing can_edit_submission.
3275
     * Testing can_edit_submission.
3276
     */
3276
     */
3277
    public function test_can_edit_submission() {
3277
    public function test_can_edit_submission(): void {
3278
        $this->resetAfterTest();
3278
        $this->resetAfterTest();
3279
        $course = $this->getDataGenerator()->create_course();
3279
        $course = $this->getDataGenerator()->create_course();
3280
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3280
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3281
        $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
3281
        $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
Línea 3297... Línea 3297...
3297
    }
3297
    }
Línea 3298... Línea 3298...
3298
 
3298
 
3299
    /**
3299
    /**
3300
     * Testing can_edit_submission with the editothersubmission capability.
3300
     * Testing can_edit_submission with the editothersubmission capability.
3301
     */
3301
     */
3302
    public function test_can_edit_submission_with_editothersubmission() {
3302
    public function test_can_edit_submission_with_editothersubmission(): void {
3303
        $this->resetAfterTest();
3303
        $this->resetAfterTest();
3304
        $course = $this->getDataGenerator()->create_course();
3304
        $course = $this->getDataGenerator()->create_course();
3305
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3305
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3306
        $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
3306
        $student = $this->getDataGenerator()->create_and_enrol($course, 'student');
Línea 3328... Línea 3328...
3328
    }
3328
    }
Línea 3329... Línea 3329...
3329
 
3329
 
3330
    /**
3330
    /**
3331
     * Testing can_edit_submission
3331
     * Testing can_edit_submission
3332
     */
3332
     */
3333
    public function test_can_edit_submission_separategroups() {
3333
    public function test_can_edit_submission_separategroups(): void {
3334
        $this->resetAfterTest();
3334
        $this->resetAfterTest();
3335
        $course = $this->getDataGenerator()->create_course();
3335
        $course = $this->getDataGenerator()->create_course();
Línea 3336... Línea 3336...
3336
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3336
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 3366... Línea 3366...
3366
    }
3366
    }
Línea 3367... Línea 3367...
3367
 
3367
 
3368
    /**
3368
    /**
3369
     * Testing can_edit_submission
3369
     * Testing can_edit_submission
3370
     */
3370
     */
3371
    public function test_can_edit_submission_separategroups_with_editothersubmission() {
3371
    public function test_can_edit_submission_separategroups_with_editothersubmission(): void {
3372
        $this->resetAfterTest();
3372
        $this->resetAfterTest();
3373
        $course = $this->getDataGenerator()->create_course();
3373
        $course = $this->getDataGenerator()->create_course();
Línea 3374... Línea 3374...
3374
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3374
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 3416... Línea 3416...
3416
    }
3416
    }
Línea 3417... Línea 3417...
3417
 
3417
 
3418
    /**
3418
    /**
3419
     * Test if the view blind details capability works
3419
     * Test if the view blind details capability works
3420
     */
3420
     */
3421
    public function test_can_view_blind_details() {
3421
    public function test_can_view_blind_details(): void {
Línea 3422... Línea 3422...
3422
        global $DB;
3422
        global $DB;
3423
 
3423
 
3424
        $this->resetAfterTest();
3424
        $this->resetAfterTest();
Línea 3449... Línea 3449...
3449
    }
3449
    }
Línea 3450... Línea 3450...
3450
 
3450
 
3451
    /**
3451
    /**
3452
     * Testing get_shared_group_members
3452
     * Testing get_shared_group_members
3453
     */
3453
     */
3454
    public function test_get_shared_group_members() {
3454
    public function test_get_shared_group_members(): void {
3455
        $this->resetAfterTest();
3455
        $this->resetAfterTest();
3456
        $course = $this->getDataGenerator()->create_course();
3456
        $course = $this->getDataGenerator()->create_course();
Línea 3457... Línea 3457...
3457
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3457
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 3502... Línea 3502...
3502
    }
3502
    }
Línea 3503... Línea 3503...
3503
 
3503
 
3504
    /**
3504
    /**
3505
     * Testing get_shared_group_members
3505
     * Testing get_shared_group_members
3506
     */
3506
     */
3507
    public function test_get_shared_group_members_override() {
3507
    public function test_get_shared_group_members_override(): void {
3508
        $this->resetAfterTest();
3508
        $this->resetAfterTest();
3509
        $course = $this->getDataGenerator()->create_course();
3509
        $course = $this->getDataGenerator()->create_course();
Línea 3510... Línea 3510...
3510
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3510
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 3563... Línea 3563...
3563
    }
3563
    }
Línea 3564... Línea 3564...
3564
 
3564
 
3565
    /**
3565
    /**
3566
     * Test get plugins file areas
3566
     * Test get plugins file areas
3567
     */
3567
     */
3568
    public function test_get_plugins_file_areas() {
3568
    public function test_get_plugins_file_areas(): void {
Línea 3569... Línea 3569...
3569
        global $DB;
3569
        global $DB;
3570
 
3570
 
3571
        $this->resetAfterTest();
3571
        $this->resetAfterTest();
Línea 3636... Línea 3636...
3636
     * Test override exists
3636
     * Test override exists
3637
     *
3637
     *
3638
     * This function needs to obey the group override logic as per the assign grading table and
3638
     * This function needs to obey the group override logic as per the assign grading table and
3639
     * the overview block.
3639
     * the overview block.
3640
     */
3640
     */
3641
    public function test_override_exists() {
3641
    public function test_override_exists(): void {
3642
        global $DB;
3642
        global $DB;
Línea 3643... Línea 3643...
3643
 
3643
 
3644
        $this->resetAfterTest();
3644
        $this->resetAfterTest();
3645
        $course = $this->getDataGenerator()->create_course();
3645
        $course = $this->getDataGenerator()->create_course();
Línea 3735... Línea 3735...
3735
    }
3735
    }
Línea 3736... Línea 3736...
3736
 
3736
 
3737
    /**
3737
    /**
3738
     * Test the quicksave grades processor
3738
     * Test the quicksave grades processor
3739
     */
3739
     */
3740
    public function test_process_save_quick_grades() {
3740
    public function test_process_save_quick_grades(): void {
3741
        $this->resetAfterTest();
3741
        $this->resetAfterTest();
3742
        $course = $this->getDataGenerator()->create_course();
3742
        $course = $this->getDataGenerator()->create_course();
3743
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
3743
        $teacher = $this->getDataGenerator()->create_and_enrol($course, 'teacher');
Línea 3811... Línea 3811...
3811
    }
3811
    }
Línea 3812... Línea 3812...
3812
 
3812
 
3813
    /**
3813
    /**
3814
     * Test updating activity completion when submitting an assessment.
3814
     * Test updating activity completion when submitting an assessment.
3815
     */
3815
     */
3816
    public function test_update_activity_completion_records_solitary_submission() {
3816
    public function test_update_activity_completion_records_solitary_submission(): void {
Línea 3817... Línea 3817...
3817
        $this->resetAfterTest();
3817
        $this->resetAfterTest();
3818
 
3818
 
3819
        $course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
3819
        $course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
Línea 3847... Línea 3847...
3847
    }
3847
    }
Línea 3848... Línea 3848...
3848
 
3848
 
3849
    /**
3849
    /**
3850
     * Test updating activity completion when submitting an assessment.
3850
     * Test updating activity completion when submitting an assessment.
3851
     */
3851
     */
3852
    public function test_update_activity_completion_records_team_submission() {
3852
    public function test_update_activity_completion_records_team_submission(): void {
Línea 3853... Línea 3853...
3853
        $this->resetAfterTest();
3853
        $this->resetAfterTest();
3854
 
3854
 
3855
        $course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
3855
        $course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
Línea 3898... Línea 3898...
3898
    }
3898
    }
Línea 3899... Línea 3899...
3899
 
3899
 
3900
    /**
3900
    /**
3901
     * Test updating activity completion when submitting an assessment for MDL-67126.
3901
     * Test updating activity completion when submitting an assessment for MDL-67126.
3902
     */
3902
     */
3903
    public function test_update_activity_completion_records_team_submission_new() {
3903
    public function test_update_activity_completion_records_team_submission_new(): void {
Línea 3904... Línea 3904...
3904
        $this->resetAfterTest();
3904
        $this->resetAfterTest();
3905
 
3905
 
3906
        $course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
3906
        $course = $this->getDataGenerator()->create_course(['enablecompletion' => 1]);
Línea 3973... Línea 3973...
3973
     * Test fix_null_grades
3973
     * Test fix_null_grades
3974
     * @param number $grade The grade we should set in the assign grading table.
3974
     * @param number $grade The grade we should set in the assign grading table.
3975
     * @param number $expectedcount The finalgrade we expect in the gradebook after fixing the grades.
3975
     * @param number $expectedcount The finalgrade we expect in the gradebook after fixing the grades.
3976
     * @dataProvider fix_null_grades_provider
3976
     * @dataProvider fix_null_grades_provider
3977
     */
3977
     */
3978
    public function test_fix_null_grades($grade, $gradebookvalue) {
3978
    public function test_fix_null_grades($grade, $gradebookvalue): void {
3979
        global $DB;
3979
        global $DB;
Línea 3980... Línea 3980...
3980
 
3980
 
Línea 3981... Línea 3981...
3981
        $this->resetAfterTest();
3981
        $this->resetAfterTest();
Línea 4029... Línea 4029...
4029
    }
4029
    }
Línea 4030... Línea 4030...
4030
 
4030
 
4031
    /**
4031
    /**
4032
     * Test grade override displays 'Graded' for students
4032
     * Test grade override displays 'Graded' for students
4033
     */
4033
     */
4034
    public function test_grade_submission_override() {
4034
    public function test_grade_submission_override(): void {
Línea 4035... Línea 4035...
4035
        global $DB, $PAGE, $OUTPUT;
4035
        global $DB, $PAGE, $OUTPUT;
Línea 4036... Línea 4036...
4036
 
4036
 
Línea 4085... Línea 4085...
4085
    }
4085
    }
Línea 4086... Línea 4086...
4086
 
4086
 
4087
    /**
4087
    /**
4088
     * Test the result of get_filters is consistent.
4088
     * Test the result of get_filters is consistent.
4089
     */
4089
     */
4090
    public function test_get_filters() {
4090
    public function test_get_filters(): void {
Línea 4091... Línea 4091...
4091
        $this->resetAfterTest();
4091
        $this->resetAfterTest();
4092
 
4092
 
4093
        $course = $this->getDataGenerator()->create_course();
4093
        $course = $this->getDataGenerator()->create_course();
Línea 4105... Línea 4105...
4105
     * @param array $assignconfig the config to use when creating the assignment.
4105
     * @param array $assignconfig the config to use when creating the assignment.
4106
     * @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
4106
     * @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
4107
     * @param array $expectedproperties an map containing the expected names and values for the assign instance data.
4107
     * @param array $expectedproperties an map containing the expected names and values for the assign instance data.
4108
     */
4108
     */
4109
    public function test_assign_get_instance(array $courseconfig, array $assignconfig, array $enrolconfig,
4109
    public function test_assign_get_instance(array $courseconfig, array $assignconfig, array $enrolconfig,
4110
            array $expectedproperties) {
4110
            array $expectedproperties): void {
4111
        $this->resetAfterTest();
4111
        $this->resetAfterTest();
Línea 4112... Línea 4112...
4112
 
4112
 
Línea 4113... Línea 4113...
4113
        set_config('enablecourserelativedates', true); // Enable relative dates at site level.
4113
        set_config('enablecourserelativedates', true); // Enable relative dates at site level.
Línea 4185... Línea 4185...
4185
     * @param array $assignconfig the config to use when creating the assignment.
4185
     * @param array $assignconfig the config to use when creating the assignment.
4186
     * @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
4186
     * @param array $enrolconfig the config to use when enrolling the user (this will be the active user).
4187
     * @param array $expectedproperties an map containing the expected names and values for the assign instance data.
4187
     * @param array $expectedproperties an map containing the expected names and values for the assign instance data.
4188
     */
4188
     */
4189
    public function test_assign_get_default_instance(array $courseconfig, array $assignconfig, array $enrolconfig,
4189
    public function test_assign_get_default_instance(array $courseconfig, array $assignconfig, array $enrolconfig,
4190
            array $expectedproperties) {
4190
            array $expectedproperties): void {
4191
        $this->resetAfterTest();
4191
        $this->resetAfterTest();
Línea 4192... Línea 4192...
4192
 
4192
 
Línea 4193... Línea 4193...
4193
        set_config('enablecourserelativedates', true); // Enable relative dates at site level.
4193
        set_config('enablecourserelativedates', true); // Enable relative dates at site level.
Línea 4245... Línea 4245...
4245
    }
4245
    }
Línea 4246... Línea 4246...
4246
 
4246
 
4247
    /**
4247
    /**
4248
     * Test that cron task uses task API to get its last run time.
4248
     * Test that cron task uses task API to get its last run time.
4249
     */
4249
     */
4250
    public function test_cron_use_task_api_to_get_lastruntime() {
4250
    public function test_cron_use_task_api_to_get_lastruntime(): void {
4251
        global $DB;
4251
        global $DB;
4252
        $this->resetAfterTest();
4252
        $this->resetAfterTest();
Línea 4253... Línea 4253...
4253
        $course = $this->getDataGenerator()->create_course();
4253
        $course = $this->getDataGenerator()->create_course();
Línea 4295... Línea 4295...
4295
    }
4295
    }
Línea 4296... Línea 4296...
4296
 
4296
 
4297
    /**
4297
    /**
4298
     * Test submissions that need grading output after one ungraded submission
4298
     * Test submissions that need grading output after one ungraded submission
4299
     */
4299
     */
4300
    public function test_submissions_need_grading() {
4300
    public function test_submissions_need_grading(): void {
Línea 4301... Línea 4301...
4301
        global $PAGE;
4301
        global $PAGE;
4302
 
4302
 
4303
        $this->resetAfterTest();
4303
        $this->resetAfterTest();
Línea 4350... Línea 4350...
4350
    /**
4350
    /**
4351
     * Test that attachments should not be provided if \assign->show_intro returns false.
4351
     * Test that attachments should not be provided if \assign->show_intro returns false.
4352
     *
4352
     *
4353
     * @covers \assign::should_provide_intro_attachments
4353
     * @covers \assign::should_provide_intro_attachments
4354
     */
4354
     */
4355
    public function test_should_provide_intro_attachments_with_show_intro_disabled() {
4355
    public function test_should_provide_intro_attachments_with_show_intro_disabled(): void {
4356
        $this->resetAfterTest();
4356
        $this->resetAfterTest();
4357
        $futuredate = time() + 300;
4357
        $futuredate = time() + 300;
4358
        list($assign, $instance, $student) = $this->create_submission([
4358
        list($assign, $instance, $student) = $this->create_submission([
4359
            'alwaysshowdescription' => '0',
4359
            'alwaysshowdescription' => '0',
4360
            'allowsubmissionsfromdate' => $futuredate,
4360
            'allowsubmissionsfromdate' => $futuredate,
Línea 4365... Línea 4365...
4365
    /**
4365
    /**
4366
     * Test that attachments should be provided if user has capability to manage activity.
4366
     * Test that attachments should be provided if user has capability to manage activity.
4367
     *
4367
     *
4368
     * @covers \assign::should_provide_intro_attachments
4368
     * @covers \assign::should_provide_intro_attachments
4369
     */
4369
     */
4370
    public function test_should_provide_intro_attachments_with_bypass_capability() {
4370
    public function test_should_provide_intro_attachments_with_bypass_capability(): void {
4371
        $this->resetAfterTest();
4371
        $this->resetAfterTest();
4372
        list($assign, $instance, $student) = $this->create_submission([
4372
        list($assign, $instance, $student) = $this->create_submission([
4373
            'submissionattachments' => 1,
4373
            'submissionattachments' => 1,
4374
        ]);
4374
        ]);
4375
        // Provide teaching role to student1 so they are able to bypass time limit restrictions on viewing attachments.
4375
        // Provide teaching role to student1 so they are able to bypass time limit restrictions on viewing attachments.
Línea 4380... Línea 4380...
4380
    /**
4380
    /**
4381
     * Test that attachments should be provided if submissionattachments is disabled.
4381
     * Test that attachments should be provided if submissionattachments is disabled.
4382
     *
4382
     *
4383
     * @covers \assign::should_provide_intro_attachments
4383
     * @covers \assign::should_provide_intro_attachments
4384
     */
4384
     */
4385
    public function test_should_provide_intro_attachments_with_submissionattachments_disabled() {
4385
    public function test_should_provide_intro_attachments_with_submissionattachments_disabled(): void {
4386
        $this->resetAfterTest();
4386
        $this->resetAfterTest();
4387
        list($assign, $instance, $student) = $this->create_submission();
4387
        list($assign, $instance, $student) = $this->create_submission();
4388
        $this->assertTrue($assign->should_provide_intro_attachments($student->id));
4388
        $this->assertTrue($assign->should_provide_intro_attachments($student->id));
4389
    }
4389
    }
Línea 4390... Línea 4390...
4390
 
4390
 
4391
    /**
4391
    /**
4392
     * Test that attachments should not be provided if submissionattachments is enabled with no open submission.
4392
     * Test that attachments should not be provided if submissionattachments is enabled with no open submission.
4393
     *
4393
     *
4394
     * @covers \assign::should_provide_intro_attachments
4394
     * @covers \assign::should_provide_intro_attachments
4395
     */
4395
     */
4396
    public function test_should_provide_intro_attachments_with_submissionattachments_enabled_and_submissions_closed() {
4396
    public function test_should_provide_intro_attachments_with_submissionattachments_enabled_and_submissions_closed(): void {
4397
        $this->resetAfterTest();
4397
        $this->resetAfterTest();
4398
        // Set cut-off date to the past.
4398
        // Set cut-off date to the past.
4399
        list($assign, $instance, $student) = $this->create_submission([
4399
        list($assign, $instance, $student) = $this->create_submission([
4400
            'timelimit' => '300',
4400
            'timelimit' => '300',
Línea 4407... Línea 4407...
4407
    /**
4407
    /**
4408
     * Test that attachments should be provided if submissionattachments is enabled with an open submission.
4408
     * Test that attachments should be provided if submissionattachments is enabled with an open submission.
4409
     *
4409
     *
4410
     * @covers \assign::should_provide_intro_attachments
4410
     * @covers \assign::should_provide_intro_attachments
4411
     */
4411
     */
4412
    public function test_should_provide_intro_attachments_submissionattachments_enabled_and_an_open_submission() {
4412
    public function test_should_provide_intro_attachments_submissionattachments_enabled_and_an_open_submission(): void {
4413
        $this->resetAfterTest();
4413
        $this->resetAfterTest();
4414
        set_config('enabletimelimit', '1', 'assign');
4414
        set_config('enabletimelimit', '1', 'assign');
4415
        list($assign, $instance, $student) = $this->create_submission([
4415
        list($assign, $instance, $student) = $this->create_submission([
4416
            'timelimit' => '300',
4416
            'timelimit' => '300',
4417
            'submissionattachments' => 1,
4417
            'submissionattachments' => 1,
Línea 4426... Línea 4426...
4426
    /**
4426
    /**
4427
     * Test that a submission using a time limit is currently open.
4427
     * Test that a submission using a time limit is currently open.
4428
     *
4428
     *
4429
     * @covers \assign::is_attempt_in_progress
4429
     * @covers \assign::is_attempt_in_progress
4430
     */
4430
     */
4431
    public function test_is_attempt_in_progress_with_open_submission() {
4431
    public function test_is_attempt_in_progress_with_open_submission(): void {
4432
        global $DB;
4432
        global $DB;
4433
        $this->resetAfterTest();
4433
        $this->resetAfterTest();
4434
        set_config('enabletimelimit', '1', 'assign');
4434
        set_config('enabletimelimit', '1', 'assign');
4435
        list($assign, $instance, $student) = $this->create_submission([
4435
        list($assign, $instance, $student) = $this->create_submission([
4436
            'timelimit' => '300',
4436
            'timelimit' => '300',
Línea 4445... Línea 4445...
4445
    /**
4445
    /**
4446
     * Test that a submission using a time limit is started without a start time.
4446
     * Test that a submission using a time limit is started without a start time.
4447
     *
4447
     *
4448
     * @covers \assign::is_attempt_in_progress
4448
     * @covers \assign::is_attempt_in_progress
4449
     */
4449
     */
4450
    public function test_is_attempt_in_progress_with_open_submission_and_no_timestarted() {
4450
    public function test_is_attempt_in_progress_with_open_submission_and_no_timestarted(): void {
4451
        $this->resetAfterTest();
4451
        $this->resetAfterTest();
4452
        set_config('enabletimelimit', '1', 'assign');
4452
        set_config('enabletimelimit', '1', 'assign');
4453
        list($assign, $instance, $student) = $this->create_submission([
4453
        list($assign, $instance, $student) = $this->create_submission([
4454
            'timelimit' => '300',
4454
            'timelimit' => '300',
4455
        ]);
4455
        ]);
Línea 4460... Línea 4460...
4460
    /**
4460
    /**
4461
     * Test that a submission using a time limit is currently not open.
4461
     * Test that a submission using a time limit is currently not open.
4462
     *
4462
     *
4463
     * @covers \assign::is_attempt_in_progress
4463
     * @covers \assign::is_attempt_in_progress
4464
     */
4464
     */
4465
    public function test_is_attempt_in_progress_with_no_open_submission() {
4465
    public function test_is_attempt_in_progress_with_no_open_submission(): void {
4466
        global $DB;
4466
        global $DB;
4467
        $this->resetAfterTest();
4467
        $this->resetAfterTest();
4468
        set_config('enabletimelimit', '1', 'assign');
4468
        set_config('enabletimelimit', '1', 'assign');
4469
        list($assign, $instance, $student) = $this->create_submission([
4469
        list($assign, $instance, $student) = $this->create_submission([
4470
            'timelimit' => '300',
4470
            'timelimit' => '300',
Línea 4547... Línea 4547...
4547
    /**
4547
    /**
4548
     * Test user filtering by First name, Last name and Submission status.
4548
     * Test user filtering by First name, Last name and Submission status.
4549
     *
4549
     *
4550
     * @covers \assign::is_userid_filtered
4550
     * @covers \assign::is_userid_filtered
4551
     */
4551
     */
4552
    public function test_is_userid_filtered() {
4552
    public function test_is_userid_filtered(): void {
4553
        $this->resetAfterTest();
4553
        $this->resetAfterTest();
Línea 4554... Línea 4554...
4554
 
4554
 
4555
        // Generate data and simulate student submissions.
4555
        // Generate data and simulate student submissions.
4556
        $course = $this->getDataGenerator()->create_course();
4556
        $course = $this->getDataGenerator()->create_course();