MDL-51090 question: further refinements to validating manual grades
This commit is contained in:
@@ -204,7 +204,7 @@ abstract class question_behaviour {
|
||||
|
||||
$vars = array('comment' => PARAM_RAW, 'commentformat' => PARAM_INT);
|
||||
if ($this->qa->get_max_mark()) {
|
||||
$vars['mark'] = question_attempt::PARAM_MARK;
|
||||
$vars['mark'] = PARAM_RAW_TRIMMED;
|
||||
$vars['maxmark'] = PARAM_FLOAT;
|
||||
}
|
||||
return $vars;
|
||||
@@ -477,15 +477,25 @@ abstract class question_behaviour {
|
||||
}
|
||||
|
||||
if ($pendingstep->has_behaviour_var('mark')) {
|
||||
$fraction = $pendingstep->get_behaviour_var('mark') /
|
||||
$pendingstep->get_behaviour_var('maxmark');
|
||||
if ($pendingstep->get_behaviour_var('mark') === '') {
|
||||
$mark = question_utils::clean_param_mark($pendingstep->get_behaviour_var('mark'));
|
||||
if ($mark === null) {
|
||||
throw new coding_exception('Inalid number format ' . $pendingstep->get_behaviour_var('mark') .
|
||||
' when processing a manual grading action.', 'Question ' . $this->question->id .
|
||||
', slot ' . $this->qa->get_slot());
|
||||
|
||||
} else if ($mark === '') {
|
||||
$fraction = null;
|
||||
} else if ($fraction > $this->qa->get_max_fraction() || $fraction < $this->qa->get_min_fraction()) {
|
||||
throw new coding_exception('Score out of range when processing ' .
|
||||
'a manual grading action.', 'Question ' . $this->question->id .
|
||||
', slot ' . $this->qa->get_slot() . ', fraction ' . $fraction);
|
||||
|
||||
} else {
|
||||
$fraction = $pendingstep->get_behaviour_var('mark') /
|
||||
$pendingstep->get_behaviour_var('maxmark');
|
||||
if ($fraction > $this->qa->get_max_fraction() || $fraction < $this->qa->get_min_fraction()) {
|
||||
throw new coding_exception('Score out of range when processing ' .
|
||||
'a manual grading action.', 'Question ' . $this->question->id .
|
||||
', slot ' . $this->qa->get_slot() . ', fraction ' . $fraction);
|
||||
}
|
||||
}
|
||||
|
||||
$pendingstep->set_fraction($fraction);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user