Is anyone doing any XML driven multimedia projects in Moodle 2.x?

Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Number of replies: 38
Picture of Plugin developers

Hi Moodlers,

Is anyone doing any XML driven multimedia projects in Moodle 2.x? Are you able to upload and reference (zipped or FTP) packages of multiple media files in XML (SMIL)?

I'm looking into possible methods of deploying MVC multimedia web clients in Moodle 2.x that consume media resources in Moodle's file repository system. Is this something you're currently doing and if so how? The applications are likely to consume large numbers of files, hence the need for XML.

Looking forward to your replies.

Average of ratings: -
In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Anyone?

Is anyone using SMIL, RealText, TimedText, MPEG-7, anything?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Bump.

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Frank Ralf -
Hi Matt,

I'm very interested in anything XML but haven't used it for multimedia yet. In fact, I have only learned about those concepts from your posting wink Sounds very interesting, though.

However, I find the file API of Moodle 2.0 not very accessible so that might become an issue.

Cheers,
Frank

PS:
Great blog! "What’s SMIL and why should we use it?"
In reply to Frank Ralf

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Well we have an XML driven textbook-like-content project which lets you stick audio and video and Flash in, also features a record-yourself-talking Java applet and er probably other junk that might be described as multimedia - although I hope we've avoided the most gimmicky end of the word.

(By that I mean that we have not provided any system support for 'gimmick' multimedia, and that instead, our course teams are busily hand-crafting their gimmicks as we speak smile)

We haven't released the oucontent project yet (incidentally the Moodle part is only one 'rendering' from the system, we also use it to produce printed textbooks, but that part relies on commercial software and won't be released). I'm hoping that we will release it eventually.

--sam

In reply to Frank Ralf

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Thanks for your replies.

Re: "However, I find the file API of Moodle 2.0 not very accessible so that might become an issue."

This is why I'm asking. I can make Moodle 1.9's file management system work quite well with XML driven activities, but I'm not so sure about Moodle 2.x.

Anyone?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Oh, that? The file API works fine - it's irrelevant whether an activity is 'XML-driven' or not, you use the file API just the same...

It can be a bit difficult to learn, and there may be cases of slight performance reduction (where you need to copy a file an extra time) but there is nothing stopping you using it for to store and serve files for any kind of activity regardless of whether it happens to use XML or not. For example, if you need to load an XML file into memory, it's easy to do this using the file API.

I didn't find it very difficult to change our system (mentioned) to use file API. It did take about 2 days of work and I was partly learning the details of the file API at the time (and, er, finding things wrong with it - which were fixed before the final release of Moodle 2). You can read a bit more about it in a document I wrote about the Moodle 2 conversion process for that module if you like. (Obviously the document is old...)

--sam

In reply to sam marshall

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Hi Sam,

Thanks for your response. The link you posted leads to Moodle.org's home page. Can you provide a link to the document?

Cheers!

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Frank Ralf -
In reply to Frank Ralf

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

It is actually an earlier blog post, but the document link in the blog post doesn't work, so that's no help here. smile

Let's try the low-tech approach:

https://docs.google.com/open?id=0BwFVUu6OwBtgZmNlOGI5MzUtYTdlMS00NDRhLTg3OWEtYzcwNzUxNGJiMjJk

--sam

In reply to sam marshall

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Thanks for that Sam!

I have a more specific question...

Suppose I have a zipped content package which includes a couple of hundred images, MP3 files, SWFs and maybe video and an XML file that references them. That package gets uploaded (FTP or through a Moodle interface) to the moodledata files repository. The XML file gets loaded by a browser application, i.e. Javascript, Flash or Java, so the location of the app doing the loading is on a Moodle page, e.g. http://example.com/mod/somemodule/view.php?id=99

