From 13d32e22979f6fab7d6f6e825cee09cd0b808019 Mon Sep 17 00:00:00 2001 From: skodak Date: Mon, 3 Jul 2006 15:43:41 +0000 Subject: [PATCH] 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; merged from MOODLE_16_STABLE --- admin/report/courseoverview/mod.php | 7 +++++-- admin/report/stats/mod.php | 4 ++++ course/user.php | 5 ++++- lib/statslib.php | 9 ++++++--- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/admin/report/courseoverview/mod.php b/admin/report/courseoverview/mod.php index 1350aa2dad..7d74d21e2b 100644 --- a/admin/report/courseoverview/mod.php +++ b/admin/report/courseoverview/mod.php @@ -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 '
'."\n"; print_table($table); echo '
'; + if ($statsstatus !== NULL) { + notify ($statsstatus); + } + } ?> diff --git a/admin/report/stats/mod.php b/admin/report/stats/mod.php index c4433a9feb..2b2ddbe4f7 100644 --- a/admin/report/stats/mod.php +++ b/admin/report/stats/mod.php @@ -8,5 +8,9 @@ echo '

'; echo ''.get_string('stats').''; echo '

'; + $statsstatus = stats_check_uptodate($course->id); + if ($statsstatus !== NULL) { + notify ($statsstatus); + } } ?> \ No newline at end of file diff --git a/course/user.php b/course/user.php index c062a8c4cc..5b61e73693 100644 --- a/course/user.php +++ b/course/user.php @@ -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'); diff --git a/lib/statslib.php b/lib/statslib.php index 85d03831e2..8aab1fe3d2 100644 --- a/lib/statslib.php +++ b/lib/statslib.php @@ -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); } -- 2.39.5