Bug #5974 - Course overview report should not error when stats are not up to date; fixed by changing the return value from stats_check_uptodate(), NULL is now OK, string value describes error and adding notify() where needed
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -49,6 +48,10 @@
|
||||
echo '<form action="report/courseoverview/index.php" method="post">'."\n";
|
||||
print_table($table);
|
||||
echo '</form>';
|
||||
if ($statsstatus !== NULL) {
|
||||
notify ($statsstatus);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
?>
|
||||
+4
-1
@@ -86,7 +86,10 @@
|
||||
|
||||
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');
|
||||
|
||||
+6
-3
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user