You are here

function _quiz_get_results in Quiz 5

Same name and namespace in other branches
  1. 5.2 quiz.module \_quiz_get_results()
  2. 6.6 quiz.module \_quiz_get_results()
  3. 6.2 quiz.module \_quiz_get_results()
  4. 6.3 quiz.module \_quiz_get_results()
  5. 6.4 quiz.module \_quiz_get_results()
  6. 6.5 quiz.module \_quiz_get_results()
  7. 7 quiz.module \_quiz_get_results()
2 calls to _quiz_get_results()
quiz_admin in ./quiz.module
Quiz Admin
quiz_start_actions in ./quiz.module
Actions to take place at the start of a quiz

File

./quiz.module, line 1354
Quiz Module

Code

function _quiz_get_results($nid = '', $uid = 0) {
  $results = array();
  $args = array();
  $sql = "SELECT n.nid nid,\n                 n.title title,\n                 u.name name,\n                 qr.rid rid,\n                 qr.time_start,\n                 qr.time_end\n          FROM {node} n, {quiz} q, {quiz_result} qr, {users} u\n          WHERE\n            n.type = 'quiz'\n              AND\n            n.nid = q.nid\n              AND\n            qr.quiz_nid = q.nid\n              AND\n            u.uid = qr.uid";
  if ($nid) {
    $sql .= " AND qr.quiz_nid = %d";
    $args[] = $nid;
  }
  if ($uid != 0) {
    $sql .= " AND qr.uid = %d";
    $args[] = $uid;
  }
  $sql .= " ORDER BY qr.rid ASC";
  $dbresult = db_query($sql, $args);

  //Create results array
  while ($line = db_fetch_array($dbresult)) {
    $results[$line['rid']] = $line;
  }
  return $results;
}