The active bug report for this is MDL-80965.
Tim Hunt
Posts made by Tim Hunt
If you want to ignore Andrew's very valid warnings, then people have already made and shared a plugin here: https://moodle.org/plugins/tiny_fontcolor
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.)
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.)
This is a known bug: MDL-80386. Has not been fixed yet.
We recently created a question type which does exaclty this but I have not yet had time to publish it in the plugins database.