From a5ff898f908fa81591cbf0735057dfd748a49e7f Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Thu, 14 Jun 2018 10:47:31 +0800 Subject: [PATCH] MDL-60950 assign: Test for the requires grading filter This test covers when the requires grading filter is applied, but the assignment has no grade and the feedbackcomments plugin is disabled. --- mod/assign/tests/locallib_test.php | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/mod/assign/tests/locallib_test.php b/mod/assign/tests/locallib_test.php index db8958af401..bcf64d63f6b 100644 --- a/mod/assign/tests/locallib_test.php +++ b/mod/assign/tests/locallib_test.php @@ -189,6 +189,35 @@ class mod_assign_locallib_testcase extends advanced_testcase { } } + /** + * Test filter by requires grading. + * + * This is specifically checking an assignment with no grade to make sure we do not + * get an exception thrown when rendering the grading table for this type of assignment. + */ + public function test_gradingtable_filter_by_requiresgrading_no_grade() { + global $PAGE; + + $this->setUser($this->editingteachers[0]); + $params = array('assignsubmission_onlinetext_enabled' => 1, + 'assignfeedback_comments_enabled' => 0, + 'grade' => GRADE_TYPE_NONE); + $assign = $this->create_instance($params); + + $PAGE->set_url(new moodle_url('/mod/assign/view.php', array( + 'id' => $assign->get_course_module()->id, + 'action' => 'grading', + ))); + + // Render the table with the requires grading filter. + $gradingtable = new assign_grading_table($assign, 1, ASSIGN_FILTER_REQUIRE_GRADING, 0, true); + $output = $assign->get_renderer()->render($gradingtable); + + // Test that the filter function does not throw errors for assignments with no grade. + $this->assertContains(get_string('nothingtodisplay'), $output); + } + + /** * Test submissions with extension date. */ -- 2.43.0