import {call as fetchMany} from 'core/ajax';
import {normaliseResult} from 'core_grades/grades/grader/gradingpanel/normalise';
+import {compareData} from 'core_grades/grades/grader/gradingpanel/comparison';
// Note: We use jQuery.serializer here until we can rewrite Ajax to use XHR.send()
export const storeCurrentGrade = async(component, contextid, itemname, gradeduserid, rootNode) => {
const form = rootNode.querySelector('form');
- return normaliseResult(await fetchMany([{
- methodname: `gradingform_rubric_grader_gradingpanel_store`,
- args: {
- component,
- contextid,
- itemname,
- gradeduserid,
- formdata: jQuery(form).serialize(),
- },
- }])[0]);
+ if (compareData(form) === true) {
+ return normaliseResult(await fetchMany([{
+ methodname: `gradingform_rubric_grader_gradingpanel_store`,
+ args: {
+ component,
+ contextid,
+ itemname,
+ gradeduserid,
+ formdata: jQuery(form).serialize(),
+ },
+ }])[0]);
+ } else {
+ return '';
+ }
};
$criterion = [];
if ($definition->rubric_criteria) {
// Iterate over the defined criterion in the rubric and map out what we need to render each item.
- $criterion = array_map(function($criterion) use ($definitionid, $fillings, $context) {
+ $criterion = array_map(function($criterion) use ($definitionid, $fillings, $context, $hasgrade) {
// The general structure we'll be returning, we still need to get the remark (if any) and the levels associated.
$result = [
'id' => $criterion['id'],
'id' => null,
'criterionid' => $criterion['id'],
'score' => '-',
- 'definition' => 'Not set',
- 'checked' => null,
+ 'definition' => get_string('notset', 'gradingform_rubric'),
+ 'checked' => !$hasgrade,
];
// Consult the grade filling to see if a level has been selected and if it is the current level.
if (array_key_exists('levelid', $filling) && $filling['levelid'] == 0) {
$string['lockzeropoints_help'] = 'This setting only applies if the sum of the minimum number of points for each criterion is greater than 0. If ticked, the minimum achievable grade for the rubric will be greater than 0. If unticked, the minimum possible score for the rubric will be mapped to the minimum grade available for the activity (which is 0 unless a scale is used).';
$string['name'] = 'Name';
$string['needregrademessage'] = 'The rubric definition was changed after this student had been graded. The student can not see this rubric until you check the rubric and update the grade.';
+$string['notset'] = 'Not set';
$string['pluginname'] = 'Rubric';
$string['pointsvalue'] = '{$a} points';
$string['previewrubric'] = 'Preview rubric';
require(['core/auto_rows'], function(AutoRows) {
AutoRows.init(document.getElementById('gradingform_rubric-{{uniqid}}'));
});
-{{/js}}
\ No newline at end of file
+{{/js}}