You are here

function quiz_access_my_result in Quiz 7.5

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.4 quiz.module \quiz_access_my_result()

Helper function to determine if a user has access to view a specific quiz result.

Parameters

int $result_id: Result id.

Return value

bool 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 247
quiz.module Main file for the Quiz module.

Code

function quiz_access_my_result($result_id) {
  global $user;

  // Check if the quiz taking has been completed.
  if ($quiz_result = quiz_result_load($result_id)) {
    $node = node_load($quiz_result->nid, $quiz_result->vid);
    if (quiz_access_to_score($quiz_result) || $quiz_result->time_end > 0 && $quiz_result->uid == $user->uid) {
      return TRUE;
    }
  }
  return FALSE;
}