public function QuizQuestionResponse::quizContextAccessToScore in OG Quiz 7
Helper function to determine if a user has access to score a quiz.
Parameters
$quiz_creator: uid of the quiz creator.
Return value
bool
2 calls to QuizQuestionResponse::quizContextAccessToScore()
- LongAnswerResponse::getReportFormAnswerFeedback in includes/
og_long_answer.php - LongAnswerResponse::getReportFormScore in includes/
og_long_answer.php - Implementation of getReportFormScore
File
- includes/
og_quiz_question.php, line 817 - Classes used in the Quiz Question module.
Class
- QuizQuestionResponse
- Each question type must store its own response data and be able to calculate a score for that data.
Code
public function quizContextAccessToScore($quiz_creator = NULL) {
// Must we check this node, or the parent quiz ?
if (!isset($this->checkWhat)) {
if (isset($this->question->nid) && og_is_group_content_type('node', $this->question->type)) {
$groups = og_get_entity_groups('node', $this->node);
if (!empty($groups)) {
$this->checkWhat = 'self';
}
}
// If empty, check the parent quiz.
if (!isset($this->checkWhat)) {
// Try fetching the parent quiz, if any.
$quiz = $this
->getParentQuiz();
if (isset($quiz)) {
$this->checkWhat = 'parent';
}
else {
// Use default permissions.
$this->checkWhat = 'none';
}
}
}
if ($this->checkWhat != 'none') {
if ($this->checkWhat == 'parent') {
$node = $this
->getParentQuiz();
}
else {
$node = clone $this->question;
}
if ($quiz_creator == NULL && ($quiz = quiz_get_quiz_from_menu())) {
$quiz_creator = $quiz->uid;
}
if (!($access = og_quiz_ogs_access($node, array(
'score taken quiz answer',
'score taken quiz answer',
)))) {
$access = og_quiz_ogs_access($node, 'score own quiz');
if ($access) {
global $user;
$access = $access && $user->uid == $quiz_creator;
}
}
}
return isset($access) ? $access : quiz_access_to_score($quiz_creator);
}