You are here

function hook_quiz_access in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 quiz.api.php \hook_quiz_access()
  2. 7.5 quiz.api.php \hook_quiz_access()
  3. 6.x quiz.api.php \hook_quiz_access()

Implements hook_quiz_access().

Control access to Quizzes.

Modules may implement Quiz access control hooks to block access to a Quiz or display a non-blocking message. Blockers are keyed by a blocker name, and must be an array keyed by 'success' and 'message'.

See also

quiz_quiz_access() for default access implementations.

1 function implements hook_quiz_access()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

quiz_quiz_access in ./quiz.module
Implements hook_quiz_access().

File

./quiz.api.php, line 166
quiz.api.php Hooks provided by Quiz module.

Code

function hook_quiz_access($op, $quiz, $account) {
  if ($op == 'take') {
    $today = date('l');
    if ($today == 'Monday') {
      return array(
        'monday' => array(
          'success' => FALSE,
          'message' => t('You cannot take quizzes on Monday.'),
        ),
      );
    }
    else {
      return array(
        'not_monday' => array(
          'success' => TRUE,
          'message' => t('It is not Monday so you may take quizzes.'),
        ),
      );
    }
  }
}