How moodle create itemid for media files?

How moodle create itemid for media files?

by Pravin Deshmukh -
Number of replies: 3

Hello,

I am using moodle 2.8

I have a question that how moodle convert draft itemid (temporary) into permanent itemid for any file

I am observing that when I upload video file in lesson, it looks like

draftfile.php?file=%2F1027%2Fuser%2Fdraft%2F391340851%2Ffilename.mp4

But same file showing in Code view of editor showing like

<p><a href="http://learning.lorekart.net/draftfile.php?file=/853/user/draft/248439929/filename.mp4">draftfile.php?file=%2F1027%2Fuser%2Fdraft%2F391340851%2Ffilename.mp4</a></p>

in both line itemid has been change and second rows itemid that 248439929.

I wants to know how itemid change of any file in moodle and in which mdl table it store.






Average of ratings: -
In reply to Pravin Deshmukh

Re: How moodle create itemid for media files?

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

The draftitemid is randomly generated each time you open up a form with a text editor / file manager element in it.

This is only valid for the time between the form being displayed and the form being saved (actually, the draft areas persist for a couple of weeks, before being automatically deleted, but that is only because you can't tell if a form has been abandoned).

When the form is saved, there will be some code (usually a call to file_postupdate_standard_editor or file_postupdate_standard_filemanager) which tells Moodle to transfer the files from the draft area into the specified real storage area (just like there will be a function call, usually file_prepare_standard_editor or file_prepare_standard_filemanager to populate the draft area before the form is displayed).

There is no fixed mapping between draftitemid and real context / filearea / itemid / etc. - it is specific to the form being displayed and the code that handles it.

Average of ratings: Useful (1)
In reply to Davo Smith

Re: How moodle create itemid for media files?

by Pravin Deshmukh -

So how can I get specific file which is used in lesson from database?

In reply to Pravin Deshmukh

Re: How moodle create itemid for media files?

by Davo Smith -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

You'd have to look at the internal code of the Lesson activity to find out exactly where the files are stored. The details you need will be something like:


Average of ratings: Useful (1)