Error "Uncaught TypeError: Cannot set property 'moduleFlavor' of unidentified" for Only Two of Nine Courses

Error "Uncaught TypeError: Cannot set property 'moduleFlavor' of unidentified" for Only Two of Nine Courses

by Devin McElheran -
Number of replies: 1

Hi Everyone,

I've recently taken on our company's Moodle instance after the departure of our Applications Support person. 

We have the SANS Cyber Security awareness SCORM package. And of the many modules, only two are doing this and started to do so after no changes were made to the system, or at least not by our team.

The link for the SCORM module popup opens and then fails to load the content (Image attached). 

The full error is as below, copied from Chrome's DevTools:

Uncaught TypeError: Cannot set property 'moduleFlavor' of undefined
    at Object.<anonymous> (courseware-new.js:1)
    at Object.<anonymous> (jquery.min.js:2)
    at i (jquery.min.js:2)
    at Object.fireWith [as resolveWith] (jquery.min.js:2)
    at y (jquery.min.js:4)
    at XMLHttpRequest.c (jquery.min.js:4)

The Moodle logs make no mention of any failures to load the content.

Searching for Moodle combined with the first line of the error returned nothing of use.

Is this likely due to corruption? What actions can I take to investigate further (the JS seems to be 'compiled' down to linebreak-less single letter variable names, very difficult to parse)?.

Thank you,

Devin


Attachment moodle_failure_to_load.png
Average of ratings: -
In reply to Devin McElheran

Re: Error "Uncaught TypeError: Cannot set property 'moduleFlavor' of unidentified" for Only Two of Nine Courses

by warren felsh -

In JavaScript almost everything is an object, null and undefined are exception. When you try to access an undefined variable it always returns undefined and we cannot get or set any property of undefined. In that case, an application will throw Uncaught TypeError cannot set property of undefined

In most cases, you are missing the initialization . So, you need to initialize the variable first. Moreover, if you are not sure a variable that will always have some value, the best practice is to check the value of variables for null or undefined before using them. If you just want to check whether there's any value, you can do:

if( value ) {

  //do something

}

Or, if you do not know whether a variable exists (that means, if it was declared) you should check with the typeof operator .

if ( typeof(some_variable) !== "undefined" && some_variable !== null ) {

  //deal with value

}