diff --git a/views/vpl_grapher.class.php b/views/vpl_grapher.class.php
index 8c73967053109c226fb27e61968f08661e8f5c82..5268a72b1fc444bb6945f10d91091131730fa0a2 100644
--- a/views/vpl_grapher.class.php
+++ b/views/vpl_grapher.class.php
@@ -339,11 +339,14 @@ class vpl_grapher {
         }
         $start = vpl_timestamp_to_midnight($start);
 
-        // End of time span is either module due date, either now.
+        // End of time span is either module due date, either last submission date.
         if ($this->vpl->get_instance()->duedate > 0) {
             $end = $this->vpl->get_instance()->duedate;
         } else {
-            $end = time();
+            $end = 0;
+            foreach ($this->submissions as $subinstance) {
+                $end = max($end, $subinstance->datesubmitted);
+            }
         }
         $end = vpl_timestamp_to_midnight($end);