fix hotpot reports to handle new group structure in Moodle 1.8 (MDL-8944)

This commit is contained in:
gbateson
2007-03-17 13:28:34 +00:00
parent b139c82dfc
commit 843808a9d8
+7 -6
View File
@@ -51,7 +51,7 @@
// assemble array of form data
$formdata = array(
'mode' => $mode,
'reportusers' => has_capability('mod/hotpot:viewreport',$modulecontext) ? optional_param('reportusers', get_user_preferences('hotpot_reportusers', 'allusers'), PARAM_ALPHA) : 'this',
'reportusers' => has_capability('mod/hotpot:viewreport',$modulecontext) ? optional_param('reportusers', get_user_preferences('hotpot_reportusers', 'allusers'), PARAM_ALPHANUM) : 'this',
'reportattempts' => optional_param('reportattempts', get_user_preferences('hotpot_reportattempts', 'all'), PARAM_ALPHA),
'reportformat' => optional_param('reportformat', 'htm', PARAM_ALPHA),
'reportshowlegend' => optional_param('reportshowlegend', get_user_preferences('hotpot_reportshowlegend', '0'), PARAM_INT),
@@ -83,12 +83,13 @@
// check for groups
if (preg_match('/^group(\d*)$/', $formdata['reportusers'], $matches)) {
$formdata['reportusers'] = 'group';
$formdata['reportgroupid'] = 0;
// validate groupid
if (is_numeric($matches[1]) && get_field('groups', 'courseid', 'id', $matches[1])===$course->id) {
$formdata['reportusers'] = 'group';
$formdata['reportgroupid'] = $matches[1];
} else {
$formdata['reportgroupid'] = 0; // groupid is invalid
if ($groups = groups_get_groups_names($course->id)) {
if (isset($groups[$matches[1]])) {
$formdata['reportgroupid'] = $matches[1];
}
}
}