Posts made by Tim Hunt

Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
It is possible to create questions with PHP code - Moodle does that when the user submits the edit question form.

I would not try to do that by directly inserting data into the database. Many tables are invovled (depending on question type).

To see the required code, probably the simplest example is the code used to generate test data for automated tests: https://github.com/moodle/moodle/blob/main/question/tests/generator/lib.php#L97. (Do not use that test code directly in your real code, but you can learn form it.)