You are here

public function MultichoiceQuestion::delete in Quiz 6.4

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

Implementation of delete

Overrides QuizQuestion::delete

See also

QuizQuestion#delete()

File

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

Class

MultichoiceQuestion
Extension of QuizQuestion.

Code

public function delete($only_this_version = FALSE) {
  $delete_properties = 'DELETE FROM {quiz_multichoice_properties} WHERE nid = %d';
  $delete_answers = 'DELETE FROM {quiz_multichoice_answers} WHERE question_nid = %d';
  $delete_multi_results = '
      DELETE FROM {quiz_multichoice_user_answer_multi}
      USING {quiz_multichoice_user_answer_multi}
      INNER JOIN {quiz_multichoice_user_answers}
      ON {quiz_multichoice_user_answer_multi}.user_answer_id = {quiz_multichoice_user_answers}.id
      WHERE {quiz_multichoice_user_answers}.question_nid = %d' . ($only_this_version ? ' AND question_vid = %d' : '');
  $delete_results = 'DELETE FROM {quiz_multichoice_user_answers} WHERE question_nid = %d';
  if ($only_this_version) {
    $delete_properties .= ' AND vid = %d';
    $delete_answers .= ' AND question_vid = %d';
    $delete_results .= ' AND question_vid = %d';
  }
  db_query($delete_properties, $this->node->nid, $this->node->vid);
  db_query($delete_answers, $this->node->nid, $this->node->vid);
  db_query($delete_multi_results, $this->node->nid, $this->node->vid);
  db_query($delete_results, $this->node->nid, $this->node->vid);
  parent::delete($only_this_version);
}