diff --git a/course/moodleform_mod.php b/course/moodleform_mod.php index 1f5b051a787..33014d668ac 100644 --- a/course/moodleform_mod.php +++ b/course/moodleform_mod.php @@ -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. diff --git a/lang/en/rating.php b/lang/en/rating.php index 79cc8d25987..1282b05e17b 100644 --- a/lang/en/rating.php +++ b/lang/en/rating.php @@ -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.'; \ No newline at end of file