Won't Fix
Details
Details
Priority
Affects versions
Components
Assignee
Moodle HQ
Moodle HQReporter
Thomas Robb
Thomas RobbParticipants
Michael de Raadt
Moodle HQ
Thomas Robb
Clockify
Clockify
Created 29 April 2008 at 21:47
Updated 6 February 2012 at 16:31
Resolved 6 February 2012 at 16:31
The mdl_data_records table stores the group id of the student and this is used when a group selection is used to display specific records in the database. This means that if the student is a member of two groups and the wrong group is selected for display, the student's record will not show. Rather than relying on a groupid field in the data_records, it would be preferable to extract all records for each user who belongs to a specific group within a course using a sql selection procedure instead.
This can be effected in this way (in data/view.php)
Around line (360)
// if ($currentgroup) {
// $groupselect = " AND (r.groupid = '$currentgroup' OR r.groupid = 0)";
// } else {
// $groupselect = ' ';
// }
if ($currentgroup) {
$courseid = $data->course;
$groupselect = " AND r.userid = m.userid AND (m.groupid = '$currentgroup' OR r.groupid = 0) AND g.courseid = '$courseid'";
} else {
$groupselect = ' ';
}
Around line 440
} else {
$what = ' DISTINCT r.id, r.approved, r.timecreated, r.userid, u.firstname, u.lastname ';
$count = ' COUNT(r.id) ';
// $tables = $CFG->prefix.'data_records r, '.$CFG->prefix.'user u ';
$tables = $CFG->prefix.'data_records r, '.$CFG->prefix.'user u, ' .$CFG->prefix.'groups_members m, ' .$CFG->prefix.'groups g ';
$where = 'WHERE r.dataid = '.$data->id. ' AND r.userid = u.id ';
$sortorder = ' ORDER BY r.timecreated '.$order. ' ';
$searchselect = ' ';
// If requiredentries is not reached, only show current user's entries
if (!$requiredentries_allowed) {
$where .= ' AND u.id = ' . $USER->id;
}
}
Around line 460
$totalcount = count_records_sql($sqlcount); //this no longer works. Using mysql_num_rows instead below.
Around line 510
$records = get_records_sql($sqlselect, $page * $nowperpage, $nowperpage);
$totalcount = mysql_num_rows($records);
NOTE that this is might not be a complete solution. I was only interested in display all records, without any search criteria. This does what I want it to do.