You are here

function quiz_my_results in Quiz 7

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

Show results for the current quiz

1 string reference to 'quiz_my_results'
quiz_menu in ./quiz.module
Implements hook_menu().

File

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

Code

function quiz_my_results($node) {
  global $user;
  $results = array();
  $res = db_query('
    SELECT qnp.nid, qnp.pass_rate, qnrs.result_id, qnrs.time_start, qnrs.time_end, qnrs.score
    FROM {quiz_node_properties} qnp
    INNER JOIN {quiz_node_results} qnrs ON qnrs.nid = qnp.nid
    WHERE qnrs.uid = :uid AND qnrs.nid = :nid AND qnrs.is_evaluated = 1
    ORDER BY qnrs.result_id DESC', array(
    ':uid' => $user->uid,
    ':nid' => $node->nid,
  ));

  // Create an array out of the results.
  while ($line = $res
    ->fetchAssoc()) {
    $results[$line['result_id']] = $line;
  }
  return theme('quiz_my_results_for_quiz', array(
    'rows' => $results,
  ));
}