Add hook at the end of the quiz - refs BT#16791

pull/3274/head
Angel Fernando Quiroz Campos 5 years ago
parent 39267e5716
commit bb099be88f
  1. 4
      main/exercise/exercise_result.php
  2. 29
      main/inc/lib/hook/HookQuizEnd.php
  3. 13
      main/inc/lib/hook/interfaces/HookQuizEndEventInterface.php
  4. 15
      main/inc/lib/hook/interfaces/HookQuizEndObserverInterface.php

@ -199,6 +199,10 @@ if (!empty($learnpath_id) && $saveResults) {
Exercise::saveExerciseInLp($learnpath_item_id, $exe_id);
}
$hookQuizEnd = HookQuizEnd::create();
$hookQuizEnd->setEventData(['exe_id' => $exe_id]);
$hookQuizEnd->notifyQuizEnd();
// Unset session for clock time
ExerciseLib::exercise_time_control_delete(
$objExercise->id,

@ -0,0 +1,29 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookQuizEnd.
*/
class HookQuizEnd extends HookEvent implements HookQuizEndEventInterface
{
/**
* HookQuizEnd constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookQuizEnd');
}
/**
* @inheritDoc
*/
public function notifyQuizEnd()
{
/** @var HookQuizEndObserverInterface $observer */
foreach ($this->observers as $observer) {
$observer->hookQuizEnd($this);
}
}
}

@ -0,0 +1,13 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookQuizEndEventInterface.
*/
interface HookQuizEndEventInterface extends HookEventInterface
{
/**
* @return void
*/
public function notifyQuizEnd();
}

@ -0,0 +1,15 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookQuizEndObserverInterface.
*/
interface HookQuizEndObserverInterface
{
/**
* @param HookQuizEndEventInterface $hookvent
*
* @return mixed
*/
public function hookQuizEnd(HookQuizEndEventInterface $hookvent);
}
Loading…
Cancel
Save