/[drupal]/contributions/modules/quiz/DEVELOPER.txt
ViewVC logotype

Contents of /contributions/modules/quiz/DEVELOPER.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.3 - (show annotations) (download)
Thu Aug 13 16:48:17 2009 UTC (3 months, 1 week ago) by sivaji
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +0 -0 lines
File MIME type: text/plain
Merging GSoC code with HEAD.
1 NOTES ON DEVELOPING EXTENSIONS FOR QUIZ
2 =======================================
3
4 Hooks for interacting with a quiz:
5 - hook_quiz_begin($quiz, $rid): This hook is called when a user first begins a quiz.
6 - hook_quiz_finished($quiz, $score, $rid): This hook is called immediately after a user finishes taking a quiz.
7 - hook_quiz_scored($quiz, $score, $rid): This is called when a quiz score is updated. See http://drupal.org/node/460456
8
9
10 DEVELOPING NEW QUESTION TYPES:
11
12 There are two different ways to create a new question type: the "old" way, which
13 uses traditional Drupal hooks, but requires substantial coding, and the "new" OO
14 way, which is much faster to develop.
15
16 1. Creating a question type the old way
17 =======================================
18
19 To create a question type the "old" way, you will need to develop a custom
20 module that parforms all of the necessary actions. There are several hooks you
21 will need to implement. The best place to start is with the multichoice module.
22
23 Hooks you need to implement when developing a new question type:
24
25 hook_list_questions() // List of questions
26 hook_quiz_question_info() // Info about a question type.
27 hook_evaluate_question() // Check whether question is correct or not.
28 hook_get_report()
29 hook_render_question()
30
31 hook_quiz_question_score() // Given information about a quiz question, determine the score
32 hook_quiz_personality_question_score() // Given information about a quiz question, determine the personality category
33
34 Theme functions
35 ===============
36 Where {$type} is the question type, e.g. multichoice or long_answer...
37
38 theme_{$type}_report() // Report at end of quiz
39 theme_{$type}_feedback() // Feedback given during the taking of the quiz.
40
41
42 2. Creating a new question type using quiz_question
43 ===================================================
44
45 In this method, you need to create a new module that extends the existing
46 question type core. The True/False question type provides a precise example.
47
48 Here are the steps:
49
50 1. Create a new module
51 2. Use your module's .install file to create the necessary tables
52 3. Make sure you module implements hook_quiz_question_info()
53 4. Define classes that implement QuizQuestion and QuizQuestionResponse.
54 (Hint: You may want to extend the Abstract classes where available.)
55 For a complete example, see quiz_question.truefalse.inc.

  ViewVC Help
Powered by ViewVC 1.1.2