Index: CHANGELOG.txt
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/CHANGELOG.txt,v
retrieving revision 1.11
diff -u -r1.11 CHANGELOG.txt
--- CHANGELOG.txt	15 Feb 2008 00:18:03 -0000	1.11
+++ CHANGELOG.txt	30 Jul 2008 02:26:19 -0000
@@ -1,12 +1,9 @@
 $Id: CHANGELOG.txt,v 1.11 2008/02/15 00:18:03 westwesterson Exp $
 
 -----------
-5.x-2.0-dev
+HEAD
 -----------
-
-changes since 5.x-2.0-beta2
-------------
-
+- updated to use schema api in quiz
 
 version 5.x-2.0-beta2
 ------------
Index: multichoice.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/multichoice.info,v
retrieving revision 1.6
diff -u -r1.6 multichoice.info
--- multichoice.info	20 Aug 2007 18:07:02 -0000	1.6
+++ multichoice.info	30 Jul 2008 02:26:19 -0000
@@ -2,4 +2,5 @@
 name = Multichoice
 package = Quiz
 description = Multiple choice question type
-dependencies = quiz
+dependencies[] = quiz
+core = 6.x
\ No newline at end of file
Index: quiz.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/quiz.module,v
retrieving revision 1.134
diff -u -r1.134 quiz.module
--- quiz.module	9 Jan 2008 04:12:03 -0000	1.134
+++ quiz.module	30 Jul 2008 02:26:21 -0000
@@ -60,8 +60,7 @@
 /**
  * Implementation of hook_access().
  */
