Automating Quiz

Automating Quiz

Binoj D -
Atsakymų skaičius: 10

I would like to programmatically create quiz in a section of a specific course and import questions in moodle xml format and add in the quiz I just created. What is the best way to approach this problem? Insert into tables directly?

Inherit moodle classes? If so, what are the classes I should be concentrating on?

Moodle 2.5.1+ (Build: 20130808)

Pažymių vidurkis: -
Atsakymas į Binoj D

Re: Automating Quiz

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis

You need to call the same API functions that the Moodle quiz does when you create a quiz through the Moodle UI. E.g. quiz_add_instance and quiz_add_quiz_question.

Alternatively, write a script that generates a Moodle backup file representing one quiz, and then restore that backup file.

Atsakymas į Tim Hunt

Re: Automating Quiz

Binoj D -

Thanks for the pointers. The restoring script part will not be feasible for me because, we will be having 20-50 quizzes per day each in its own course. So risk of human error (of people importing wrong quiz in wrong course) is high in this case. Will try calling the functions directly and let you know. Is there any way of catching the request sent by the script used to add a quiz, edit.php, etc. so that we know what are all the functions called? We use conditional grading, ip restriction too.

Atsakymas į Binoj D

Re: Automating Quiz

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis
Atsakymas į Tim Hunt

Re: Automating Quiz

Binoj D -

Thanks for the pointers in creating quizzes with restore script. We need to get the grades of students from moodle to our ERP so that students' marks are documented in our ERP to which students/parents have access to to track their performance. If I create quizzes/courses with restore scripts, I will not be able to automatically pull grades from moodle right? So, if I create courses & quizzes from my code by calling functions, I assume it'll return the primary keys of the quizzes/courses using which I can query moodle database for grades, question statistics, etc. Am I thinking this the right way?

Atsakymas į Binoj D

Re: Automating Quiz

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis

All grades in Moodle end up in the gradebook.

You can export the data from there (either manually, or scripted) in a variety of formats, including a simple XML format, and send them to another system.

Atsakymas į Tim Hunt

Re: Automating Quiz

Binoj D -

Yeah, but in order to get the correct grades for the correct quiz programmatically after the quiz closes, I would need the quiz's id right? How would the external system know which quiz's mark to import? If I get the quiz id when I create the quiz, I can store it in a reference table and then get the grades from the gradebook.

Atsakymas į Binoj D

Re: Automating Quiz

Tim Hunt -
Core developers paveikslėlis Documentation writers paveikslėlis Particularly helpful Moodlers paveikslėlis Peer reviewers paveikslėlis Plugin developers paveikslėlis

In order to facilitate integrating with external systems, various things in Moodle (including users, courses, grade items, ...) have a field in the database called 'idnumber'. That field has almost no significance to Moodle. It is there so you can put in an id that is meaningful to other systems, so that they can indentify things. So, give your quizzes / grade items and idnumber that corresponds to the id in the other system.

Atsakymas į Tim Hunt

Re: Automating Quiz

Binoj D -

Courses have idnumber but quizzes do not have liūdnas

Is there any way I can get list of quizzes in a course? (my quizzes are spread across 5 sections in a course. each section has 2 quizzes. course is in topics format)