You are here

function course_quiz_quiz_result_update in Course 8.3

Same name and namespace in other branches
  1. 8.2 modules/course_quiz/course_quiz.module \course_quiz_quiz_result_update()
  2. 3.x modules/course_quiz/course_quiz.module \course_quiz_quiz_result_update()

Implements hook_quiz_result_update().

Deprecated

But there is no alternative. Switch to entity event subscriber when it becomes available in core.

See also

https://www.drupal.org/project/drupal/issues/2551893

File

modules/course_quiz/course_quiz.module, line 15

Code

function course_quiz_quiz_result_update(QuizResult $quiz_result) {
  if ($quiz_result
    ->get('is_evaluated')
    ->getString()) {
    $quiz = $quiz_result
      ->getQuiz();
    $account = User::load($quiz_result
      ->get('uid')
      ->getString());
    if ($courseObject = course_get_course_object('quiz', $quiz
      ->id())) {

      /* @var $courseObject CourseObjectQuiz */
      $courseObject
        ->getFulfillment($account)
        ->grade($quiz_result);
    }
  }
}