Hello everyone,
My question might seem obvious, but I am an intern and I started working with moodle recently.
I am working on a custom activity module and the modedit page looks as follows (The text is in French, sorry about that) :
As you can see it's a simple form with a text field and a JSON filemanager input. My issue comes from managing the JSON file that is sent by the user. I need to save it (and I was asked not to do it using a database) and fetch it in order to feed it to my view.php and have a visual representation of the data. I believe adding the following code to lib.php should save the file to moodledata, since I've tried it via a plugin page :
if ($fromform = $mform->get_data()){
$jsonfile = $fromform->userfile;
file_save_draft_area_files($jsonfile, $context->id, 'mod_glossary', 'attachment',
0, array('subdirs' => 0, 'maxbytes' => $maxbytes, 'maxfiles' => 50));
If it is, I'm having trouble understanding how moodle ids work, and I would want to associate the file with a course id, since it should be a unique file per course. Starting from there I would need to fetch the file associated to that id in my view.php which I'm not quite sure how to do. I have spent a lot of time reading the documentation but I am still puzzled as how to do this, hence my question.
Thanks.