From b9dc4c3cbea62cd7e6d8191604801be3e91f2c1c Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Fri, 8 Feb 2013 15:44:18 +0800 Subject: [PATCH] MDL-37039 Assignment - Do not apply filters to grading table for offline assignments Because the filters do not make sense for offline assignments, they are hidden. But if the active filter prevents you from seeing any assignments you cannot change it. This change makes it so the filters are also not applied when the assignment is an offline assignment. --- mod/assign/gradingtable.php | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/mod/assign/gradingtable.php b/mod/assign/gradingtable.php index a5172c21f52..e0a5e867cf9 100644 --- a/mod/assign/gradingtable.php +++ b/mod/assign/gradingtable.php @@ -134,19 +134,22 @@ class assign_grading_table extends table_sql implements renderable { $where = 'u.id ' . $userwhere; $params = array_merge($params, $userparams); - if ($filter == ASSIGN_FILTER_SUBMITTED) { - $where .= ' AND s.timecreated > 0 '; - } - if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) { - $where .= ' AND (s.timemodified IS NOT NULL AND - s.status = :submitted AND - (s.timemodified > g.timemodified OR g.timemodified IS NULL))'; - $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED; - } - if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) { - $userfilter = (int) array_pop(explode('=', $filter)); - $where .= ' AND (u.id = :userid)'; - $params['userid'] = $userfilter; + // The filters do not make sense when there are no submissions, so do not apply them. + if ($this->assignment->is_any_submission_plugin_enabled()) { + if ($filter == ASSIGN_FILTER_SUBMITTED) { + $where .= ' AND s.timecreated > 0 '; + } + if ($filter == ASSIGN_FILTER_REQUIRE_GRADING) { + $where .= ' AND (s.timemodified IS NOT NULL AND + s.status = :submitted AND + (s.timemodified > g.timemodified OR g.timemodified IS NULL))'; + $params['submitted'] = ASSIGN_SUBMISSION_STATUS_SUBMITTED; + } + if (strpos($filter, ASSIGN_FILTER_SINGLE_USER) === 0) { + $userfilter = (int) array_pop(explode('=', $filter)); + $where .= ' AND (u.id = :userid)'; + $params['userid'] = $userfilter; + } } $this->set_sql($fields, $from, $where, $params);