public function MultichoiceResponse::delete in Quiz 7.6
Same name and namespace in other branches
- 6.4 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::delete()
- 7 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::delete()
- 7.4 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::delete()
- 7.5 question_types/multichoice/multichoice.classes.inc \MultichoiceResponse::delete()
Implementation of delete
Overrides QuizQuestionResponse::delete
See also
QuizQuestionResponse#delete()
File
- question_types/
multichoice/ multichoice.classes.inc, line 879 - The main classes for the multichoice question type.
Class
- MultichoiceResponse
- Extension of QuizQuestionResponse
Code
public function delete() {
$user_answer_id = array();
$query = db_query('SELECT id FROM {quiz_multichoice_user_answers} WHERE question_nid = :nid AND question_vid = :vid AND result_id = :result_id', array(
':nid' => $this->question->nid,
':vid' => $this->question->vid,
':result_id' => $this->result_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_id', $this->result_id)
->condition('question_nid', $this->question->nid)
->condition('question_vid', $this->question->vid)
->execute();
}