]> git.mjollnir.org Git - moodle.git/commitdiff
Bug #5974 - Course overview report should not error when stats are not up to date...
authorskodak <skodak>
Mon, 3 Jul 2006 15:43:41 +0000 (15:43 +0000)
committerskodak <skodak>
Mon, 3 Jul 2006 15:43:41 +0000 (15:43 +0000)
admin/report/courseoverview/mod.php
admin/report/stats/mod.php
course/user.php
lib/statslib.php

index 1350aa2dadfb58698572dde4688f77bf6fe18960..7d74d21e2b3c9c1b97111b6383211e2f6b6082d5 100644 (file)
@@ -18,8 +18,7 @@
         $numcourses = optional_param('numcourses', 20, PARAM_INT);
 
         $course = get_site();
-        stats_check_uptodate($course->id);
-
+        $statsstatus = stats_check_uptodate($course->id);
 
         $reportoptions = stats_get_report_options($course->id,STATS_MODE_RANKED);
 
         echo '<form action="report/courseoverview/index.php" method="post">'."\n";
         print_table($table);
         echo '</form>';
+        if ($statsstatus !== NULL) {
+            notify ($statsstatus);
+        }
+
     }
 ?>
 
index c4433a9febb1894b62da729ceb3f370704c1d7d0..2b2ddbe4f79d534ddfda22fa3685bcc2dc713d97 100644 (file)
@@ -8,5 +8,9 @@
         echo '<p style="text-align:center;">';
         echo '<a href="'.$CFG->wwwroot.'/admin/report/stats/index.php?course='.$course->id.'">'.get_string('stats').'</a>';
         echo '</p>';
+        $statsstatus = stats_check_uptodate($course->id);
+        if ($statsstatus !== NULL) {
+            notify ($statsstatus);
+        }
     }
 ?>
\ No newline at end of file
index c062a8c4cc1a42dcb246c7393184e77105b40a1c..5b61e73693360eeb56d63357fa6a207152bc8c76 100644 (file)
 
             require_once($CFG->dirroot.'/lib/statslib.php');
 
-            stats_check_uptodate($course->id);
+            $statsstatus = stats_check_uptodate($course->id);
+            if ($statsstatus !== NULL) {
+                notify ($statsstatus);
+            }
 
             $earliestday = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_daily ORDER BY timeend LIMIT 1');
             $earliestweek = get_field_sql('SELECT timeend FROM '.$CFG->prefix.'stats_user_weekly ORDER BY timeend LIMIT 1');
index 85d03831e278c6665f0fe6eac39fa8795dd83f87..8aab1fe3d26d261de61d6769f14c5db3da5d8c50 100644 (file)
@@ -913,18 +913,21 @@ function stats_check_uptodate($courseid=0) {
     $latestday = stats_get_start_from('daily');
 
     if ((time() - 60*60*24*2) < $latestday) { // we're ok
-        return true;
+        return NULL;
     }
 
+    $a = new object();
     $a->daysdone = get_field_sql("SELECT count(distinct(timeend)) from {$CFG->prefix}stats_daily");
 
     // how many days between the last day and now?
     $a->dayspending = ceil((stats_get_base_daily() - $latestday)/(60*60*24));
 
     if ($a->dayspending == 0 && $a->daysdone != 0) {
-        return true; // we've only just started...
+        return NULL; // we've only just started...
     }
-    error(get_string('statscatchupmode','error',$a),$CFG->wwwroot.'/course/view.php?id='.$courseid);
+
+    //return error as string
+    return get_string('statscatchupmode','error',$a);
 }