Refactor 'truefalse' question type into its own module
turadg - July 3, 2009 - 18:21
| Project: | Quiz |
| Version: | 6.x-4.x-dev |
| Component: | Code - Quiz module |
| Category: | task |
| Priority: | normal |
| Assigned: | sivaji |
| Status: | closed |
Jump to:
Description
Somewhat along the lines of http://drupal.org/node/508744 ...
Currently the truefalse question type is integrated into the quiz_question module code and directory. In trying to understand how quiz_question works, it's difficult to identity what is essential to quiz_question and what is part of truefalse.
Let this issue serve to track the progress of refactoring truefalse out of quiz_question. (mbutcher confirmed on IRC this is a good move.)

#1
A new truefalse module has been written. Please update your working copy. You may have to clear cache to flush autoload caching.
Following changes has been made while writing this module
1.question_types/quiz_question/quiz_question.truefalse.inc has been removed
2. A new directory truefalse under question_type which following files has been created
truefalse.classes.inc truefalse.install truefalse.theme.inc truefalse.info truefalse.module3. quiz_question_schema has been changed to truefalse_schema so you are likely to get this error message when you install this module.
* user warning: Table 'qsquiz_truefalse_node' already exists query: CREATE TABLE qsquiz_truefalse_node ( `nid` INT unsigned NOT NULL, `vid` INT unsigned NOT NULL, `correct_answer` TINYINT unsigned DEFAULT 0, `feedback` TEXT DEFAULT NULL, PRIMARY KEY (vid, nid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /home/sivaji/Public/quiz-dev4/includes/database.inc on line 515.* user warning: Table 'qsquiz_truefalse_user_answers' already exists query: CREATE TABLE qsquiz_truefalse_user_answers ( `question_nid` INT unsigned NOT NULL, `question_vid` INT unsigned NOT NULL, `result_id` INT unsigned NOT NULL, `answer` TINYINT unsigned DEFAULT 0, `score` INT unsigned NOT NULL DEFAULT 0, PRIMARY KEY (result_id, question_nid, question_vid) ) /*!40100 DEFAULT CHARACTER SET UTF8 */ in /home/sivaji/Public/quiz-dev4/includes/database.inc on line 515.
It breaks the already existing truefalse questions. It is expected to make the quiz upgrade little painful. Any suggestions to fix this will be greatly appreciated.
#2
This module goes into quiz 4.x.
#3
Nice work.
To avoid breaking the earlier TF, you can add code to the install hook that looks for the earlier T/F questions and answers in the older tables and moves their data over to the new TF tables.
#4
Okay i have changed hooks_install as follow
Before
/*** Implementation of hook_install().
*/
function truefalse_install() {
drupal_install_schema('truefalse');
}
Now
/*** Implementation of hook_install().
*/
function truefalse_install() {
if (!db_table_exists('quiz_truefalse_node') && !db_table_exists('quiz_truefalse_user_answers')) {
drupal_install_schema('truefalse');
}
}
#5
marking it as fixed. Feel free to open it again if required.
#6
Automatically closed -- issue fixed for 2 weeks with no activity.