/** * @param TestSessionMemento $sessionMemento */ protected function triggerStateChanged(TestSessionMemento $sessionMemento) { $event = new QtiTestStateChangeEvent($this, $sessionMemento); if ($event instanceof ServiceLocatorAwareInterface) { $event->setServiceLocator($this->getServiceLocator()); } $this->getEventManager()->trigger($event); }
/** * Catch changing of session state * @param QtiTestStateChangeEvent $event */ public static function testStateChanged(QtiTestStateChangeEvent $event) { $session = $event->getSession(); $state = $session->getState(); $deliveryMonitoringService = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID); $deliveryExecution = self::getDeliveryExecutionById($session->getSessionId()); $data = $deliveryMonitoringService->getData($deliveryExecution, false); $data->setTestSession($session); $data->updateData([DeliveryMonitoringService::STATUS, DeliveryMonitoringService::CONNECTIVITY, DeliveryMonitoringService::CURRENT_ASSESSMENT_ITEM, DeliveryMonitoringService::END_TIME]); $deliveryMonitoringService->save($data); if ($event->getPreviousState() !== AssessmentTestSessionState::INITIAL && $state === AssessmentTestSessionState::SUSPENDED) { self::setHasBeenPaused($session->getSessionId(), true); } }