Set Image Course - API

Set Image Course - API

by Clóvis Amorim -
Number of replies: 1
Hello, I already use the create_course function but I cannot inform the image course at the time of creation. Is there any way using this function? or is there another function to set the course image via programming?
Average of ratings: -
In reply to Clóvis Amorim

Re: Set Image Course - API

by Benjamin Ellis -
Picture of Particularly helpful Moodlers
Hi,

 You can do it with the create course function but you have to pretend to have uploaded the image file.  I am doing this from memory so you may need to check my logic.  The field holding the image is overviewfiles_filemanager and its value would normally be the image file's draftitemid.  I am assuming that the image is already on the server so using the File API, you get an unused the draftitemid, copy the existing file to the draft area and set the field to the draftitemid before calling create_course(). 

Hope I am making sense.