You are here

function quiz_access_to_score in Quiz 7.5

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.6 quiz.module \quiz_access_to_score()
  4. 7 quiz.module \quiz_access_to_score()
  5. 7.4 quiz.module \quiz_access_to_score()

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

Parameters

QuizResult $quiz_result:

Return value

true|null Returns TRUE if the user has access, NULL otherwise.

3 calls to quiz_access_to_score()
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.
QuizResultAnswerController::buildContent in includes/QuizResultAnswerController.class.inc
Build the response content with feedback.
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 270
quiz.module Main file for the Quiz module.

Code

function quiz_access_to_score(QuizResult $quiz_result) {
  global $user;
  $quiz = node_load($quiz_result->nid);
  if (user_access('score own quiz') && $quiz->uid == $user->uid) {
    return TRUE;
  }
  if (user_access('score any quiz')) {
    return TRUE;
  }
  if (user_access('score taken quiz answer') && $quiz_result->uid == $user->uid) {
    return TRUE;
  }
}