Index: quiz.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/quiz/quiz.install,v
retrieving revision 1.12
diff -r1.12 quiz.install
31c31
<         quiz_always TINYINT NOT NULL default 0,
---
>         quiz_always TINYINT NOT NULL DEFAULT 0,
138a139,164
> /*
>  *  This update will make schema up-to-date from version 1.1
>  *
>  *  The following databases have changed names:
>  *    From              	To
>  *    quiz 					quiz_node_properties
>  *    quiz_questions 		quiz_node_relationship
>  *	  quiz_question 		quiz_node_question_properties
>  *    quiz_result 			quiz_node_results
>  *    quiz_question_results quiz_node_results_answers
>  *	  
>  *
>  *  TODO: SCORE NEEDS TO BE UPDATED WITH A CALCULATED SCORE
>  *  A new function needs to be added to this script which will calculate the
>  *  score for each result.
>  *
>  *  'answers' in quiz_node_results_answers need to be checked against the 
>  *  answer in the multichoice module. Then this result needs to be added to the 
>  *  score column in quiz_node_properties.
>  *
>  *  I have not deleted the following columns as they are needed to 
>  *  calculate the score column.
>  *
>  *  
>  */
> 
145,146c171,233
<       // add a result option to the answer table
<       $ret[] = update_sql("ALTER TABLE {quiz_question_answer} ADD result_option INTEGER UNSIGNED NULL");
---
>     
>       // rename quiz to quiz_node_properties
>       $ret[] = update_sql("ALTER TABLE {quiz} RENAME TO {quiz_node_properties}");
>       // update quiz_node_properties to new schema
>       $ret[] = update_sql("ALTER TABLE {quiz_node_properties} DROP number_of_questions;");
>       $ret[] = update_sql("ALTER TABLE {quiz_node_properties} 
>         ADD property_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
>         ADD vid INTEGER UNSIGNED NOT NULL AFTER property_id,
>         ADD number_of_random_questions TINYINT UNSIGNED DEFAULT 0 NOT NULL AFTER nid,
>         ADD tid INTEGER UNSIGNED NOT NULL DEFAULT 0,
>         DROP PRIMARY KEY,
>         ADD PRIMARY KEY (property_id),
>         ADD KEY vid (nid, vid);
>       ");
>       
>       // rename quiz_questions to quiz_node_relationship
>       $ret[] = update_sql("ALTER TABLE {quiz_questions} RENAME TO {quiz_node_relationship}");
>       // update quiz_node_relationship to new schema
>       $ret[] = update_sql("ALTER TABLE {quiz_node_relationship}
>         DROP PRIMARY KEY,
>         CHANGE quiz_nid parent_nid INTEGER UNSIGNED NOT NULL,
>         ADD parent_vid INTEGER UNSIGNED NOT NULL AFTER parent_nid,
>         CHANGE question_nid child_nid INTEGER UNSIGNED NOT NULL,
>         ADD child_vid INTEGER UNSIGNED NOT NULL AFTER child_nid,
>         ADD PRIMARY KEY (parent_nid, parent_vid, child_nid, child_vid);
>       ");
>       
>       // rename quiz_question to quiz_node_question_properties
>       $ret[] = update_sql("ALTER TABLE {quiz_question} RENAME TO {quiz_node_question_properties}");
>       // update quiz_node_question_properties to new schema
>       $ret[] = update_sql("ALTER TABLE {quiz_node_question_properties}
>         ADD vid INTEGER UNSIGNED NOT NULL AFTER nid,
>         ADD number_of_answers TINYINT UNSIGNED DEFAULT 1 NOT NULL,
>         DROP PRIMARY KEY;
>       ");
>       
>       
>       
>       // rename quiz_result to quiz_node_result
>       $ret[] = update_sql("ALTER TABLE {quiz_result} RENAME TO {quiz_node_results}");
>       // update quiz_node_result to new schema
>       $ret[] = update_sql("ALTER TABLE {quiz_node_results}
>         DROP PRIMARY KEY,
>         DROP score,
>         CHANGE rid result_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT FIRST,
>         CHANGE quiz_nid nid INTEGER UNSIGNED NOT NULL,
>         ADD vid INTEGER UNSIGNED NOT NULL AFTER nid,
>         ADD score TINYINT NOT NULL DEFAULT 0,
>         ADD PRIMARY KEY (result_id);
>       ");
>       
>       // rename quiz_question_results to quiz_node_results_answers
>       $ret[] = update_sql("ALTER TABLE {quiz_question_results} RENAME TO {quiz_node_results_answers}");
>       // update quiz_node_results_answers to new schema
>       $ret[] = update_sql("ALTER TABLE {quiz_node_results_answers}
>         DROP PRIMARY KEY,
>         CHANGE result_rid result_id INT UNSIGNED NOT NULL,
>         ADD question_vid INT UNSIGNED NOT NULL AFTER question_nid,
>         ADD is_correct TINYINT UNSIGNED NOT NULL DEFAULT '0',
>         ADD points_awarded TINYINT NOT NULL DEFAULT '0',
>         ADD answer_timestamp INT UNSIGNED NOT NULL,
>         ADD PRIMARY KEY(result_id, question_nid, question_vid);
>       ");
149c236
<       $ret[] = update_sql("CREATE TABLE {quiz_result_options} (
---
>       $ret[] = update_sql("CREATE TABLE {quiz_node_result_options} (
Index: multichoice.install
===================================================================
RCS file: /cvs/drupal/contributions/modules/quiz/multichoice.install,v
retrieving revision 1.1
diff -r1.1 multichoice.install
48a49
> 
57a59,96
>       
>       
> function multichoice_update_1() {
>   $ret = array();
>   
>   switch ($GLOBALS['db_type']) {
>     case 'mysql':
>     case 'mysqli':
>       // Create the quiz node user answers multichoice table
>       $ret[] = update_sql("CREATE TABLE {quiz_multichoice_user_answers} (
>         question_nid INTEGER UNSIGNED NOT NULL,
>         question_vid INTEGER UNSIGNED NOT NULL,
>         result_id INTEGER UNSIGNED NOT NULL,
>         answer_id INTEGER UNSIGNED NOT NULL,
>         PRIMARY KEY(result_id, question_nid, question_vid, answer_id)
>       ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
>       
>       // add a result option to the answer table
>       $ret[] = update_sql("ALTER TABLE {quiz_question_answer} DROP INDEX question_nid;");
>       $ret[] = update_sql("ALTER TABLE {quiz_question_answer} RENAME TO {quiz_multichoice_answers};");
>       $ret[] = update_sql("ALTER TABLE {quiz_multichoice_answers}
>         DROP PRIMARY KEY,
>         CHANGE aid answer_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
>         CHANGE question_nid nid INTEGER UNSIGNED NOT NULL,
>         ADD vid INTEGER UNSIGNED NOT NULL AFTER nid,
>         CHANGE answer answer varchar(255) NOT NULL,
>         CHANGE feedback feedback LONGTEXT,
>         ADD result_option INTEGER UNSIGNED DEFAULT 0 AFTER feedback,
>         ADD is_correct TINYINT UNSIGNED DEFAULT 0,
>         ADD PRIMARY KEY(answer_id);
>       ");
> 
> 
>       break;
>   }
>   return $ret;
> }
>       
