Commit 017015fe authored by Astor Bizard's avatar Astor Bizard
Browse files

Fixed daily activity graph bug related to DST management.

parent 5f78ba40
......@@ -961,8 +961,8 @@ function vpl_get_webservice_urlbase($vpl) {
. '&wstoken=' . $token . '&id=' . $vpl->get_course_module()->id . '&wsfunction=';
}
function vpl_timestamp_to_midnight($timestamp) {
return $timestamp - ($timestamp + date('Z')) % 86400;
function vpl_timestamp_to_midday($timestamp) {
return $timestamp - ($timestamp + date('Z')) % 86400 + 43200;
}
function vpl_get_name_fields_display() {
......
......@@ -337,7 +337,7 @@ class vpl_grapher {
$start = min($start, $subinstance->datesubmitted);
}
}
$start = vpl_timestamp_to_midnight($start);
$start = vpl_timestamp_to_midday($start);
// End of time span is either module due date, either last submission date.
if ($this->vpl->get_instance()->duedate > 0) {
......@@ -348,7 +348,7 @@ class vpl_grapher {
$end = max($end, $subinstance->datesubmitted);
}
}
$end = vpl_timestamp_to_midnight($end);
$end = vpl_timestamp_to_midday($end);
// Compute per-day activity (ie. number of submissions).
$days = array();
......@@ -359,8 +359,11 @@ class vpl_grapher {
}
foreach ($this->submissions as $subinstance) {
$daysubmitted = vpl_timestamp_to_midnight($subinstance->datesubmitted);
$dailyactivity[($daysubmitted - $start) / 86400] ++;
$daysubmitted = vpl_timestamp_to_midday($subinstance->datesubmitted);
$dayoffset = ($daysubmitted - $start) / 86400;
if (isset($dailyactivity[$dayoffset])) {
$dailyactivity[$dayoffset] ++;
}
}
// Draw the graph.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment