Multiple Choice answer field

This module provides a simple field that can be used as a simple quiz or multiple choice questions. It provides a field with a textfield and a checkbox / radio selection combined. If added to any entity (node/content type, user, taxonomy term, ...) the editor of the entity can enter multiple answers in the textfields and determine which answers are correct.

This module is for everybody who does not want to use the whole complex system of the quiz module, but just a simple field for multiple choice questions.

Maintenance Info

Sorry, due to time limitations I'm currently not able to maintain this module any more. If there is anybody out there who wants to care about it, just ping me.

Usage

  • Add the field to any entity, for example a content type in the "manage fields" settings of your content type / user / taxonomy term / ...
  • set the number of values, maybe just use unlimited
  • create a new node of your content type / a new entity instance
  • you can use the title field (or another textfield) to enter the question
  • now enter a possible answer in the field quiz textfield
  • mark the checkbox if this is a correct answer
  • push "add another item", to get a new textfield (if the number of values was set to unlimited, else you have the number of possibilities already listed)
  • enter a new answer in the field quiz textfield
  • mark the checkbox if this is a correct answer
  • continue until all answers are set

It is possible to mark multiple answers as correct. So you can mark one answer as correct or multiple. If multiple answers are checked, the correct answers have all marked from the user but not even a single wrong one. So all correct answers have to be chosen.
The answers can be shuffled (setting in the configuration) when displayed, so the order of the answers changes for each page view.

When the entity/node is displayed to the current user, the multiple answers are shown to her/him together with a checkbox or a radio selection (if just one answer is correct) for each answer. The user can select which answers are correct.

Answer Feedback

Since version 7.x-1.6 there is ajax support possible. so it is possible to switch if the feedback message to the answers should be displayed directly below the answer options, or if the user should be redirected on a separate feedback page. In the admin settings of the module (admin/config/system/field-quiz) there is a checkbox to select the desired functionality.

If the answer(s) is/are correct:

  • ajax: display the success feedback below the answer options
  • redirect: redirect the user to the url "quiz/success/quiz_node_id", where the success feedback message is displayed

If minimum one answer option is wrong:

  • ajax: the sorry feedback message is displayed below the answer options
  • redirect: the user is redirected to the url "quiz/sorry/[entity_type]/[quiz_entity_id]", where the retry feedback message is displayed. Examples:
    • quiz/sorry/node/3
    • quiz/sorry/user/5
    • quiz/sorry/taxonomy_term/7

Answer Feedback Texts

Version 7.x-1.7 ships now with the possibility to enter your own custom feedback texts. Therefore you can go to the settings page admin/config/system/field-quiz and set your own feedback texts.

Theming

When the user is redirected to a separate page for displaying the feedback message there are separate theming functions, which are displaying the HTML for the messages. These theming functions can be overwritten and customized in your theme. At the end of the url the entity type and entity id of the quiz node is added (see above). So it is easy possible to get the entity type and the entity id of the quiz page the user comes from and use the elements of this entity in the custom theme implementation.

In the ajax implementation the message is embedded in the form currently. But here the same theming functions are used which can be overwritten and customized in your theme.

Radios support

With version 7.x-1.4 there came support for radios. As radios just submit one value it will be possible to just select one answer and submit it. To use radios for selecting the answer you create a field in your entity as written above. But just one answer should be marked as correct. There is an administration setting at admin/config/system/field-quiz where you can check if you want to use radios. If selected and just one answer is marked as correct, the system will display radios for the answers.

Drupal 8 Version

The Version 8.x-1.0-alpha2 is just released and ready for testing. The branch is available, so feel free to help with patches. This release is very old. Currently the D7 issues are handled and afterwards the D8 version will be continued.

Hint

This is by now a base module. Feel free to extend it or use it for other purposes.
If you have further ideas, do not hesitate to open an issue ;-)

Supporting organizations: 
Development of the module.

Project information

Releases