Permalink
Browse files

Merge branch 'wip-mdl-32759-m23' of git://github.com/rajeshtaneja/moo…

…dle into MOODLE_23_STABLE
  • Loading branch information...
2 parents 69be24a + d54294d commit f16751f85616b481dd1597129fa638c2b5f4628c @stronk7 stronk7 committed Aug 22, 2012
View
@@ -742,7 +742,8 @@ public function adjust_raw_grade($rawgrade, $rawmin, $rawmax) {
// Standardise score to the new grade range
// NOTE: this is not compatible with current assignment grading
- if ($this->itemmodule != 'assignment' and ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
+ $isassignmentmodule = ($this->itemmodule == 'assignment') || ($this->itemmodule == 'assign');
+ if (!$isassignmentmodule && ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
$rawgrade = grade_grade::standardise_score($rawgrade, $rawmin, $rawmax, $this->grademin, $this->grademax);
}
@@ -64,6 +64,7 @@
$string['batchoperationlock'] = 'lock submissions';
$string['batchoperationunlock'] = 'unlock submissions';
$string['batchoperationreverttodraft'] = 'revert submissions to draft';
+$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['conversionexception'] = 'Could not convert assignment. Exception was: {$a}.';
$string['configshowrecentsubmissions'] = 'Everyone can see notifications of submissions in recent activity reports.';
View
@@ -45,7 +45,7 @@ class mod_assign_mod_form extends moodleform_mod {
* @return void
*/
function definition() {
- global $CFG, $DB;
+ global $CFG, $DB, $PAGE;
$mform = $this->_form;
$mform->addElement('header', 'general', get_string('general', 'form'));
@@ -109,6 +109,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('assign_grades', 'assignment = ? AND grade <> -1', array($this->_instance))) {
+ $module = array(
+ 'name' => 'mod_assign',
+ 'fullpath' => '/mod/assign/module.js',
+ 'requires' => array('node', 'event'),
+ 'strings' => array(array('changegradewarning', 'mod_assign'))
+ );
+ $PAGE->requires->js_init_call('M.mod_assign.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_assign')));
+ $mform->insertElementBefore($noscriptwarning, 'grade');
+ }
}
/**
View
@@ -127,4 +127,16 @@ M.mod_assign.init_grading_options = function(Y) {
});
}
});
+};
+
+M.mod_assign.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_assign.changegradewarning);
+ }
+ });
+ }
};
@@ -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);
+ }
+ });
+ }
+};
@@ -56,6 +56,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.';
@@ -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 @@ 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

0 comments on commit f16751f

Please sign in to comment.