You are here

function multichoice_load in Quiz 6.2

Same name and namespace in other branches
  1. 5.2 multichoice.module \multichoice_load()
  2. 5 multichoice.module \multichoice_load()
  3. 6.6 question_types/multichoice/multichoice.module \multichoice_load()
  4. 6.3 question_types/multichoice/multichoice.module \multichoice_load()
  5. 6.5 question_types/multichoice/multichoice.module \multichoice_load()

Implementation of hook_load().

File

./multichoice.module, line 513
Multiple choice question type for the Quiz module.

Code

function multichoice_load($node) {
  $additions = new stdClass();
  $question_vid = $node->vid;
  $additions->properties = db_fetch_array(db_query("SELECT * FROM {quiz_node_question_properties} WHERE nid = %d AND vid = %d", $node->nid, $question_vid));
  $answers = array();
  $result = db_query("SELECT * FROM {quiz_multichoice_answers} WHERE nid = %d AND vid = %d", $node->nid, $question_vid);
  while ($line = db_fetch_array($result)) {
    $answers[] = $line;
  }
  $additions->answers = $answers;

  // Just check for multiple answers for now.
  $additions->multiple_answers = $additions->properties['number_of_answers'] > 1 ? 1 : 0;
  return $additions;
}