New assignment type filemanager problems

New assignment type filemanager problems

by Simon Sprankel -
Number of replies: 5

Dear all,

I write a new assignment type and I try to add some settings fields in my assignment.class.php in the function setup_elements. This works fine for select boxes or text fields, but I have problems if I add a filemanager like that:

$mform->addElement('filemanager', 'animaljar', get_string('uploadanimaljar', 'assignment_animation'), null, array('maxbytes' => $CFG->maxbytes, 'maxfiles' => 1, 'accepted_types' => array('*.asu') ));

The filemanager does not show up, I only see the loading graphic. I do not have any idea what is wrong so I would be very thankful if anyone could help me out.

Cheers and thanks in advance,
Simon

Average of ratings: -
In reply to Simon Sprankel

Re: New assignment type filemanager problems

by Itamar Tzadok -

To begin with the filemanager element name should be 'animaljar_filemanager'. You also need to prepare the filemanager before form and postupdate after submission. See http://docs.moodle.org/dev/Using_the_File_API_in_Moodle_forms for invaluable info. hth smile

In reply to Itamar Tzadok

Re: New assignment type filemanager problems

by Simon Sprankel -

Thanks for your answer.

The name of the filemanager should not be a problem, although I changed it now. I already read the page "Using the File API in Moodle forms". What do you mean with "You also need to prepare the filemanager before form and postupdate after submission"?

In reply to Simon Sprankel

Re: New assignment type filemanager problems

by Itamar Tzadok -

The suffix '_filemanager' in the name of the element is essential and the element cannot work otherwise. The form element needs a draft file area to store existing files or uploaded files. The id of the draft area is fed to the element. If the draft area is not prepared (and there are various ways to do that, high and low level) the file manager cannot work. Then after submission, all the uploaded files should be moved from the draft area to a proper area. That's the post update. And again there are various way to do that, high and low level. It's all in the docs. hth smile

In reply to Itamar Tzadok

Re: New assignment type filemanager problems

by Simon Sprankel -

Thanks for your explanation. It seems to be a different problem. It is not my code, I also do not see the filepicker/filemanager in another assignment type. I get this error in the Firefox console if I create ANY assignment type:

An invalid or illegal string was specified" code: "12  frag.innerHTML = html;

http://localhost/moodle/theme/yui_combo.php?3.2.0/build/yui/yui-base.js&3.2.0/build/oop/oop.js&3.2.0/build/dom/dom.js&3.2.0/build/yui/yui-later.js&3.2.0/build/event-custom/event-custom-base.js&3.2.0/build/event/event-base.js&3.2.0/build/pluginhost/pluginhost.js&3.2.0/build/event/event-delegate.js&3.2.0/build/node/node.js&3.2.0/build/yui/get.js&3.2.0/build/loader/loader.js (Zeile 3410)
In Chromium, the error looks like that:
yui_combo.php:825Uncaught Error: INVALID_STATE_ERR: DOM Exception 11
proto.error yui_combo.php:825
proto._attach yui_combo.php:473
proto.use.handleLoader yui_combo.php:648
Y.Loader._finish yui_combo.php:14133
Y.Loader._onSuccess yui_combo.php:14165
Y.Loader.loadNext yui_combo.php:14609
Y.Loader.loadNext.handleSuccess yui_combo.php:14378
Y.Get._finish yui_combo.php:12076
Y.Get._next yui_combo.php:12139
Y.Get._track.n.onload yui_combo.php:12302
I guess this is the problem that the filemanager does not load properly. I am also affected by this bug:
http://tracker.moodle.org/browse/MDL-27234?page=com.atlassian.jira.plugin.system.issuetabpanels%3Aall-tabpanel#issue-tabs
I am really disappointed about Moodle right now. These are my first weeks in Moodle development and such simple things seem to be a big problem...
Cheers,
Simon
In reply to Simon Sprankel

Re: New assignment type filemanager problems

by Simon Sprankel -

Okay here is the solution for anyone who also has the problem that the filemanager does not load properly when creating a new assignment type:
Turn off the "XML strict headers" option under Site administration - Development - Debugging and it will hopefully work again smile