You probably want to start here: https://docs.moodle.org/dev/Using_the_question_engine_from_module
But, be warned (if you are new to Moodle), that this is probably one of the most complex parts of Moodle to understand (possibly with the exception of the backup & restore code).