Posts made by Martin Dougiamas

Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Plugin developers Picture of Testers
Yep, I totally agree about autosaving being a good solution here.

We talked about this some time ago ... there are basically three parts to a perfect solution IMO:

1) Some JS in the editor to post the text to Moodle frequently where it gets stored in a special temptext table, indexed by the current path (eg mod/forum/post.php and the user ID).

2) When ever a new editor is launched, some JS in the editor queries Moodle for default content, passing the URL as a parameter. If text is found in the temptext table, it gets inserted in the textarea by default (or provided via button if that is deemed better)

3) When saving the Moodle form, all temporary texts for that URL and user ID are deleted (ensuring they don't keep popping up).

David Mudrak was actually working on this (MDL-18014) but it would be great if you could finish it off and make it ready for HEAD!
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Plugin developers Picture of Testers
OK, after some thinking and discussing I think the best and most practical route for Moodle 2.0 is the one now described here:

http://docs.moodle.org/en/Development:Editor_file_management

This plan seems to hit all the requirements and keeps things simple so it's the one we're going ahead with now.

Please feel free to track/comment/help on MDL-16597 (and MDL-14589)
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Plugin developers Picture of Testers
If you are making it as a patch for 1.9 then it's pretty much for the OLPC project only. We can't add new features like this to the stable branch.

However, if the integration was done in the next couple of months with 2.0 in mind then it COULD make it into Moodle 2.0 (and I would very much like to see that). Personally I would target 2.0 first and port it backwards to 1.9 later.

For a 1.9 patch the URLs for displaying the images should be exactly the same (and you should provide some sane sort of upgrade script to upgrade the file locations in 2.0), otherwise people will lose their images when they upgrade to 2.0.
Picture of Core developers Picture of Documentation writers Picture of Moodle HQ Picture of Plugin developers Picture of Testers
This is EXACTLY what the new File API in Moodle 2.0 is about, storing and serving files securely attached to images and modules. It sounds like you are reinventing some wheels there!

Every textarea now has a "filearea" associated with it, and this information is given to the HTML editor (and is thus accessible to the paint editor).

You basically just have to get the save button in paint program to call a script to save the data in the filearea of the current text, in just the same way as the File picker works.

Some of the finer details of the API may yet change (Petr is actively working on it), but these should get you started:

http://docs.moodle.org/en/Development:Using_the_File_API

http://docs.moodle.org/en/Development:Using_the_File_API_in_Moodle_forms (not as relevant to you)

...and especially see my midterm feedback http://docs.moodle.org/en/Development_talk:Paint_tool wink