You are here

function quiz_update_total_score_fast in Quiz 7

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

Updates the total score using only one mySql query.

Parameters

$rid: Result id

$quiz_vid: Quiz node version id

1 call to quiz_update_total_score_fast()
quiz_report_form_submit in ./quiz.pages.inc
Submit the report form

File

./quiz.pages.inc, line 200
User pages.

Code

function quiz_update_total_score_fast($rid, $quiz_vid) {
  $sql = 'UPDATE {quiz_node_results} r
          SET r.score = ROUND(
            100 * (
              SELECT SUM(a.points_awarded)
              FROM {quiz_node_results_answers} a
              WHERE a.result_id = %d
            ) / (
              SELECT max_score
              FROM {quiz_node_properties} qnp
              WHERE vid = %d
            )
          )
          WHERE r.result_id = %d';

  // TODO Please convert this statement to the D7 database API syntax.

  /* db_query($sql, $rid, $quiz_vid, $rid) */
  NULL;
}