You are here

function _quiz_delete_results in Quiz 6.4

Same name and namespace in other branches
  1. 8.4 quiz.admin.inc \_quiz_delete_results()
  2. 7.6 quiz.admin.inc \_quiz_delete_results()
  3. 7 quiz.admin.inc \_quiz_delete_results()
  4. 7.4 quiz.admin.inc \_quiz_delete_results()

Delete a single result, or all results for a given user and a given quiz.

Parameters

$rid: result if for the result to be deleted

$nid: Node id for the quiz the result belongs to. If set all the users results for this quiz will be deleted.

1 call to _quiz_delete_results()
quiz_results_mr_form_submit in ./quiz.admin.inc
Submit function for the result browser form

File

./quiz.admin.inc, line 2400
Administrator interface for Quiz module.

Code

function _quiz_delete_results($rid, $nid = NULL) {
  $rids = array();

  // We are to delete all results for a certain user on a certain quiz.
  if (isset($nid)) {
    $sql = 'SELECT result_id
            FROM {quiz_node_results}
            WHERE nid = %d AND uid = (
              SELECT uid
              FROM {quiz_node_results}
              WHERE result_id = %d
            )';
    $res = db_query($sql, $nid, $rid);
    while ($result = db_result($res)) {
      $rids[] = $result;
    }
  }
  else {
    $rids[] = $rid;
  }
  quiz_delete_results($rids);
}