You are here

function multichoice_delete in Quiz 5

Same name and namespace in other branches
  1. 5.2 multichoice.module \multichoice_delete()
  2. 6.6 question_types/multichoice/multichoice.module \multichoice_delete()
  3. 6.2 multichoice.module \multichoice_delete()
  4. 6.3 question_types/multichoice/multichoice.module \multichoice_delete()
  5. 6.5 question_types/multichoice/multichoice.module \multichoice_delete()

Implementation of hook_delete().

File

./multichoice.module, line 264
Multiple choice question type for quiz module

Code

function multichoice_delete(&$node) {

  // for all quizzes that have this quiz with status ALWAYS, reduce number of questions by 1
  db_query("UPDATE {quiz} SET number_of_questions = number_of_questions-1 WHERE nid IN (SELECT quiz_nid FROM {quiz_questions} WHERE question_status = %d AND question_nid = %d)", QUESTION_ALWAYS, $node->nid);

  // delete all answers for this question
  db_query("DELETE FROM {quiz_question_answer} WHERE question_nid = %d", $node->nid);

  // delete this question from all quizzes
  db_query("DELETE FROM {quiz_question} WHERE nid = %d", $node->nid);
  db_query("DELETE FROM {quiz_questions} WHERE question_nid = %d", $node->nid);
}