You are here

function quiz_access in Quiz 7.5

Same name and namespace in other branches
  1. 5.2 quiz.module \quiz_access()
  2. 5 quiz.module \quiz_access()
  3. 6.6 quiz.module \quiz_access()
  4. 6.2 quiz.module \quiz_access()
  5. 6.3 quiz.module \quiz_access()
  6. 6.4 quiz.module \quiz_access()
  7. 6.5 quiz.module \quiz_access()

Find out if a quiz is available for taking or not.

Parameters

stdClass $quiz: The quiz node.

stdClass $account: The user to check.

Return value

array An array keyed with: 'success' and 'message'.

Related topics

3 calls to quiz_access()
quiz_take_access in ./quiz.module
Does the current user have access to take the quiz?
quiz_take_page in ./quiz.module
Page to either resume a quiz or display a start quiz form.
quiz_view in ./quiz.module
Implements hook_view().

File

./quiz.module, line 2277
quiz.module Main file for the Quiz module.

Code

function quiz_access($op = 'take', stdClass $quiz, stdClass $account = NULL) {
  if (!$account) {
    global $user;
    $account = $user;
  }
  $hooks = module_invoke_all('quiz_access', $op, $quiz, $account);
  drupal_alter('quiz_access', $hooks, $op, $quiz, $account);
  uasort($hooks, 'drupal_sort_weight');
  $success = NULL;
  foreach ($hooks as $hook) {
    if (empty($hook['success'])) {
      return $hook;
    }
    if ($hook['success'] && !$success) {
      $success = $hook;
    }
  }
  if (!empty($success)) {
    return $success;
  }

  // No blockers.
  return array(
    'success' => TRUE,
  );
}