You are here

public function MultichoiceResponse::delete in Quiz 7.5

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

Implementation of delete().

Overrides QuizQuestionResponse::delete

See also

QuizQuestionResponse::delete()

1 call to MultichoiceResponse::delete()
MultichoiceResponse::save in question_types/multichoice/multichoice.classes.inc
Implementation of save().

File

question_types/multichoice/multichoice.classes.inc, line 881
Multichoice classes.

Class

MultichoiceResponse
Extension of QuizQuestionResponse.

Code

public function delete() {
  $user_answer_id = array();
  $query = db_query('SELECT id FROM {quiz_multichoice_user_answers} WHERE result_answer_id = :raid', array(
    ':raid' => $this->result_answer_id,
  ));
  while ($user_answer = $query
    ->fetch()) {
    $user_answer_id[] = $user_answer->id;
  }
  if (!empty($user_answer_id)) {
    db_delete('quiz_multichoice_user_answer_multi')
      ->condition('user_answer_id', $user_answer_id, 'IN')
      ->execute();
  }
  db_delete('quiz_multichoice_user_answers')
    ->condition('result_answer_id', $this->result_answer_id)
    ->execute();
}