Description

If I install Moodle 1.8 Windows complete package, let the database install and complete first setup, then rename the moodle folder to moodle-1.7 and extract the latest moodle-1.8 generic build in its place, then go to the /admin/ page and authenticate as administrator to apply the database table changes, then create a new course in the Miscellaneous group, then automatically get prompted to Add an AICC/SCORM package, then choose to upload the package as uploaded to http://www.peterchamberlin.dsl.pipex.com/M2775101-2004.zip, then provide a title and description for it and then click the Save Changes button then...

Which is called by:
ret = validate_mod_scorm_mod_form_reference(frm.elements['reference']) && ret

Which fails because there's no such element "reference"

Getting past this error then results in a pause while the package is extracted and made ready to be added to the course and then I receive an empty HTML page and no error message. If I wipe down the filename and go to the /course/ folder then I see that the package has not been added and it goes through the auto-add process again. I see that the package files have been extracted to course folder "2" but in the \moodledata\2\moddata\scorm\KdkWOQVF\ folder I see some of the extracted files and the package .zip file - but in checking what's been extracting I see that the operation stopped before file \M2775101\help\help\measureDCVoltage_images\MeasureDCVoltage_04.jpg was in place. On repeating this entire process in Firefox I note that the extraction stops around the same place, but not on the exact file. Firefox also raises a JavaScript error and receives an empty page in response to the Save Changes form submission.

This seems like a pretty major fault to have in a 1.8 version that's being "polished". It seems to be package specific as most of my generated content files, and some from other vendors, goes wrong in a similar manor. Others work fine. Our package is SCORM 2004 3rd Edition conformant.

Peter Chamberlin
added a comment - 04/Apr/07 5:16 PM This issue also occurs with a SCORM 1.2 conformant package in Moodle 1.8 (31st March release).
Try importing the package at:
http://www.peterchamberlin.dsl.pipex.com/M2582801_C01-1.2.zip (29.52Mb)
This package imports fine in Moodle 1.7.2
I cannot get any error information, even when setting debugging mode to high and developer levels. Well, under 'developer' I can't even get to the import page due to XSL parser errors.

Why has there been no response to this bug report? The issue is still present with my latest SCORM 1.2 packages on Moodle 1.8 latest daily build, including the simple JavaScript error.

Is it because the "bug fixes for Moodle 1.8.x" link at the top of this page doesn't actually reference this tracked issue? That's because the filter settings associated with request 10077 doesn't include "Affects version 1.8" or 1.8.1

Peter Chamberlin
added a comment - 08/May/07 10:11 PM Why has there been no response to this bug report? The issue is still present with my latest SCORM 1.2 packages on Moodle 1.8 latest daily build, including the simple JavaScript error.
Is it because the "bug fixes for Moodle 1.8.x" link at the top of this page doesn't actually reference this tracked issue? That's because the filter settings associated with request 10077 doesn't include "Affects version 1.8" or 1.8.1
Change the Component field to SCORM?

Jose Martin
added a comment - 12/May/07 1:10 AM Hi Peter, I have the same error. I think that the problem could be that the script stop after x seconds. When I try with a small course it works OK, but if the Packege is over 6 MB fails.

Peter Chamberlin
added a comment - 06/Jun/07 4:13 PM This issue does seem to be timeout related, since I produced a smaller 1.2 package and that imported okay (a very small package).
I found the following issue: http://tracker.moodle.org/browse/MDL-9557
This points things the way of the scorm_delete_files() function in mod\scorm\locallib.php where a set_time_limit(5) limits the maximum tree deletion ability for top nodes..
Hopefully someone will fix this bug (and the JavaScript form submission one), until then at least I have something to recommend to clients to adjust to avoid this issue in 1.8

Roberto Pinna
added a comment - 07/Jun/07 6:31 AM The JS error is in libform generated javascript code.
By the way I get no problem during importing the big package on Moodle 1.8+.
It's imported and played without problems.

we were also getting the same error in moodle 1.9 while uploading scorm 1.2 courses.

we found the problem to be in mod/scorm/mod_form.php at the code:
$mform->addRule('reference', get_string('required'), 'required', null, 'client');

The error was occuring at the argument 'reference'. When we checked the source code of the page (Adding a new SCORM/AICC), we found the input box name of "Package file" as 'reference[value]'. We changed the argument to "reference[value]". That is, $mform->addRule('reference[value]', get_string('required'), 'required', null, 'client');

CommLab India
added a comment - 07/Jul/08 8:39 PM Hi,
we were also getting the same error in moodle 1.9 while uploading scorm 1.2 courses.
we found the problem to be in mod/scorm/mod_form.php at the code:
$mform->addRule('reference', get_string('required'), 'required', null, 'client');
The error was occuring at the argument 'reference'. When we checked the source code of the page (Adding a new SCORM/AICC), we found the input box name of "Package file" as 'reference [value] '. We changed the argument to "reference [value] ". That is, $mform->addRule('reference [value] ', get_string('required'), 'required', null, 'client');
It works fine!
Regards,
CommLab India

assigning to Piers - can you please check this out? - it doesn't happen 100% of the time, so I wonder if different versions of JS handle it differently? - or if reference is set differently under certain conditions?

