From 47f4909a08b4775b7575bb2db5bebcef17531a43 Mon Sep 17 00:00:00 2001 From: Marina Glancy Date: Wed, 13 Apr 2016 12:00:14 +0800 Subject: [PATCH] MDL-53443 mod_feedback: fix SQL statment to work on all DB --- mod/feedback/analysis_course.php | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/mod/feedback/analysis_course.php b/mod/feedback/analysis_course.php index 1c4d84d4f6d..cd22c775784 100644 --- a/mod/feedback/analysis_course.php +++ b/mod/feedback/analysis_course.php @@ -110,11 +110,7 @@ if (is_array($items)) { } if ($courseitemfilter > 0) { - $avgvalue = 'avg(value)'; - if ($DB->get_dbfamily() == 'postgres') { // TODO: this should be moved to standard sql DML function ;-) - $avgvalue = 'avg(cast (value as integer))'; - } - + $avgvalue = 'avg(' . $DB->sql_cast_char2int('value', true) . ')'; $sql = "SELECT fv.course_id, c.shortname, $avgvalue AS avgvalue FROM {feedback_value} fv, {course} c, {feedback_item} fi WHERE fv.course_id = c.id AND fi.id = fv.item AND fi.typ = ? AND fv.item = ?