function quiz_update_total_score_fast in Quiz 6.4
Same name and namespace in other branches
- 8.4 quiz.pages.inc \quiz_update_total_score_fast()
- 7.6 quiz.pages.inc \quiz_update_total_score_fast()
- 7 quiz.pages.inc \quiz_update_total_score_fast()
- 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 180 - 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';
db_query($sql, $rid, $quiz_vid, $rid);
}