public function MatchingQuestion::delete in Quiz 7.6
Same name and namespace in other branches
- 6.6 question_types/matching/matching.classes.inc \MatchingQuestion::delete()
- 6.3 question_types/matching/matching.classes.inc \MatchingQuestion::delete()
- 6.4 question_types/matching/matching.classes.inc \MatchingQuestion::delete()
- 6.5 question_types/matching/matching.classes.inc \MatchingQuestion::delete()
- 7 question_types/matching/matching.classes.inc \MatchingQuestion::delete()
- 7.4 question_types/matching/matching.classes.inc \MatchingQuestion::delete()
- 7.5 question_types/matching/matching.classes.inc \MatchingQuestion::delete()
Implementation of delete
Overrides QuizQuestion::delete
See also
QuizQuestion#delete($only_this_version)
File
- question_types/
matching/ matching.classes.inc, line 104 - matching.classes
Class
- MatchingQuestion
- Extension of QuizQuestion.
Code
public function delete($only_this_version = FALSE) {
parent::delete($only_this_version);
$delete_properties = db_delete('quiz_matching_properties')
->condition('nid', $this->node->nid);
if ($only_this_version) {
$delete_properties
->condition('vid', $this->node->vid);
$match_id = db_query('SELECT match_id FROM {quiz_matching_node} WHERE nid = :nid AND vid = :vid', array(
':nid' => $this->node->nid,
':vid' => $this->node->vid,
))
->fetchCol();
db_delete('quiz_matching_user_answers')
->condition('match_id', is_array($match_id) ? $match_id : array(
0,
), 'IN')
->execute();
db_delete('quiz_matching_node')
->condition('nid', $this->node->nid)
->condition('vid', $this->node->vid)
->execute();
}
else {
$match_id = db_query('SELECT match_id FROM {quiz_matching_node} WHERE nid = :nid', array(
':nid' => $this->node->nid,
))
->fetchCol();
if (!empty($match_id)) {
db_delete('quiz_matching_user_answers')
->condition('match_id', $match_id, 'IN')
->execute();
}
db_delete('quiz_matching_node')
->condition('nid', $this->node->nid)
->execute();
}
$delete_properties
->execute();
}