In Moodle 1.9, you can dynamically feed the app a root URL to get to moodledata, e.g. http://example.com/file.php/[courseid]/ from teh $CFG and $COURSE objects. Then, the URLs in the XML file only have to reference local paths, e.g. packagename/mp3/somefile.mp3 and the app can just concatenate them, i.e. http://example.com/file.php/[courseid]/packagename/mp3/somefile.mp3 In this way, the content packages are independent and exchangeable between Moodle installations and other LMS' and CMS' without any editing.

So in an XML file, how would I reference media files in moodledata? Is there any way to make the references transferable from one installation to another?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
  1. On a course, with editing on: Add a resrouce... -> File.
  2. Upload the .zip as the file.
  3. Use the little menu to unzip it.
  4. Select the main file (e.g. packagename/mp3/somefile.mp3) and mark it as the main file.
  5. Save the form, after completing any other required fields.
  6. Back on the course page, click the link to test it.
In reply to Tim Hunt

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Tim,

I don't think I explained the example clearly enough...

There's a Moodle page, e.g. http://example.com/mod/somemodule/view.php?id=99 with an app embedded in it.

The app loads an XML file from moodledata, e.g. http://example.com/file.php/99/packagename/xml/xmlfile.xml.

In that XML file, there are links to the media files, e.g.:

< _audio_ name="normal" src="packagename/mp3/audiofile . mp3" / >

< _img_ name="pic" src="packagename/pix/imagefile . jpg" / >

< _video_ name="main" src="packagename/video/videofile . mp4" / >

The app needs to find those files in order to load them. In Moodle 1.9 that would mean passing in $CFG->wwwroot.'file.php/'.$COURSE->id.'/' to the app at runtime so it could then concatenate "http://example.com/file.php/99/" ($CFG->wwwroot.'/file.php/'.$COURSE->id.'/') with "packagename/mp3/audiofile . mp3" (In E4X that would be: _xml.body.seq[0].par[0].audio(@name == "normal").@src).

Using $CFG->wwwroot.'file.php/'.$COURSE->id.'/' at runtime means that you can transfer the content package to another Moodle, e.g. http://anothermoodle.com/school/ and all the links will still work, i.e. http://anothermoodle.com/school/file.php/62/ + packagename/mp3/audiofile . mp3.

Does that make sense?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Right, and in Moodle 2.x, it is all very similar, except that you use a baseURL involving pluginfile.php.

In reply to Tim Hunt

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Can you give an example?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Yes. Follow the steps I gave above (make a zip containing an index.html that uses relative URL to load some CSS and some images). Then inspect what happens when Moodle displays that resource, using a tool like Firebug.

In reply to Tim Hunt

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Mmm...

