Automate Quiz creation - $quiz object documented?

Automate Quiz creation - $quiz object documented?

par Colin Matheson,
Nombre de réponses : 1

I am working on a block which imports questions from Quizlet into the question bank and creates a quiz using the site defaults from those questions. I have the import working and I am looking to auto-create the quiz. I see the function quiz_add_instance takes an object, but I am not sure all of the variables I need to define. Is the $quiz object documented somewhere? Also does quiz_add_instance handle all the necessary info that the course and section needs to display properly?

Thanks for any assistance.

Moyenne des évaluations  -
En réponse à Colin Matheson

Re: Automate Quiz creation - $quiz object documented?

par Tim Hunt,
Avatar Core developers Avatar Documentation writers Avatar Particularly helpful Moodlers Avatar Peer reviewers Avatar Plugin developers

Yes, and no.

No, there is nowhere that the $quiz object is documented, as such.

However, it very closely follows the data in the mdl_quiz table, and that has documentations (Admin -> Development -> XMLDB -> mod/quiz/db/install.xml -> [Doc].

Also, the data that is passed to quiz_add_instance comes from mod/quiz/mod_form.php, and again that gives you a lot of information about what each field means (through the help icons in the UI) and what the allowed values are (in the code).

quiz_add_instance only saves the quiz-specific data. The changes to course_sections, course_modues etc is handled by Moodle core in a way that (last time I looked) was not easy to reuse. You need to start reading code in course/mod_edit.php.