MDL-47684 mod: better validation of rating options

This commit is contained in:
Sam Hemelryk 2014-10-16 14:50:56 +13:00
parent 2fdb4c6b00
commit 8028df293a
2 changed files with 9 additions and 0 deletions

View File

@ -291,6 +291,14 @@ abstract class moodleform_mod extends moodleform {
}
}
// Ratings: Don't let them select an aggregate type without selecting a scale.
// If the user has selected to use ratings but has not chosen a scale or set max points then the form is
// invalid. If ratings have been selected then the user must select either a scale or max points.
// This matches (horrible) logic in data_preprocessing.
if (isset($data['assessed']) && $data['assessed'] > 0 && empty($data['scale'])) {
$errors['assessed'] = get_string('scaleselectionrequired', 'rating');
}
// Completion: Don't let them choose automatic completion without turning
// on some conditions. Ignore this check when completion settings are
// locked, as the options are then disabled.

View File

@ -55,3 +55,4 @@ $string['ratingtime'] = 'Restrict ratings to items with dates in this range:';
$string['ratings'] = 'Ratings';
$string['rolewarning'] = 'Roles with permission to rate';
$string['rolewarning_help'] = 'To submit ratings users require the moodle/rating:rate capability and any module specific capabilities. Users assigned the following roles should be able to rate items. The list of roles may be amended via the permissions link in the administration block.';
$string['scaleselectionrequired'] = 'When selecting a ratings aggregate type you must also select to use either a scale or set a maximum points.';