You are here

function quiz_get_user_results in Quiz 7

Same name and namespace in other branches
  1. 8.4 quiz.pages.inc \quiz_get_user_results()
  2. 5.2 quiz.module \quiz_get_user_results()
  3. 5 quiz.module \quiz_get_user_results()
  4. 6.6 quiz.pages.inc \quiz_get_user_results()
  5. 6.2 quiz.pages.inc \quiz_get_user_results()
  6. 6.3 quiz.pages.inc \quiz_get_user_results()
  7. 6.4 quiz.pages.inc \quiz_get_user_results()
  8. 6.5 quiz.pages.inc \quiz_get_user_results()
  9. 7.4 quiz.pages.inc \quiz_get_user_results()

Displays all the quizzes the user has taken part in.

Parameters

$user_id: User id

Return value

HTML output for page.

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

File

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

Code

function quiz_get_user_results($uid) {
  $results = array();
  $dbresult = db_query('SELECT DISTINCT(n.nid), n.title, qnp.pass_rate, qnrs.result_id, qnrs.time_start, qnrs.time_end, qnrs.score, qnrs.is_evaluated
    FROM {node} n
    INNER JOIN {quiz_node_properties} qnp ON n.nid = qnp.nid
    INNER JOIN {quiz_node_results} qnrs ON qnrs.nid = qnp.nid
    INNER JOIN {users} u ON u.uid = qnrs.uid
    WHERE n.type = :type
      AND u.uid = :uid
    ORDER BY qnrs.result_id ASC', array(
    ':type' => 'quiz',
    ':uid' => $uid,
  ));

  // Create an array out of the results.
  foreach ($dbresult as $result) {
    $result = (array) $result;
    $results[$result['result_id']] = $result;
  }
  return theme('quiz_get_user_results', array(
    'results' => $results,
  ));
}