more work on stats reports ...

This commit is contained in:
mjollnir_
2006-09-24 07:13:33 +00:00
parent be91f51dab
commit 96edb010da
7 changed files with 143 additions and 52 deletions
+14 -9
View File
@@ -66,13 +66,18 @@
if (!empty($report) && !empty($time)) {
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
." WHERE timeend >= ".$param->timeafter
." GROUP BY courseid "
.$param->extras
." ORDER BY ".$param->orderby
." LIMIT ".$numcourses;
if (!empty($param->sql)) {
$sql = $param->sql ." LIMIT ".$numcourses;
} else {
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
." WHERE timeend >= ".$param->timeafter.' AND stattype = \'activity\''
." GROUP BY courseid "
.$param->extras
." ORDER BY ".$param->orderby
." LIMIT ".$numcourses;
}
error_log($sql);
$courses = get_records_sql($sql);
@@ -82,7 +87,7 @@
} else {
echo '<div align="center"><img src="'.$CFG->wwwroot.'/'.$CFG->admin.'/report/courseoverview/reportsgraph.php?time='.$time.'&report='.$report.'&numcourses='.$numcourses.'" /></div>';
$table = new object();
$table = new StdClass;
$table->align = array('left','center','center','center');
$table->head = array(get_string('course'),$param->line1);
if (!empty($param->line2)) {
@@ -101,7 +106,7 @@
$a[] = $c->line2;
}
if (isset($c->line3)) {
$a[] = $c->line3;
$a[] = round($c->line3,2);
}
$table->data[] = $a;
}
+10 -6
View File
@@ -16,12 +16,16 @@
$param = stats_get_parameters($time,$report,SITEID,STATS_MODE_RANKED);
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
." WHERE timeend >= ".$param->timeafter
." GROUP BY courseid "
.$param->extras
." ORDER BY ".$param->orderby
." LIMIT ".$numcourses;
if (!empty($param->sql)) {
$sql = $param->sql ." LIMIT ".$numcourses;
} else {
$sql = "SELECT courseid,".$param->fields." FROM ".$CFG->prefix.'stats_'.$param->table
." WHERE timeend >= ".$param->timeafter.' AND stattype = \'activity\''
." GROUP BY courseid "
.$param->extras
." ORDER BY ".$param->orderby
." LIMIT ".$numcourses;
}
$courses = get_records_sql($sql);
+7 -1
View File
@@ -18,13 +18,19 @@
$time = optional_param('time', 0, PARAM_INT);
$mode = optional_param('mode', STATS_MODE_GENERAL, PARAM_INT);
$userid = optional_param('userid', 0, PARAM_INT);
$roleid = 0;
if ($report > 50) {
$roleid = substr($report,1);
$report = 5;
}
if ($report == STATS_REPORT_USER_LOGINS) {
$courseid = SITEID; //override
}
if ($mode == STATS_MODE_RANKED) {
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report.php?time='.$time);
redirect($CFG->wwwroot.'/'.$CFG->admin.'/report/stats/index.php?time='.$time);
}
if (!$course = get_record("course","id",$courseid)) {