Skip to content
Browse files

fixes for overriding of scales, outcomes and minor access control tweak

  • Loading branch information...
1 parent ffe6eb2 commit 0658afc9a1c17c1aec094d0ef6f72cc9058e02a0 skodak committed Aug 7, 2007
Showing with 31 additions and 8 deletions.
  1. +6 −1 grade/edit/tree/grade.php
  2. +6 −1 grade/edit/tree/grade_form.php
  3. +8 −2 grade/report/grader/lib.php
  4. +11 −4 lib/grade/grade_item.php
View
7 grade/edit/tree/grade.php
@@ -108,6 +108,11 @@
} else if ($data = $mform->get_data(false)) {
$old_grade_grade = new grade_grade(array('userid'=>$data->userid, 'itemid'=>$grade_item->id), true); //might not exist yet
+ // fix no grade for scales
+ if ($grade_item->gradetype == GRADE_TYPE_SCALE and $data->finalgrade < 1) {
+ $data->finalgrade = NULL;
+ }
+
// update final grade or feedback
$grade_item->update_final_grade($data->userid, $data->finalgrade, NULL, 'editgrade', $data->feedback, $data->feedbackformat);
@@ -125,7 +130,7 @@
}
}
- if (has_capability('moodle/grade:override', $context)) {
+ if (has_capability('moodle/grade:manage', $context) or has_capability('moodle/grade:override', $context)) {
// ignore overridden flag when changing final grade
if ($old_grade_grade->finalgrade == $grade_grade->finalgrade) {
if ($grade_grade->set_overridden($data->overridden) and empty($data->overridden)) {
View
7 grade/edit/tree/grade_form.php
@@ -24,7 +24,12 @@ function definition() {
} else if ($grade_item->gradetype == GRADE_TYPE_SCALE) {
// scale grade
$scaleopt = array();
- $scaleopt[-1] = get_string('nograde');
+
+ if (empty($grade_item->outcomeid)) {
+ $scaleopt[-1] = get_string('nograde');
+ } else {
+ $scaleopt[-1] = get_string('nooutcome', 'grades');
+ }
$i = 1;
if ($scale = get_record('scale', 'id', $grade_item->scaleid)) {
View
10 grade/report/grader/lib.php
@@ -616,10 +616,16 @@ function get_studentshtml() {
}
if ($this->get_pref('quickgrading') and $grade->is_editable()) {
+ $oldval = empty($gradeval) ? -1 : $gradeval;
+ if (empty($item->outcomeid)) {
+ $nogradestr = $this->get_lang_string('nograde');
+ } else {
+ $nogradestr = $this->get_lang_string('nooutcome', 'grades');
+ }
$studentshtml .= '<input type="hidden" name="oldgrade_'.$userid.'_'
- .$item->id.'" value="'.$gradeval.'"/>';
+ .$item->id.'" value="'.$oldval.'"/>';
$studentshtml .= choose_from_menu($scaleopt, 'grade_'.$userid.'_'.$item->id,
- $gradeval, $this->get_lang_string('nograde'), '', '-1',
+ $gradeval, $nogradestr, '', '-1',
true, false, $tabindices[$item->id]['grade']);
} elseif(!empty($scale)) {
$scales = explode(",", $scale->scale);
View
15 lib/grade/grade_item.php
@@ -611,6 +611,10 @@ function regrade_final_grades($userid=null) {
return "Could not calculate grades for grade item"; // TODO: improve and localize
}
+ // noncalculated outcomes already have final values - raw grades not used
+ } else if ($this->is_outcome_item()) {
+ return true;
+
// aggregate the category grade
} else if ($this->is_category_item() or $this->is_course_item()) {
// aggregate category grade item
@@ -1262,13 +1266,16 @@ function update_final_grade($userid, $finalgrade=false, $source=NULL, $note=NULL
$grade->finalgrade = $finalgrade;
}
- // if we can update the raw grade, do update it
- if ($this->is_outcome_item() or !$this->is_normal_item()
- or $this->plusfactor != 0 or $this->multfactor != 1
- or !events_is_registered('grade_updated', $this->itemtype.'/'.$this->itemmodule)) {
+ if ($this->is_outcome_item()) {
+ // no updates of raw grades for outcomes - raw grades not used
+
+ } else if (!$this->is_normal_item() or $this->plusfactor != 0 or $this->multfactor != 1
+ or !events_is_registered('grade_updated', $this->itemtype.'/'.$this->itemmodule)) {
+ // we can not update the raw grade - flag it as overridden
if (!$grade->overridden) {
$grade->overridden = time();
}
+
} else {
$grade->rawgrade = $finalgrade;
// copy current grademin/max and scale

0 comments on commit 0658afc

Please sign in to comment.
Something went wrong with that request. Please try again.