LMSouq
moodle-core Open

Understanding Moodle $context

CO
Community Contributor
1 month ago
3 views
Problem Description
From [Moodle doc][1]: > A context is a space in Moodle where roles can be assigned. I understand that a context is a logical space used to manage Moodle objects. I developed a custom block plugin with a file upload where I use `file_prepare_draft_area` and`file_save_draft_area_files` functions.There is a `$context` parameter that must be passed and I am don't really know what context should I pass ? This mean, I guess, in which logical space should I put my block plugin uploaded files ? In my opinion, the most logical would be store the uploaded files in a context related to my block plugin. I tried to use context_block::instance($instanceid) but I don't know how to get $instanceid param. - Which context should I use in this case? - How to get it? [1]: https://moodle.org/mod/glossary/showentry.php?eid=9984&displayformat=dictionary

AI-Generated Solution

Powered by LMSouq AI · GPT-4.1-mini

✓ Solution Ready
Analyzing problem and generating solution…
Was this solution helpful?
Back to Knowledge Base