From d89ce46808bba272e3ef05ed4afa0d3b119b2525 Mon Sep 17 00:00:00 2001 From: Philipp Albrecht Date: Wed, 13 Feb 2019 03:36:51 +0100 Subject: [PATCH] Fixed rare filtering issue for old studentquiz instances --- classes/condition/studentquiz_condition.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/classes/condition/studentquiz_condition.php b/classes/condition/studentquiz_condition.php index 10cf7ac0..cbc878bb 100755 --- a/classes/condition/studentquiz_condition.php +++ b/classes/condition/studentquiz_condition.php @@ -139,11 +139,13 @@ protected function init() { } private function get_special_sql($sqldata, $name) { - if (substr($sqldata, 0, 12) === 'mydifficulty') { - return str_replace('mydifficulty', 'ROUND(1 - (sp.correctattempts / sp.attempts),2)', $sqldata); - } - if ($name == "onlynew") { - return str_replace('myattempts', 'sp.attempts', $sqldata); + if ($this->studentquiz->aggregated) { + if (substr($sqldata, 0, 12) === 'mydifficulty') { + return str_replace('mydifficulty', 'ROUND(1 - (sp.correctattempts / sp.attempts),2)', $sqldata); + } + if ($name == "onlynew") { + return str_replace('myattempts', 'sp.attempts', $sqldata); + } } return $sqldata; }