You are here

function quiz_end_actions in Quiz 7

Same name and namespace in other branches
  1. 8.4 quiz.module \quiz_end_actions()
  2. 5.2 quiz.module \quiz_end_actions()
  3. 6.6 quiz.module \quiz_end_actions()
  4. 6.2 quiz.module \quiz_end_actions()
  5. 6.3 quiz.module \quiz_end_actions()
  6. 6.4 quiz.module \quiz_end_actions()
  7. 6.5 quiz.module \quiz_end_actions()
  8. 7.6 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

Related topics

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

File

./quiz.module, line 2284
Quiz Module

Code

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

  // 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.
    // @todo Add ability to assign multiple actions and pass the actions_do() an
    //   array of aid's
    // @todo Create feature to only fire action if certain score is reached.
    $context = array(
      'result_id' => $rid,
      'score' => $score,
    );
    actions_do($quiz->aid, $quiz, $context, $score);
  }

  // Call hook_quiz_finished().
  module_invoke_all('quiz_finished', $quiz, $score, $rid);
  return $score;
}