function og_quiz_access_results in OG Quiz 7
Custom access callback for accessing quiz results.
Parameters
stdClass $node:
int $rid:
Return value
bool
1 string reference to 'og_quiz_access_results'
- og_quiz_menu_alter in ./
og_quiz.module - Implements hook_menu_alter().
File
- ./
og_quiz.module, line 228 - Module hooks and custom logic.
Code
function og_quiz_access_results($node, $rid = NULL) {
if ($node->type != 'quiz') {
if ($node->type == 'poll' && module_exists("poll")) {
return _poll_menu_access($node, 'access content', TRUE);
}
return FALSE;
}
if (!($access = og_quiz_ogs_access($node, 'view any quiz results'))) {
global $user;
if ($access = og_quiz_ogs_access($node, 'view results for own quiz')) {
$access = $access && $node->uid == $user->uid;
}
if (!$access) {
if ($access = og_quiz_ogs_access($node, 'score taken quiz answer')) {
if (isset($rid)) {
$res = db_query('SELECT qnr.nid, qnr.uid FROM {quiz_node_results} qnr WHERE result_id = :result_id', array(
':result_id' => $rid,
))
->fetch();
if ($res && $res->nid != $node->nid) {
return FALSE;
}
}
$access = $access && isset($rid) && $res && $res->uid == $user->uid;
}
}
}
return isset($access) ? $access : quiz_access_results($node, $rid);
}