Best way of specifying a URL in a GIFT file?

Best way of specifying a URL in a GIFT file?

by Timothy Takemoto -
Number of replies: 3

When writing a quiz using GIFT what is the best way of specifying the path to the files that the quiz references?

1) Is it better to use the "localhost" annotation


or the absolute address annotation
http://mydomain.com/moodle/file.php/3/filename
I would rather use the former if it is okay, since I will be importing the GIFT to more than one site.

2) I heard a rumour (that I have repeated on these forums) that the "=" in the <a href="...>click</a> needs to be escaped using "\=" but a GIFT export does not include that escape character. I have also heard a rumour that the lack of escape characters in GIFT exports may be a GIFT export problem. I seem to have been able to import GIFT's without the escape characters but I am wondering if the lack of escape characters before the

3) Lets say I am writing GIFT using an editor and I am planning to upload to more than one course. That means I do not know which course id to put into the URL (e.g. 3 in the example below)

                                      *
Do I have to change the 3 to the id of each course that I upload to?
Where are the files kept if they are used by multiple courses (if the category is made public)?
Is there a way of specificing "coursefiles" in the url e.g.

or
coursefiles/filename.mp3

Is it better to put the files in the site files?
Or perhaps off site somewhere?

Tim

Average of ratings: -
In reply to Timothy Takemoto

Re: Best way of specifying a URL in a GIFT file?

by Zbigniew Fiedorowicz -
localhost refers to the client computer.  So urls with the localhost designation will only work if both the client and the server are running on the same machine.
In reply to Zbigniew Fiedorowicz

Re: Best way of specifying a URL in a GIFT file?

by Timothy Takemoto -

Hi Zbigniew

Ah, sorry...I thought it was a notation created by Horward's export rountine but, come to think of it, I exported the GIFT file from my desktop moodle!

I exported the following
// question: 1329  name: ptest 11e
::ptest 11e::Listen to the following recording and select the most appropriate response<a href\="

http://localhost/file.php/9/2005e/2005e-011.mp3">:</a>{
 ~The man doesn't like xyz....

and uploaded to an online moodle and it worked fine, but only for me because the files are there in my computer? I thought that the links had been changed to match the server.

There is no notation to mean $CFG->wwwroot ? or thiscoursefiles?

In a recent discussion of the backup routines, Martin mentioned that the root url is recognised and coded and then that is converted to suit the rooturl of the server onto which the backup is installed. Is there nothing like that in GIFT? In otherwords, a GIFT import will have to be written to match the server into which it is loaded. Let's say I upload some soudn files to the files space of a course, then upload a GIFT that refers to them. Then use those questions in another course, will the sound filed then be refering to the previous course? Or will the files be moved accross to the new course? I am confused.

Timothy

In reply to Timothy Takemoto

Re: Best way of specifying a URL in a GIFT file?

by Enrique Castro -
Picture of Core developers Picture of Particularly helpful Moodlers
Hi Tim,
 AFAIK the GIFT import is a simple text import. It will not take care of any domainroot conversion or whatever. What you write ends up in the quiz as you write it (except the control symbols {, }, =, ~, #,  or escaped "\"). Once in Moodle, it is treated as HTML source, so be careful with "<" and "<". And the "automatic formatting" filter available at non-HTML editor text area may apply (for url and so).

Thus, my guess is that each time you import it to a different course you need to adjust the urls and manually upload files to that course.

I wonder if a different approach will not work: just upload files and import GIFT file into a quiz category in a fake course. Then you can:
a) Make the category public, so allowing to share and copy questions in different courses
b) Make a backup copy containing just that quiz. You can then restore that questions to use in any other installation of moodle.

- Enrique -