You are here

function quiz_get_score_array in Quiz 7

Same name and namespace in other branches
  1. 8.6 quiz.pages.inc \quiz_get_score_array()
  2. 8.4 quiz.pages.inc \quiz_get_score_array()
  3. 8.5 quiz.pages.inc \quiz_get_score_array()
  4. 6.4 quiz.pages.inc \quiz_get_score_array()
  5. 7.6 quiz.pages.inc \quiz_get_score_array()
  6. 7.4 quiz.pages.inc \quiz_get_score_array()
  7. 7.5 quiz.pages.inc \quiz_get_score_array()

Returns an array of score information for a quiz

Parameters

unknown_type $rid:

unknown_type $quiz_vid:

unknown_type $is_evaluated:

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

File

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

Code

function quiz_get_score_array($rid, $quiz_vid, $is_evaluated) {
  $sql = 'SELECT max_score, number_of_random_questions
          FROM {quiz_node_properties}
          WHERE vid = %d';
  $properties = db_fetch_object(db_query('SELECT max_score, number_of_random_questions
          FROM {quiz_node_properties}
          WHERE vid = :vid', array(
    ':vid' => $quiz_vid,
  )));
  $sql = 'SELECT SUM(points_awarded)
          FROM (quiz_node_results_answers)
          WHERE result_id = %d';
  $total_score = db_query('SELECT SUM(points_awarded)
          FROM (quiz_node_results_answers)
          WHERE result_id = :result_id', array(
    ':result_id' => $rid,
  ))
    ->fetchField();
  return array(
    'question_count' => $properties->number_of_random_questions + _quiz_get_num_always_questions($quiz_vid),
    'possible_score' => $properties->max_score,
    'numeric_score' => $total_score,
    'percentage_score' => $properties->max_score == 0 ? 0 : round($total_score * 100 / $properties->max_score),
    'is_evaluated' => $is_evaluated,
  );
}