From: moodler Date: Sun, 24 Sep 2006 05:53:45 +0000 (+0000) Subject: Better errors X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=13e21433a4131fb40a5915207d7ad750f4d9c242;p=moodle.git Better errors --- diff --git a/course/report/stats/report.php b/course/report/stats/report.php index e862d50a1c..42740d5898 100644 --- a/course/report/stats/report.php +++ b/course/report/stats/report.php @@ -114,98 +114,100 @@ $stats = get_records_sql($sql); if (empty($stats)) { - error(get_string('statsnodata'.((!empty($user)) ? 'user' : '')),$CFG->wwwroot.'/stats/index.php?course='.$course->id.'&mode='.$mode.'&time='.$time); - } - - $stats = stats_fix_zeros($stats,$param->timeafter,$param->table,(!empty($param->line2))); - - print_heading($course->shortname.' - '.get_string('statsreport'.$report) - .((!empty($user)) ? ' '.get_string('statsreportforuser').' ' .fullname($user,true) : '') - .((!empty($roleid)) ? ' '.get_field('role','name','id',$roleid) : '')); - + notify(get_string('statsnodata')); - if (empty($CFG->gdversion)) { - echo "(".get_string("gdneed").")"; } else { - if ($mode == STATS_MODE_DETAILED) { - echo '
'; + + $stats = stats_fix_zeros($stats,$param->timeafter,$param->table,(!empty($param->line2))); + + print_heading($course->shortname.' - '.get_string('statsreport'.$report) + .((!empty($user)) ? ' '.get_string('statsreportforuser').' ' .fullname($user,true) : '') + .((!empty($roleid)) ? ' '.get_field('role','name','id',$roleid) : '')); + + + if (empty($CFG->gdversion)) { + echo "(".get_string("gdneed").")"; } else { - echo '
'; + if ($mode == STATS_MODE_DETAILED) { + echo '
'; + } else { + echo '
'; + } } - } - $table = new StdClass; - $table->align = array('left','center','center','center'); - $param->table = str_replace('user_','',$param->table); - $table->head = array(get_string('periodending','moodle',$param->table)); - if (empty($param->crosstab)) { - $table->head[] = $param->line1; - if (!empty($param->line2)) { - $table->head[] = $param->line2; - } - } - if (empty($param->crosstab)) { - foreach ($stats as $stat) { - $a = array(userdate($stat->timeend-(60*60*24),get_string('strftimedate'),$CFG->timezone),$stat->line1); - if (isset($stat->line2)) { - $a[] = $stat->line2; - } - if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) { - $a[] = '' - .get_string('course').' ' .get_string('logs').' '; + $table = new StdClass; + $table->align = array('left','center','center','center'); + $param->table = str_replace('user_','',$param->table); + $table->head = array(get_string('periodending','moodle',$param->table)); + if (empty($param->crosstab)) { + $table->head[] = $param->line1; + if (!empty($param->line2)) { + $table->head[] = $param->line2; } - $table->data[] = $a; } - } else { - $data = array(); - $roles = array(); - $times = array(); - $missedlines = array(); - foreach ($stats as $stat) { - if (!empty($stat->zerofixed)) { - $missedlines[] = $stat->timeend; - } - $data[$stat->timeend][$stat->roleid] = $stat->line1; - if ($stat->roleid != 0) { - if (!array_key_exists($stat->roleid,$roles)) { - $roles[$stat->roleid] = get_field('role','name','id',$stat->roleid); + if (empty($param->crosstab)) { + foreach ($stats as $stat) { + $a = array(userdate($stat->timeend-(60*60*24),get_string('strftimedate'),$CFG->timezone),$stat->line1); + if (isset($stat->line2)) { + $a[] = $stat->line2; } + if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) { + $a[] = '' + .get_string('course').' ' .get_string('logs').' '; + } + $table->data[] = $a; } - if (!array_key_exists($stat->timeend,$times)) { - $times[$stat->timeend] = userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone); - } - } - foreach ($data as $time => $rolesdata) { - if (in_array($time,$missedlines)) { - $rolesdata = array(); - foreach ($roles as $roleid => $guff) { - if ($roleid == 0 ) { - continue; + } else { + $data = array(); + $roles = array(); + $times = array(); + $missedlines = array(); + foreach ($stats as $stat) { + if (!empty($stat->zerofixed)) { + $missedlines[] = $stat->timeend; + } + $data[$stat->timeend][$stat->roleid] = $stat->line1; + if ($stat->roleid != 0) { + if (!array_key_exists($stat->roleid,$roles)) { + $roles[$stat->roleid] = get_field('role','name','id',$stat->roleid); } - $rolesdata[$roleid] = 0; + } + if (!array_key_exists($stat->timeend,$times)) { + $times[$stat->timeend] = userdate($stat->timeend,get_string('strftimedate'),$CFG->timezone); } } - krsort($rolesdata); - $row = array_merge(array($times[$time]),$rolesdata); - if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) { - $row[] = '' - .get_string('course').' ' .get_string('logs').' '; + foreach ($data as $time => $rolesdata) { + if (in_array($time,$missedlines)) { + $rolesdata = array(); + foreach ($roles as $roleid => $guff) { + if ($roleid == 0 ) { + continue; + } + $rolesdata[$roleid] = 0; + } + } + krsort($rolesdata); + $row = array_merge(array($times[$time]),$rolesdata); + if (empty($CFG->loglifetime) || ($stat->timeend-(60*60*24)) >= (time()-60*60*24*$CFG->loglifetime)) { + $row[] = '' + .get_string('course').' ' .get_string('logs').' '; + } + $table->data[] = $row; } - $table->data[] = $row; + krsort($roles); + $table->head = array_merge($table->head,$roles); } - krsort($roles); - $table->head = array_merge($table->head,$roles); - } - $table->head[] = get_string('logs'); - if (!empty($lastrecord)) { - $lastrecord[] = $lastlink; - $table->data[] = $lastrecord; + $table->head[] = get_string('logs'); + if (!empty($lastrecord)) { + $lastrecord[] = $lastlink; + $table->data[] = $lastrecord; + } + print_table($table); } - print_table($table); - } + } -?> \ No newline at end of file +?>