You are here

public function MultichoiceResponse::save in Quiz 7.5

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 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::save()
  4. 7.4 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 856
Multichoice classes.

Class

MultichoiceResponse
Extension of QuizQuestionResponse.

Code

public function save() {
  $this
    ->delete();
  $user_answer_id = db_insert('quiz_multichoice_user_answers')
    ->fields(array(
    'result_answer_id' => $this->result_answer_id,
    '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++) {
    if ($this->user_answer_ids[$i]) {
      $query
        ->values(array(
        $user_answer_id,
        $this->user_answer_ids[$i],
      ));
    }
  }
  $query
    ->execute();
}