I would like to create a forum into a Moodle course (specified by the user) using PHP.
I’ve tried to search it for the net but I haven’t found nothing, even in Moodle webservices (in which I cannot find a function to create a forum).
The idea is the user to choose a course (one in which he/she’ll be studying), select a “unit”, insert a title and the content, and submit it (the rest of the options can be the default ones).
I can retrieve all the data I want from Database but I cannot create any forum. I’ve tried adding it via SQL too, but I haven’t been able neither.
Hope someone here can help me!
Thanks for your time.
If you directly want to create a forum then you need to do following steps –
course=courseid,module=7(for forum, in moodle 2.9 the forum id is 9),instance=fourmid,visible=1,showavailability=1
Insert record if not exist or Update record into mdl_course_section with following values and get sectionid
course = courseid, visible = 1, sequence = moduleid(comma seprated),
Update mdl_course_module table and update sectionid
Finally rebuild moodle coures cache
Here is the moodle code to create a new fourm.