diff --git a/mod/assignment/assignment.js b/mod/assignment/assignment.js index 8615c4b..0df5909 100644 --- a/mod/assignment/assignment.js +++ b/mod/assignment/assignment.js @@ -35,3 +35,15 @@ M.mod_assignment.init_tree = function(Y, expand_all, htmlid) { tree.render(); }); }; + +M.mod_assignment.init_grade_change = function(Y) { + var gradeNode = Y.one('select[name="grade"]'); + if (gradeNode) { + var originalValue = gradeNode.get('value'); + gradeNode.on('change', function() { + if (gradeNode.get('value') != originalValue) { + alert(M.str.mod_assignment.changegradewarning); + } + }); + } +}; diff --git a/mod/assignment/lang/en/assignment.php b/mod/assignment/lang/en/assignment.php index bef1da4..b77b1e1 100644 --- a/mod/assignment/lang/en/assignment.php +++ b/mod/assignment/lang/en/assignment.php @@ -55,6 +55,7 @@ $string['assignment:view'] = 'View assignment'; $string['availabledate'] = 'Available from'; $string['cannotdeletefiles'] = 'An error occurred and files could not be deleted'; $string['cannotviewassignment'] = 'You can not view this assignment'; +$string['changegradewarning'] = 'Warning: this assignment has graded submissions and changing the grade will not automatically re-calculate new submission grades. You must re-grade all submissions if you choose to continue.'; $string['comment'] = 'Comment'; $string['commentinline'] = 'Comment inline'; $string['commentinline_help'] = 'If enabled, the submission text will be copied into the feedback comment field during grading, making it easier to comment inline (using a different colour, perhaps) or to edit the original text.'; diff --git a/mod/assignment/mod_form.php b/mod/assignment/mod_form.php index 85c8423..313522c 100644 --- a/mod/assignment/mod_form.php +++ b/mod/assignment/mod_form.php @@ -9,7 +9,7 @@ class mod_assignment_mod_form extends moodleform_mod { protected $_assignmentinstance = null; function definition() { - global $CFG, $DB; + global $CFG, $DB, $PAGE; $mform =& $this->_form; // this hack is needed for different settings of each subtype @@ -76,6 +76,11 @@ class mod_assignment_mod_form extends moodleform_mod { $this->standard_coursemodule_elements(); $this->add_action_buttons(); + + if (!empty($this->_instance) and $DB->record_exists_select('assignment_submissions', 'assignment = ? AND grade > -1', array($this->_instance))) { + $module = array('name'=> 'mod_assignment', 'fullpath'=> '/mod/assignment/assignment.js', 'requires'=> array('node', 'event'), 'strings' => array(array('changegradewarning', 'mod_assignment'))); + $PAGE->requires->js_init_call('M.mod_assignment.init_grade_change', null, false, $module); + } } // Needed by plugin assignment types if they include a filemanager element in the settings form