Index: multichoice.install
===================================================================
RCS file: /xampp/htdocs/drupal/dev/quiz/multichoice.install,v
retrieving revision 1.1
diff -u -r1.1 multichoice.install
--- multichoice.install	24 Jul 2008 16:34:07 -0000	1.1
+++ multichoice.install	24 Jul 2008 21:05:26 -0000
@@ -20,7 +20,7 @@
    * Stores correct answers for multichoice quiz.
    */
     // Create the quiz node user answers multichoice table.
-    $schema('quiz_multichoice_user_answers') = array(
+    $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),
@@ -36,38 +36,35 @@
   	   * 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 */;");
-	
+    $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}');
-  }
-
-  // Erase any saved variable settings from the database.
-  db_query("DELETE FROM {variable} WHERE name LIKE '%s%%'", 'multichoice_');
-  
+   drupal_uninstall_schema('multichoice');
+ 
   // Delete from nodes and node_revisions.
   switch ($GLOBALS['db_type']) {
     case 'mysql':
Index: multichoice.module
===================================================================
RCS file: /xampp/htdocs/drupal/dev/quiz/multichoice.module,v
retrieving revision 1.1
diff -u -r1.1 multichoice.module
--- multichoice.module	24 Jul 2008 16:34:07 -0000	1.1
+++ multichoice.module	24 Jul 2008 21:38:44 -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',
@@ -623,8 +614,8 @@
  *  The answer id.
  */
 function multichoice_store_answer($nid, $vid, $rid, $answer_id, $numanswers) {
-  $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)==$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",
@@ -937,4 +928,35 @@
     $shortstring = substr($shortstring, 0, $breakpoint);
   }
   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),
+    ),	
+  );
 }

