Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

…dle into MOODLE_23_STABLE
  • Loading branch information...
commit f16751f85616b481dd1597129fa638c2b5f4628c 2 parents 69be24a + d54294d
Eloy Lafuente (stronk7) authored August 22, 2012
3  lib/grade/grade_item.php
@@ -742,7 +742,8 @@ public function adjust_raw_grade($rawgrade, $rawmin, $rawmax) {
742 742
 
743 743
             // Standardise score to the new grade range
744 744
             // NOTE: this is not compatible with current assignment grading
745  
-            if ($this->itemmodule != 'assignment' and ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
  745
+            $isassignmentmodule = ($this->itemmodule == 'assignment') || ($this->itemmodule == 'assign');
  746
+            if (!$isassignmentmodule && ($rawmin != $this->grademin or $rawmax != $this->grademax)) {
746 747
                 $rawgrade = grade_grade::standardise_score($rawgrade, $rawmin, $rawmax, $this->grademin, $this->grademax);
747 748
             }
748 749
 
1  mod/assign/lang/en/assign.php
@@ -64,6 +64,7 @@
64 64
 $string['batchoperationlock'] = 'lock submissions';
65 65
 $string['batchoperationunlock'] = 'unlock submissions';
66 66
 $string['batchoperationreverttodraft'] = 'revert submissions to draft';
  67
+$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.';
67 68
 $string['comment'] = 'Comment';
68 69
 $string['conversionexception'] = 'Could not convert assignment. Exception was: {$a}.';
69 70
 $string['configshowrecentsubmissions'] = 'Everyone can see notifications of submissions in recent activity reports.';
17  mod/assign/mod_form.php
@@ -45,7 +45,7 @@ class mod_assign_mod_form extends moodleform_mod {
45 45
      * @return void
46 46
      */
47 47
     function definition() {
48  
-        global $CFG, $DB;
  48
+        global $CFG, $DB, $PAGE;
49 49
         $mform = $this->_form;
50 50
 
51 51
         $mform->addElement('header', 'general', get_string('general', 'form'));
@@ -109,6 +109,21 @@ function definition() {
109 109
         $this->standard_coursemodule_elements();
110 110
 
111 111
         $this->add_action_buttons();
  112
+
  113
+        // Add warning popup/noscript tag, if grades are changed by user.
  114
+        if ($mform->elementExists('grade') && !empty($this->_instance) && $DB->record_exists_select('assign_grades', 'assignment = ? AND grade <> -1', array($this->_instance))) {
  115
+            $module = array(
  116
+                'name' => 'mod_assign',
  117
+                'fullpath' => '/mod/assign/module.js',
  118
+                'requires' => array('node', 'event'),
  119
+                'strings' => array(array('changegradewarning', 'mod_assign'))
  120
+                );
  121
+            $PAGE->requires->js_init_call('M.mod_assign.init_grade_change', null, false, $module);
  122
+
  123
+            // Add noscript tag in case
  124
+            $noscriptwarning = $mform->createElement('static', 'warning', null,  html_writer::tag('noscript', get_string('changegradewarning', 'mod_assign')));
  125
+            $mform->insertElementBefore($noscriptwarning, 'grade');
  126
+        }
112 127
     }
113 128
 
114 129
     /**
12  mod/assign/module.js
@@ -127,4 +127,16 @@ M.mod_assign.init_grading_options = function(Y) {
127 127
             });
128 128
         }
129 129
     });
  130
+};
  131
+
  132
+M.mod_assign.init_grade_change = function(Y) {
  133
+    var gradenode = Y.one('#id_grade');
  134
+    if (gradenode) {
  135
+        var originalvalue = gradenode.get('value');
  136
+        gradenode.on('change', function() {
  137
+            if (gradenode.get('value') != originalvalue) {
  138
+                alert(M.str.mod_assign.changegradewarning);
  139
+            }
  140
+        });
  141
+    }
130 142
 };
12  mod/assignment/assignment.js
@@ -35,3 +35,15 @@ M.mod_assignment.init_tree = function(Y, expand_all, htmlid) {
35 35
         tree.render();
36 36
     });
37 37
 };
  38
+
  39
+M.mod_assignment.init_grade_change = function(Y) {
  40
+    var gradenode = Y.one('#id_grade');
  41
+    if (gradenode) {
  42
+        var originalvalue = gradenode.get('value');
  43
+        gradenode.on('change', function() {
  44
+            if (gradenode.get('value') != originalvalue) {
  45
+                alert(M.str.mod_assignment.changegradewarning);
  46
+            }
  47
+        });
  48
+    }
  49
+};
1  mod/assignment/lang/en/assignment.php
@@ -56,6 +56,7 @@
56 56
 $string['availabledate'] = 'Available from';
57 57
 $string['cannotdeletefiles'] = 'An error occurred and files could not be deleted';
58 58
 $string['cannotviewassignment'] = 'You can not view this assignment';
  59
+$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.';
59 60
 $string['comment'] = 'Comment';
60 61
 $string['commentinline'] = 'Comment inline';
61 62
 $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.';
17  mod/assignment/mod_form.php
@@ -9,7 +9,7 @@ class mod_assignment_mod_form extends moodleform_mod {
9 9
     protected $_assignmentinstance = null;
10 10
 
11 11
     function definition() {
12  
-        global $CFG, $DB;
  12
+        global $CFG, $DB, $PAGE;
13 13
         $mform =& $this->_form;
14 14
 
15 15
         // this hack is needed for different settings of each subtype
@@ -76,6 +76,21 @@ function definition() {
76 76
         $this->standard_coursemodule_elements();
77 77
 
78 78
         $this->add_action_buttons();
  79
+
  80
+        // Add warning popup/noscript tag, if grades are changed by user.
  81
+        if ($mform->elementExists('grade') && !empty($this->_instance) && $DB->record_exists_select('assignment_submissions', 'assignment = ? AND grade <> -1', array($this->_instance))) {
  82
+            $module = array(
  83
+                'name' => 'mod_assignment',
  84
+                'fullpath' => '/mod/assignment/assignment.js',
  85
+                'requires' => array('node', 'event'),
  86
+                'strings' => array(array('changegradewarning', 'mod_assignment'))
  87
+                );
  88
+            $PAGE->requires->js_init_call('M.mod_assignment.init_grade_change', null, false, $module);
  89
+
  90
+            // Add noscript tag in case
  91
+            $noscriptwarning = $mform->createElement('static', 'warning', null,  html_writer::tag('noscript', get_string('changegradewarning', 'mod_assignment')));
  92
+            $mform->insertElementBefore($noscriptwarning, 'grade');
  93
+        }
79 94
     }
80 95
 
81 96
     // Needed by plugin assignment types if they include a filemanager element in the settings form

0 notes on commit f16751f

Please sign in to comment.
Something went wrong with that request. Please try again.