General developer forum
Moodle 3.4. Quiz creation process in PHP
I used the insert_record function to put data into quiz and quiz_sections table. There's a function quiz_add_instance which adds data to the tables quiz and quiz_section and returns the quiz_id. But this functionn calls another function quiz_after_add_or_update. In this function there is a variable $cmid. What is the use of cmid and how do I fetch/generate it to proceed further?
I already went through the link, but the thing I could not understand is the relation between section field with the course_module table.
The only 'section' field I am aware of is in mdl_course_sections.
mdl_course_sections has several fields:
- id - the unique id of the section (i.e. section 2 in two different courses will have a different id here)
- course - the course the section belongs to
- section - the section position within the course (0, 1, 2, 3, etc. for each course) (i.e. if there is a 2nd section in multiple courses, then all of them will have a 2 here).
- sequence - ordered, comma-separated list of ids for the mdl_course_modules table, the activities that are present in that course section
I could finally get all my required data into the database and created a quiz.
The tables I modified are:
quiz, quiz_sections, course_modules, course_sections and quiz_slots
Now since all the tables have data and I got a quiz id from using the DML functions provided by moodle, the quiz should show up but I am still not able to see the quiz on my moodle dashboard. Is there anything left to do now? Is there any other table that I might be missing out or anything that I haven't done? Really need some assistance now.