Upload files to moodle under a selected course

943 views Asked by At

I have created a particular course using the moodle rest api and i would like to add a files into that particular course. The course may take the week/topic form. I need to add the uploaded file under a selected topic/week how can i achieve that? .I used core_files_upload to upload files but how can i add it to a selected course?

Array 
(
    [contextid] => int        
    [component] => string        
    [filearea] => string        
    [itemid] => int        
    [filepath] => string        
    [filename] => string        
    [url] => string        
)
1

There are 1 answers

0
davosmith On

In order to make a file appear in a course, you would need to create an instance of the 'mod_resource' activity in the course and then attach the relevant file to that resource.

I don't believe there is currently any webservice for creating activities within a course (https://tracker.moodle.org/browse/MDL-40779 appears to still be incomplete).

The best you can do at the moment would be to create a custom Moodle plugin (probably a local plugin) and then implement your own webservice in order to add this functionality.