/** * Alter an H5Ps parameters * * May be used to alter the content itself or the behaviour of the H5P * * @param type $filtered * json object */ function hook_h5p_filtered_params_alter(&$filtered) { // Example code from the Quiz module // Disables the retry and solutions options at the end of H5P questions if (_quiz_is_taking_context()) { if (isset($filtered->behaviour)) { $quiz = quiz_get_quiz_from_menu(); if (isset($filtered->behaviour->enableRetry)) { $filtered->behaviour->enableRetry = FALSE; } if (isset($filtered->behaviour->enableSolutionsButton)) { $filtered->behaviour->enableSolutionsButton = $quiz->display_feedback && $quiz->feedback_time == QUIZ_FEEDBACK_QUESTION; } } } }
/** * Helper function to determine if a user has access to score a quiz. * * @param $quiz_creator * uid of the quiz creator. * * @return bool */ 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); }