-function quiz_access($op, $node) {
-  global $user;
+function quiz_access($op, $node, $account) {
 
   if ($op == 'view') {
     return user_access('access quiz');
@@ -98,93 +97,71 @@
 /**
  * Implementation of hook_menu().
  */
-function quiz_menu($may_cache) {
-  $items = array();
-  if ($may_cache) {
-    $access = user_access(QUIZ_PERM_ADMIN_CONFIG);
-    $items[] = array(
-      'path' => 'admin/settings/quiz',
+function quiz_menu() {
+
+    drupal_add_css(drupal_get_path('module', 'quiz') .'/quiz.css', 'module', 'all');
+
+    $items['admin/settings/quiz'] = array(
       'title' => t('@quiz Configuration', array('@quiz' => QUIZ_NAME)),
       'description' => t('Configure @quiz options.', array('@quiz' => QUIZ_NAME)),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('quiz_admin_settings'),
-      'access' => user_access(QUIZ_PERM_ADMIN_CONFIG),
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('quiz_admin_settings'),
+      'access arguments' => array(QUIZ_PERM_ADMIN_CONFIG),
       'type' => MENU_NORMAL_ITEM, // optional
     );
-
-    $items[] = array(
-      'path' => 'node/add/quiz',
-      'title' => t('@quiz', array('@quiz' => QUIZ_NAME)),
-      'access' => user_access('create quiz'),
-    );
-
-    $items[] = array(
-      'path' => 'admin/quiz/results',
+    $items['admin/quiz/results'] = array(
       'title' => t('@quiz Results', array('@quiz' => QUIZ_NAME)),
-      'callback' => 'quiz_admin',
-      'access' => user_access('administer quiz'),
+      'page callback' => 'quiz_admin',
+      'access arguments' => array('administer quiz'),
       'type' => MENU_NORMAL_ITEM,
     );
-  }
-  else {
-    drupal_add_css(drupal_get_path('module', 'quiz') .'/quiz.css', 'module', 'all');
-    if (arg(0) == 'node' && is_numeric(arg(1))) {
-      $node = node_load(arg(1));
-      if ($node->type == 'quiz') {
-        // Menu item for creating adding questions to quiz.
-        $items[] = array(
-          'path' => 'node/'. arg(1) .'/questions',
-          'title' => t('Manage questions'),
-          'callback' => 'quiz_questions',
-          'access' => user_access('create quiz'),
-          'type' => MENU_LOCAL_TASK,
-        );
-      if (user_access('administer quiz')) {
-          $items[] = array(
-            'path' => 'node/'. arg(1) .'/quiz/admin',
-            'title' => t('Quiz Admin', array('@quiz' => QUIZ_NAME)),
-            'callback' => 'theme_quiz_view',
-            'callback arguments' => array(node_load(arg(1))),
-            'access' => user_access('administer quiz'),
-            'type' => MENU_LOCAL_TASK,
-          );
-        }
-      }
-    }
-    else {
-      $items[] = array(
-        'path' => 'user/'. arg(1) .'/myresults',
-        'title' => t('My Results'),
-        'callback' => 'quiz_get_user_results',
-        'access' => user_access('user results'),
-        'type' => MENU_LOCAL_TASK,
-      );
-
-      $items[] = array(
-        'path' => 'user/quiz/'. arg(2) .'/userresults',
-        'title' => t('User Results'),
-        'callback' => 'quiz_user_results',
-        'access' => user_access('user results'),
-        'type' => MENU_CALLBACK,
-      );
+	
+	$node = node_load(arg(1));
+    if ($node->type == 'quiz') {
+
+    // Menu item for creating adding questions to quiz.
+    $items['node/%/questions'] = array(
+      'title' => t('Manage questions'),
+      'page callback' => 'quiz_questions',
+      'access arguments' => array('create quiz'),
+      'type' => MENU_LOCAL_TASK,
+    );
+    $items['node/%/admin'] = array(
+      'title' => t('Quiz Admin', array('@quiz' => QUIZ_NAME)),
+      'page callback' => 'theme_quiz_view',
+      'page arguments' => array(2),
+      'access arguments' => array('administer quiz'),
+      'type' => MENU_LOCAL_TASK,
+    );
+}
+    $items['user/%/myresults'] = array(
+      'title' => t('My Results'),
+      'page callback' => 'quiz_get_user_results',
+      'access arguments' => array('user results'),
+      'type' => MENU_LOCAL_TASK,
+    );
 
-      $items[] = array(
-        'path' => 'admin/quiz/'. arg(2) .'/view',
-        'title' => t('View @quiz', array('@quiz' => QUIZ_NAME)),
-        'callback' => 'quiz_admin_results',
-        'access' => user_access('administer quiz'),
-        'type' => MENU_CALLBACK,
-      );
-               
-      $items[] = array(
-        'path' => 'admin/quiz/'. arg(2) .'/delete',
-        'title' => t('Delete @quiz', array('@quiz' => QUIZ_NAME)),
-        'callback' => 'quiz_admin_result_delete',
-        'access' => user_access('administer quiz'),
-        'type' => MENU_CALLBACK,
-      );
-    }
-  }
+    $items['user/quiz/%/userresults'] = array(
+      'title' => t('User Results'),
+      'page callback' => 'quiz_user_results',
+      'access arguments' => array('user results'),
+      'type' => MENU_CALLBACK,
+    );
+	  
+    $items['admin/quiz/%/view'] = array(
+      'title' => t('View @quiz', array('@quiz' => QUIZ_NAME)),
+      'page callback' => 'quiz_admin_results',
+      'page arguments' => array(2),	  
+      'access arguments' => array('administer quiz'),
+      'type' => MENU_CALLBACK,
+    );
+	  
+    $items['admin/quiz/%/delete'] = array(
+      'title' => t('Delete @quiz', array('@quiz' => QUIZ_NAME)),
+      'page callback' => 'quiz_admin_result_delete',
+      'access arguments' => array('administer quiz'),
+      'type' => MENU_CALLBACK,
+    );
   return $items;
 }
 
@@ -560,10 +537,10 @@
  */
 function _quiz_insert_result_option($option) {
   if (empty($option['option_id'])) {
-    $option['option_id'] = db_next_id('{quiz_node_result_options}'.'_option_id');
-    $sql = "INSERT INTO {quiz_node_result_options} (nid, vid, option_id, option_name, option_summary, option_start, option_end)".
-           " VALUES(%d, %d, %d, '%s', '%s', %d, %d)";
-    $values = array($option['nid'],
+    $sql = "INSERT INTO {quiz_node_result_options} (nid, vid, option_name, option_summary, option_start, option_end)".
+           " VALUES(%d, %d, '%s', '%s', %d, %d)";
+   $option['option_id'] = db_last_insert_id('{quiz_node_result_options}','option_id');
+   $values = array($option['nid'],
                     $option['vid'],
                     $option['option_id'],
                     $option['option_name'],
@@ -718,8 +695,44 @@
   return $output;
 }
 
+function quiz_theme() {
+  return array(
+    'quiz_availability' => array(
+      'arguments' => array('node' => NULL),
+    ),
+	'quiz_view' => array(
+	  'arguments' => array('node' => NULL, 'teaser' => FALSE, 'page' => FALSE),
+	),
+	'quiz_get_user_results' => array(
+      'arguments' => array('results' => NULL),
+	),
+	'quiz_question_table' => array(
+	  'arguments' => array('questions' => NULL, 'quiz_id' => NULL),
+	),
+	'quiz_take_question' => array(
+	  'arguments' => array('quiz' => NULL, 'question_node' => NULL),
+	),
+	'quiz_admin_summary' => array(
+	  'arguments' => array('quiz' =>NULL, 'questions' => NULL, 'score' =>NULL, 'summary' => NULL),
+	),
+	'quiz_user_summary' => array(
+	  'arguments' => array('quiz' =>NULL, 'questions' => NULL, 'score' =>NULL, 'summary' => NULL),
+	),
+	'quiz_feedback' => array(
+	  'arguments' => array('questions' => NULL, 'showpoints' =>TRUE, 'showfeedback' => FALSE),
+	),
+	'quiz_question_feedback' => array(
+	  'arguments' => array('quiz' => NULL, 'report' => NULL),
+	),
+	'quiz_questions' => array(
+      'arguments' => array('form' => NULL),
+	),	
+	'quiz_no_feedback' => array(),	
+  );
+}
+
 /**
- * Theme the node view for quizzes.
+ * Hook Theme the node view for quizzes.
  * 
  * @ingroup themeable
  */
@@ -774,7 +787,7 @@
   if (function_exists(taxonomy_node_get_terms)) {
     $output .= '<h3>'. t('Taxonomy selection') .'</h3>';
     $terms = array();
-    foreach (taxonomy_node_get_terms($node->nid) as $term) {
+    foreach (taxonomy_node_get_terms($node) as $term) {
       $terms[] = check_plain($term->name);
     }
     if (!empty($terms)) {
@@ -874,15 +887,15 @@
  *  HTML output for page.
  */
 function quiz_take_quiz() {
-  global $user;
-  if (arg(0) == 'node' && is_numeric(arg(1)) && user_access('access quiz')) {
-    if ($quiz = node_load(arg(1))) {
+  if (user_access('access quiz')) {
+    if ($quiz = menu_get_object()) {
+	
       // If anonymous user and no unique hash, refresh with a unique string to prevent caching.
-      if (!$user->uid && arg(4) == NULL) {
+      if (!$quiz->name && arg(4) == NULL) {
         drupal_goto('node/'. $quiz->nid .'/quiz/start/'. md5(mt_rand() . time()));
       }
       if ($user->uid && $quiz->takes != 0) {
-        $times = db_num_rows(db_query("SELECT result_id " .
+        $times = db_result(db_query("SELECT COUNT('result_id') " .
                                       "FROM {quiz_node_results} " .
                                       "WHERE nid = %d AND vid = %d AND uid = %d",
                                       $quiz->nid, $quiz->vid, $user->uid));
@@ -991,8 +1004,8 @@
  * Store a quiz question result.
  */
 function quiz_store_question_result($nid, $vid, $rid, $is_correct) {
-  $result = db_query("SELECT result_id FROM {quiz_node_results_answers} WHERE question_nid = %d AND question_vid = %d AND result_id = %d", $nid, $vid, $rid);
-  if (db_num_rows($result)) {
+  $result = db_query("SELECT COUNT('result_id') FROM {quiz_node_results_answers} WHERE question_nid = %d AND question_vid = %d AND result_id = %d", $nid, $vid, $rid);
+  if ($result) {
     db_query("UPDATE {quiz_node_results_answers} ".
             "SET is_correct = %d, points_awarded = %d, answer_timestamp = %d " . 
             "WHERE question_nid = %d AND question_vid = %d AND result_id = %d",
@@ -1189,11 +1202,12 @@
   }
 
   // Insert quiz_node_results record.
-  $rid = db_next_id('{quiz_node_results}_result_id');
   $result = db_query("INSERT INTO {quiz_node_results} " .
                      "(result_id, nid, vid, uid, time_start) " .
                      "VALUES (%d, %d, %d, %d, %d)", $rid, $quiz->nid, $quiz->vid, $user->uid, time());
-  if ($result) {
+  $rid = db_last_insert_id('{quiz_node_results}', 'result_id');
+
+ if ($result) {
     return $rid;
   }
   else {
@@ -1306,8 +1320,8 @@
 /**
  * Implementation of hook_help().
  */
-function quiz_help($section) {
-  switch ($section) {
+function quiz_help($path, $arg) {
+  switch ($path) {
     case 'admin/help#quiz':
       return t('
 <h3>Description</h3>
@@ -1413,10 +1427,10 @@
     </dl>
   </li>
   <li>Once the quiz has been created, click the <b>add questions</b> tab to assign questions to the quiz.</li>
-  <li>Select a radio button next to each question indicating if the question should appear (Randomly, Always, or Never), and click <strong>Submit questions</strong>.</li>
+  <li>Select a radio button next to each question indicating if the question should appear (Randomly, Always, or Never), and click <strong></strong>.</li>
   <li>Repeat process until satisfied with question selection.</li>
 </ol>
-    ', array('@quiz' => QUIZ_NAME, '@admin-access' => url('admin/user/access'), '@admin-modules' => url('admin/build/modules'), '@admin-taxonomy' => url('admin/content/taxonomy'), '@create-content' => url('node/add'), '@multichoice' => url('node/add/multichoice'), '@create-quiz' => url('node/add/quiz')));
+    ', array('@quiz' => QUIZ_NAME, '@admin-access' => url('admin/user/permissions'), '@admin-modules' => url('admin/build/modules'), '@admin-taxonomy' => url('admin/content/taxonomy'), '@create-content' => url('node/add'), '@multichoice' => url('node/add/multichoice'), '@create-quiz' => url('node/add/quiz')));
     case 'node/add#quiz':
       return t('A collection of questions designed to create interactive tests');
     default:
@@ -1642,17 +1656,17 @@
   $form['new_revision'] = array(
     '#type' => 'checkbox',
     '#default_value' => in_array('revision', variable_get('node_options_quiz', array())),
-    '#title' => 'New Revision',
+    '#title' => t('New Revision'),
     '#description' => t('Allow question status changes to create a new revision of the quiz?'),
   );
 
+  $form['timestamp'] = array('#type' => 'hidden', '#value' => time());
+
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Submit questions'),
   );
 
-  $form['timestamp'] = array('#type' => 'hidden', '#value' => time());
-
   return $form;
 }
 
@@ -1665,7 +1679,7 @@
  *  Array of questions objects.
  */
 function _quiz_get_unused_questions($quiz_vid = NULL, $nid_keys = FALSE) {
-  $quiz       = node_load( (int) arg(1) );
+  $quiz       = menu_get_object();
   $types      = _quiz_get_question_types();
   $where_sql  = '';
   $questions = array();
@@ -1716,40 +1730,39 @@
  * @param $values
  *  Array containing the form values.
  */
-function quiz_questions_form_submit($form_id, $values) {
-  // Load the node.
-  $quiz = node_load(arg(1));
+function quiz_questions_form_submit($form, &$form_state) {
+ 
   // Update quiz with selected question options.
-  if (!quiz_update_questions($values['question_status'], $values['new_revision'])) {
+  if (!quiz_update_questions($form_state['values']['question_status'], $form_state['values']['new_revision'])) {
     form_set_error('', t('Either no questions were selected, or there was a problem updating your @quiz. Please try again.', array('@quiz' => QUIZ_NAME)));
     return;
   }
 
   // Check if selecting random question from pool, and not via term.
-  if (empty($values['random_term_id'])) {
+  if (empty($form_state['values']['random_term_id'])) {
     $assigned_random =0;
-    if (is_array($values['question_status'])) {
-      foreach ($values['question_status'] as $id => $status) {
+    if (is_array($form_state['values']['question_status'])) {
+      foreach ($form_state['values']['question_status'] as $id => $status) {
         if (QUESTION_ALWAYS == $status) {
           $assigned_random++;
         }
       }
     }
 
-    if ($values['num_random_questions'] > $assigned_random) {
-      $values['num_random_questions'] = $assigned_random;
+    if ($form_state['values']['num_random_questions'] > $assigned_random) {
+      $form_state['values']['num_random_questions'] = $assigned_random;
       drupal_set_message(t('The number of random questions for this @quiz have been lowered to %anum to match the number of questions you assigned.', array('@quiz' => QUIZ_NAME, '%anum' => $assigned_random), 'status'));
     }
   }
   else {
     // Warn user if not enough questions available with this term_id.
-    $available_random = count(_quiz_get_random_questions($values['num_random_questions'], $values['random_term_id']));
-    if ($values['num_random_questions'] > $available_random) {
+    $available_random = count(_quiz_get_random_questions($form_state['values']['num_random_questions'], $form_state['values']['random_term_id']));
+    if ($form_state['values']['num_random_questions'] > $available_random) {
       drupal_set_message(t('There are currently not enough questions assigned to this term (@random). Please lower the number of random quetions or assign more questions to this taxonomy term before taking this @quiz.', array('@random' => $available_random, '@quiz' => QUIZ_NAME)), 'error');
     }
   }
 
-  $result = db_query("UPDATE {quiz_node_properties} SET number_of_random_questions = %d, tid = %d WHERE vid = %d AND nid = %d", $values['num_random_questions'], $values['random_term_id'], $quiz->vid, $quiz->nid);
+  $result = db_query("UPDATE {quiz_node_properties} SET number_of_random_questions = %d, tid = %d WHERE vid = %d AND nid = %d", $form_state['values']['num_random_questions'], $form_state['values']['random_term_id'], $quiz->vid, $quiz->nid);
   if (!$result) {
     drupal_set_message(t('There was an error updating the @quiz.', array('@quiz' => QUIZ_NAME)), 'error');
   }
@@ -1770,7 +1783,7 @@
  *  Number of questions that meet the criteria.
  */
 function quiz_get_num_questions($nid, $vid, $type) {
-  return db_num_rows(db_query("SELECT parent_vid FROM {quiz_node_relationship} WHERE parent_vid = %d AND parent_nid = %d AND question_status = %d", $vid, $nid, $type));
+  return db_result(db_query("SELECT COUNT('parent_vid') FROM {quiz_node_relationship} WHERE parent_vid = %d AND parent_nid = %d AND question_status = %d", $vid, $nid, $type));
 }
 
 /**
@@ -1826,7 +1839,8 @@
 
   // Create new revision of current quiz (if any question status has been changed).
   if (!empty($changes)) {
-    drupal_execute('node_form', array('revision' => '1'), $quiz);
+    $rev = array('revision' => '1');
+    drupal_execute('node_form', $rev, $quiz);
     drupal_set_message(t('A new revision of the @quiz has been created.', array('@quiz' => QUIZ_NAME)));
   }
 
@@ -1907,20 +1921,20 @@
 /**
  * Validation of the Form Settings form.
  */
-function quiz_settings_form_validate($form_id, $form_values) {
-  if (!is_numeric($form_values['num_random_questions']) || $form_values['num_random_questions'] <0 ) {
+function quiz_settings_form_validate($form, &$form_state) {
+  if (!is_numeric($form_state['values']['num_random_questions']) || $form_state['values']['num_random_questions'] <0 ) {
     form_set_error('num_random_questions', t('The number of random questions must be at least 0.'));
   }
-  if (!is_numeric($form_values['quiz_default_close']) || $form_values['quiz_default_close'] <= 0) {
+  if (!is_numeric($form_state['values']['quiz_default_close']) || $form_state['values']['quiz_default_close'] <= 0) {
     form_set_error('quiz_default_close', t('The default number of days before a quiz is closed must be a number greater than 0.'));
   }
-  if (!is_numeric($form_values['quiz_default_pass_rate'])) {
+  if (!is_numeric($form_state['values']['quiz_default_pass_rate'])) {
     form_set_error('quiz_default_pass_rate', t('The pass rate value must be a number between 0% and 100%.'));
   }
-  if ($form_values['quiz_default_pass_rate'] > 100) {
+  if ($form_state['values']['quiz_default_pass_rate'] > 100) {
     form_set_error('quiz_default_pass_rate', t('The pass rate value must not be more than 100%.'));
   }
-  if ($form_values['quiz_default_pass_rate'] < 0) {
+  if ($form_state['values']['quiz_default_pass_rate'] < 0) {
     form_set_error('quiz_default_pass_rate', t('The pass rate value must not be less than 0%.'));
   }
 }
@@ -2020,11 +2034,12 @@
                       t('Delete'),
                       t('Cancel'));
 }
-function quiz_admin_result_delete_form_submit($form_id, $form_values) {
-  db_query("DELETE FROM {quiz_node_results} WHERE result_id = %d", $form_values['del_rid']);
-  db_query("DELETE FROM {quiz_node_results_answers} WHERE result_id = %d", $form_values['del_rid']);
+function quiz_admin_result_delete_form_submit($form, &$form_state) {
+  db_query("DELETE FROM {quiz_node_results} WHERE result_id = %d", $form_state['values']['del_rid']);
+  db_query("DELETE FROM {quiz_node_results_answers} WHERE result_id = %d", $form_state['values']['del_rid']);
   drupal_set_message(t('Deleted result.'));
-  return "admin/quiz/results";
+  $form_state['redirect'] = 'admin/quiz/results';
+  $form_state['nid'] = $node->nid;  
 }
 
 function _quiz_get_answers($rid) {
Index: multichoice.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/multichoice.module,v
retrieving revision 1.62
diff -u -r1.62 multichoice.module
--- multichoice.module	3 Jan 2008 00:40:12 -0000	1.62
+++ multichoice.module	30 Jul 2008 02:26:20 -0000
@@ -21,8 +21,7 @@
 /**
  * Implementation of hook_access().
  */
-function multichoice_access($op, $node) {
-  global $user;
+function multichoice_access($op, $node, $account) {
 
   if ($op == 'create') {
     return user_access('create multichoice');
@@ -51,24 +50,15 @@
 /**
  * Implementation of hook_menu().
  */
-function multichoice_menu($may_cache) {
-  $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'node/add/multichoice',
-      'title' => t(MULTICHOICE_NAME),
-      'access' => user_access('create multichoice'),
-    );
-    $items[] = array(
-      'path' => 'admin/settings/multichoice',
+function multichoice_menu() {
+    $items['admin/settings/multichoice'] = array(
       'title' => t('Multichoice Configuration'),
-      'description' => t('Configure Multichoice questions fo users.'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('multichoice_admin_settings_form'),
-      'access' => user_access(QUIZ_PERM_ADMIN_CONFIG),
+      'description' => t('Configure Multichoice questions for users.'),
+      'page callback' => 'drupal_get_form',
+      'page arguments' => array('multichoice_admin_settings_form'),
+      'access arguments' => array(QUIZ_PERM_ADMIN_CONFIG),
       'type' => MENU_NORMAL_ITEM,
     );
-  }
   return $items;
 }
 
@@ -401,8 +391,8 @@
   foreach ($node->answers as $value) {
     if (trim($value['answer']) != "") {
       db_query("INSERT INTO {quiz_multichoice_answers} " .
-              "(answer_id, nid, vid, answer, feedback, is_correct, result_option) VALUES (%d, %d, %d, '%s', '%s', %d, %d)", 
-              db_next_id('{quiz_multichoice_answers}_answer_id'), $node->nid, $question_vid, $value['answer'], $value['feedback'], $value['correct'], $value['result_option']);
+              "(nid, vid, answer, feedback, is_correct, result_option) VALUES (%d, %d, '%s', '%s', %d, %d)", 
+              $node->nid, $question_vid, $value['answer'], $value['feedback'], $value['correct'], $value['result_option']);
     }
   }
 }
@@ -438,8 +428,8 @@
     else if (trim($value['answer']) != "") {
       // If there is an answer, insert a new row.
       db_query("INSERT INTO {quiz_multichoice_answers} (answer_id, nid, vid, answer, feedback, is_correct, result_option) " .
-              "VALUES(%d, %d, %d, '%s', '%s', %d, %d)", 
-              db_next_id('{quiz_multichoice_answers}_answer_id'), $node->nid, $question_vid, $value['answer'], $value['feedback'], $value['correct'], $value['result_option']);
+              "VALUES(%d, %d, '%s', '%s', %d, %d)", 
+               $node->nid, $question_vid, $value['answer'], $value['feedback'], $value['correct'], $value['result_option']);
     }
   }
 
@@ -454,7 +444,8 @@
       // This will also create new quiz-question relation entries in the quiz_node_relationship table.
       $sql = "SELECT * FROM {node} WHERE vid = %d";
       $quiz_old = db_fetch_object(db_query($sql, $quiz->parent_vid));
-      drupal_execute('node_form', array('revision' => '1'), $quiz_old);
+	  $rev = array('revision' => '1');
+      drupal_execute('node_form', $rev, $quiz_old);
   		
       // Update question vid in quiz_node_relationship table for each row that
       // contains the question vid prior to the increment (new revision).
@@ -558,7 +549,7 @@
     '#default_value' => -1,
   );
   
-  $quiz = node_load(arg(1)); 
+  $quiz = menu_get_object(); 
   if ($quiz->backwards_navigation == 1 && $node->question_number) {
     $form['back'] = array(
       '#type' => 'submit',
@@ -597,9 +588,11 @@
   // Unset $_POST, otherwise it tries to use the previous answers on the next page...
   unset($_POST['tries']);
 
+  $numanswers = db_query("SELECT count(answer_id) FROM {quiz_multichoice_answers} " .
+                      "WHERE nid = %d AND vid = %d AND is_correct = 1", $question->nid, $question->vid);
   if ($rid && !empty($tries)) {
     foreach ($tries as $answer_id) {
-      multichoice_store_answer($question->nid, $question->vid, $rid, $answer_id);
+      multichoice_store_answer($question->nid, $question->vid, $rid, $answer_id, $numanswers);
     }
   }
 
@@ -619,9 +612,9 @@
  * @param $answer_id
  *  The answer id.
  */
-function multichoice_store_answer($nid, $vid, $rid, $answer_id) {
-  $result = db_query("SELECT result_id FROM {quiz_multichoice_user_answers} WHERE question_nid = %d AND question_vid = %d AND result_id = %d", $nid, $vid, $rid);
-  if (db_num_rows($result)) {
+function multichoice_store_answer($nid, $vid, $rid, $answer_id, $numanswers) {
+  $result = db_query("SELECT COUNT('result_id') FROM {quiz_multichoice_user_answers} WHERE question_nid = %d AND question_vid = %d AND result_id = %d", $nid, $vid, $rid);
+  if ($result == $numanswers) {
     db_query("UPDATE {quiz_multichoice_user_answers} " . 
             "SET answer_id = %d " . 
             "WHERE question_nid = %d AND question_vid = %d AND result_id = %d",
@@ -650,7 +643,7 @@
   while ($answer = db_fetch_array($answers)) {
     $correct_answers[] = $answer['answer_id'];
   }
-  return ($correct_answers === $tried);
+  return (array_values($correct_answers) === array_values($tried));
 }
 
 // New singing and dancing one.
@@ -935,3 +928,34 @@
   }
   return $title . $shortstring;
 }
+/**
+ * 
+ * Hook_theme() required by 6.x
+ * 
+ * @return
+ * An array of themable functions
+ *
+ * @ingroup themeable
+ */
+function multichoice_theme() {
+  return array(
+    'multichoice_generate_title' => array(
+      'arguments' => array('node' => NULL),
+    ),
+    'multichoice_feedback' => array(
+      'arguments' => array('quiz' => NULL, 'report' => NULL),
+    ),
+    'multichoice_report' => array(
+      'arguments' => array('question' => NULL, 'showpoints' => NULL, '$showfeedback' => NULL),
+    ),
+    'multichoice_selected' => array(
+      'arguments' => array(),
+    ),
+    'multichoice_unselected' => array(
+      'arguments' => array(),
+    ),
+    'multichoice_form' => array(
+      'arguments' => array('form' => NULL),
+    ),	
+  );
+}
Index: quiz.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/quiz.install,v
retrieving revision 1.20
diff -u -r1.20 quiz.install
--- quiz.install	5 Jan 2008 23:54:31 -0000	1.20
+++ quiz.install	30 Jul 2008 02:26:20 -0000
@@ -2,222 +2,17 @@
 //$Id: quiz.install,v 1.20 2008/01/05 23:54:31 westwesterson Exp $
 
 /**
+ * @file
+ * Quiz install schema for installing the quiz module
+ *
+ */
+
+/**
  * Implementation of hook_install()
  */
 function quiz_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      /**
-       * Connect all the quiz specific properties to the correct version of a quiz.
-       */
-        // Create the quiz node properties table
-        db_query("CREATE TABLE {quiz_node_properties} (
-          property_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-          vid INTEGER UNSIGNED NOT NULL,
-          nid INTEGER UNSIGNED NOT NULL,
-          number_of_random_questions TINYINT UNSIGNED DEFAULT 0 NOT NULL,
-          pass_rate TINYINT UNSIGNED NOT NULL,
-          summary_pass LONGTEXT,
-          summary_default LONGTEXT,
-          shuffle TINYINT UNSIGNED NOT NULL,
-          backwards_navigation TINYINT UNSIGNED NOT NULL,
-          feedback_time TINYINT UNSIGNED NOT NULL,
-          quiz_open INTEGER UNSIGNED DEFAULT 0,
-          quiz_close INTEGER UNSIGNED DEFAULT 0,
-          takes TINYINT UNSIGNED NOT NULL,
-          time_limit INTEGER UNSIGNED DEFAULT 0 NOT NULL,
-          quiz_always TINYINT NOT NULL DEFAULT 0,
-          tid INTEGER UNSIGNED NOT NULL DEFAULT 0,
-          PRIMARY KEY(property_id),
-          KEY vid (vid, nid)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      /**
-       * Both a quiz and a quiz question are nodes with versions.  A quiz is a parent node of a quiz question,
-       * making the quiz question the child.
-       *
-       * The quiz_node_relationship table stores this relationship in a way that allows a quiz question to be
-       * the child of multiple quizzes without losing version history.
-       *
-       * Future functionality will allow a quiz question to be a parent of another quiz question with the same
-       * data model.  This will make adaptive quiz functionality possible without redesign.
-       */
-        // Create the quiz node relationship table
-        db_query("CREATE TABLE {quiz_node_relationship} (
-          parent_nid INTEGER UNSIGNED NOT NULL,
-          parent_vid INTEGER UNSIGNED NOT NULL,
-          child_nid INTEGER UNSIGNED NOT NULL,
-          child_vid INTEGER UNSIGNED NOT NULL,
-          question_status TINYINT UNSIGNED DEFAULT 1 NOT NULL,
-          PRIMARY KEY(parent_nid, parent_vid, child_nid, child_vid)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-    
-      /**
-       * This connects all the quiz question specific properties to the correct version of a quiz question.
-       */
-        // Create the quiz node question properties table
-        db_query("CREATE TABLE {quiz_node_question_properties} (
-          nid INTEGER UNSIGNED NOT NULL,
-          vid INTEGER UNSIGNED NOT NULL,
-          number_of_answers TINYINT UNSIGNED DEFAULT 1 NOT NULL
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-    
-      /**
-       * Quiz specific options concerning  availability and access to scores.
-       */
-        // Create the quiz node results table
-        db_query("CREATE TABLE {quiz_node_results} (
-          result_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-          nid INTEGER UNSIGNED NOT NULL,
-          vid INTEGER UNSIGNED NOT NULL,
-          uid INTEGER UNSIGNED NOT NULL,
-          time_start INTEGER UNSIGNED DEFAULT 0,
-          time_end INTEGER UNSIGNED DEFAULT 0,
-          released INTEGER UNSIGNED DEFAULT 0,
-          score TINYINT NOT NULL DEFAULT 0,
-          PRIMARY KEY(result_id)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-    
-      /**
-       * Information about a particular question in a result
-       */
-        db_query("CREATE TABLE {quiz_node_results_answers} (
-          result_id INT UNSIGNED NOT NULL ,
-          question_nid INT UNSIGNED NOT NULL ,
-          question_vid INT UNSIGNED NOT NULL ,
-          is_correct TINYINT UNSIGNED NOT NULL DEFAULT '0',
-          points_awarded TINYINT NOT NULL DEFAULT '0',
-          answer_timestamp INT UNSIGNED NOT NULL,
-          PRIMARY KEY(result_id, question_nid, question_vid)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-    
-      /**
-       * Allows custom feedback based on the results of a user completing a quiz.
-       */
-        // Create the quiz node result options table
-        db_query("CREATE TABLE {quiz_node_result_options} (
-          option_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-          nid INTEGER UNSIGNED NOT NULL,
-          vid INTEGER UNSIGNED NOT NULL,
-          option_name VARCHAR(255) NOT NULL,
-          option_summary LONGTEXT,
-          option_start INTEGER UNSIGNED DEFAULT 0,
-          option_end INTEGER UNSIGNED DEFAULT 0,
-          PRIMARY KEY(option_id)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      break;
-
-    case 'pgsql':
-      /**
-       * Connect all the quiz specific properties to the correct version of a quiz.
-       */
-        // Create the quiz node properties table
-        db_query("CREATE TABLE {quiz_node_properties} (
-          property_id SERIAL,
-          vid int_unsigned NOT NULL,
-          nid int_unsigned NOT NULL,
-          number_of_random_questions smallint_unsigned DEFAULT 0 NOT NULL,
-          pass_rate smallint_unsigned NOT NULL,
-          summary_pass TEXT,
-          summary_default TEXT,
-          shuffle smallint_unsigned NOT NULL,
-          backwards_navigation smallint_unsigned NOT NULL,
-          feedback_time smallint_unsigned NOT NULL,
-          quiz_open int_unsigned DEFAULT 0,
-          quiz_close int_unsigned DEFAULT 0,
-          takes smallint_unsigned NOT NULL,
-          time_limit int_unsigned DEFAULT 0 NOT NULL,
-          quiz_always smallint NOT NULL DEFAULT 0,
-          tid int_unsigned NOT NULL DEFAULT 0,
-          PRIMARY KEY(property_id)
-        );");
-        db_query("CREATE INDEX idx_{quiz_node_properties}_vidnid ON {quiz_node_properties}(vid, nid);");
-
-      /**
-       * Both a quiz and a quiz question are nodes with versions.  A quiz is a parent node of a quiz question,
-       * making the quiz question the child.
-       *
-       * The quiz_node_relationship table stores this relationship in a way that allows a quiz question to be
-       * the child of multiple quizzes without losing version history.
-       *
-       * Future functionality will allow a quiz question to be a parent of another quiz question with the same
-       * data model.  This will make adaptive quiz functionality possible without redesign.
-       */
-        // Create the quiz node relationship table
-        db_query("CREATE TABLE {quiz_node_relationship} (
-          parent_nid int_unsigned NOT NULL,
-          parent_vid int_unsigned NOT NULL,
-          child_nid int_unsigned NOT NULL,
-          child_vid int_unsigned NOT NULL,
-          question_status smallint_unsigned DEFAULT 1 NOT NULL,
-          PRIMARY KEY(parent_nid, parent_vid, child_nid, child_vid)
-        );");
-    
-      /**
-       * This connects all the quiz question specific properties to the correct version of a quiz question.
-       */
-        // Create the quiz node question properties table
-        db_query("CREATE TABLE {quiz_node_question_properties} (
-          nid int_unsigned NOT NULL,
-          vid int_unsigned NOT NULL,
-          number_of_answers smallint_unsigned DEFAULT 1 NOT NULL
-        );");
-    
-      /**
-       * Quiz specific options concerning  availability and access to scores.
-       */
-        // Create the quiz node results table
-        db_query("CREATE TABLE {quiz_node_results} (
-          result_id SERIAL,
-          nid int_unsigned NOT NULL,
-          vid int_unsigned NOT NULL,
-          uid int_unsigned NOT NULL,
-          time_start int_unsigned DEFAULT 0,
-          time_end int_unsigned DEFAULT 0,
-          released int_unsigned DEFAULT 0,
-          score smallint NOT NULL DEFAULT 0,
-          PRIMARY KEY(result_id)
-        );");
-    
-      /**
-       * Information about a particular question in a result
-       */
-        db_query("CREATE TABLE {quiz_node_results_answers} (
-          result_id int_unsigned NOT NULL ,
-          question_nid int_unsigned NOT NULL ,
-          question_vid int_unsigned NOT NULL ,
-          is_correct smallint_unsigned NOT NULL DEFAULT '0',
-          points_awarded smallint NOT NULL DEFAULT '0',
-          answer_timestamp int_unsigned NOT NULL,
-          PRIMARY KEY(result_id, question_nid, question_vid)
-        );");
-    
-      /**
-       * Allows custom feedback based on the results of a user completing a quiz.
-       */
-        // Create the quiz node result options table
-        db_query("CREATE TABLE {quiz_node_result_options} (
-          option_id SERIAL,
-          nid int_unsigned NOT NULL,
-          vid int_unsigned NOT NULL,
-          option_name VARCHAR(255) NOT NULL,
-          option_summary TEXT,
-          option_start int_unsigned DEFAULT 0,
-          option_end int_unsigned DEFAULT 0,
-          PRIMARY KEY(option_id)
-        );");
-
-        db_query("CREATE FUNCTION plus_bigint_smallint_unsigned(bigint,smallint_unsigned)
-          RETURNS bigint AS 'select $1 + $2::bigint'
-          LANGUAGE 'sql';");
-
-        db_query("CREATE OPERATOR + ( 
-          PROCEDURE = plus_bigint_smallint_unsigned, 
-          LEFTARG = bigint, 
-          RIGHTARG = smallint_unsigned );");
-      break;
-  }
+  // Create Tables
+  drupal_install_schema('quiz');
   // Default the "Show Author and Date" for quiz nodes to OFF.
   $temp_array = variable_get('theme_settings', $default);
   $temp_array['toggle_node_info_quiz'] = 0;
@@ -225,465 +20,128 @@
 }
 
 /**
+* Implementation of hook_schema().
+*/
+function quiz_schema() {
+  /**
+   * Connect all the quiz specific properties to the correct version of a quiz.
+   */
+    // Create the quiz node properties table
+    $schema['quiz_node_properties'] = array(
+      'fields' => array(
+        'property_id' => array('type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+        'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'number_of_random_questions' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'pass_rate' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE),
+        'summary_pass' => array('type' => 'text', 'length' => 65535),
+        'summary_default' => array('type' => 'text', 'length' => 65535),
+        'shuffle' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE),
+        'backwards_navigation' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE),
+        'feedback_time' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE),
+        'quiz_open' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'quiz_close' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'takes' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE),
+        'time_limit' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'quiz_always' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
+        'tid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+      ),
+      'primary key' => array('property_id'),
+    );
+
+  /**
+   * Both a quiz and a quiz question are nodes with versions.  A quiz is a parent node of a quiz question,
+   * making the quiz question the child.
+   *
+   * The quiz_node_relationship table stores this relationship in a way that allows a quiz question to be
+   * the child of multiple quizzes without losing version history.
+   *
+   * Future functionality will allow a quiz question to be a parent of another quiz question with the same
+   * data model.  This will make adaptive quiz functionality possible without redesign.
+   */
+    // Create the quiz node relationship table
+    $schema['quiz_node_relationship'] = array(
+      'fields' => array(
+        'parent_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'parent_vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'child_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'child_vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'question_status' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1),
+      ),
+      'primary key' => array('parent_nid', 'parent_vid', 'child_nid', 'child_vid'),
+    );
+
+  /**
+   * This connects all the quiz question specific properties to the correct version of a quiz question.
+   */
+    // Create the quiz node question properties table
+    $schema['quiz_node_question_properties'] = array(
+      'fields' => array(
+        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'number_of_answers' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 1),
+      ),
+    );
+
+  /**
+   * Quiz specific options concerning  availability and access to scores.
+   */
+    // Create the quiz node results table
+    $schema['quiz_node_results'] = array(
+      'fields' => array(
+        'result_id' => array('type' => 'serial', 'size' => 'normal', 'unsigned' => TRUE, 'not null' => TRUE),
+        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'uid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'time_start' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0),
+        'time_end' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0),
+        'released' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0),
+        'score' => array('type' => 'int', 'size' => 'tiny', 'not null' => TRUE, 'default' => 0),
+      ),
+      'primary key' => array('result_id'),
+    );
+
+  /**
+   * Information about a particular question in a result
+   */
+    $schema['quiz_node_results_answers'] = array(
+      'fields' => array(
+        'result_id' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'question_nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'question_vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'is_correct' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'points_awarded' => array('type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'not null' => TRUE, 'default' => 0),
+        'answer_timestamp' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+      ),
+      'primary key' => array('result_id', 'question_nid', 'question_vid')
+    );
+
+  /**
+   * Allows custom feedback based on the results of a user completing a quiz.
+   */
+    // Create the quiz node result options table
+    $schema['quiz_node_result_options'] = array(
+      'fields' => array(
+        'option_id' => array('type' => 'serial', 'size' => 'normal', 'unsigned' => TRUE, 'not null' => TRUE),
+        'nid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'vid' => array('type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'option_name' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+        'option_summary' => array('type' => 'text', 'length' => 65535),
+        'option_start' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0),
+        'option_end' => array('type' => 'int', 'unsigned' => TRUE, 'default' => 0),
+      ),
+      'primary key' => array('option_id')
+    );
+    return $schema;
+}
+
+/**
  * Implementation of hook_uninstall()
  */
 function quiz_uninstall() {
-  db_query('DROP TABLE {quiz_node_relationship}');
-  db_query('DROP TABLE {quiz_node_properties}');
-  db_query('DROP TABLE {quiz_node_question_properties}');
-  db_query('DROP TABLE {quiz_node_results}');
-  db_query('DROP TABLE {quiz_node_result_options}');
-  db_query('DROP TABLE {quiz_node_results_answers}');
-  
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      // delete from nodes and node_revisions
-      db_query('DELETE FROM {node}, {node_revisions} USING {node} LEFT JOIN {node_revisions} USING (nid) WHERE type IN ("quiz")');
-      break;
-    case 'pgsql':
-      // delete from nodes and node_revisions
-      db_query("DELETE FROM {node_revisions} WHERE nid IN (SELECT nid FROM {node} WHERE type IN ('quiz'))");
-      db_query("DELETE FROM {node} WHERE type IN ('quiz')");
-      db_query("DROP OPERATOR + ( bigint, smallint_unsigned );");
-      db_query("DROP FUNCTION plus_bigint_smallint_unsigned(bigint,smallint_unsigned);");
-      break;
-  }
-
+  drupal_uninstall_schema('quiz');
   variable_del('quiz_name');
   variable_del('quiz_default_close');
   variable_del('quiz_use_passfail');
   variable_del('quiz_default_pass_rate');
 }
-
-/**
- * Implementation of hook_update_N().
- *
- */
-function quiz_update_2() {
-  $ret = array();
-  //Use db_update to display which queries were run
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-  	
-      /**
-       * Stores correct answers for multichoice quiz.
-       */
-      // Creates 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 */;");
-
-      /**
-       * Stores user answers for multichoice quiz.
-       */
-      // Creates the quiz node answers multichoice table.
-      $ret[] = update_sql("CREATE TABLE {quiz_multichoice_answers} (
-        answer_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-        nid INTEGER UNSIGNED NOT NULL,
-        vid INTEGER UNSIGNED NOT NULL,
-        answer varchar(255) NOT NULL,
-        feedback LONGTEXT,
-        result_option INTEGER UNSIGNED DEFAULT 0,
-        is_correct TINYINT UNSIGNED DEFAULT 0,
-        PRIMARY KEY(answer_id)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      /**
-       * This connects all the quiz specific properties to the correct version of a quiz.
-       */
-      // Creates the quiz node properties table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_properties} (
-        property_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-        vid INTEGER UNSIGNED NOT NULL,
-        nid INTEGER UNSIGNED NOT NULL,
-        number_of_random_questions TINYINT UNSIGNED DEFAULT 0 NOT NULL,
-        pass_rate TINYINT UNSIGNED NOT NULL,
-        summary_pass LONGTEXT,
-        summary_default LONGTEXT,
-        shuffle TINYINT UNSIGNED NOT NULL,
-        backwards_navigation TINYINT UNSIGNED NOT NULL,
-        feedback_time TINYINT UNSIGNED NOT NULL,
-        quiz_open INTEGER UNSIGNED DEFAULT 0,
-        quiz_close INTEGER UNSIGNED DEFAULT 0,
-        takes TINYINT UNSIGNED NOT NULL,
-        time_limit INTEGER UNSIGNED DEFAULT 0 NOT NULL,
-        quiz_always TINYINT NOT NULL default 0,
-        tid INTEGER UNSIGNED NOT NULL DEFAULT 0,
-        PRIMARY KEY(property_id),
-        KEY vid (vid, nid)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      /**
-       * Both a quiz and a quiz question are nodes with versions.  A quiz is a parent node of a quiz question,
-       * making the quiz question the child.
-       *
-       * The quiz_node_relationship table stores this relationship in a way that allows a quiz question to be 
-       * the child of multiple quizzes without losing version history.
-       *
-       * Future functionality will allow a quiz question to be a parent of another quiz question with the same
-       * data model.  This will make adaptive quiz functionality possible without redesign.
-       */
-      // Creates the quiz node relationship table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_relationship} (
-        parent_nid INTEGER UNSIGNED NOT NULL,
-        parent_vid INTEGER UNSIGNED NOT NULL,
-        child_nid INTEGER UNSIGNED NOT NULL,
-        child_vid INTEGER UNSIGNED NOT NULL,
-        question_status TINYINT UNSIGNED DEFAULT 1 NOT NULL,
-        PRIMARY KEY(parent_nid, parent_vid, child_nid, child_vid)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      /**
-       * This connects all the quiz question specific properties to the correct version of a quiz question.
-       */
-      // Creates the quiz node question properties table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_question_properties} (
-        nid INTEGER UNSIGNED NOT NULL,
-        vid INTEGER UNSIGNED NOT NULL,
-        number_of_answers TINYINT UNSIGNED DEFAULT 1 NOT NULL
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      /**
-       * Quiz specific options concerning  availability and access to scores.
-       */
-      // Creates the quiz node results table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_results} (
-        result_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-        nid INTEGER UNSIGNED NOT NULL,
-        vid INTEGER UNSIGNED NOT NULL,
-        uid INTEGER UNSIGNED NOT NULL,
-        time_start INTEGER UNSIGNED DEFAULT 0,
-        time_end INTEGER UNSIGNED DEFAULT 0,
-        released INTEGER UNSIGNED DEFAULT 0,
-        score TINYINT NOT NULL DEFAULT 0,
-        PRIMARY KEY(result_id)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      /**
-       * Information about a particular question in a result
-       */
-      $ret[] = update_sql("CREATE TABLE {quiz_node_results_answers} (
-        result_id INT UNSIGNED NOT NULL ,
-        question_nid INT UNSIGNED NOT NULL ,
-        question_vid INT UNSIGNED NOT NULL ,
-        is_correct TINYINT UNSIGNED NOT NULL DEFAULT '0',
-        points_awarded TINYINT NOT NULL DEFAULT '0',
-        answer_timestamp INT UNSIGNED NOT NULL,
-        PRIMARY KEY(result_id, question_nid, question_vid)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-    
-      /**
-       * Allows custom feedback based on the results of a user completing a quiz.
-       */
-      // Creates the quiz node result options table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_result_options} (
-        option_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-        nid INTEGER UNSIGNED NOT NULL,
-        vid INTEGER UNSIGNED NOT NULL,
-        option_name VARCHAR(255) NOT NULL,
-        option_summary LONGTEXT,
-        option_start INTEGER UNSIGNED DEFAULT 0,
-        option_end INTEGER UNSIGNED DEFAULT 0,
-        PRIMARY KEY(option_id)
-      ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-      quiz_data_update_2();
-      break;
-      
-    case 'pgsql':
-  	
-      /**
-       * Stores correct answers for multichoice quiz.
-       */
-      // Creates the quiz node user answers multichoice table.
-      $ret[] = update_sql("CREATE TABLE {quiz_multichoice_user_answers} (
-        question_nid int_unsigned NOT NULL,
-        question_vid int_unsigned NOT NULL,
-        result_id int_unsigned NOT NULL,
-        answer_id int_unsigned NOT NULL,
-        PRIMARY KEY(result_id, question_nid, question_vid, answer_id)
-      );");
-
-      /**
-       * Stores user answers for multichoice quiz.
-       */
-      // Creates the quiz node answers multichoice table.
-      $ret[] = update_sql("CREATE TABLE {quiz_multichoice_answers} (
-        answer_id SERIAL,
-        nid int_unsigned NOT NULL,
-        vid int_unsigned NOT NULL,
-        answer varchar(255) NOT NULL,
-        feedback text,
-        result_option int_unsigned DEFAULT 0,
-        is_correct smallint_unsigned DEFAULT 0,
-        PRIMARY KEY(answer_id)
-      );");
-
-      /**
-       * This connects all the quiz specific properties to the correct version of a quiz.
-       */
-      // Creates the quiz node properties table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_properties} (
-        property_id SERIAL,
-        vid int_unsigned NOT NULL,
-        nid int_unsigned NOT NULL,
-        number_of_random_questions smallint_unsigned DEFAULT 0 NOT NULL,
-        pass_rate smallint_unsigned NOT NULL,
-        summary_pass text,
-        summary_default text,
-        shuffle smallint_unsigned NOT NULL,
-        backwards_navigation smallint_unsigned NOT NULL,
-        feedback_time smallint_unsigned NOT NULL,
-        quiz_open int_unsigned DEFAULT 0,
-        quiz_close int_unsigned DEFAULT 0,
-        takes smallint_unsigned NOT NULL,
-        time_limit int_unsigned DEFAULT 0 NOT NULL,
-        quiz_always smallint NOT NULL default 0,
-        tid int_unsigned NOT NULL DEFAULT 0,
-        PRIMARY KEY(property_id)
-      );");
-      $ret[] = update_sql("CREATE INDEX idx_{quiz_node_properties}_vidnid ON {quiz_node_properties}(vid, nid);");
-
-      /**
-       * Both a quiz and a quiz question are nodes with versions.  A quiz is a parent node of a quiz question,
-       * making the quiz question the child.
-       *
-       * The quiz_node_relationship table stores this relationship in a way that allows a quiz question to be 
-       * the child of multiple quizzes without losing version history.
-       *
-       * Future functionality will allow a quiz question to be a parent of another quiz question with the same
-       * data model.  This will make adaptive quiz functionality possible without redesign.
-       */
-      // Creates the quiz node relationship table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_relationship} (
-        parent_nid int_unsigned NOT NULL,
-        parent_vid int_unsigned NOT NULL,
-        child_nid int_unsigned NOT NULL,
-        child_vid int_unsigned NOT NULL,
-        question_status smallint_unsigned DEFAULT 1 NOT NULL,
-        PRIMARY KEY(parent_nid, parent_vid, child_nid, child_vid)
-      );");
-
-      /**
-       * This connects all the quiz question specific properties to the correct version of a quiz question.
-       */
-      // Creates the quiz node question properties table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_question_properties} (
-        nid int_unsigned NOT NULL,
-        vid int_unsigned NOT NULL,
-        number_of_answers smallint_unsigned DEFAULT 1 NOT NULL
-      );");
-
-      /**
-       * Quiz specific options concerning  availability and access to scores.
-       */
-      // Creates the quiz node results table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_results} (
-        result_id SERIAL,
-        nid int_unsigned NOT NULL,
-        vid int_unsigned NOT NULL,
-        uid int_unsigned NOT NULL,
-        time_start int_unsigned DEFAULT 0,
-        time_end int_unsigned DEFAULT 0,
-        released int_unsigned DEFAULT 0,
-        score smallint NOT NULL DEFAULT 0,
-        PRIMARY KEY(result_id)
-      );");
-
-      /**
-       * Information about a particular question in a result
-       */
-      $ret[] = update_sql("CREATE TABLE {quiz_node_results_answers} (
-        result_id int_unsigned NOT NULL ,
-        question_nid int_unsigned NOT NULL ,
-        question_vid int_unsigned NOT NULL ,
-        is_correct smallint_unsigned NOT NULL DEFAULT '0',
-        points_awarded smallint NOT NULL DEFAULT '0',
-        answer_timestamp int_unsigned NOT NULL,
-        PRIMARY KEY(result_id, question_nid, question_vid)
-      );");
-    
-      /**
-       * Allows custom feedback based on the results of a user completing a quiz.
-       */
-      // Creates the quiz node result options table.
-      $ret[] = update_sql("CREATE TABLE {quiz_node_result_options} (
-        option_id SERIAL,
-        nid int_unsigned NOT NULL,
-        vid int_unsigned NOT NULL,
-        option_name VARCHAR(255) NOT NULL,
-        option_summary text,
-        option_start int_unsigned DEFAULT 0,
-        option_end int_unsigned DEFAULT 0,
-        PRIMARY KEY(option_id)
-      );");
-      quiz_data_update_2();
-      break;
-  }
-  return $ret;
-}
-
-/**
- * Updates data from quiz 1.1.
- *
- */
-function quiz_data_update_2() {
-  $results = db_query("SELECT * FROM {quiz}");
-  while ($row = db_fetch_object($results)) {
-    $nid = $row->nid;
-    $number_of_random_questions = 0;
-    $pass_rate = $row->pass_rate;
-    $summary_pass = $row->summary_pass;
-    $summary_default = $row->summary_default;
-    $shuffle = $row->shuffle;
-    $backwards_navigation = $row->backwards_navigation;
-    $feedback_time = $row->feedback_time;
-    $quiz_open = $row->quiz_open;
-    $quiz_close = $row->quiz_close;
-    $takes = $row->takes;
-    $time_limit = $row->time_limit;
-    $quiz_alaways = $row->quiz_always;
-    $node = node_load($nid);
-    $vid = $node->vid;
-    $tid = $node->tid;
-    $sql = "INSERT INTO {quiz_node_properties} ".
-           "(vid, nid, number_of_random_questions, shuffle, quiz_open, quiz_close, takes, pass_rate, ".
-           "summary_pass, summary_default, quiz_always, feedback_time, tid) ".
-           "VALUES(%d, %d, %d, %d, %d, %d, %d, %d, '%s', '%s', %d, %d, %d)";
-    db_query($sql, $vid, $nid, $number_of_random_questions, $shuffle, $quiz_open, $quiz_close, $takes, 
-            $pass_rate, $summary_pass, $summary_default, $quiz_always, $feedback_time, $tid);
-  }
-  $results = db_query("SELECT * FROM {quiz_question_answer}");
-  while ($row = db_fetch_object($results)) {
-    $question_nid = $row->question_nid;
-    $answer = $row->answer;
-    $feedback = $row->feedback;
-    $points = $row->points;
-    $result_option = $row->result_option;
-    $node = node_load($question_nid);
-    $vid = $node->vid;
-    $is_correct = $points;
-    db_query("INSERT INTO {quiz_multichoice_answers} (nid, vid, answer, feedback, result_option, is_correct) ".
-             "VALUES(%d, %d, '%s', '%s', %d, %d)", $question_nid, $vid, $answer, $feedback, $result_option, $is_correct);
-  }
-  $results = db_query("SELECT * FROM {quiz_questions}");
-  while ($row = db_fetch_object($results)) {  
-    $parent_nid = $row->quiz_nid;
-    $child_nid = $row->question_nid;
-    $parent = node_load($parent_nid);
-    $parent_vid = $parent->vid;
-    $child = node_load($child_nid);
-    $child_vid = $child->vid;
-    $question_status = $row->question_status;
-    db_query("INSERT INTO {quiz_node_relationship} (parent_nid, parent_vid, child_nid, child_vid, question_status) ".
-             "VALUES (%d, %d, %d, %d, %d)", $parent_nid, $parent_vid, $child_nid, $child_vid, $question_status);
-  }
-  $results = db_query("SELECT nid, properties FROM {quiz_question}");
-  while ($row = db_fetch_object($results)) { 
-    $count = 0;
-    $nid = $row->nid;
-    $count = (db_result(db_query("SELECT COUNT(aid) FROM {quiz_question_answer} WHERE question_nid = %d AND points = 1 ", $nid))); 
-    db_query("INSERT INTO {quiz_node_question_properties} (nid, vid, number_of_answers) ".
-             "VALUES (%d, %d, %d)", $nid, $vid, $count);
-  }
-  $results = db_query("SELECT * FROM {quiz_result}");
-  while ($row = db_fetch_object($results)) {
-    $rid = $row->rid;
-    $quiz_nid = $row->quiz_nid;
-    $quiz = node_load($quiz_nid);
-    $quiz_vid = $quiz->vid;
-    $uid = $row->uid;
-    $time_start = $row->time_start;
-    $time_end = $row->time_end;
-    $released = $row->released;
-    $score = $row->score;
-    db_query("INSERT INTO {quiz_node_results} (nid, vid, uid, time_start, time_end, released, score) ".
-             "VALUES (%d, %d, %d, %d, %d, %d, %d)", $nid, $vid, $uid, $time_start, $time_end, $released, $score);
-    $results2 = db_query("SELECT * FROM {quiz_question_results} WHERE result_rid=%d", $rid);
-    while ($row2 = db_fetch_object($results2)) {
-      $result_rid = $row2->result_rid;
-      $question_nid = $row2->question_nid;
-      $answer = $row2->answer;
-      $temp_answers = unserialize($answer);
-      $tried = $temp_answers['tried'][0];
-      foreach ($temp_answers['answers'] as $line) {
-        $aid = $line['aid'];
-        if ($aid == $tried) {
-          $question_nid = $line['question_nid'];
-          $question = node_load($question_nid);
-          $question_vid = $question->vid;
-          $is_correct = $line['points'];
-          $points_awarded = $line['points'];
-          $answer_timestamp = time();
-          db_query("INSERT INTO {quiz_multichoice_user_answers} (question_nid, question_vid, result_id, answer_id) ".
-                   "VALUES (%d, %d, %d, %d)", $question_nid, $question_vid, $rid, $aid);
-          db_query("INSERT INTO {quiz_node_results_answers} ".
-                   "(result_id, question_nid, question_vid, is_correct, points_awarded, answer_timestamp) ".
-                   "VALUES (%d, %d, %d, %d, %d, %d)",
-                  $rid, $question_nid, $question_vid, $is_correct, $points_awarded, $answer_timestamp);
-        } /* endif */
-      } /* end foreach */
-    } /* end while */
-  } /* end while */
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-      $select_questionanswer = db_query("SELECT name,id FROM {sequences} WHERE name='%s'", '({quiz_multichoice_answers}_answer_id');
-      $results = db_fetch_object($select_questionanswer);
-      if ($results->id > 0) {
-        $old_value = db_fetch_object(db_query("SELECT name,id FROM {sequences} WHERE name='%s'", '{quiz_question_answer}_aid'));
-        $value = $results->id + $old_value->id;
-        db_query("UPDATE {sequences} SET id = %d, WHERE name = '%d'", $value, '{quiz_multichoice_answers}_answer_id');
-      }
-      else {
-        $old_value = db_fetch_object(db_query("SELECT name,id FROM {sequences} WHERE name='%s'", '{quiz_question_answer}_aid'));
-        $value = $old_value->id;
-        db_query("INSERT INTO {sequences} (name,id) VALUES('%s',%d)", '{quiz_multichoice_answers}_answer_id', $value);
-      }
-      $select_questionanswer = db_query("SELECT name,id FROM {sequences} WHERE name='%s'", '{quiz_node_results}_result_id');
-      $results = db_fetch_object($select_questionanswer);
-      if ($results->id > 0) {
-        $old_value = db_fetch_object(db_query("SELECT name,id FROM {sequences} WHERE name='%s'", '{quiz_results}_rid'));
-        $value = $results->id + $old_value->id;
-        db_query("UPDATE {sequences} SET id = %d, WHERE name = '%d'", $value, '{quiz_node_results}_result_id');
-      }
-      else {
-        $old_value = db_fetch_object(db_query("SELECT name,id FROM {sequences} WHERE name='%s'", '{quiz_results}_rid'));
-        $value = $old_value->id;
-        db_query("INSERT INTO {sequences} (name,id) VALUES('%s',%d)", '{quiz_node_results}_result_id', $value);
-      }
-      break;
-      
-    case 'pgsql':
-      // {quiz_multichoice_answers}_answer_id_seq
-      $select = db_query("SELECT max(answer_id) AS id FROM {quiz_multichoice_answers}");
-      $results = db_fetch_object($select);
-      if ($results->id > 0) {
-        db_query("SELECT setval('%s',%d)",'{quiz_multichoice_answers}_answer_id_seq', $results->id);
-      }
-      // {quiz_node_properties}_property_id_seq
-      $select = db_query("SELECT max(property_id) AS id FROM {quiz_node_properties}");
-      $results = db_fetch_object($select);
-      if ($results->id > 0) {
-        db_query("SELECT setval('%s',%d)",'{quiz_node_properties}_property_id_seq', $results->id);
-      }
-      // {quiz_node_result_options}_option_id_seq
-      $select = db_query("SELECT max(option_id) AS id FROM {quiz_node_result_options}");
-      $results = db_fetch_object($select);
-      if ($results->id > 0) {
-        db_query("SELECT setval('%s',%d)",'{quiz_node_result_options}_option_id_seq', $results->id);
-      }
-      // {quiz_node_results}_result_id_seq
-      $select = db_query("SELECT max(result_id) AS id FROM {quiz_node_results}");
-      $results = db_fetch_object($select);
-      if ($results->id > 0) {
-        db_query("SELECT setval('%s',%d)",'{quiz_node_results}_result_id_seq', $results->id);
-      }
-      break;
-  } /* end switch */      
-}
\ No newline at end of file
Index: quiz_views.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/quiz_views.info,v
retrieving revision 1.1
diff -u -r1.1 quiz_views.info
--- quiz_views.info	3 Jan 2008 11:40:45 -0000	1.1
+++ quiz_views.info	30 Jul 2008 02:26:21 -0000
@@ -2,4 +2,6 @@
 name = Quiz Views
 package = Quiz
 description = Exposes quiz to views for more advanced interface capabilites
-dependencies = quiz views
+dependencies[] = quiz
+dependencies[] = views
+core=6.x
Index: multichoice.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/multichoice.install,v
retrieving revision 1.5
diff -u -r1.5 multichoice.install
--- multichoice.install	3 Jan 2008 00:40:12 -0000	1.5
+++ multichoice.install	30 Jul 2008 02:26:19 -0000
@@ -2,93 +2,70 @@
 // $Id: multichoice.install,v 1.5 2008/01/03 00:40:12 westwesterson Exp $
 
 /**
+ * @file
+ * Multichoice Install (a quiz question type)
+ */
+
+/**
  * Implementation of hook_install()
  */
 function multichoice_install() {
-  switch ($GLOBALS['db_type']) {
-    case 'mysql':
-    case 'mysqli':
-  	  /**
-  	   * Stores correct answers for multichoice quiz.
-  	   */
-        // Create the quiz node user answers multichoice table.
-        db_query("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 */;");
-	  
-  	  /**
-  	   * Stores user answers for multichoice quiz.
-  	   */
-        // Create the quiz node answers multichoice table.
-        db_query("CREATE TABLE {quiz_multichoice_answers} (
-          answer_id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
-          nid INTEGER UNSIGNED NOT NULL,
-          vid INTEGER UNSIGNED NOT NULL,
-          answer varchar(255) NOT NULL,
-          feedback LONGTEXT,
-          result_option INTEGER UNSIGNED DEFAULT 0,
-          is_correct TINYINT UNSIGNED DEFAULT 0,
-          PRIMARY KEY(answer_id)
-        ) /*!40100 DEFAULT CHARACTER SET utf8 */;");
-
-      break;
+  drupal_install_schema('multichoice');
+}
 
-    case 'pgsql':
-  	  /**
-  	   * Stores correct answers for multichoice quiz.
-  	   */
-        // Create the quiz node user answers multichoice table.
-        db_query("CREATE TABLE {quiz_multichoice_user_answers} (
-          question_nid int_unsigned NOT NULL,
-          question_vid int_unsigned NOT NULL,
-          result_id int_unsigned NOT NULL,
-          answer_id int_unsigned NOT NULL,
-          PRIMARY KEY(result_id, question_nid, question_vid, answer_id)
-        );");
+/**
+* Implementation of hook_schema().
+*/
+function multichoice_schema() {
+  /**
+   * Stores correct answers for multichoice quiz.
+   */
+    // Create the quiz node user answers multichoice table.
+    $schema('quiz_multichoice_user_answers') = array(
+      'fields' => array(
+        'question_nid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'question_vid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'result_id' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'answer_id' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+      ),
+      'primary key' => array(
+        result_id, question_nid, question_vid, answer_id
+      ),
+    );
 	  
   	  /**
   	   * Stores user answers for multichoice quiz.
   	   */
         // Create the quiz node answers multichoice table.
-        db_query("CREATE TABLE {quiz_multichoice_answers} (
-          answer_id SERIAL,
-          nid int_unsigned NOT NULL,
-          vid int_unsigned NOT NULL,
-          answer varchar(255) NOT NULL,
-          feedback text,
-          result_option int_unsigned DEFAULT 0,
-          is_correct smallint_unsigned DEFAULT 0,
-          PRIMARY KEY(answer_id)
-        );");
-	
-      break;
-	  
-  }
+    $schema['quiz_multichoice_answers'] = array(
+      'fields' => array(
+        'answer_id' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE),
+        'nid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'vid' => array( 'type' => 'int', 'unsigned' => TRUE, 'not null' => TRUE),
+        'answer' => array( 'type' => 'varchar', 'length' => 255, 'not null' => TRUE),
+        'feedback' => array( 'type' => 'text', 'length' => 65535),
+        'result_option' => array( 'type' => 'int', 'unsigned' => TRUE, 'default' => 0),
+		'is_correct' => array( 'type' => 'int', 'size' => 'tiny', 'unsigned' => TRUE, 'default' => 0),
+      ),
+      'primary key' => array(
+        answer_id
+      ),
+    );	
+
   // Default the "Show Author and Date" for this question type to OFF.
   $temp_array = variable_get('theme_settings', $default);
   $temp_array['toggle_node_info_multichoice'] = 0;
   variable_set('theme_settings', $temp_array);
+
+  return $schema;
 }
 
 /**
  * Implementation of hook_uninstall()
  */
 function multichoice_uninstall() {
-  // Remove the two tables we created for this module.
-  if (db_table_exists('quiz_multichoice_answers')) {
-    db_query('DROP TABLE {quiz_multichoice_answers}');
-  }
-  if (db_table_exists('quiz_multichoice_user_answers')) {
-    db_query('DROP TABLE {quiz_multichoice_user_answers}');
-  }
+  drupal_uninstall_schema('multichoice');
 
-  // Erase any saved variable settings from the database.
-  db_query("DELETE FROM {variable} WHERE name LIKE '%s%%'", 'multichoice_');
-  
   // Delete from nodes and node_revisions.
   switch ($GLOBALS['db_type']) {
     case 'mysql':
