creating questions/answers with SQL in table?

creating questions/answers with SQL in table?

by Gerrit Leder -
Number of replies: 5

Hello all,

I have created a quiz course with id 1 and course 5 in table mdl_quiz:

SELECT * FROM `mdl_quiz`

1 5 ISTQB Quiz <p>ISTQB Quiz</p> 1 0 0 0 autosubmit 0 deferredfeedback 0 0 0 1 2 -1 69904 4368 4368 4368 4368 4368 4368 1 free 1 0.00000 10.00000 0 1489163494

- 0 0 0 0 0 0 0

How can I add questions and answers via SQL? What tables do I have to use for it?

Thanks in advance!

BR

Gerrit

Average of ratings: -
In reply to Gerrit Leder

Re: creating questions/answers with SQL in table?

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

Sorry, https://docs.moodle.org/dev/Quiz_database_structure is out-of date (the main change is that quiz_question_instances has been renamed quiz_slots).

The best approach is to look in the databse when you add a question uising the user-interface, and see what changed.

Average of ratings: Useful (2)
In reply to Tim Hunt

Re: creating questions/answers with SQL in table?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

This diagram might help

http://www.examulator.com/er/components/quiz.html

When I update that I will refer to 

https://docs.moodle.org/dev/Quiz_database_structure

For inspiration.

Tims suggestion of doing updates and seeing what has changed has worked well for me in the past.

Average of ratings: Useful (1)
In reply to Marcus Green

Re: creating questions/answers with SQL in table?

by Gerrit Leder -

Thanks a lot!


This is what I was looking for...

In reply to Gerrit Leder

Re: creating questions/answers with SQL in table?

by Marcus Green -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

You may find it useful to install the free MySQL workbench tool and download this file.

http://www.examulator.com/er/moodle_31_erd.mwb

That way you can see all the tables and not rely on my possibly arbitrary choices on what to include in those diagrams.

If you are not running Moodle 3.1 you may find your version among these

http://www.examulator.com/er/archive.html

Though the database structure does not tend to change wildly from one release to another.