NOTES ON DEVELOPING EXTENSIONS FOR QUIZ
=======================================
Hooks for interacting with a quiz:
- hook_quiz_begin($quiz, $rid): This hook is called when a user first begins a quiz.
- hook_quiz_finished($quiz, $score, $rid): This hook is called immediately after a user finishes taking a quiz.
- hook_quiz_scored($quiz, $score, $rid): This is called when a quiz score is updated. See http://drupal.org/node/460456
DEVELOPING NEW QUESTION TYPES:
There are two different ways to create a new question type: the "old" way, which
uses traditional Drupal hooks, but requires substantial coding, and the "new" OO
way, which is much faster to develop.
1. Creating a question type the old way
=======================================
To create a question type the "old" way, you will need to develop a custom
module that parforms all of the necessary actions. There are several hooks you
will need to implement. The best place to start is with the multichoice module.
Hooks you need to implement when developing a new question type:
hook_list_questions() // List of questions
hook_quiz_question_info() // Info about a question type.
hook_evaluate_question() // Check whether question is correct or not.
hook_get_report()
hook_render_question()
hook_quiz_question_score() // Given information about a quiz question, determine the score
hook_quiz_personality_question_score() // Given information about a quiz question, determine the personality category
Theme functions
===============
Where {$type} is the question type, e.g. multichoice or long_answer...
theme_{$type}_report() // Report at end of quiz
theme_{$type}_feedback() // Feedback given during the taking of the quiz.
2. Creating a new question type using quiz_question
===================================================
In this method, you need to create a new module that extends the existing
question type core. The True/False question type provides a precise example.
Here are the steps:
1. Create a new module
2. Use your module's .install file to create the necessary tables
3. Make sure you module implements hook_quiz_question_info()
4. Define classes that implement QuizQuestion and QuizQuestionResponse.
(Hint: You may want to extend the Abstract classes where available.)
For a complete example, see quiz_question.truefalse.inc.
View source
- NOTES ON DEVELOPING EXTENSIONS FOR QUIZ
- =======================================
-
- Hooks for interacting with a quiz:
- - hook_quiz_begin($quiz, $rid): This hook is called when a user first begins a quiz.
- - hook_quiz_finished($quiz, $score, $rid): This hook is called immediately after a user finishes taking a quiz.
- - hook_quiz_scored($quiz, $score, $rid): This is called when a quiz score is updated. See http://drupal.org/node/460456
-
-
- DEVELOPING NEW QUESTION TYPES:
-
- There are two different ways to create a new question type: the "old" way, which
- uses traditional Drupal hooks, but requires substantial coding, and the "new" OO
- way, which is much faster to develop.
-
- 1. Creating a question type the old way
- =======================================
-
- To create a question type the "old" way, you will need to develop a custom
- module that parforms all of the necessary actions. There are several hooks you
- will need to implement. The best place to start is with the multichoice module.
-
- Hooks you need to implement when developing a new question type:
-
- hook_list_questions() // List of questions
- hook_quiz_question_info() // Info about a question type.
- hook_evaluate_question() // Check whether question is correct or not.
- hook_get_report()
- hook_render_question()
-
- hook_quiz_question_score() // Given information about a quiz question, determine the score
- hook_quiz_personality_question_score() // Given information about a quiz question, determine the personality category
-
- Theme functions
- ===============
- Where {$type} is the question type, e.g. multichoice or long_answer...
-
- theme_{$type}_report() // Report at end of quiz
- theme_{$type}_feedback() // Feedback given during the taking of the quiz.
-
-
- 2. Creating a new question type using quiz_question
- ===================================================
-
- In this method, you need to create a new module that extends the existing
- question type core. The True/False question type provides a precise example.
-
- Here are the steps:
-
- 1. Create a new module
- 2. Use your module's .install file to create the necessary tables
- 3. Make sure you module implements hook_quiz_question_info()
- 4. Define classes that implement QuizQuestion and QuizQuestionResponse.
- (Hint: You may want to extend the Abstract classes where available.)
- For a complete example, see quiz_question.truefalse.inc.