function _quiz_get_results in Quiz 6.4
Same name and namespace in other branches
- 5.2 quiz.module \_quiz_get_results()
- 5 quiz.module \_quiz_get_results()
- 6.6 quiz.module \_quiz_get_results()
- 6.2 quiz.module \_quiz_get_results()
- 6.3 quiz.module \_quiz_get_results()
- 6.5 quiz.module \_quiz_get_results()
- 7 quiz.module \_quiz_get_results()
Get all results, or results for a given user and/or quiz.
Parameters
$nid: Node ID for the quiz.
$uid: Optional user ID to constrain results to just that user.
Return value
A list of results.
File
- ./
quiz.module, line 3419 - Quiz Module
Code
function _quiz_get_results($nid = '', $uid = 0) {
$results = array();
$args = array();
$sql = "SELECT n.nid, n.title, u.name, u.uid, qnrs.result_id, qnrs.score, qnrs.time_start, qnrs.time_end, qnp.pass_rate\n FROM {node} n\n INNER JOIN {quiz_node_results} qnrs ON qnrs.nid = n.nid\n INNER JOIN {users} u ON u.uid = qnrs.uid\n INNER JOIN {quiz_node_properties} qnp ON qnrs.vid = qnp.vid\n WHERE n.type = 'quiz'";
if ($nid) {
$sql .= " AND qnrs.nid = %d";
$args[] = $nid;
}
if ($uid != 0) {
$sql .= " AND qnrs.uid = %d";
$args[] = $uid;
}
$sql .= " ORDER BY qnrs.result_id DESC";
$dbresult = db_query(db_rewrite_sql($sql), $args);
while ($line = db_fetch_array($dbresult)) {
$results[$line['result_id']] = $line;
}
return $results;
}