From 2f61fc0ee652934ae04a1905bb54d6940593362e Mon Sep 17 00:00:00 2001 From: nicolasconnault Date: Tue, 17 Jul 2007 07:41:52 +0000 Subject: [PATCH] MDL-10477 Implementing rangesdisplaytype, finishing off this task --- grade/report/grader/index.php | 2 +- grade/report/grader/lib.php | 105 ++++++++++++++--------- grade/report/grader/preferences_form.php | 3 + grade/report/grader/settings.php | 6 ++ lang/en_utf8/grades.php | 2 + version.php | 2 +- 6 files changed, 78 insertions(+), 42 deletions(-) diff --git a/grade/report/grader/index.php b/grade/report/grader/index.php index 65c2f3d33ab..0388e8f1772 100644 --- a/grade/report/grader/index.php +++ b/grade/report/grader/index.php @@ -65,7 +65,7 @@ print_paging_bar($numusers, $report->page, $report->get_pref('studentsperpage'), $reporthtml = ''; $reporthtml .= $report->get_headerhtml(); -$reporthtml .= $report->get_scalehtml(); +$reporthtml .= $report->get_rangehtml(); $reporthtml .= $report->get_studentshtml(); $reporthtml .= $report->get_groupavghtml(); $reporthtml .= $report->get_gradeavghtml($numusers); //TODO: numusers not in function definition?? diff --git a/grade/report/grader/lib.php b/grade/report/grader/lib.php index 94773158481..cbde3e90ea0 100644 --- a/grade/report/grader/lib.php +++ b/grade/report/grader/lib.php @@ -589,25 +589,10 @@ class grade_report_grader extends grade_report { $studentshtml .= ''; foreach ($this->items as $item) { - // Percentage format if specified by user (check each item for a set preference) - $gradedisplaytype = $this->get_pref('gradedisplaytype', $item->id); - $percentsign = ''; - - if ($gradedisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { - $percentsign = '%'; - } if (isset($this->finalgrades[$userid][$item->id])) { $gradeval = $this->finalgrades[$userid][$item->id]->finalgrade; - // Convert the grade to percentage if needed - if ($gradedisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { - $gradeval = grade_grades::standardise_score($gradeval, - $this->finalgrades[$userid][$item->id]->grademin, - $this->finalgrades[$userid][$item->id]->grademax, - 0, 100); - } - $grade = new grade_grades($this->finalgrades[$userid][$item->id], false); $grade->feedback = stripslashes_safe($this->finalgrades[$userid][$item->id]->feedback); $grade->feedbackformat = $this->finalgrades[$userid][$item->id]->feedbackformat; @@ -640,7 +625,6 @@ class grade_report_grader extends grade_report { // if in editting mode, we need to print either a text box // or a drop down (for scales) - // grades in item of type grade category or course are not directly editable if ($USER->gradeediting) { // We need to retrieve each grade_grade object from DB in order to @@ -676,9 +660,9 @@ class grade_report_grader extends grade_report { } else if ($item->gradetype != GRADE_TYPE_TEXT) { // Value type if ($this->get_pref('quickgrading') and $grade->is_editable()) { $studentshtml .= '' . $percentsign; + .$item->id.'" value="'.$this->get_grade_clean($gradeval).'"/>'; } else { - $studentshtml .= $this->get_grade_clean($gradeval) . $percentsign; + $studentshtml .= $this->get_grade_clean($gradeval); } } @@ -693,6 +677,22 @@ class grade_report_grader extends grade_report { } } else { + // Percentage format if specified by user (check each item for a set preference) + $gradedisplaytype = $this->get_pref('gradedisplaytype', $item->id); + $percentsign = ''; + + if ($gradedisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { + $percentsign = '%'; + } + + // Convert the grade to percentage if needed + if ($gradedisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE && !is_null($gradeval)) { + $gradeval = grade_grades::standardise_score($gradeval, + $this->finalgrades[$userid][$item->id]->grademin, + $this->finalgrades[$userid][$item->id]->grademax, + 0, 100); + } + // If feedback present, surround grade with feedback tooltip if (!empty($grade->feedback)) { if ($grade->feedbackformat == 1) { @@ -706,7 +706,7 @@ class grade_report_grader extends grade_report { // finalgrades[$userid][$itemid] could be null because of the outer join // in this case it's different than a 0 - if ($item->scaleid && !empty($scales_array[$item->scaleid])) { + if ($item->scaleid && !empty($scales_array[$item->scaleid]) && $gradedisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW) { $scale = $scales_array[$item->scaleid]; $scales = explode(",", $scale->scale); @@ -744,7 +744,7 @@ class grade_report_grader extends grade_report { * @return string HTML */ function get_groupavghtml() { - global $CFG; + global $CFG, $USER; $averagesdisplaytype = $this->get_pref('averagesdisplaytype'); @@ -778,7 +778,9 @@ class grade_report_grader extends grade_report { foreach ($this->items as $item) { // Determine which display type to use for this average $gradedisplaytype = $this->get_pref('gradedisplaytype', $item->id); - if ($averagesdisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT) { // Inherit specific column or general preference + if ($USER->gradeediting) { + $displaytype = GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW; + } elseif ($averagesdisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT) { // Inherit specific column or general preference $displaytype = $gradedisplaytype; } else { // General preference overrides specific column display type $displaytype = $averagesdisplaytype; @@ -805,17 +807,16 @@ class grade_report_grader extends grade_report { } $gradehtml = $scales[$scaleval-1]; + $rawvalue = $scaleval; } else { $gradeval = $this->get_grade_clean($sum/$groupscount[$item->id]); + $gradehtml = round($gradeval, $this->get_pref('decimalpoints', $item->id)); + $rawvalue = $gradeval; + } - $percentsign = ''; - - if ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { - $percentsign = '%'; - $gradeval = grade_grades::standardise_score($gradeval, $item->grademin, $item->grademax, 0, 100); - } - - $gradehtml = round($gradeval, $this->get_pref('decimalpoints', $item->id)) . $percentsign; + if ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { + $gradeval = grade_grades::standardise_score($rawvalue, $item->grademin, $item->grademax, 0, 100); + $gradehtml = round($gradeval, $this->get_pref('decimalpoints', $item->id)) . '%'; } $groupavghtml .= ''; } @@ -830,7 +831,7 @@ class grade_report_grader extends grade_report { * @return string HTML */ function get_gradeavghtml() { - global $CFG; + global $CFG, $USER; $averagesdisplaytype = $this->get_pref('averagesdisplaytype'); @@ -861,7 +862,9 @@ class grade_report_grader extends grade_report { foreach ($this->items as $item) { // Determine which display type to use for this average $gradedisplaytype = $this->get_pref('gradedisplaytype', $item->id); - if ($averagesdisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT) { // Inherit specific column or general preference + if ($USER->gradeediting) { + $displaytype = GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW; + } elseif ($averagesdisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT) { // Inherit specific column or general preference $displaytype = $gradedisplaytype; } else { // General preference overrides specific column display type $displaytype = $averagesdisplaytype; @@ -884,16 +887,17 @@ class grade_report_grader extends grade_report { } $gradehtml = $scales[$scaleval-1]; + $rawvalue = $scaleval; } else { $gradeval = $this->get_grade_clean($sum/$classcount[$itemid]); - $percentsign = ''; - if ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { - $gradeval = grade_grades::standardise_score($gradeval, $item->grademin, $item->grademax, 0, 100); - $percentsign = '%'; - } + $gradehtml = round($gradeval, $this->get_pref('decimalpoints', $item->id)); + $rawvalue = $gradeval; + } - $gradehtml = round($gradeval, $this->get_pref('decimalpoints', $item->id)) . $percentsign; + if ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { + $gradeval = grade_grades::standardise_score($rawvalue, $item->grademin, $item->grademax, 0, 100); + $gradehtml = round($gradeval, $this->get_pref('decimalpoints', $item->id)) . '%'; } $gradeavghtml .= ''; @@ -905,15 +909,36 @@ class grade_report_grader extends grade_report { } /** - * Builds and return the HTML row of scales for each column (i.e. range). + * Builds and return the HTML row of ranges for each column (i.e. range). * @return string HTML */ - function get_scalehtml() { + function get_rangehtml() { + global $USER; + $scalehtml = ''; if ($this->get_pref('showranges')) { + $rangesdisplaytype = $this->get_pref('rangesdisplaytype'); $scalehtml = ''; foreach ($this->items as $item) { - $scalehtml .= ''; + // Determine which display type to use for this range + $gradedisplaytype = $this->get_pref('gradedisplaytype', $item->id); + if ($USER->gradeediting) { + $displaytype = GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW; + } elseif ($rangesdisplaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT) { // Inherit specific column or general preference + $displaytype = $gradedisplaytype; + } else { // General preference overrides specific column display type + $displaytype = $rangesdisplaytype; + } + + if ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW) { + $grademin = $this->get_grade_clean($item->grademin); + $grademax = $this->get_grade_clean($item->grademax); + } elseif ($displaytype == GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE) { + $grademin = 0; + $grademax = 100; + } + + $scalehtml .= ''; } $scalehtml .= ''; } diff --git a/grade/report/grader/preferences_form.php b/grade/report/grader/preferences_form.php index 417e366d0af..cd4d7d80532 100644 --- a/grade/report/grader/preferences_form.php +++ b/grade/report/grader/preferences_form.php @@ -41,6 +41,9 @@ class grader_report_preferences_form extends moodleform { 'averagesdisplaytype' => array(GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT => get_string('inherit', 'grades'), GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW => get_string('raw', 'grades'), GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades')), + 'rangesdisplaytype' => array(GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT => get_string('inherit', 'grades'), + GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW => get_string('raw', 'grades'), + GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades')), 'decimalpoints' => array(0, 1, 2, 3, 4, 5), 'studentsperpage' => 'text'); diff --git a/grade/report/grader/settings.php b/grade/report/grader/settings.php index b954c15aa44..ccffb9e6ca4 100644 --- a/grade/report/grader/settings.php +++ b/grade/report/grader/settings.php @@ -23,6 +23,12 @@ $settings->add(new admin_setting_configselect('grade_report_gradedisplaytype', g array(GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW => get_string('raw', 'grades'), GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades')))); +$settings->add(new admin_setting_configselect('grade_report_rangesdisplaytype', get_string('rangesdisplaytype', 'grades'), + get_string('configrangesdisplaytype', 'grades'), false, + array(GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT => get_string('inherit', 'grades'), + GRADE_REPORT_GRADE_DISPLAY_TYPE_RAW => get_string('raw', 'grades'), + GRADE_REPORT_GRADE_DISPLAY_TYPE_PERCENTAGE => get_string('percentage', 'grades')))); + $settings->add(new admin_setting_configselect('grade_report_averagesdisplaytype', get_string('averagesdisplaytype', 'grades'), get_string('configaveragesdisplaytype', 'grades'), false, array(GRADE_REPORT_GRADE_DISPLAY_TYPE_INHERIT => get_string('inherit', 'grades'), diff --git a/lang/en_utf8/grades.php b/lang/en_utf8/grades.php index 44f3a24e507..29b53ab9541 100644 --- a/lang/en_utf8/grades.php +++ b/lang/en_utf8/grades.php @@ -40,6 +40,7 @@ $string['configgradedisplaytype'] = 'Grades can be shown as raw grades or as per $string['configmeanselection'] = 'Select which types of grades will be included in the column averages. Cells with no grade can be ignored, or counted as 0 (default setting).'; $string['configquickfeedback'] = 'Quick Feedback adds a text input element in each grade cell on the grader report, allowing you to edit many grades at once. You can then click the Update button to perform all these changes at once, instead of one at a time.'; $string['configquickgrading'] = 'Quick Grading adds a text input element in each grade cell on the grader report, allowing you to edit the feedback for many grades at once. You can then click the Update button to perform all these changes at once, instead of one at a time.'; +$string['configrangesdisplaytype'] = 'Specifies how to display the range for each column in the grader report. The default and recommended value is Inherit, which first checks the display type of each column, and if such is not set explicitly, defaults to the more general Grade Display Type. If Raw or Percentage are selected, they ignore the individual settings for each column, and use exclusively the selected type.'; $string['configshowcalculations'] = 'Whether to show calculator icons near each grade item and category, tooltips over calculated items and a visual indicator that a column is calculated.'; $string['configshoweyecons'] = 'Whether to show a show/hide icon near each grade (controlling its visibility to the user).'; $string['configshowaverages'] = 'Show column averages in the grader report.'; @@ -194,6 +195,7 @@ $string['preferences'] = 'Preferences'; $string['quickfeedback'] = 'Quick Feedback'; $string['quickgrading'] = 'Quick Grading'; $string['range'] = 'Range'; +$string['rangesdisplaytype'] = 'Range display type'; $string['rank'] = 'Rank'; $string['raw'] = 'Raw'; $string['rawpct'] = 'Raw %%'; diff --git a/version.php b/version.php index 10948f14a61..8a8dd7beb4f 100644 --- a/version.php +++ b/version.php @@ -6,7 +6,7 @@ // This is compared against the values stored in the database to determine // whether upgrades should be performed (see lib/db/*.php) - $version = 2007071700; // YYYYMMDD = date + $version = 2007071701; // YYYYMMDD = date // XY = increments within a single day $release = '1.9 dev'; // Human-friendly version name
' . fullname($user) . ''.$gradehtml.''.$gradehtml.'
'.$this->get_lang_string('range','grades').''. $this->get_grade_clean($item->grademin).'-'. $this->get_grade_clean($item->grademax).''. $grademin.'-'. $grademax.'