Moodle
  1. Moodle
  2. MDL-33843

Assignment grading pages throw JS error

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.3
    • Component/s: Assignment
    • Labels:
    • Rank:
      41943

      Description

      There is an error that pops up in the main grading page and individual student submission grading pages.

      I believe it has to do with quick grading, although the error appears with quick grading both off and on.

      M.core_formchangechecker is undefined
      http://michael.moodle.local/moodle_testing/lib/javascript.php/1340084662/mod/assign/module.js
      Line 6
      

      In Chrome the error appears as...

      Uncaught TypeError: Cannot read property 'set_form_changed' of undefined (anonymous function)
      module.js:6
      

      IE reports...

      Webpage error details
      
      User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C)
      Timestamp: Tue, 19 Jun 2012 07:00:49 UTC
      
      
      Message: Unable to get value of the property 'set_form_changed': object is null or undefined
      Line: 6
      Char: 492
      Code: 0
      URI: http://michael.moodle.local/moodle_testing/lib/javascript.php/1340084662/mod/assign/module.js
      

        Issue Links

          Activity

          Hide
          Damyon Wiese added a comment -

          I'll take a look now. The best idea here is to remove the custom dirty form handling completely and make some improvements to the default dirty form handling for 2.4.

          Show
          Damyon Wiese added a comment - I'll take a look now. The best idea here is to remove the custom dirty form handling completely and make some improvements to the default dirty form handling for 2.4.
          Hide
          Damyon Wiese added a comment -

          What this code was trying to do was to prevent the "You have unsaved changes" warning when the only thing that had changes on the page was the selection checkboxes in the grading table (which are not relevant).

          Show
          Damyon Wiese added a comment - What this code was trying to do was to prevent the "You have unsaved changes" warning when the only thing that had changes on the page was the selection checkboxes in the grading table (which are not relevant).
          Hide
          Dan Poltawski added a comment -

          Hey Andrew,

          Could you peer review this one since you added the formchanger?

          Show
          Dan Poltawski added a comment - Hey Andrew, Could you peer review this one since you added the formchanger?
          Hide
          Andrew Nicols added a comment -

          This change looks fine to me. The check_dirty_quickgrading_form isn't actually used anyway.

          If the functionality is still desired, then it's relatively trivial to add to the core formchangechecker:

          2307 moodle:master> git d
          diff --git a/lib/yui/formchangechecker/formchangechecker.js b/lib/yui/formchangechecker/formchangechecker.js
          index dc819aa..699e048 100644
          --- a/lib/yui/formchangechecker/formchangechecker.js
          +++ b/lib/yui/formchangechecker/formchangechecker.js
          @@ -88,7 +88,10 @@ YUI.add('moodle-core-formchangechecker',
                   /**
                    * Set the form changed state to true
                    */
          -        M.core_formchangechecker.set_form_changed = function() {
          +        M.core_formchangechecker.set_form_changed = function(e) {
          +            if (e.target.hasClass('ignoredirty')) {
          +                return;
          +            }
                       M.core_formchangechecker.stateinformation.formchanged = 1;
           
                       // Once the form has been marked as dirty, we no longer need to keep track of form elements
          

          This can be used in combination with the ignoredirty class you were previously using.

          For future reference, if you really really did need to override the standard method, you'd just need to wrap it in the right framework:
          Wrap the M.core_formchangechecker.set_form_changed function in

          Y.use('moodle-core-formchangechecker', function(Y) {
            M.core_formchangecherk.set_form_changed = function(e) {
              // ...
            }
          });
          

          (this would need to go inside the M.mod_assign.init_grading_options = function(Y) {} definition)

          I think given the proximity to 2.3 though, the best solution would either be to:

          • remove this entirely; or
          • add the ignoredirty option to core.

          My preferred option is to remove this entirely and address this better for 2.4.

          Show
          Andrew Nicols added a comment - This change looks fine to me. The check_dirty_quickgrading_form isn't actually used anyway. If the functionality is still desired, then it's relatively trivial to add to the core formchangechecker: 2307 moodle:master> git d diff --git a/lib/yui/formchangechecker/formchangechecker.js b/lib/yui/formchangechecker/formchangechecker.js index dc819aa..699e048 100644 --- a/lib/yui/formchangechecker/formchangechecker.js +++ b/lib/yui/formchangechecker/formchangechecker.js @@ -88,7 +88,10 @@ YUI.add('moodle-core-formchangechecker', /** * Set the form changed state to true */ - M.core_formchangechecker.set_form_changed = function() { + M.core_formchangechecker.set_form_changed = function(e) { + if (e.target.hasClass('ignoredirty')) { + return ; + } M.core_formchangechecker.stateinformation.formchanged = 1; // Once the form has been marked as dirty, we no longer need to keep track of form elements This can be used in combination with the ignoredirty class you were previously using. For future reference, if you really really did need to override the standard method, you'd just need to wrap it in the right framework: Wrap the M.core_formchangechecker.set_form_changed function in Y.use('moodle-core-formchangechecker', function(Y) { M.core_formchangecherk.set_form_changed = function(e) { // ... } }); (this would need to go inside the M.mod_assign.init_grading_options = function(Y) {} definition) I think given the proximity to 2.3 though, the best solution would either be to: remove this entirely; or add the ignoredirty option to core. My preferred option is to remove this entirely and address this better for 2.4.
          Hide
          Damyon Wiese added a comment -

          Thanks Andrew,

          Removing it completely and then looking at this core change for 2.4 is my preferred option too.

          Show
          Damyon Wiese added a comment - Thanks Andrew, Removing it completely and then looking at this core change for 2.4 is my preferred option too.
          Hide
          Sam Hemelryk added a comment -

          Thanks guys, this has been integrated now.
          Indeed I agree that this is now something best looked at in 2.4.
          Daymon, if you haven't already could you please create a tracker issue to do just that.

          Cheers
          Sam

          Show
          Sam Hemelryk added a comment - Thanks guys, this has been integrated now. Indeed I agree that this is now something best looked at in 2.4. Daymon, if you haven't already could you please create a tracker issue to do just that. Cheers Sam
          Hide
          Michael de Raadt added a comment -

          Test result: Success

          Tested in FF, Chrome and IE9. No JS errors reported.

          Show
          Michael de Raadt added a comment - Test result: Success Tested in FF, Chrome and IE9. No JS errors reported.
          Hide
          Damyon Wiese added a comment -

          Thanks Sam, I have created and linked a ticket.

          Show
          Damyon Wiese added a comment - Thanks Sam, I have created and linked a ticket.
          Hide
          Eloy Lafuente (stronk7) added a comment -

          And this has been incorporated to all the weekly builds and also, to Moodle 2.3 Release Candidate 1, yay!

          Many, many thanks for your hard work!

          Ciao

          Show
          Eloy Lafuente (stronk7) added a comment - And this has been incorporated to all the weekly builds and also, to Moodle 2.3 Release Candidate 1, yay! Many, many thanks for your hard work! Ciao

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: