Ask your Symfony questions! Pay money and get answers fast! (more info)

Creating a Quiz System Symfony


Hi there,

I would like to create a quiz system in symfony, but i have no idea how to start. So the facts...

1. A quiz can contain several questions.
2. A question may be true/false, more choices (only one (radio) or more (checkbox)), a simple value (number, string), essay (textarea), etc...
3. The administrator can create quizzes with several types of questions.
4. The administrator can check the result of a quiz of a user. NOT only the score! The administrator can see the whole filled quiz with the incorrect and correct answers. Of course, the admin see which checkbox or radio button is checked...and which is the correct..
5. The user can review his quiz with results.

Unfornately I have no idea how to do this. I think there should be two question tables, one for questions and one for questionAnswers. I dont know how to create a form that has many subforms, and how to review it again after saving... embed forms? Or how to calculate the result score...

Do you have a quiz system?
Should I use a plugin for this?
Or should I write the whole module?
Do you have a similar solution that works fine?

Any help would be appriciated! If you can attach codes to your comment, it would be great, i can understand a lot from code examples...

Thank you so much,

Answers (3)


Nate Flink answers:

This is a lot of work todo, as I have been involved in symfony several projects with relatively simple quizzes / form wizards. Expect lots of testing, and most likely bugs to creep into the process. If your dead set on writing this yourself, then your going to want to get to know symfony forms, actions and views/templates. This is work that is well worth it. There is an excellent forms tutorial available on the symfony project website.

IMHO, a faster and easier way, would be to install a pre built elearning tool with a quiz feature, such as Moodle ( or Atutor (

Another super fast option would be setting up a quiz using Wufoo forms (


Bill Hunt answers:

I've written a few of these, and there are a lot of factors to take into account. You're best off to find a plugin to handle it - but if not, you'll need to resolve the following issues:

Are the survey questions or answer options going to change at any point? If the survey is always going to be the same, the existing form framework can be very useful - just create an answer table with a column for each question.

If the survey content will change, you've got to hack a decent amount of code from scratch. You'll need a table to hold questions and a table to hold possible answers for select lists or checkboxes, etc. In your user's answer table, you're going to want to store the original question as well as the text of the answer the user selected - so if the question changes in the survey, the original question and answer will be preserved and not rendered invalid in the user's submitted copy.

If you're going to have multiple answers allowed to a given question ("Check all that apply"), you'll have to store answers in a relational many-to-one table. Avoiding this allows you to keep everything much cleaner in a one-to-one relationship. Your answer table will probably look something like:

CREATE TABLE `quiz_user_question_answer_index` (
`id` int(10) unsigned NOT NULL auto_increment,
`quiz_user_id` int(10) unsigned default NULL,
`quiz_question_id` int(10) unsigned default NULL,
`quiz_question_answer_id` int(10) unsigned default NULL,
`question_text` text,
`answer_text` text,
`date_created` datetime default NULL,
`date_modified` datetime default NULL,
KEY `quiz_user_id` (`quiz_user_id`),
KEY `quiz_question_id` (`quiz_question_id`),
KEY `quiz_question_answer_id` (`quiz_question_answer_id`)

Structuring your data is actually the hardest part. Once that's done, just create a view that iterates through the questions and shows them, then handle your errors and save your data per usual on submit.


Sergey Kushniruk answers:

Give a try to existing plugin:

saki comments:

I know this plugin, but I don't find any tutorial, readme or information about it. Do you know how to use it?

saki comments:

I think this plugin is not sf 1.4 compatible.:( during symfony doctrine:build it gives me fatal errors...