public function QuizQuestion::viewCanRevealCorrect in Quiz 8.4
Determines if the user can view the correct answers
Return value
boolean true iff the view may include the correct answers to the question
6 calls to QuizQuestion::viewCanRevealCorrect()
- ClozeQuestion::getNodeView in question_types/
cloze/ lib/ Drupal/ cloze/ ClozeQuestion.php - Implementation of getNodeView()
- LongAnswerQuestion::getNodeView in question_types/
long_answer/ lib/ Drupal/ long_answer/ LongAnswerQuestion.php - Implementation of getNodeView
- MatchingQuestion::getNodeView in question_types/
matching/ lib/ Drupal/ matching/ MatchingQuestion.php - Implementation of getNodeView
- MultichoiceQuestion::getNodeView in question_types/
multichoice/ lib/ Drupal/ multichoice/ MultichoiceQuestion.php - Implementation of getNodeView
- ShortAnswerQuestion::getNodeView in question_types/
short_answer/ lib/ Drupal/ short_answer/ ShortAnswerQuestion.php - Implementation of getNodeView
File
- question_types/
quiz_question/ lib/ Drupal/ quiz_question/ QuizQuestion.php, line 646 - Classes used in the Quiz Question module.
Class
- QuizQuestion
- A base implementation of a quiz_question, adding a layer of abstraction between the node API, quiz API and the question types.
Namespace
Drupal\quiz_questionCode
public function viewCanRevealCorrect() {
$user = \Drupal::currentUser();
// permission overrides the hook
if (user_access('view any quiz question correct response') || $user
->id() == $this->node
->getAuthorId()) {
return TRUE;
}
$results = module_invoke_all('answers_access', $this->node);
$may_view_answers = in_array(TRUE, $results);
return $may_view_answers;
}