How can I list the videos I added to the course on the front page?

Re: How can I list the videos I added to the course on the front page?

by Diane Soini -
Number of replies: 0
I wrote a block plugin that did something similar to what you want. Here's a broad overview of what I did:

I created a database activity (mod_data) and then I have the id of that activity as a $CFG->whatevernameyouwant variable. That way I can test in dev and production.

My plugin is complicated by needing to be able to show the images in the mod_data activity without users being logged in. You might need to do this, too.

Boiled down to the bare minimum, it queries the database to find that mod_data item and then I query for the field data that I need to identify the images in the mdl_files table. This field data is related to how mod_data activities store their data. I'm not as familiar with how mod_lessons store its data. You'll have to read all the database tables to figure out how to get a handle to the videos from your mod_lesson. It will likely involve the contextid of your mod_lesson activity.

The mdl_files table will have a contenthash that tells you exactly where the file is on your file system that you want. If the contenthash is abcxyzgobblygook, the file will be located in $CFG->wwwroot/filedir/ab/cx/abcxyzgobblygook. So with a contextid, an itemid and the filename you can get the mdl_files table to find the file you want to display.

Then I have a special file that doesn't require people to be logged in or enrolled or anything that will use the contextid, itemid and filename to look up the file in mdl_files and stream it as an image of whatever mimetype is in mdl_files.

Then I use /path/to/blocks/myblock/images.php as the URL for showing the image.

You could do something similar for a video.