Skip to content

Commit

Permalink
MDL-53864 mod_feedback: fixed varying results on MSSQL
Browse files Browse the repository at this point in the history
  • Loading branch information
mdjnelson committed Apr 21, 2016
1 parent 4f33514 commit 4aa7e3f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mod/feedback/analysis_course.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@
}

if ($courseitemfilter > 0) {
$avgvalue = 'avg(' . $DB->sql_cast_char2int('value', true) . ')';
$sql = "SELECT fv.course_id, c.shortname, $avgvalue AS avgvalue
$sumvalue = 'SUM(' . $DB->sql_cast_char2real('value', true) . ')';
$sql = "SELECT fv.course_id, c.shortname, $sumvalue AS sumvalue, COUNT(value) as countvalue
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 = ?
GROUP BY course_id, shortname
ORDER BY avgvalue desc";
ORDER BY sumvalue desc";

if ($courses = $DB->get_records_sql($sql, array($courseitemfiltertyp, $courseitemfilter))) {
$item = $DB->get_record('feedback_item', array('id'=>$courseitemfilter));
Expand All @@ -133,7 +133,7 @@
echo '<tr>';
echo '<td>'.$shortname.'</td>';
echo '<td align="right">';
echo number_format(($c->avgvalue), 2, $sep_dec, $sep_thous);
echo number_format(($c->sumvalue / $c->countvalue), 2, $sep_dec, $sep_thous);
echo '</td>';
echo '</tr>';
}
Expand Down

0 comments on commit 4aa7e3f

Please sign in to comment.