diff --git a/locallib.php b/locallib.php index f1de56ff0500d10b034ddba0be258fbb9af58e69..e375e345f87ebf12999dbbbc1e4f9aceea25787e 100644 --- a/locallib.php +++ b/locallib.php @@ -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() { diff --git a/views/vpl_grapher.class.php b/views/vpl_grapher.class.php index 6235d6663f302cb5f1edbe89c0628eed2b77c644..aa1ca971733bcdc2ddb59d1e46838e7346ca2eee 100644 --- a/views/vpl_grapher.class.php +++ b/views/vpl_grapher.class.php @@ -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.