I've tried to follow your instructions. I've read through the related pages on repositories, etc. on Moodle 2.0 docs wiki (they don't seem to match my Moodle 2.1 installation).

I can't find any options to unzip packages.

So the dynamic root will be something like: http://localhost/moodle21/pluginfile.php/[id]/ <- but the ID appears to change with every file and the resulting file paths seem to be unpredictable. If the files are uploaded to another course/Moodle, will the paths change?

I can get a single app to load a single file, but I can't find an easy way to get a loaded XML file to reference uploaded media files. The method that I understand you're suggesting is to upload the files via FTP and then embed them each individually somewhere and copy the resulting URLs (200Xs!). It looks like the copied URLs will change with any new Moodle installation so the resulting XML files won't be portable.

Is this correct or am I missing something?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Update: Just tried using a static web page in the same directory and using relative links. Relative links always get broken. The repository system seems to need abolute URLs.

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You are missing something: Here it is explained better: http://ourlearning.co.uk/?p=83

In reply to Tim Hunt

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

That's what I did and a variety of other ways. The files work locally but not when displayed via Moodle. Additionally, when I looked at the page source, Moodle had messed up the Flash embed code in the HTML page. The FlashVars don't get passed in and the link to the SWF file is broken.

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Bump.

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Dirk Meyer -

Hi Matt,

we are starting to implement a process that includes an external fileserver from which moodle resources such as page and book draw CSS and  JS files. We have large and small html packages containing large video files, flash objetcs etc. We also use HTML templates as starting points for lessons. 

After adding the code into moodle resources, the html becomes part of that resource which then allows for easy editing with the moodle editor. Because we use absolute links in the packages, the CSS and JS files continue to point to the external file server. An examle to a course is here: http://moodle.rockyview.ab.ca/mod/page/view.php?id=42351 The icons and text formatting you see is controlled from files located on the external server.

I am sure there are limitations to this process, one of which is the dependency on the external file server. I do know however that large video files and flash objects load very fast on the clients computer, even in fairly remote locations in Canada. In fact, they seem to be faster then if they were to come from wthin moodle.

What we are also working on is to built on  EXE as our authoring tool for rich content and lessons allowing for templating if so desired which will then allow for easy integrationg into moodle.

In reply to Dirk Meyer

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Thanks Dirk,

It's good to know what other people are doing with Moodle 2.x. It looks good!

My ultimate aim is to develop a plugin module for Moodle 2.x that can integrate simply and easily with a standard installation, i.e. no add-on bucket servers, so that a novice can upload, unzip and install in one go, and it'll work. Absolute file paths would only work with a remote file repository service and wouldn't be portable between Moodle installations.

The only other option that I can see is packaging interactions as SCORM format but that brings all kinds of limitations and latency issues that my module is designed to avoid.

Does anyone know of a way to get relative file paths to work in Moodle and be transferable, i.e. shareable, between Moodle installations?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Matt - just to confirm what Tim said earlier, we have no problem here with relative file paths within a standard Moodle 'File' resource. In fact I have even done this live, twice, in front of an audience at presentations for staff here who will be working with Moodle 2.

My demo zipfile includes html, image, css, and JS files with relative links. I didn't have any Flash, because this is 2011* I don't know Flash.

Unfortunately it is slightly too large to upload here but I didn't do anything special in the slightest so I think you should have no problem with relative links in File resource, unless maybe there are some odd settings on your server?

--sam

* :>

In reply to sam marshall

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Sam,

What you have described in your document works. There's no problem with that. However, relative links between files uploaded in separate actions using Moodle 2.x's file API to moodledata apparently do not. Each file upload creates a new and unique file path which is not compatible with the W3C.org recommended practice of referencing resources in XML (including SMIL) regardless of whether the client side technology is Flash, Java, Silverlight or Javascript.

If you're not familiar with Flash, perhaps you could provide an example in another language where a browser client references files from an XML file?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

So, you seem to be saying "I can use Method A, which works, or Method B, which does not work. I choose to use Method B for no good reason, and then moan that it does not work."

If that is not a fair summary of what you are saying, please explain.

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

I don't have time to make a demo but why do you think there would be any problem referencing an XML file using relative url when there is no problem referencing CSS, JS, and JPG/PNG files using relative URLs? They're loaded basically the same way, it's not going to make a difference if the browser loads one through an XmlHttpRequest (or from Flash) and the others from img tags or whatever.

Just make sure to stick your files in the same file object (is that where you're going wrong?) and that's it! You're done, everything works exactly as you'd expect. If you want a folder structure within the file object you can have that too. No problem that I know of...

--sam

In reply to sam marshall

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers
Hi Sam, Relative links work fine. I have no problem reproducing what you've described. I can also reproduce the same with Flash although there are some complications with Moodle filtering Flash embed code, which I should be able to resolve when I develop an activity module. What I'm trying to achieve is a way for a group of media files, i.e. images, audio, animation and/or video, to be referenced by an XML file before they are uploaded. The basic idea is: #1 - We have any number of client-side applications in Flash, Java, Javascript and/or Silverlight. It should be platform agnostic, I'm a Flash developer so I'm concentrating on Flash but there are, for example, Javascript SMIL XML players for playing sequenced multimedia presentations. This is the kind of technology that would provide a web standards alternative to PPT files and many of the current presentation authoring software packages such as Adobe Captivate, Articulate, etc. #2 - We have a library of multimedia resources that are collated and referenced by XML files. Course content creators would upload packages of media files and XML that are loaded and presented/played by any of the client-side applications. Therefore, I'm looking for a way to be able to reliably predict the file paths to media files that the XML files can use to reference them. The ultimate aim is to make media resources and XML shareable between client-side applications, and make client-side applications and media resources shareable between courses and also different installations and versions of Moodle. This approach would also provide a basic model for supporting multimedia sequencing file types such as SMIL video and audio playlists (which support multi language captioning) and MPEG-7 (http://en.wikipedia.org/wiki/MPEG-7). Currently, I can't find a way to do this and that's why I'm asking for your help. Is the only solution to use 3rd party file repositories or is there a "Moodle only" solution? I've published a blog article about some of the advantages of using this approach to deploying interactive multimedia web content in this way: http://blog.matbury.com/2011/10/23/whats-smil-and-why-should-we-use-it/ The WYSIWYG editor seems to be broken!
In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Okay, I still don't understand your problem. You say you want to be able to reference assets in an XML file before they are uploaded. Here is how you can do this:

<assets><asset name="frog.jpg"/><asset name="toad.jpg"/></assets>

Then upload your xml file together with 'frog.jpg' and 'toad.jpg' into a File activity. The XML file will now contain correct relative references to the two files (for example, if the XML file is http://example.org/pluginfile.php/whatever/list.xml, the jpg file would be ).

You are correct that it would be hard to predict the absolute URL before creating the activity, but why would you want to use absolute URLs in this kind of xml file? SMIL, for example, supports relative paths. Using absolute URLs guarantees it won't be transferrable between systems in the way you would like.

Should you for some reason require absolute URLs, just create the file activity first (empty); now you can tell what the absolute paths will be. Then create your xml file (including the now-known absolute urls) and upload it all.

The exact same problem re. absolute URLs would have occurred in Moodle 1.9 - you can't predict the absolute URL of a file in Moodle 1.9 until after creating the course. Same is true in Moodle 2 except with 'after creating the File activity'. There is of course nothing to stop you creating a file activity the instant after you create the course so the slight difference has no consequence.

--sam

In reply to sam marshall

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Please allow me to explain.

Passing relative links to an app in a web page at "localhost/moodle/mod/somemodule/view.php" will not give the correct paths to a file in moodledata, e.g. name="frog.jpg", will give an incorrect path to the file, i.e. "localhost/moodle/mod/somemodule/frog.jpg"

Here are 3 URLs I retrieved from a package uploaded and unzipped in moodledata:

Flash application link = "http://localhost/moodle/pluginfile.php/24/mod_resource/content/4/smil_cartridge_checker.swf"

SMIL XML file link = "localhost/moodle/pluginfile.php/25/mod_resource/content/5/commonobjects/xml/elem_common_objects.smil"

  • localhost/moodle/pluginfile.php/25/mod_resource/content/7/commonobjects/pix/addressbook1.jpg
  • localhost/moodle/pluginfile.php/25/mod_resource/content/8/commonobjects/pix/book1.jpg
  • localhost/moodle/pluginfile.php/25/mod_resource/content/9/commonobjects/pix/coins1.jpg

As you can see, an XML file could not provide valid links to applications embedded in Moodle pages even if it's uploaded with the same package as the media files.

The XML file would need to be:

<seq>

<par>

<img name="addressbook" src="localhost/moodle/pluginfile.php/25/mod_resource/content/7/commonobjects/pix/addressbook1.jpg" />

<img name="book" src="localhost/moodle/pluginfile.php/25/mod_resource/content/7/commonobjects/pix/book1.jpg" />

<img name="coins" src="localhost/moodle/pluginfile.php/25/mod_resource/content/7/commonobjects/pix/coins1.jpg" />

</par>

</seq>

Rather than:

<seq>

<par>

<img name="addressbook" src="commonobjects/pix/addressbook1.jpg" />

<img name="book" src="commonobjects/pix/book1.jpg" />

<img name="coins" src="commonobjects/pix/coins1.jpg" />

</par>

</seq>

So how can we provide an application embedded in a Moodle web page a way of correctly linking to media files stored in moodledata?

Also, is there any way of referencing files in moodledata without deploying them as content in a Moodle module?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

I don't understand how but you are definitely doing this wrong...! Are you by chance using the Folder resource? That one is no use to man nor beast - don't ever use it, always use File.

I just uploaded my 'click to frog' zip again and used right-click to get the image URLs. Here they are (ignore the ?grr, that was just added for this forum post):

http://sm449.vledev2.open.ac.uk/moodle/pluginfile.php/30008/mod_resource/content/1/frog.png?grr
http://sm449.vledev2.open.ac.uk/moodle/pluginfile.php/30008/mod_resource/content/1/pond.jpg?grr

Then I did the CSS file using web developer toolkit:

http://sm449.vledev2.open.ac.uk/moodle/pluginfile.php/30008/mod_resource/content/1/clicktofrog.css

Meanwhile, my html file (from 'view frame info' on the iframe) is:

http://sm449.vledev2.open.ac.uk/moodle/pluginfile.php/30008/mod_resource/content/1/index.html

As you can see, relative links will work fine. This is using moodle standard File so that the index.html will be in an iframe (or separate) in the same location as everything else, but should you wish to implement anything in a custom module so that its view.php is in a different place, that's not a problem either: all you need to do is store the locations as relative path in your xml, then prepend the root path (http://sm449.vledev2.open.ac.uk/moodle/pluginfile.php/30008/mod_resource/content/1/) when you output it. This situation is, of course, the same as it is in moodle 1 where again, view.php was not in the same location so you couldn't use relative paths to file resources (without including dependency on, in this case, the course id); in 1.9 you would have needed to prepend $CFG->wwwroot . '/file.php/123/' or something, when outputting.

--sam

PS Don't bother trying any of those links - my dev server is safely behind our firewall!

PPS I hope. smile

In reply to sam marshall

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Hi Sam,

Re:

OK, here's what I tried. There's already a directory containing a bunch on images in the file repository:

  1. I created a link to one of the images: Add a resource > File
  2. Set it to force download so that it would reveal the Moodle generated link. I got: http://localhost/moodle/pluginfile.php/32/mod_resource/content/1/book1.jpg
  3. I navigated to the link in my browser and the image appeared.
  4. Then I tried changing the link to another file in the same directory: http://localhost/moodle21/pluginfile.php/32/mod_resource/content/1/addressbook1.jpg
  5. I navigated to the link in my browser and got the message:

"Sorry, the requested file could not be found

Stack trace:
  • line 429 of \lib\setuplib.php: moodle_exception thrown
  • line 1556 of \lib\filelib.php: call to print_error()
  • line 716 of \pluginfile.php: call to send_file_not_found()"

Each time a link to a file in the same directory, I get a different path, as I described before. The numbers in the path seem to be incremental but apart from that I don't know of any reliable way to predict them or any way to reference them in an uploaded XML file.

No apps were harmed in the making of this experiment.

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

OK, from what I can tell and what I've read elsewhere, this issue is unresolved.

So it looks like if we want to reference files as if they were static, we need to use an external files repository/directory that resolves path names consistently, for example, Flickr or AWS.

One of the advantages of using XML driven apps is that if you have say 200 files, you can collate and sequence subsets of those files simply by copying and editing the XML files, for example:

  • /directory/pix/... (100 files)
  • /directory/audio/... (100 files)
  • /directory/xml/all_100_images_collated_with_corresponding_audio.smil
  • /directory/xml/images_with_red_in_them_plus_corresponding_audio.smil
  • /directory/xml/images_with_green_in_them_plus_corresponding_audio.smil
  • /directory/xml/images_with_blue_in_them_plus_corresponding_audio.smil

My next question is, do you think it's better to keep the XML files in Moodle's file repository (MFR) or on the external files repository? Appart from the course backup and shared file editing issues, what are the pros and cons of each? Are there any caveats to storing XML files in MFR? For example, how easy are they to edit/update and have the changes reflected in all activities modules that use them?

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Seriously I have no idea what you are doing but this totally does not happen. (Update: Wait, I think I've figured it out... Hmm... See end.)

Please follow these identical instructions exactly. I'm doing this now on qa.moodle.net which is publicly accessible so you can do it on that server too (but it does also work on 2.1.x which we still use at the OU).

1. Take two image files which must be called a.jpg and b.jpg.

2. On qa.moodle.net, log in as manager.

3. Go into the course 'Moodle features demo'.

4. Turn editing on.

5. From 'Add a resource', choose 'File'.

6. Type in the name 'Predictable file URLS - the definitive proof' and type 'x' in description.

7. Under content, click Add and choose File upload. Browse to a.jpg.

8. OK everything (we're going to close it down to prove you can add files later) and click 'Save and display'.

9. On the resulting page, right-click the image and choose 'Copy image location'. Then open a new tab and paste in the URL, which will be something like:

http://qa.moodle.net/pluginfile.php/179/mod_resource/content/1/a.jpg?stopthedamnfilter

10. Back in the Moodle page, choose 'Edit settings'.

11. Click Add, upload a file, browse to b.jpg, save and display (resulting page still only shows a.jpg)

12. In your other browser tab where you had the image open on its own, change the URL to b.jpg without changing anything else:

http://qa.moodle.net/pluginfile.php/179/mod_resource/content/1/b.jpg?stopthedamnfilter

13. Observe that the second image loads and none of the numbers changed.

OKAY, here's the part where I finally figured it out. What you're trying to do is add a whole directory of files to a File resource at once by adding a single file. As you say this doesn't work. If you want to achieve that, you can do so by uploading a zipfile and expanding it. Another way (if you want it in multiple places) would be to ensure you manage these files within Moodle as a File object so that this is the definitive location. For example, you might want to put it in the front page site files area so that everyone can access it, or otherwise put it in a course that you know all necessary users can access. (Hint: Metacourse.)

Within a File object, all added files have a predictable URL. This means that by adding and using a single File object you can have identical feature to that provided by the 'Files' section in Moodle 1.9, the difference being that it's now possible (not mandatory!) to have multiple File objects in a course instead of just one. As before the URLs are entirely predictable within a File object but they are not predictable between File objects due to the inclusion of different numerical identifiers (in the case of Moodle 1.9, it's course IDs; in Moodle 2 it's context IDs). So there has been no reduction in functionality in this area since 1.9.

I believe in 2.3 it is planned to have repository support that will let you share files in lots of different locations (e.g. let's say you want 10 copies of your 'here are all the files' object because you don't want to put it in front page files for some reason [licensing, etc] but you need it on 10 different course - at present, just like in Moodle 1.9, this would require 10 independent copies of the object and if you edit one the other 9 won't change - in 2.3 there is supposed to be a way to defer this to an external repository or otherwise allow you to update the file once and change it everywhere).

--sam

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Hi Matt

 We do the same thing, load XML files into flash widgets and those files contain paths to directories and individual media files, and sometimes other xml files dynamically created.

I think the problem you had with "Sorry, the requested file could not be found" could be simply because both files had not been copied over to the file resource module. You only selected one. And the other was inaccessible because it wasn't there in there in the file resource.

We needed to manage files that had been copied over from the repository and we need to do it in bulk, because there could be ten, twenty, thirty audio or video files accessed by a single widget in a module. And we also needed to be able to edit the XML file too.

We ended up writing a custom file explorer to manage the files within the mods. So we can create/rename/delete/copy over etc files and directories of files between courses and mods.

I have seen it said by expert people on these forums that such an explorer is not needed, but I couldn't see how we could do it without one. (My own forum posts, sadly did not get as much attention as this one.)

And actually the good news is that the file paths are pretty predictable, and you can make sure of it using the various APIs from the FileBrowser and FileStorage objects.

We have not actually finished the file explorer but it is working pretty well. I was hoping to have something to show by the end of the month. Doesn't look like we will make it. If you want more info. contact me over at http://www.poodll.com

In reply to Justin Hunt

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by sam marshall -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

The primary thing you can't do with the current system out of the box is have multiple copies which are all referring to the same file. For instance, say you have an activity with 50 video files in it. There is no problem at all with duplicating that and using it on 10 courses (just use backup/restore features or the duplicate button as needed). BUT if you then want to update that activity, you now have 10 places to update it in. You can't update it in one place and have them all change. That's why I recommended storing these things in site files or in a metacourse - solutions which are generally good but can have some user interface consequences you don't want depending on how you include the files.

On another topic, just for a real-life example we had here very recently of why you don't really lose anything over the old 'course files' area in 1.9 - we had a course in 1.9 where we had stuff in the file area like this:

a.html
b.html
c.html
audio/1.mp3
audio/2.mp3
...
audio/500.mp3

In 1.9 we had just been linking to a.html or b.html or c.html from different places, but all three (there were more than three) of those HTML files reference a selection of the 500 (there were less than 500) audio files in the audio folder.

This is easy to handle in 2.x - the solution is to create a single file activity that contains all these related files (as above). You can set the start page to a.html. Now you have two choices - if you think you'll never want to edit this, you can duplicate it twice and set the start page to b.html and c.html respectively (you now have 3 independent copies; they don't take up extra disk space, and you could easily transfer say just B to some other course if you liked, but it will make changing the audio files a pain). Or you can just create one copy and also add two URL links that go into direct-link to b.html and c.html.

As far as I'm aware, there is not really anything you could achieve with the Files area in 1.9 that you can't achieve by this approach (stick all the files that used to be in the files area into a File object). So that's why experts may say it is 'not needed'. However, I think the Files area had a few more editing features about moving things around within it, which may be where your files explorer comes in handy. Also, if you want to do something cleverer than just treat a File like your old files area (ie have activities as totally independent learning objects, even if they share some files, while not having to manage it manually when you change those files) then this is not possible out of the box - it was not possible (at all) in Moodle 1.9 either - and your file explorer may help with that.

--sam

In reply to Justin Hunt

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Hi Justin,

Thanks for the insight and and the links. Your Poodll project looks fascinating and right up my street. Please let me know if I can help in any way.

Hi Sam,

Thanks for taking the time to help. It's been very much appreciated. I actually depend, to a great extent, on having a central library of media files per course and using XML to reference subsections of it. It's a very flexible and easy to manage system. Ideally, I'd like something more like the front page directory, i.e. moodledata/1/ perhaps moodledata/0/?, that only allows access from authenticated users but can be shared across courses. I guess that's more like an external files repository or CMS.

In Moodle 1.9, I use a browser client to check for broken links between the XML files and the course directory media files.

In reply to Matt Bury

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Matt,
not sure if could be of any help but if you have a testing environment you could give my DAVRoot plugin a try: I'm exploring the features and limits of the File API starting from what the File API allows to do and that plugin is the result of my investigations.

HTH,
Matteo

In reply to Matteo Scaramuccia

Re: Is anyone doing any XML driven multimedia projects in Moodle 2.x?

by Matt Bury -
Picture of Plugin developers

Hi Matteo,

Thanks! I've downloaded it and I'll have a look.