You are here

function quiz_delete_results in Quiz 7

Same name and namespace in other branches
  1. 8.4 quiz.module \quiz_delete_results()
  2. 6.4 quiz.module \quiz_delete_results()
  3. 7.6 quiz.module \quiz_delete_results()
  4. 7.4 quiz.module \quiz_delete_results()

Delete quiz results.

Parameters

$rids: Result ids for the results to be deleted.

5 calls to quiz_delete_results()
quiz_delete in ./quiz.module
Implements hook_delete().
_quiz_delete_old_in_progress in ./quiz.module
Delete quiz responses for quizzes that haven't been finished.
_quiz_delete_results in ./quiz.admin.inc
Delete a single result, or all results for a given user and a given quiz.
_quiz_delete_users_results in ./quiz.module
Deletes all results associated with a given user.
_quiz_maintain_results in ./quiz.module
Deletes results for a quiz according to the keep results setting

File

./quiz.module, line 3961
Quiz Module

Code

function quiz_delete_results($rids) {
  if (empty($rids)) {
    return;
  }
  $sql = 'SELECT result_id, question_nid, question_vid FROM {quiz_node_results_answers}
          WHERE result_id IN(:result_id)';
  $result = db_query($sql, array(
    ':result_id' => $rids,
  ));
  foreach ($result as $record) {
    quiz_question_delete_result($record->result_id, $record->question_nid, $record->question_vid);
  }
  db_delete('quiz_node_results_answers')
    ->condition('result_id', $rids, 'IN')
    ->execute();
  db_delete('quiz_node_results')
    ->condition('result_id', $rids, 'IN')
    ->execute();
}