Skip to content

Commit

Permalink
Improves grade setting update
Browse files Browse the repository at this point in the history
But still problem to unhidden grade is hidden by gradebook
  • Loading branch information
jcrodriguez-dis committed Aug 11, 2018
1 parent 3cbb0ba commit f26b647
Showing 1 changed file with 15 additions and 14 deletions.
29 changes: 15 additions & 14 deletions lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,33 +41,34 @@ function vpl_grade_item_update($instance, $grades=null) {
global $CFG;
require_once($CFG->libdir.'/gradelib.php');

$params = array('itemname' => $instance->name);
$params ['hidden'] = ($instance->visiblegrade > 0) ? 0 : 1;
$itemdetails = array('itemname' => $instance->name);
$itemdetails ['hidden'] = ($instance->visiblegrade > 0) ? 0 : 1;
if ( isset($instance->cmidnumber) ) {
$params['idnumber'] = $instance->cmidnumber;
$itemdetails['idnumber'] = $instance->cmidnumber;
}
if ($instance->grade > 0) {
$params['gradetype'] = GRADE_TYPE_VALUE;
$params['grademax'] = $instance->grade;
$params['grademin'] = 0;
$itemdetails['gradetype'] = GRADE_TYPE_VALUE;
$itemdetails['grademax'] = $instance->grade;
$itemdetails['grademin'] = 0;

} else if ($instance->grade < 0) {
$params['gradetype'] = GRADE_TYPE_SCALE;
$params['scaleid'] = -$instance->grade;
$itemdetails['gradetype'] = GRADE_TYPE_SCALE;
$itemdetails['scaleid'] = -$instance->grade;

}
if ($instance->grade == 0 || $instance->example != 0) {
$params['gradetype'] = GRADE_TYPE_NONE;
$params['deleted'] = 1;
$itemdetails['gradetype'] = GRADE_TYPE_NONE;
$itemdetails['deleted'] = 1;
}

if ($grades === 'reset') {
$params['reset'] = true;
$itemdetails['reset'] = true;
$grades = null;
}

if ($grades != null) {
$itemdetails = null;
}
return grade_update('mod/vpl', $instance->course, 'mod', 'vpl',
$instance->id, 0, $grades, $params);
$instance->id, 0, $grades, $itemdetails);
}

/**
Expand Down

0 comments on commit f26b647

Please sign in to comment.