Add hook system for My Student's Quizzes tracking table - refs BT#15821

pull/3023/head
Angel Fernando Quiroz Campos 7 years ago
parent f103bf22dd
commit ae366abf4d
  1. 54
      main/inc/lib/hook/HookMyStudentsQuizTracking.php
  2. 21
      main/inc/lib/hook/interfaces/HookMyStudentsQuizTrackingEventInterface.php
  3. 38
      main/inc/lib/hook/interfaces/HookMyStudentsQuizTrackingObserverInterface.php

@ -0,0 +1,54 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Class HookMyStudentsQuizTracking.
*/
class HookMyStudentsQuizTracking extends HookEvent implements HookMyStudentsQuizTrackingEventInterface
{
/**
* HookMyStudentsQuizTracking constructor.
*
* @throws Exception
*/
protected function __construct()
{
parent::__construct('HookMyStudentsQuizTracking');
}
/**
* @return array
*/
public function notifyTrackingHeader()
{
$results = [];
/** @var HookMyStudentsQuizTrackingObserverInterface $observer */
foreach ($this->observers as $observer) {
$results[] = $observer->trackingHeader($this);
}
return $results;
}
/**
* @param int $quizId
* @param int $studentId
*
* @return array
*/
public function notifyTrackingContent($quizId, $studentId)
{
$this->eventData['quiz_id'] = $quizId;
$this->eventData['student_id'] = $studentId;
$results = [];
/** @var HookMyStudentsQuizTrackingObserverInterface $observer */
foreach ($this->observers as $observer) {
$results[] = $observer->trackingContent($this);
}
return $results;
}
}

@ -0,0 +1,21 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookMyStudentsQuizTrackingEventInterface.
*/
interface HookMyStudentsQuizTrackingEventInterface extends HookEventInterface
{
/**
* @return array
*/
public function notifyTrackingHeader();
/**
* @param int $quizId
* @param int $studentId
*
* @return array
*/
public function notifyTrackingContent($quizId, $studentId);
}

@ -0,0 +1,38 @@
<?php
/* For licensing terms, see /license.txt */
/**
* Interface HookMyStudentsQuizTrackingObserverInterface.
*/
interface HookMyStudentsQuizTrackingObserverInterface extends HookObserverInterface
{
/**
* Return an associative array this value and attributes.
* <code>
* [
* 'value' => 'Users online',
* 'attrs' => ['class' => 'text-center'],
* ]
* </code>
*
* @param HookMyStudentsQuizTrackingEventInterface $hook
*
* @return array
*/
public function trackingHeader(HookMyStudentsQuizTrackingEventInterface $hook);
/**
* Return an associative array this value and attributes.
* <code>
* [
* 'value' => '5 connected users ',
* 'attrs' => ['class' => 'text-center text-success'],
* ]
* </code>
*
* @param HookMyStudentsQuizTrackingEventInterface $hook
*
* @return array
*/
public function trackingContent(HookMyStudentsQuizTrackingEventInterface $hook);
}
Loading…
Cancel
Save