Skip to content

Commit

Permalink
Merge branch 'wip-mdl-53300' of https://github.com/rajeshtaneja/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
David Monllao committed Mar 8, 2016
2 parents d94df7a + bdd4bed commit 406151d
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions lib/form/modgrade.php
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,9 @@ public function onQuickFormEvent($event, $arg, &$caller) {
return true;
}
// Check if we are changing the scale type when grades are present.
if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'scale') {
// If modgrade_type is empty then use currentgradetype.
$gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
if ($gradetype === 'scale') {
if (isset($val['modgrade_scale']) && ($val['modgrade_scale'] !== $this->currentscaleid)) {
return false;
}
Expand All @@ -381,7 +383,9 @@ public function onQuickFormEvent($event, $arg, &$caller) {
return true;
}
// Check if we are changing the max grade if we are using ratings and there is a grade.
if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'point') {
// If modgrade_type is empty then use currentgradetype.
$gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
if ($gradetype === 'point') {
if (isset($val['modgrade_point']) &&
grade_floats_different($this->currentgrade, $val['modgrade_point'])) {
return false;
Expand All @@ -391,21 +395,23 @@ public function onQuickFormEvent($event, $arg, &$caller) {
};
$checkmaxgrade = function($val) {
// Closure to validate a max points value. See the note above about scope if this confuses you.
if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'point') {
if (!isset($val['modgrade_point'])) {
return false;
// If modgrade_type is empty then use currentgradetype.
$gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
if ($gradetype === 'point') {
if (isset($val['modgrade_point'])) {
return $this->validate_point($val['modgrade_point']);
}
return $this->validate_point($val['modgrade_point']);
}
return true;
};
$checkvalidscale = function($val) {
// Closure to validate a scale value. See the note above about scope if this confuses you.
if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'scale') {
if (!isset($val['modgrade_scale'])) {
return false;
// If modgrade_type is empty then use currentgradetype.
$gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
if ($gradetype === 'scale') {
if (isset($val['modgrade_scale'])) {
return $this->validate_scale($val['modgrade_scale']);
}
return $this->validate_scale($val['modgrade_scale']);
}
return true;
};
Expand All @@ -416,7 +422,9 @@ public function onQuickFormEvent($event, $arg, &$caller) {
return true;
}
// Closure to validate a scale value. See the note above about scope if this confuses you.
if (isset($val['modgrade_type']) && $val['modgrade_type'] === 'point') {
// If modgrade_type is empty then use currentgradetype.
$gradetype = isset($val['modgrade_type']) ? $val['modgrade_type'] : $this->currentgradetype;
if ($gradetype === 'point' && isset($val['modgrade_point'])) {
// Work out if the value was actually changed in the form.
if (grade_floats_different($this->currentgrade, $val['modgrade_point'])) {
if (empty($val['modgrade_rescalegrades'])) {
Expand Down

0 comments on commit 406151d

Please sign in to comment.