From 9d17228c2f1be57ea16938e2f876ab62afea08b4 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Fri, 9 Feb 2024 12:18:01 +0000 Subject: [PATCH 1/2] Rewrite student_search_table query Details on internal WR 427905 --- classes/output/student_search_table.php | 45 ++++++++++++++++--------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/classes/output/student_search_table.php b/classes/output/student_search_table.php index 526899a1..0fc99515 100644 --- a/classes/output/student_search_table.php +++ b/classes/output/student_search_table.php @@ -513,28 +513,41 @@ public function query_db($pagesize, $useinitialsbar = false) { } $sql = "SELECT u.*, - COALESCE(qo.timeopen, $quizobj->timestampopen) AS timeopen, - COALESCE(qo.timeclose, $quizobj->timestampclose) AS timeclose, - COALESCE(qo.timelimit, $quizobj->timestamplimit) AS timelimit, - COALESCE(qa.state, (CASE - WHEN us.userid > 0 THEN 'loggedin' - ELSE 'notloggedin' - END)) AS state, + qo.timeopen AS timeopen, + qo.timeclose AS timeclose, + qo.timelimit AS timelimit, + COALESCE( + qa.state, + ( + CASE + WHEN us.userid > 0 THEN 'loggedin' + ELSE 'notloggedin' + END + ) + ) AS state, qa.attemptid, qa.timestart, - qa.timefinish, - $quizobj->assessid AS quiz, - $context->instanceid as quizinstance, - $quizobj->timestampopen AS quiztimeopen, - $quizobj->timestampclose AS quiztimeclose, - $quizobj->timestamplimit AS quiztimelimit, - '$quizobj->name' AS quizname + qa.timefinish FROM {user} u $finaljoin->joins WHERE $finaljoin->wheres"; - $records = $DB->get_records_sql($sql, $params); - $allrecords = array_merge($allrecords, $records); + $records = $DB->get_records_sql($sql, $params); + $quizdata = [ + 'quiz' => $quizobj->assessid, + 'quizinstance' => $context->instanceid, + 'quiztimeopen' => $quizobj->timestampopen, + 'quiztimeclose' => $quizobj->timestampclose, + 'quiztimelimit' => $quizobj->timestamplimit, + 'quizname' => $quizobj->name, + ]; + foreach ($records as &$record) { + $record->timeopen = $record->timeopen ?? $quizobj->timestampopen; + $record->timeclose = $record->timeclose ?? $quizobj->timestampclose; + $record->timelimit = $record->timelimit ?? $quizobj->timestampopen; + $record = (object)array_merge((array)$record, $quizdata); + } + $allrecords = array_merge($allrecords, $records); } if (!empty($this->get_sql_sort())) { From aeb052cd84a18fe2ef68deb29457a4019d04a540 Mon Sep 17 00:00:00 2001 From: Mark Johnson Date: Mon, 12 Feb 2024 13:26:10 +0000 Subject: [PATCH 2/2] Add plugin->supported --- version.php | 1 + 1 file changed, 1 insertion(+) diff --git a/version.php b/version.php index 2ab140da..feca0c60 100644 --- a/version.php +++ b/version.php @@ -28,4 +28,5 @@ $plugin->release = '2021101500'; $plugin->version = 2021101500; $plugin->requires = 2018051712; +$plugin->supported = [311, 311]; $plugin->maturity = MATURITY_BETA;