Permalink
Browse files

Fixed user graphs for site-level, all logs

  • Loading branch information...
moodler
moodler committed Jul 25, 2003
1 parent b0dd12a commit da0c90c3135933ee5a38c4d9f141e1ca35c8e7cd
Showing with 14 additions and 3 deletions.
  1. +9 −1 course/loggraph.php
  2. +5 −2 lib/datalib.php
View
@@ -34,6 +34,14 @@
switch ($type) {
case "usercourse.png":
$site = get_site();
if ($course->id == $site->id) {
$courseselect = 0;
} else {
$courseselect = $course->id;
}
$maxseconds = COURSE_MAX_LOG_DISPLAY * 3600 * 24; // seconds
if ($timenow - $course->startdate > $maxseconds) {
$course->startdate = $timenow - $maxseconds;
@@ -63,7 +71,7 @@
$timestart = $timefinish;
}
if ($rawlogs = get_logs_usercourse($user->id, $course->id, $coursestart)) {
if ($rawlogs = get_logs_usercourse($user->id, $courseselect, $coursestart)) {
foreach ($rawlogs as $rawlog) {
$logs[$rawlog->day] = $rawlog->num;
}
View
@@ -1249,11 +1249,14 @@ function get_logs($select, $order) {
function get_logs_usercourse($userid, $courseid, $coursestart) {
global $CFG;
if ($courseid) {
$courseselect = " AND course = '$courseid' ";
}
return get_records_sql("SELECT floor((`time` - $coursestart)/86400) as day, count(*) as num
FROM {$CFG->prefix}log
WHERE userid = '$userid'
AND course = '$courseid'
AND `time` > '$coursestart'
AND `time` > '$coursestart' $courseselect
GROUP BY day ");
}

0 comments on commit da0c90c

Please sign in to comment.