From 2eb67a629170167649cb22180cd040c22513158e Mon Sep 17 00:00:00 2001 From: Dragon Dionysius Date: Mon, 4 Feb 2019 03:28:26 +0100 Subject: [PATCH] minor fixes to sql coding style --- classes/question/bank/performances_column.php | 8 ++++---- classes/question/bank/question_bank_filter.php | 4 ++-- classes/question/bank/tag_column.php | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/classes/question/bank/performances_column.php b/classes/question/bank/performances_column.php index 86b3623b..5ec74497 100644 --- a/classes/question/bank/performances_column.php +++ b/classes/question/bank/performances_column.php @@ -151,7 +151,7 @@ public function get_extra_joins() { WHERE qasd.name = '-submit' AND sq.id = " . $this->studentquizid . " AND sqa.userid = " . $this->currentuserid . " - AND qas.fraction is not null + AND qas.fraction IS NOT NULL GROUP BY qa.questionid ) qasdmax ON qasd.id = qasdmax.maxqasdid WHERE qasd.name = '-submit' @@ -167,13 +167,13 @@ public function get_required_fields() { if ($this->studentquiz->aggregated) { return array('sp.attempts practice', 'sp.attempts AS myattempts', "( - CASE WHEN sp.attempts is null + CASE WHEN sp.attempts IS NULL THEN '' ELSE CASE WHEN sp.lastanswercorrect = 1 THEN 'gradedright' ELSE 'gradedwrong' - END - END + END + END ) AS mylastattempt"); } else { return array('pr.practice', 'myatts.myattempts', 'mylatts.mylastattempt'); diff --git a/classes/question/bank/question_bank_filter.php b/classes/question/bank/question_bank_filter.php index a1cdf26c..12bed076 100644 --- a/classes/question/bank/question_bank_filter.php +++ b/classes/question/bank/question_bank_filter.php @@ -223,7 +223,7 @@ public function get_sql_filter($data) { $params[$name] = "%$value%"; break; case 1: // Does not contain. - $res = ' (searchtag = 0 or searchtag is null) '; + $res = ' (searchtag = 0 OR searchtag IS NULL) '; $params[$name] = "%$value%"; break; case 2: // Equal to. @@ -239,7 +239,7 @@ public function get_sql_filter($data) { $params[$name] = "%$value"; break; case 5: // Empty. - $res = ' (tags = 0 or tags is null) '; + $res = ' (tags = 0 OR tags IS NULL) '; $params[$name] = "-ignore-"; break; default: diff --git a/classes/question/bank/tag_column.php b/classes/question/bank/tag_column.php index 75167406..cf2550e2 100644 --- a/classes/question/bank/tag_column.php +++ b/classes/question/bank/tag_column.php @@ -103,7 +103,7 @@ protected function display_content($question, $rowclasses) { * @return array sql query join additional */ public function get_extra_joins() { - $searchtag = ($this->tagfilteractive) ? "SUM(CASE WHEN t.name LIKE :searchtag then 1 else 0 end)" : "0"; + $searchtag = ($this->tagfilteractive) ? "SUM(CASE WHEN t.name LIKE :searchtag THEN 1 ELSE 0 END)" : "0"; return array('tags' => "LEFT JOIN ( SELECT ti.itemid AS questionid, COUNT(*) AS tags, " . $searchtag . " AS searchtag FROM {tag} t