Skip to content

Commit c7a5378

Browse files
committed
Autopopulate grade ranged rubric
- Final assessor sees initial assessors selected in the criterion and grade - Supports range rubric grading method.
1 parent 520880b commit c7a5378

File tree

5 files changed

+84
-1
lines changed

5 files changed

+84
-1
lines changed

amd/build/rubric_ranges.min.js

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/build/rubric_ranges.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

amd/src/rubric_ranges.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// This file is part of Moodle - http://moodle.org/
2+
//
3+
// Moodle is free software: you can redistribute it and/or modify
4+
// it under the terms of the GNU General Public License as published by
5+
// the Free Software Foundation, either version 3 of the License, or
6+
// (at your option) any later version.
7+
//
8+
// Moodle is distributed in the hope that it will be useful,
9+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
// GNU General Public License for more details.
12+
//
13+
// You should have received a copy of the GNU General Public License
14+
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
15+
16+
/**
17+
* Modify ranged rubric grading form.
18+
*
19+
* @author Sumaiya Javed <sumaiya.javed@catalyst.net.nz
20+
* @copyright Catalyst IT
21+
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
22+
*/
23+
24+
define([], function() {
25+
return {
26+
init: function(gdata) {
27+
if (gdata) {
28+
const rows = Object.values(gdata);
29+
rows.forEach(function(row) {
30+
const elementName = "advancedgrading-criteria-" + row.criterionid;
31+
const elementLevel = document.getElementById(elementName + "-levels-" + row.avglevel);
32+
if (elementLevel) {
33+
elementLevel.classList.add('checked');
34+
}
35+
const elementDefinition = document.getElementById(elementName + "-levels-" + row.avglevel + "-definition");
36+
if (elementDefinition) {
37+
elementDefinition.checked = true;
38+
}
39+
const elementGrade = document.getElementById(elementName + "-grade");
40+
if (elementGrade) {
41+
elementGrade.value = row.avggrade;
42+
}
43+
});
44+
}
45+
}
46+
};
47+
});

classes/controllers/feedback_controller.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,15 @@ protected function new_feedback() {
136136
$urlparams['stageidentifier'] = $teacherfeedback->stageidentifier;
137137
$PAGE->set_url('/mod/coursework/actions/feedbacks/new.php', $urlparams);
138138

139+
// Autopopulate average grade from initial assessors.
140+
if ($coursework && $teacherfeedback->stageidentifier == 'final_agreed_1') {
141+
if (str_contains($coursework->automaticagreementstrategy, 'none')) {
142+
$gdata = [];
143+
$gdata = $coursework->get_advanced_grading_average_grade_range_rubric($teacherfeedback->get_submission()->id);
144+
$PAGE->requires->js_call_amd('mod_coursework/rubric_ranges', 'init', [$gdata]);
145+
}
146+
}
147+
139148
// auto-populate Agreed Feedback with comments from initial marking
140149
if ($coursework && $coursework->autopopulatefeedbackcomment_enabled() && $teacherfeedback->stageidentifier == 'final_agreed_1') {
141150
// get all initial stages feedbacks for this submission

classes/models/coursework.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2119,7 +2119,23 @@ public function get_advanced_grading_active_controller() {
21192119
}
21202120

21212121
/**
2122-
* @return grading_manager
2122+
* @return bool|gradingform_controller|null
2123+
*/
2124+
public function get_advanced_grading_average_grade_range_rubric($submissionid) {
2125+
global $DB;
2126+
if ($submissionid) {
2127+
$sql = "SELECT rr.criterionid, ROUND(AVG(rr.levelid)) as avglevel, ROUND(AVG(rr.grade)) as avggrade
2128+
FROM {coursework_feedbacks} cf
2129+
LEFT JOIN {grading_instances} gi ON cf.id = gi.itemid
2130+
LEFT JOIN {gradingform_rubric_ranges_f} rr ON gi.id = rr.instanceid
2131+
WHERE cf.submissionid = :submissionid AND cf.stageidentifier NOT LIKE 'final_agreed_1' AND cf.finalised = 1 AND gi.status = 1
2132+
GROUP BY rr.criterionid ORDER BY rr.criterionid ";
2133+
return $DB->get_records_sql($sql, ['submissionid' => $submissionid]);
2134+
}
2135+
}
2136+
2137+
/**
2138+
* @return \grading_manager
21232139
*/
21242140
protected function get_advanced_grading_manager() {
21252141
return get_grading_manager($this->get_context(), 'mod_coursework', 'submissions');

0 commit comments

Comments
 (0)