Skip to content

Commit

Permalink
MDL-69956 forum: throw exception when advanced grading is not ready
Browse files Browse the repository at this point in the history
  • Loading branch information
dcai committed Apr 30, 2021
1 parent a5f0b35 commit 9e1dacc
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,9 @@ public static function get_fetch_data(gradeitem $gradeitem, stdClass $gradeduser
$hasgrade = $gradeitem->user_has_grade($gradeduser);
$grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
$instance = $gradeitem->get_advanced_grading_instance($USER, $grade);
if (!$instance) {
throw new moodle_exception('error:gradingunavailable', 'grading');
}
$controller = $instance->get_controller();
$definition = $controller->get_definition();
$fillings = $instance->get_guide_filling();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ public static function get_fetch_data(gradeitem $gradeitem, stdClass $gradeduser
$hasgrade = $gradeitem->user_has_grade($gradeduser);
$grade = $gradeitem->get_grade_for_user($gradeduser, $USER);
$instance = $gradeitem->get_advanced_grading_instance($USER, $grade);
if (!$instance) {
throw new moodle_exception('error:gradingunavailable', 'grading');
}

$controller = $instance->get_controller();
$definition = $controller->get_definition();
$fillings = $instance->get_rubric_filling();
Expand Down
1 change: 1 addition & 0 deletions lang/en/grading.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,4 @@
$string['templatetypeshared'] = 'Shared template';
$string['templatesource'] = 'Location: {$a->component} ({$a->area})';
$string['error:notinrange'] = 'Invalid grade \'{$a->grade}\' provided. Grades must be between 0 and {$a->maxgrade}.';
$string['error:gradingunavailable'] = 'The advanced grading method is not correctly set. Please check the whole forum grading options in the forum settings.';

0 comments on commit 9e1dacc

Please sign in to comment.