Automate Quiz creation - $quiz object documented?

Automate Quiz creation - $quiz object documented?

Colin Matheson-mit -
Antal besvarelser: 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.

Gennemsnitsbedømmelse: -
I svar til Colin Matheson

Re: Automate Quiz creation - $quiz object documented?

Tim Hunt-mit -
Core developers-ip assinga Documentation writers-ip assinga Particularly helpful Moodlers-ip assinga Peer reviewers-ip assinga Plugin developers-ip assinga

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.