How to get context of a course if i know contextid and component?

How to get context of a course if i know contextid and component?

door Andreas Schenkel -
Aantal antwoorden: 1
Foto van Plugin developers

I want to know to which course a file that is stored in the datebase belongs.

I have the contextid of the module where the file belongs to. How can I get the courseid or the coursecontext of this file?


Gemiddelde van de beoordelingen:  -
Als antwoord op Andreas Schenkel

Re: How to get context of a course if i know contextid and component?

door Andreas Grabs -
Foto van Core developers Foto van Particularly helpful Moodlers Foto van Peer reviewers Foto van Plugin developers Foto van Translators

Hi Andreas,

a course module always belong to a course even if it is on the frontpage.

So if you have the context of a course module you could just call its method "get_parent_context()".

Best regards
Andreas

Gemiddelde van de beoordelingen: Useful (1)