mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 17:06:53 +02:00
Merge branch 'MDL-55997-master' of git://github.com/peterRd/moodle
This commit is contained in:
commit
0d83964337
2 changed files with 28 additions and 7 deletions
|
@ -1196,11 +1196,13 @@ function stats_get_parameters($time,$report,$courseid,$mode,$roleid=0) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case STATS_REPORT_USER_VIEW:
|
case STATS_REPORT_USER_VIEW:
|
||||||
$param->fields = 'statsreads as line1, statswrites as line2, statsreads+statswrites as line3';
|
$param->fields = 'timeend, SUM(statsreads) AS line1, SUM(statswrites) AS line2, SUM(statsreads+statswrites) AS line3';
|
||||||
|
$param->fieldscomplete = true;
|
||||||
$param->line1 = get_string('statsuserreads');
|
$param->line1 = get_string('statsuserreads');
|
||||||
$param->line2 = get_string('statsuserwrites');
|
$param->line2 = get_string('statsuserwrites');
|
||||||
$param->line3 = get_string('statsuseractivity');
|
$param->line3 = get_string('statsuseractivity');
|
||||||
$param->stattype = 'activity';
|
$param->stattype = 'activity';
|
||||||
|
$param->extras = "GROUP BY timeend";
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// ******************** STATS_MODE_RANKED ******************** //
|
// ******************** STATS_MODE_RANKED ******************** //
|
||||||
|
|
|
@ -124,14 +124,33 @@ $time = array_pop($timekeys);
|
||||||
|
|
||||||
$param = stats_get_parameters($time,STATS_REPORT_USER_VIEW,$course->id,STATS_MODE_DETAILED);
|
$param = stats_get_parameters($time,STATS_REPORT_USER_VIEW,$course->id,STATS_MODE_DETAILED);
|
||||||
$params = $param->params;
|
$params = $param->params;
|
||||||
|
|
||||||
$param->table = 'user_'.$param->table;
|
$param->table = 'user_'.$param->table;
|
||||||
|
|
||||||
$sql = 'SELECT id, timeend,'.$param->fields.' FROM {stats_'.$param->table.'} WHERE '
|
// Build the conditions and parameters.
|
||||||
.(($course->id == SITEID) ? '' : ' courseid = '.$course->id.' AND ')
|
$wheres = [
|
||||||
.' userid = '.$user->id.' AND timeend >= '.$param->timeafter .$param->extras
|
"userid = :userid",
|
||||||
.' ORDER BY timeend DESC';
|
"timeend >= :timeend",
|
||||||
$stats = $DB->get_records_sql($sql, $params); //TODO: improve these params!!
|
];
|
||||||
|
$params['userid'] = $user->id;
|
||||||
|
$params['timeend'] = $param->timeafter;
|
||||||
|
// Add condition for course ID when specified.
|
||||||
|
if ($course->id != SITEID) {
|
||||||
|
$wheres[] = "courseid = :courseid";
|
||||||
|
$params['courseid'] = $course->id;
|
||||||
|
}
|
||||||
|
// Combine the conditions.
|
||||||
|
$wheresql = implode(" AND ", $wheres);
|
||||||
|
|
||||||
|
// Build the query.
|
||||||
|
$sql = "
|
||||||
|
SELECT {$param->fields}
|
||||||
|
FROM {stats_{$param->table}}
|
||||||
|
WHERE {$wheresql}
|
||||||
|
{$param->extras}
|
||||||
|
ORDER BY timeend DESC";
|
||||||
|
|
||||||
|
// Fetch the stats data.
|
||||||
|
$stats = $DB->get_records_sql($sql, $params);
|
||||||
|
|
||||||
if (empty($stats)) {
|
if (empty($stats)) {
|
||||||
print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
|
print_error('nostatstodisplay', '', $CFG->wwwroot.'/course/user.php?id='.$course->id.'&user='.$user->id.'&mode=outline');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue