Can files be accessed by URL?

Can files be accessed by URL?

by Brian Jarvis -
Number of replies: 1

I'd like to add files to my Moodle course and then access them via URL throughout the course as needed. Is this possible?

I'm trying to do something like this in the HTML of a Moodle quiz's Question Text:

<script src="https://URLofMyMoodleScriptHere.js"></script>

I've looked into file repositories but I don't know how to access those files via URL.

Thanks!

P.S. I'm the admin and only user (it's a small project)

Average of ratings: -
In reply to Brian Jarvis

Re: Can files be accessed by URL?

by Justin Hunt -
Picture of Particularly helpful Moodlers Picture of Plugin developers
I think it depends a bit on what sort of files you want to access.

If its images and other media, you are best to upload them into each area, or at least use the repository system to choose the already uploaded file. That is because Moodle does complex things with URLs. ie it uses temporary draft URLs when editing html and other ones when displaying. And it secures URLs so that the URL from one course / activity, might not be available to a different user or might get removed or changed. Basically you should leave it up to Moodle to serve the URL for media files to the user. So add them uniquely in each location.

For javascript, you might find things get complicated. If its a library you could load it from a CDN. Or you could just upload it into a dir in the Moodle site using FTP. But other people use the Generico filter (my plugin) to get javascript working in a semi-elegant way. Or you might check out Dominique Bauers https://moodleformulas.org site to see how he suggests getting JS and CSS into various place in Moodle
Average of ratings: Useful (1)