Example #1
0
 /**
  * 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 = question_utils::optional_param_mark($prefix . '-mark');
     $maxmark = optional_param($prefix . '-maxmark', null, PARAM_FLOAT);
     $minfraction = optional_param($prefix . ':minfraction', null, PARAM_FLOAT);
     $maxfraction = optional_param($prefix . ':maxfraction', null, PARAM_FLOAT);
     return is_null($mark) || $mark >= $minfraction * $maxmark && $mark <= $maxfraction * $maxmark;
 }