]> git.mjollnir.org Git - moodle.git/commitdiff
datalib: get_logs_user*() - fix invalid SQL - MDL-12426
authormartinlanghoff <martinlanghoff>
Tue, 4 Dec 2007 06:26:10 +0000 (06:26 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 4 Dec 2007 06:26:10 +0000 (06:26 +0000)
Oracle does not accept column labels in the GROUP BY section -
get_logs_usercourse() and get_logs_userday() were computing the
day/hours column and using it in the GROUP BY. The compatible fix
is to reproduce the same computation in the GROUP BY section.

Credit for the fix goes to Dennis Rochford <Dennis.Rochford@usq.edu.au>.

lib/datalib.php

index f50c4c0817a6225d596bd44ab96bb512a523d95f..abbb1f580657eaa02feba15933cf79b610e7302d 100644 (file)
@@ -1941,7 +1941,7 @@ function get_logs_usercourse($userid, $courseid, $coursestart) {
                             FROM {$CFG->prefix}log
                            WHERE userid = '$userid'
                              AND time > '$coursestart' $courseselect
-                        GROUP BY day ");
+                        GROUP BY floor((time - $coursestart)/". DAYSECS .") ");
 }
 
 /**
@@ -1968,7 +1968,7 @@ function get_logs_userday($userid, $courseid, $daystart) {
                             FROM {$CFG->prefix}log
                            WHERE userid = '$userid'
                              AND time > '$daystart' $courseselect
-                        GROUP BY hour ");
+                        GROUP BY floor((time - $daystart)/". HOURSECS .") ");
 }
 
 /**