mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Group support for Quiz reports. :-)
... except detailed stats.
This commit is contained in:
parent
a46b14ef76
commit
831b236f2c
2 changed files with 83 additions and 4 deletions
|
@ -67,6 +67,41 @@ class quiz_report extends quiz_default_report {
|
|||
return true;
|
||||
}
|
||||
|
||||
/// 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=overview&group=",
|
||||
$groups, 'selectgroup', $currentgroup, "", "", "", false, "self");
|
||||
echo '</tr></table>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// Get all teachers and students
|
||||
if ($currentgroup) {
|
||||
$users = get_users_in_group($currentgroup);
|
||||
}
|
||||
|
||||
|
||||
$table->head = array(" ", $strname, $strattempts, "$strbestgrade /$quiz->grade");
|
||||
$table->align = array("center", "left", "left", "center");
|
||||
$table->wrap = array("nowrap", "nowrap", "nowrap", "nowrap");
|
||||
|
@ -74,6 +109,11 @@ class quiz_report extends quiz_default_report {
|
|||
$table->size = array(10, "*", "80%", "*");
|
||||
|
||||
foreach ($grades as $grade) {
|
||||
if ($currentgroup) {
|
||||
if (empty($users[$grade->userid])) { /// Using groups, but this user not in group
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$picture = print_user_picture($grade->userid, $course->id, $grade->picture, false, true);
|
||||
|
||||
if ($attempts = quiz_get_user_attempts($quiz->id, $grade->userid)) {
|
||||
|
|
|
@ -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> </td>";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</tr>";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue