You are here

public function MultichoiceResponse::save in Quiz 7

Same name and namespace in other branches
  1. 6.4 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::save()
  2. 7.6 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::save()
  3. 7.4 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::save()
  4. 7.5 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::save()

Implementation of save

Overrides QuizQuestionResponse::save

See also

QuizQuestionResponse#save()

File

question_types/multichoice/multichoice.classes.inc, line 822
The main classes for the multichoice question type.

Class

MultichoiceResponse
Extension of QuizQuestionResponse

Code

public function save() {
  $user_answer_id = db_insert('quiz_multichoice_user_answers')
    ->fields(array(
    'result_id' => $this->rid,
    'question_vid' => $this->question->vid,
    'question_nid' => $this->question->nid,
    'choice_order' => $this->choice_order,
  ))
    ->execute();
  $query = db_insert('quiz_multichoice_user_answer_multi')
    ->fields(array(
    'user_answer_id',
    'answer_id',
  ));
  for ($i = 0; $i < count($this->user_answer_ids); $i++) {
    $query
      ->values(array(
      $user_answer_id,
      $this->user_answer_ids[$i],
    ));
  }
  $query
    ->execute();
}