function quiz_access_my_result in Quiz 8.4
Same name and namespace in other branches
- 6.4 quiz.module \quiz_access_my_result()
- 7.6 quiz.module \quiz_access_my_result()
- 7.4 quiz.module \quiz_access_my_result()
- 7.5 quiz.module \quiz_access_my_result()
Helper function to determine if a user has access to view a specific quiz result.
Parameters
int $rid: Result id
Return value
boolean True if access, false otherwise
1 string reference to 'quiz_access_my_result'
File
- ./
quiz.module, line 240 - Quiz Module
Code
function quiz_access_my_result($rid) {
$user = \Drupal::currentUser();
if (!\Drupal::currentUser()
->hasPermission('view own quiz results')) {
return FALSE;
}
$time_end = db_query('SELECT time_end FROM {quiz_node_results} WHERE result_id = :result_id AND uid = :uid', array(
':result_id' => $rid,
':uid' => $user
->id(),
))
->fetchField();
return $time_end > 0;
}