You are here

function quiz_access_my_result in Quiz 7.4

Same name and namespace in other branches
  1. 8.4 quiz.module \quiz_access_my_result()
  2. 6.4 quiz.module \quiz_access_my_result()
  3. 7.6 quiz.module \quiz_access_my_result()
  4. 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'
quiz_menu in ./quiz.module
Implements hook_menu().

File

./quiz.module, line 288
Quiz Module

Code

function quiz_access_my_result($rid) {
  if (!user_access('view own quiz results')) {
    return FALSE;
  }

  // Check if the quiz taking has been completed.
  $time_end = db_query('SELECT time_end FROM {quiz_node_results} WHERE result_id = :result_id', array(
    ':result_id' => $rid,
  ))
    ->fetchField();
  return $time_end > 0;
}