You are here

public function ShortAnswerQuestion::delete in Quiz 8.4

Implementation of delete

Overrides QuizQuestion::delete

See also

QuizQuestion#delete($only_this_version)

File

question_types/short_answer/lib/Drupal/short_answer/ShortAnswerQuestion.php, line 83
The main classes for the short answer question type.

Class

ShortAnswerQuestion
Extension of QuizQuestion.

Namespace

Drupal\short_answer

Code

public function delete($only_this_version = FALSE) {
  parent::delete($only_this_version);
  $delete_ans = db_delete('quiz_short_answer_user_answers');
  $delete_ans
    ->condition('question_nid', $this->node
    ->id());
  $delete_node = db_delete('quiz_short_answer_node_properties');
  $delete_node
    ->condition('nid', $this->node
    ->id());
  if ($only_this_version) {
    $delete_ans
      ->condition('question_vid', $this->node
      ->getRevisionId());
    $delete_node
      ->condition('vid', $this->node
      ->getRevisionId());
  }
  $delete_ans
    ->execute();
  $delete_node
    ->execute();
}