Group support for Quiz reports. :-)

... except detailed stats.
This commit is contained in:
moodler 2004-02-14 16:52:55 +00:00
parent a46b14ef76
commit 831b236f2c
2 changed files with 83 additions and 4 deletions

View file

@ -11,12 +11,47 @@ class quiz_report extends quiz_default_report {
optional_variable($download, "");
/// Check to see if groups are being used in this quiz
/// and if so, set $currentgroup to reflect the current group
$groupmode = groupmode($course, $cm); // Groups are being used
$currentgroup = get_and_set_current_group($course, $groupmode, $_GET['group']);
if ($groupmode and !$currentgroup and !isteacheredit($course->id)) {
print_heading("Sorry, but you can't see this group");
print_footer();
exit;
}
if ($groupmode == VISIBLEGROUPS or ($groupmode and isteacheredit($course->id))) {
if ($groups = get_records_menu("groups", "courseid", $course->id, "name ASC", "id,name")) {
echo '<table align="center"><tr><td>';
if ($groupmode == VISIBLEGROUPS) {
print_string('groupsvisible');
} else {
print_string('groupsseparate');
}
echo ':';
echo '</td><td nowrap="nowrap" align="left" width="50%">';
popup_form("report.php?id=$cm->id&mode=simplestat&group=",
$groups, 'selectgroup', $currentgroup, "", "", "", false, "self");
echo '</tr></table>';
}
}
if ($currentgroup) {
$users = get_users_in_group($currentgroup, "u.lastname ASC");
} else {
$users = get_course_students($course->id, "u.lastname ASC");
}
$data = array();
$questionorder = explode(',', $quiz->questions);
/// For each person in the class, get their best attempt
/// and create a table listing results for each person
if ($users = get_course_students($course->id, "u.lastname ASC")) {
/// For each person in the class, get their best attempt
/// and create a table listing results for each person
if ($users) {
foreach ($users as $user) {
$data[$user->id]->firstname = $user->firstname;
@ -199,7 +234,11 @@ class quiz_report extends quiz_default_report {
echo "<td><b>$datum->firstname $datum->lastname</b></td>";
if ($datum->grades) {
foreach ($datum->grades as $key => $grade) {
echo "<td>$grade</td>";
if (isset($grade)) {
echo "<td>$grade</td>";
} else {
echo "<td>&nbsp;</td>";
}
}
}
echo "</tr>";