Skip to content

Commit

Permalink
MDL-58991 report_stats: use same date handling on chart rendering
Browse files Browse the repository at this point in the history
This commmit fixes applies the same date handling used on stats
table render to the charts render.
  • Loading branch information
lameze committed Jun 6, 2017
1 parent f41c1f8 commit 2b7268d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
10 changes: 6 additions & 4 deletions report/stats/locallib.php
Expand Up @@ -264,7 +264,8 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
// bad luck, we can not link other report
} else if (empty($param->crosstab)) {
foreach ($stats as $stat) {
$a = array(userdate($stat->timeend-(60*60*24),get_string('strftimedate'),$CFG->timezone),$stat->line1);
$a = array(userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone),
$stat->line1);
if (isset($stat->line2)) {
$a[] = $stat->line2;
}
Expand Down Expand Up @@ -302,7 +303,8 @@ function report_stats_report($course, $report, $mode, $user, $roleid, $time) {
}
}
if (!array_key_exists($stat->timeend,$times)) {
$times[$stat->timeend] = userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone);
$times[$stat->timeend] = userdate($stat->timeend - DAYSECS, get_string('strftimedate'),
$CFG->timezone);
}
}

Expand Down Expand Up @@ -395,7 +397,7 @@ function report_stats_print_chart($courseid, $report, $time, $mode, $userid = 0,
foreach ($stats as $stat) {
// Build the array of formatted times indexed by timestamp used as labels.
if (!array_key_exists($stat->timeend, $times)) {
$times[$stat->timeend] = userdate($stat->timeend, get_string('strftimedate'), $CFG->timezone);
$times[$stat->timeend] = userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone);

// Just add the data if the time hasn't been added yet.
// The number of lines of data must match the number of labels.
Expand Down Expand Up @@ -436,7 +438,7 @@ function report_stats_print_chart($courseid, $report, $time, $mode, $userid = 0,

// Build the array of formatted times indexed by timestamp used as labels.
if (!array_key_exists($stat->timeend, $times)) {
$times[$stat->timeend] = userdate($stat->timeend, get_string('strftimedate'), $CFG->timezone);
$times[$stat->timeend] = userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone);
}
}
// Fill empty days with zero to avoid chart errors.
Expand Down
2 changes: 1 addition & 1 deletion report/stats/user.php
Expand Up @@ -156,7 +156,7 @@
if (!empty($stat->zerofixed)) { // Don't know why this is necessary, see stats_fix_zeros above - MD
continue;
}
$a = array(userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone),$stat->line1);
$a = array(userdate($stat->timeend - DAYSECS, get_string('strftimedate'), $CFG->timezone), $stat->line1);
$a[] = $stat->line2;
$a[] = $stat->line3;
$table->data[] = $a;
Expand Down

0 comments on commit 2b7268d

Please sign in to comment.