You are here

function quiz_delete_results in Quiz 6.4

Same name and namespace in other branches
  1. 8.4 quiz.module \quiz_delete_results()
  2. 7.6 quiz.module \quiz_delete_results()
  3. 7 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
Implementation of 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 3876
Quiz Module

Code

function quiz_delete_results($rids) {

  // Security. We avoid db_placeholders to slightly improve performance.
  foreach ($rids as $key => $value) {
    $rids[$key] = intval($value);
  }
  if (empty($rids)) {
    return;
  }
  $rids_string = implode(', ', $rids);
  $sql = 'SELECT result_id, question_nid, question_vid
          FROM {quiz_node_results_answers}
          WHERE result_id IN(' . $rids_string . ')';
  $res = db_query($sql);
  while ($res_o = db_fetch_object($res)) {
    quiz_question_delete_result($res_o->result_id, $res_o->question_nid, $res_o->question_vid);
  }
  db_query('DELETE FROM {quiz_node_results_answers} WHERE result_id IN (' . $rids_string . ')');
  db_query('DELETE FROM {quiz_node_results} WHERE result_id IN (' . $rids_string . ')');
}