Skip to content

Commit

Permalink
Merge branch 'wip-mdl-32759-m22' of git://github.com/rajeshtaneja/moo…
Browse files Browse the repository at this point in the history
…dle into MOODLE_22_STABLE
  • Loading branch information
stronk7 committed Aug 22, 2012
2 parents b1dbeb8 + 2b59c68 commit d90e223
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
12 changes: 12 additions & 0 deletions mod/assignment/assignment.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('#id_grade');
if (gradenode) {
var originalvalue = gradenode.get('value');
gradenode.on('change', function() {
if (gradenode.get('value') != originalvalue) {
alert(M.str.mod_assignment.changegradewarning);
}
});
}
};
1 change: 1 addition & 0 deletions mod/assignment/lang/en/assignment.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
$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'] = 'This assignment has graded submissions and changing the grade will not automatically re-calculate existing submission grades. You must re-grade all existing submissions, if you wish to change the grade.';
$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.';
Expand Down
17 changes: 16 additions & 1 deletion mod/assignment/mod_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -76,6 +76,21 @@ function definition() {
$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
Expand Down

0 comments on commit d90e223

Please sign in to comment.