Difference between revisions of "Talk:Using the File API in Moodle forms"

Jump to: navigation, search
(Let user choose whether external resource should be copied or not: new section)
(Let user choose whether external resource should be copied or not)
Line 24: Line 24:
 
In the above URL we have
 
In the above URL we have
  
http://hive43demo.harvestroad.com.au/moodle2 => moodle server
+
* http://hive43demo.harvestroad.com.au/moodle2 => moodle server
/repository/hive => Hive repository plug-in
+
* /repository/hive => Hive repository plug-in
/view.php => Hive repository plug-in proxy stream. It streams the content from Hive and restream it back to the client.
+
* /view.php => Hive repository plug-in proxy stream. It streams the content from Hive and * restream it back to the client.
/5/50/812 => Hive property UUID
+
* /5/50/812 => Hive property UUID
/peugeot.jpg => just a filename
+
* /peugeot.jpg => just a filename
  
 
Bear in mind that Moodle itself should be agnostic about the UUID. The UUID is given by the getListing() method in the repository plug-in and it just need to be passed back to getURL(UUID) or getFile(UUID)
 
Bear in mind that Moodle itself should be agnostic about the UUID. The UUID is given by the getListing() method in the repository plug-in and it just need to be passed back to getURL(UUID) or getFile(UUID)
  
 
I could summarise saying that Moodle should consider storing the UUID of the picked resource rather than downloading the resouce per se. The UUID is then used at request time in order to stream the resource via getFile or to create an Url to it via getUrl.
 
I could summarise saying that Moodle should consider storing the UUID of the picked resource rather than downloading the resouce per se. The UUID is then used at request time in order to stream the resource via getFile or to create an Url to it via getUrl.

Revision as of 06:30, 15 April 2011

The two code examples in the middle of the document seem a bit random. Some explanation of what's going on in them would be really useful --Howard Miller 08:32, 7 December 2010 (UTC)

Let user choose whether external resource should be copied or not

File picker automatically copies the file from the external repository into Moodle's draft area by calling getFile(UUID) on the repository plug-in.

That partially defeats the point of storing data remotely specially if the external repository version controls its content like HarvestRoad Hive(tm).

From HarvestRoad Hive customer's point of view, they would rather have their content always stored in Hive, not in Moodle, as it happens with Hive-Moodle 1.9 plug-in. So when the content gets updated in Hive, Moodle users will see the updated content. Furthermore, not sync/cron job is required.

However the file picker behaves differently when launched in the "Add Resource > URL" screen, in which the file picker calls getUrl(UUID) on the repository plug-in instead, which is pretty much what Hive customers would like to do.

Proposed solutions:

1) Quick: Rather than always copying the file why don't give a choice on the file picker on whether to copy the resource or create an URL to the resource? You could have two radio button under "Choose licence" on the file picker screen perhaps. This solution might not work if the repository does not support direct URL access or requires authentication.

2) More elaborated: give a choice on the file picker on whether to copy it or create a reference. The reference is the UUID returned by the filepicker. Don't call getFile(UUID) if user has chosen to keep it as a reference. If user has chosen 'reference' then getFile(UUID) has to be invoked everytime the item is viewed. If the item retrieval requires authentication then it is the repository plugin will perform the authentication implicitly.

We at HarvestRoad have successfully implemented solution number 2 however the resource has to be added as an URL is very limiting. In our solution our getUrl(UUID) creates and URL which actually points back to our Moodle repository plug-in which in turn streams the file from Hive. That is how we solved the authentication issue.

eg: http://hive43demo.harvestroad.com.au/moodle2/repository/hive/view.php/5/50/812/peugeot.jpg

In the above URL we have

* http://hive43demo.harvestroad.com.au/moodle2 => moodle server
* /repository/hive => Hive repository plug-in
* /view.php => Hive repository plug-in proxy stream. It streams the content from Hive and  * restream it back to the client.
* /5/50/812 => Hive property UUID
* /peugeot.jpg => just a filename

Bear in mind that Moodle itself should be agnostic about the UUID. The UUID is given by the getListing() method in the repository plug-in and it just need to be passed back to getURL(UUID) or getFile(UUID)

I could summarise saying that Moodle should consider storing the UUID of the picked resource rather than downloading the resouce per se. The UUID is then used at request time in order to stream the resource via getFile or to create an Url to it via getUrl.