Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'MDL-33548_22' of git://github.com/timhunt/moodle into M…

…OODLE_22_STABLE
  • Loading branch information...
commit c93ff53c8272ffe2121609c7f5f1a2902aee6f8a 2 parents 75bb216 + e78e39c
@nebgor nebgor authored
View
2  mod/quiz/comment.php
@@ -55,7 +55,7 @@
// Process any data that was submitted.
if (data_submitted() && confirm_sesskey()) {
- if (optional_param('submit', false, PARAM_BOOL)) {
+ if (optional_param('submit', false, PARAM_BOOL) && question_behaviour::is_manual_grade_in_range($attemptobj->get_uniqueid(), $slot)) {
$transaction = $DB->start_delegated_transaction();
$attemptobj->process_all_actions(time());
$transaction->allow_commit();
View
6 mod/quiz/report/grading/report.php
@@ -455,11 +455,7 @@ protected function validate_submitted_marks() {
foreach ($qubaids as $qubaid) {
foreach ($slots as $slot) {
- $prefix = 'q' . $qubaid . ':' . $slot . '_';
- $mark = optional_param($prefix . '-mark', null, PARAM_NUMBER);
- $maxmark = optional_param($prefix . '-maxmark', null, PARAM_NUMBER);
- $minfraction = optional_param($prefix . ':minfraction', null, PARAM_NUMBER);
- if (!is_null($mark) && ($mark < $minfraction * $maxmark || $mark > $maxmark)) {
+ if (!question_behaviour::is_manual_grade_in_range($qubaid, $slot)) {
return false;
}
}
View
17 question/behaviour/behaviourbase.php
@@ -458,7 +458,8 @@ public function process_comment(question_attempt_pending_step $pendingstep) {
$fraction = null;
} else if ($fraction > 1 || $fraction < $this->qa->get_min_fraction()) {
throw new coding_exception('Score out of range when processing ' .
- 'a manual grading action.', $pendingstep);
+ 'a manual grading action.', 'Question ' . $this->qa->get_question()->id .
+ ', slot ' . $this->qa->get_slot() . ', fraction ' . $fraction);
}
$pendingstep->set_fraction($fraction);
}
@@ -469,6 +470,20 @@ public function process_comment(question_attempt_pending_step $pendingstep) {
}
/**
+ * Validate that the manual grade submitted for a particular question is in range.
+ * @param int $qubaid the question_usage id.
+ * @param int $slot the slot number within the usage.
+ * @return bool whether the submitted data is in range.
+ */
+ public static function is_manual_grade_in_range($qubaid, $slot) {
+ $prefix = 'q' . $qubaid . ':' . $slot . '_';
+ $mark = optional_param($prefix . '-mark', null, PARAM_NUMBER);
+ $maxmark = optional_param($prefix . '-maxmark', null, PARAM_NUMBER);
+ $minfraction = optional_param($prefix . ':minfraction', null, PARAM_NUMBER);
+ return is_null($mark) || ($mark >= $minfraction * $maxmark && $mark <= $maxmark);
+ }
+
+ /**
* @param $comment the comment text to format. If omitted,
* $this->qa->get_manual_comment() is used.
* @param $commentformat the format of the comment, one of the FORMAT_... constants.
Please sign in to comment.
Something went wrong with that request. Please try again.