Skip to content

Commit

Permalink
MDL-29479 It is now possible to set the active method to null (simple…
Browse files Browse the repository at this point in the history
… direct grading)
  • Loading branch information
mudrd8mz committed Oct 5, 2011
1 parent fb13a14 commit 8cd65f1
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions grade/grading/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,13 +223,17 @@ public function set_active_method($method) {

$this->ensure_isset(array('context', 'component', 'area'));

// make sure the passed method is a valid plugin name
if ('gradingform_'.$method !== clean_param('gradingform_'.$method, PARAM_COMPONENT)) {
throw new moodle_exception('invalid_method_name', 'core_grading');
}
$available = $this->get_available_methods(false);
if (!array_key_exists($method, $available)) {
throw new moodle_exception('invalid_method_name', 'core_grading');
// make sure the passed method is empty or a valid plugin name
if (empty($method)) {
$method = null;
} else {
if ('gradingform_'.$method !== clean_param('gradingform_'.$method, PARAM_COMPONENT)) {
throw new moodle_exception('invalid_method_name', 'core_grading');
}
$available = $this->get_available_methods(false);
if (!array_key_exists($method, $available)) {
throw new moodle_exception('invalid_method_name', 'core_grading');
}
}

// get the current grading area record if it exists
Expand All @@ -252,7 +256,7 @@ public function set_active_method($method) {

} else {
// update the existing record if needed
if ($this->areacache->activemethod != $method) {
if ($this->areacache->activemethod !== $method) {
$DB->set_field('grading_areas', 'activemethod', $method, array('id' => $this->areacache->id));
}
}
Expand Down

0 comments on commit 8cd65f1

Please sign in to comment.