MDL-32759 Assignment: Changing grade for existing assignments will show warning that grades will not be scaled

This commit is contained in:
Rajesh Taneja
2012-08-14 11:44:41 +08:00
parent c36de79f5c
commit 2b59c68796
3 changed files with 29 additions and 1 deletions
+16 -1
View File
@@ -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,21 @@ class mod_assignment_mod_form extends moodleform_mod {
$this->standard_coursemodule_elements();
$this->add_action_buttons();
// Add warning popup/noscript tag, if grades are changed by user.
if ($mform->elementExists('grade') && !empty($this->_instance) && $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);
// Add noscript tag in case
$noscriptwarning = $mform->createElement('static', 'warning', null, html_writer::tag('noscript', get_string('changegradewarning', 'mod_assignment')));
$mform->insertElementBefore($noscriptwarning, 'grade');
}
}
// Needed by plugin assignment types if they include a filemanager element in the settings form