accessing course image ?

accessing course image ?

tim st.clair - ން
Number of replies: 2
ފޮޓޯ

Course summary files are pretty much just the picture for a courese, and it appears in the category pages.

https://docs.moodle.org/29/en/Course_settings#Course_summary_files

Can I access the image for the course from an external system, such as a custom page or Wordpress, etc? (that is, generate an externally accessible URL that delivers the image) 

Average of ratings: -
In reply to tim st.clair

Re: accessing course image ?

Praveen Chamarthi - ން
Yes you can access course images in wordpress websit.
you need to use course id and context id.
image will save in mdl_files database.

Thanks
-P
In reply to Praveen Chamarthi

Re: accessing course image ?

tim st.clair - ން
ފޮޓޯ

riiiight. Perhaps you could have been a little more specific?

A course image url is linked from moodle like this:

<img src="http://moodle27.site/pluginfile.php/21/course/overviewfiles/lFIn4.gif">

and has data like this:

id:43

contenthash: 99df96fb5fc92574f02aabf59f1f3479231843ea

pathnamehashce846b41cadf16800da867cfe89a9d781a573a07

context: 21

component: course

filearea: overviewfiles

itemid: 0

filepath: /

filename: lFIn4.gif

and so on.

So from an external, unauthenticated source such as my nodejs app, or wordpress, or some random jsp page, how do I calculate that row? component represents all courses, not a specific one. filename is the unknown I'm looking for. contenthash isn't the hash of the course row or anything obvious like that. There's no web service that returns information about the course image.

context appears to be mdl_context where contextlevel is the magic number "50" (e.g. why is it 50? Is it always 50 on everybody's system? Who decided it was 50? Can I look that up?) and instanceid is the row number of the course (the only number I externally know).  path is just some random fact (which also happens to always end in the row id of the same record...).