Moodle files

Moodle files

by doodle moodle -
Number of replies: 9

Hi All,

I'm using Moodle 3.2.2

I have uploaded some file in a course using Add activity of resources -> files option. These are html5, css, js files and I have selected html file as the main file (set as main file).  Now, the html page is getting displayed on the course page as expected.

Now the problem is, I'll have hundreds of such html files (along with css and js). I can create hundreds of courses to display those html files but the html files will keep on getting updated.

And, every time the html file changes I'll have to re-upload(overwrite) that html file in that particular course. I'll have to do this for these hundreds of html files which is not feasible.

So, is there a way to find out the location where each course file gets stored so that I just replace that html file and my course will get updated? I can even write a script to automate this process but the only problem is to know the location of files.


Please guide. Thank you.

Average of ratings: -
In reply to doodle moodle

Re: Moodle files

by Bret Miller -
Picture of Particularly helpful Moodlers

Accessing files directly is a risky move that could cause issues in future upgrades. That said, if your script can access both the database and moodledata files, it's possible to find them.

File information is recorded in the mdl_files table. The path to the file is the contenthash column. Using an example from my own server, a file with contenthash da39a3ee5e6b4b0d3255bfef95601890afd8070 exists and its content is stored in moodledat/filedir/da/39 with a filename of the contenthash. You can see that the first 4 characters determine the path. I chose a bad example as this is a zero-byte file, but if it were a good file, the actual file content is what is stored there no matter what type of file, there is no file extension.

So updating the files directly is doable, but it'll be some work to pull the information from the database about where each file is stored.

Average of ratings: Useful (1)
In reply to Bret Miller

Re: Moodle files

by doodle moodle -
Thanks a lot Bret. I'm quite new to moodle so could you please guide me on how to access this mdl_files database? I have installed the "complete installation package" of moodle. And, Database link is missing from the "Site administration -> server" location.

Do I need to install phpmyadmin to be able to access moodle database?


Thank you.

In reply to doodle moodle

Re: Moodle files

by Bret Miller -
Picture of Particularly helpful Moodlers

I use phpmyadmin. In theory you could use other query tools like mysql workbench or the command line mysql to query it using ssh to the server.

The database name, host, username and password are in config.php.

All the files are in the mdl_files table. The effort will come in figuring out which files belong to which course. They are linked by the internal course ID, which could be expanded by joining to mdl_course. So it's not an impossible task but it might be time consuming for hundreds of them.

Average of ratings: Useful (1)
In reply to doodle moodle

Re: Moodle files

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

As an alternative to uploading these files, have you considered putting all of these files on their own server (maybe the same server) and linking to the using the URL resource in Moodle?

I too have many, what I call, course content webpages.  I manage all of these using Dreamweaver and upload them to my server.  Then, within Moodle, I link to these.  Some of these content webpages, such as my FAQ webpage, are used in every course.  If I then decide to change something, I do so in Dreamweaver (actually, any web editing software would probably work), and then command Dreamweaver to upload the changes.  After Dreamweaver is done, all of these webpages, as viewed by the students in Moodle, see the correct information.

I do the same thing for support files such as Excel, Word, PDFs, etc.  I manage these in Dreamweaver, not in Moodle.  I just use the URL link resource in Moodle.

These content webpages become much more flexible.  For example, I can say "See my syllabus" and simply point someone to my syllabus.  Yes, this syllabus is in its course on Moodle, but it really is on my web server.

Quite honestly, I cannot recall ever uploading files into Moodle, except when making forum posts and "attaching" (uploading) screen shots.  Nor have I ever created a content page in Moodle.

So this is just a different approach to managing content.  It still requires a little thought.

In reply to Rick Jerz

Re: Moodle files

by doodle moodle -

Hi Rick,

Thanks but I cannot just display the links to the courses. Users should be able to see the course on the page directly and not through a link.

In reply to doodle moodle

Re: Moodle files

by Rick Jerz -
Picture of Particularly helpful Moodlers Picture of Testers

I am not sure what you are saying.

In my moodle, students go into the course.  Then each course has stuff for students.  One item that I always put into my course is the syllabus (as an example.)  Let's say that this syllabus, in your case, might be common to many courses, but you want to only manage one syllabus.

In my moodle, this appears as an item (in my top block, as shown below.

It really works like this:

Syllabus

Give it a try, click on Syllabus.  What you will see is my course syllabus appearing.  This syllabus was not created from within moodle, nor is it in my Moodle application.  It is on my own website, in a separate location, that I manage with Dreamweaver.  I can link to this from anywhere (even here in this discussion.)  If I make changes to this syllabus, the changes immediately are shown where ever I link to it.  If I had, let's say, 50 courses, all 50 courses would now show the updated syllabus.

In my attached screen shot, Moodle shows these external links with its URL link icon (paper with globe.)

Attachment syllabus.jpg
In reply to doodle moodle

Re: Moodle files

by Bret Miller -
Picture of Particularly helpful Moodlers
Rick's response prompts me to suggest another possibility. You could create a file system repository to upload the files into. Then you can essentially create your own manageable structure and link to those files from the courses.
In reply to Bret Miller

Re: Moodle files

by doodle moodle -

Hi Bret,

I'm looking into this. If there's a plugin which reads file system structure from a location and displays is as a file tree in Moodle. On clicking on each member of tree the content gets displayed on the right side of the file tree in Moodle??


There is a JavaScript and php plugin available for file tree structure but I don't know how to make it communicate with Moodle.

In reply to doodle moodle

Re: Moodle files

by Bret Miller -
Picture of Particularly helpful Moodlers

While I use the file system repository, I don't use it heavily enough to require a tree structure on the left side. Only the repository name is shown there. Subfolders are shown on the right side, which I guess if you had hundreds of them would be a bit messy. Sorry, I haven't researched whether there is a plugin to adjust that behavior.