You are here

function quiz_access_to_score in Quiz 8.4

Same name and namespace in other branches
  1. 6.4 quiz.module \quiz_access_to_score()
  2. 7.6 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.

6 calls to quiz_access_to_score()
LongAnswerResponse::getReportFormAnswerFeedback in question_types/long_answer/lib/Drupal/long_answer/LongAnswerResponse.php
LongAnswerResponse::getReportFormScore in question_types/long_answer/lib/Drupal/long_answer/LongAnswerResponse.php
Implementation of getReportFormScore
ShortAnswerResponse::getReportFormAnswerFeedback in question_types/short_answer/lib/Drupal/short_answer/ShortAnswerResponse.php
ShortAnswerResponse::getReportFormScore in question_types/short_answer/lib/Drupal/short_answer/ShortAnswerResponse.php
Implementation of getReportFormScore
ShortAnswerResponse::getReportFormSubmit in question_types/short_answer/lib/Drupal/short_answer/ShortAnswerResponse.php
Implementation of getReportFormSubmit

... See full list

File

./quiz.module, line 255
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 (\Drupal::currentUser()
    ->hasPermission('score any quiz')) {
    return TRUE;
  }
  if (\Drupal::currentUser()
    ->hasPermission('score own quiz') && $user->uid == $quiz_creator) {
    return TRUE;
  }
  if (\Drupal::currentUser()
    ->hasPermission('score taken quiz answer')) {
    return TRUE;
  }
}