You are here

public function ChoiceResponse::save in Quiz 6.6

Implementation of save

File

question_types/choice/choice.classes.inc, line 603
The main classes for the choice question type.

Class

ChoiceResponse
The short answer question response class.

Code

public function save() {
  $sql = "INSERT INTO {quiz_choice_user_answers}\n            (result_id, vid, nid, choice_order)\n            VALUES (%d, %d, %d, '%s')";
  db_query($sql, $this->rid, $this->question->vid, $this->question->nid, $this->choice_order);
  $user_answer_id = db_last_insert_id('{quiz_choice_user_answers}', 'id');
  for ($i = 0; $i < count($this->user_answer_ids); $i++) {
    $sql = 'INSERT INTO {quiz_choice_user_answer_multi}
              (user_answer_id, answer_id)
              VALUES(%d, %d)';
    db_query($sql, $user_answer_id, $this->user_answer_ids[$i]);
  }
}