You are here

function quiz_end_actions in Quiz 8.4

Same name and namespace in other branches
  1. 5.2 quiz.module \quiz_end_actions()
  2. 6.6 quiz.module \quiz_end_actions()
  3. 6.2 quiz.module \quiz_end_actions()
  4. 6.3 quiz.module \quiz_end_actions()
  5. 6.4 quiz.module \quiz_end_actions()
  6. 6.5 quiz.module \quiz_end_actions()
  7. 7.6 quiz.module \quiz_end_actions()
  8. 7 quiz.module \quiz_end_actions()
  9. 7.4 quiz.module \quiz_end_actions()

Actions to take at the end of a quiz

Parameters

$quiz: The quiz node

$rid: Result id

$score: Score as a number

1 call to quiz_end_actions()
quiz_take_quiz in ./quiz.module
Handles quiz taking.

File

./quiz.module, line 2878
Quiz Module

Code

function quiz_end_actions($quiz, $score, $session_data) {

  // Call hook_quiz_finished().

  //TODO: Use \Drupal::moduleHandler()->invoke($module, $hook, $args = array()). Instead module_invoke_all().
  module_invoke_all('quiz_finished', $quiz, $score, $session_data);

  // Lets piggy back here to perform the quiz defined action since were done
  // with this quiz.
  // We will verify that there is an associated action with this quiz and then
  // perform that action.
  if (!empty($quiz->aid)) {

    // Some actions are reliant on objects and I am unsure which ones, for now I
    // have simply passed the actions_do() function an empty array. By passing
    // this function a single id then it will retrieve the callback, get the
    // parameters and perform that function (action) for you.
    actions_do($quiz->aid, $quiz, $score, $session_data);
  }
  return $score;
}