on the internet there are good test and quiz scripts.
4 example:
http://webtester.us/wtdemo.php
if you want to make of your own, you can start build the mysql table with my php/mysql code generator. 🙂
you have to decide the answers type( yes or no question, or choise from 4 values, free word input)
but if you wanted to make complicated program, that cause exponentially complicated structure (mysql table structure and those queries).