You are here

function quiz_access_to_score in Quiz 7.6

Same name and namespace in other branches
  1. 8.4 quiz.module \quiz_access_to_score()
  2. 6.4 quiz.module \quiz_access_to_score()
  3. 7 quiz.module \quiz_access_to_score()
  4. 7.4 quiz.module \quiz_access_to_score()
  5. 7.5 quiz.module \quiz_access_to_score()

Helper function to determine if a user has access to score a quiz.

Parameters

$quiz_creator: uid of the quiz creator.

3 calls to quiz_access_to_score()
QuizQuestionResponse::getFeedback in question_types/quiz_question/quiz_question.core.inc
Returns a renderable array of question feedback.
QuizQuestionResponse::getReportForm in question_types/quiz_question/quiz_question.core.inc
Creates the report form for the admin pages, and for when a user gets feedback after answering questions.
quiz_access_my_result in ./quiz.module
Helper function to determine if a user has access to view a specific quiz result.

File

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

Code

function quiz_access_to_score($quiz_creator = NULL) {
  global $user;
  if ($quiz_creator == NULL && ($quiz = quiz_get_quiz_from_menu())) {
    $quiz_creator = $quiz->uid;
  }
  if (user_access('score any quiz')) {
    return TRUE;
  }
  if (user_access('score own quiz') && $user->uid == $quiz_creator) {
    return TRUE;
  }
  if (user_access('score taken quiz answer')) {
    return TRUE;
  }
}