Dan Marsden
added a comment - 08/Jul/08 4:45 AM assigning to Piers - can you please check this out? - it doesn't happen 100% of the time, so I wonder if different versions of JS handle it differently? - or if reference is set differently under certain conditions?
Dan

CommLab India
added a comment - 10/Jul/08 1:55 PM Hi Dan,
When ever we use to upload SCORM/AICC courses, we use to get this error both in offline and online versions.
Line: 205
Error: 'parentNode' is null or not an object
We changed the argument to "reference [value] " directly without any conditions.
Regards,
CommLab India

Hi Dan/ CommLab India -
In STABLE18 I can recreate the problem with "Error: 'parentNode' is null or not an object" in IE7 (and only IE - it never happens in that FF3 that I can discern). But, in HEAD, I get a different problem that seems to be happening earlier.
function validate_mod_scorm_mod_form(frm) throws an error at frm.elements['summary'].focus(); But this maybe happening for similar reasons to do with finding the parent form (I need to find a decent debugger for IE to really track this down).
Changing the argument to "reference[value]" masks the problem as it removes the validation routine, which then never gets executed... problem goes away.
It would great to get the maintainers of the core input form handling routines to comment on this (not sure who they are).

Piers Harding
added a comment - 22/Jul/08 6:09 AM Hi Dan/ CommLab India -
In STABLE18 I can recreate the problem with "Error: 'parentNode' is null or not an object" in IE7 (and only IE - it never happens in that FF3 that I can discern). But, in HEAD, I get a different problem that seems to be happening earlier.
function validate_mod_scorm_mod_form(frm) throws an error at frm.elements ['summary'] .focus(); But this maybe happening for similar reasons to do with finding the parent form (I need to find a decent debugger for IE to really track this down).
Changing the argument to "reference [value] " masks the problem as it removes the validation routine, which then never gets executed... problem goes away.
It would great to get the maintainers of the core input form handling routines to comment on this (not sure who they are).
Cheers,
Piers Harding.

Hi - after some more debugging I have narrowed down the problem in STABLE18 to a mismatch in names of the form fields and the expected names in the associated validation javascript - it's looking for reference where the actual name is reference[value].
The attached patch file MDL-9077-moodle18.patch demonstrates a hack-around for the problem by patching formslib.php, but I am not confident that this is the right solution (the maintainer for formslib.php would have a better handle on it).

Piers Harding
added a comment - 22/Jul/08 9:57 AM Hi - after some more debugging I have narrowed down the problem in STABLE18 to a mismatch in names of the form fields and the expected names in the associated validation javascript - it's looking for reference where the actual name is reference [value] .
The attached patch file MDL-9077 -moodle18.patch demonstrates a hack-around for the problem by patching formslib.php, but I am not confident that this is the right solution (the maintainer for formslib.php would have a better handle on it).
Would be good to have the right eyes on this one.
Cheers,
Piers Harding.

Jamie Pratt
added a comment - 22/Jul/08 11:24 AM hi,
Sorry client side validation is not supported for this element type.
I would suggest to remove the 'client' param from the call to addRule :
$mform->addRule('reference', get_string('required'), 'required', null);
Then the rule will be checked on the server side.
If someone wanted to work through the js used for client side validation and suggest some solid patches that would be great. Most of the js is taken directly from the pear QuickForm library.
Jamie

After correcting the reference field JS validation problem, I stumbled upon another to do with validation (client, and server) of textarea fields that have an html editor attached. When the validation fails it attempts to set the focus() on the textarea which has been masked by the iframe of the html editor.
The attached patch MDL-9077-moodle18.patch checks to see if an element is a textarea, and whether the user has htmleditor enabled - if so it bypasses the focus() call.

Piers Harding
added a comment - 23/Jul/08 8:42 AM After correcting the reference field JS validation problem, I stumbled upon another to do with validation (client, and server) of textarea fields that have an html editor attached. When the validation fails it attempts to set the focus() on the textarea which has been masked by the iframe of the html editor.
The attached patch MDL-9077 -moodle18.patch checks to see if an element is a textarea, and whether the user has htmleditor enabled - if so it bypasses the focus() call.
This issue affects all forms that use the htmleditor.
Cheers,
Piers Harding.

I am linking these two issues together because there is a correlation between the form javascript errors and the how the htmleditor overwrites/masks DOM associated DOM elements. It is worthwhile observing the difference between testing with and without the htmleditor enabled in the user settings - it cures the textarea validation issue (htmleditor being disabled).

Piers Harding
added a comment - 23/Jul/08 8:52 AM I am linking these two issues together because there is a correlation between the form javascript errors and the how the htmleditor overwrites/masks DOM associated DOM elements. It is worthwhile observing the difference between testing with and without the htmleditor enabled in the user settings - it cures the textarea validation issue (htmleditor being disabled).
Cheers,
Piers Harding.

Dan Marsden
added a comment - 23/Jul/08 9:24 AM thanks Piers - that patch doesn't cause the scorm package import failure, so I've copied your patch to MDL-15019 so we can close this bug off when your other patch goes into the stable trees.

Dan Marsden
added a comment - 24/Jul/08 7:54 AM Hi Piers,
this patch looks fine:
http://cvs.moodle.org/moodle/mod/scorm/mod_form.php?r1=1.12&r2=1.13
can you please apply this to 1.8stable and 1.9stable? - then we can close this bug.
thanks,
Dan