### Eclipse Workspace Patch 1.0
#P quiz
Index: quiz.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/quiz.module,v
retrieving revision 1.86.2.18
diff -u -r1.86.2.18 quiz.module
--- quiz.module	6 Aug 2007 23:35:32 -0000	1.86.2.18
+++ quiz.module	7 Aug 2007 00:20:01 -0000
@@ -561,7 +561,7 @@
   if (is_numeric(arg(1))) {
     $output .= '<h3>'. t('@quiz Questions', array('@quiz' => QUIZ_NAME)) .'</h3>';
     $questions = _quiz_get_questions();
-    $output .= theme('quiz_question_table', $questions);
+    $output .= theme('quiz_question_table', $questions, $node->nid);
   }
   return $output;
 }
@@ -1074,6 +1074,32 @@
     '#suffix' => '</div><br />'."\n"
   );
   
+  // Display links to create other questions
+  $form['additional_questions'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Create additional questions'),
+    '#theme' => 'additional_questions',
+  );
+  foreach (_quiz_get_question_types() as $type) {
+    $form['additional_questions'][$type] = array(
+      '#type' => 'markup',
+      '#value' => l($type, 'node/add/'. $type .'/'. $quiz->nid, array('title' => t('Go to '. $type .' administration'))) .' ',
+    );
+  }
+  
+  // Get questions assigned to this quiz
+  $questions = _quiz_get_questions();
+
+  // Display questions
+  $form['assigned_questions'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Questions assigned to this @quiz', array('@quiz' => QUIZ_NAME)),
+  );
+  $form['assigned_questions']['questions'] = array(
+    '#type' => 'markup',
+    '#value' => theme('quiz_question_table', $questions, $quiz->nid),
+  );
+
   // Retrieve question list from database
   $sql = "SELECT DISTINCT n.nid, n.type, r.body, r.format FROM {node} n, {node_revisions} r WHERE n.nid = r.nid AND n.type IN ('". implode("','", _quiz_get_question_types()) ."') ";
   $result = db_query($sql);
@@ -1098,6 +1124,8 @@
     '#type' => 'fieldset',
     '#title' => t('The following questions were found'),
     '#theme' => 'quiz_filtered_questions',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
   );
 
   $form['filtered_question_list']['question_status']['#tree'] = TRUE;
@@ -1118,31 +1146,6 @@
     );
   }
   
-  // Get questions assigned to this quiz
-  $questions = _quiz_get_questions();
-
-  // Display questions
-  $form['assigned_questions'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Questions assigned to this @quiz', array('@quiz' => QUIZ_NAME)),
-  );
-  $form['assigned_questions']['questions'] = array(
-    '#type' => 'markup',
-    '#value' => theme('quiz_question_table', $questions),
-  );
-
-  // Display links to create other questions
-  $form['additional_questions'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Create additional questions'),
-    '#theme' => 'additional_questions',
-  );
-  foreach (_quiz_get_question_types() as $type) {
-    $form['additional_questions'][$type] = array(
-      '#type' => 'markup',
-      '#value' => l($type, 'node/add/'. $type, array('title' => t('Go to '. $type .' administration'))) .' ',
-    );
-  }
   $form['submit'] = array(
     '#type' => 'submit',
     '#value' => t('Submit questions'),
@@ -1641,7 +1644,7 @@
  * @return
  *   HTML to output table
  */
-function theme_quiz_question_table($questions) {
+function theme_quiz_question_table($questions, $quiz_id = NULL) {
   $output = '';
   $rows = array();
   $status_descriptions = array(t('Random'), t('Always'), t('Never'));
@@ -1650,7 +1653,7 @@
       $status_descriptions[$question->status],
       check_markup($question->question),
       $question->type,
-      l('Edit', 'node/'. $question->nid .'/edit'));
+      l('Edit', 'node/'. $question->nid .'/edit/'. $quiz_id));
   }
   $header = array(t('Status'), t('Question'), t('Type'), t('Edit'));
 
Index: multichoice.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/quiz/multichoice.module,v
retrieving revision 1.39.2.5
diff -u -r1.39.2.5 multichoice.module
--- multichoice.module	6 Aug 2007 21:59:45 -0000	1.39.2.5
+++ multichoice.module	7 Aug 2007 00:20:01 -0000
@@ -66,6 +66,14 @@
  * Implementation of hook_form().
  */
 function multichoice_form(&$node) {
+  // quiz id here to tie creating a question to a specific quiz
+  $quiz_id = arg(3); 
+  if (!empty($quiz_id)) {
+    $form['quiz_id'] = array(
+      '#type' => 'value',
+      '#value' => $quiz_id,
+    );
+  }    
 
   // Display multichoice form
   $form['title'] = array(
@@ -144,6 +152,11 @@
     '#title' => t('I need more answers'),
   );
 
+  // if coming from quiz view, go back there on submit
+  if (!empty($quiz_id)) {
+    $form['#redirect'] = 'node/'. $quiz_id .'/questions'; 
+  }
+
   return $form;
 }
 
@@ -208,6 +221,10 @@
  */
 function multichoice_insert(&$node) {
   db_query("INSERT INTO {quiz_question} (nid, properties) VALUES(%d, '%s')", $node->nid, serialize(array('multiple_answers' => $node->multiple_answers)));
+  // we came from editing a quiz, so we should add this question to the quiz directly
+  if ($node->quiz_id > 0) { 
+    db_query('INSERT INTO {quiz_questions} (quiz_nid, question_nid, question_status) VALUES (%d, %d, %d)', $node->quiz_id, $node->nid, QUESTION_ALWAYS);
+  }
   
   while (list($key, $value) = each($node->answers)) {
     if (trim($value['answer']) != "")
