* @package oat\taoProctoring */ class TestSessionConnectivityStatusService extends ConfigurableService implements TestSessionConnectivityStatusServiceInterface { const HAS_ONLINE_MODE = 'onlineMode'; /** * Whether test session is online * @param string $sessionId test session identifier * @return bool */ public function isOnline($sessionId) { if(!$this->hasOnlineMode()){ \common_Logger::w('Using of `oat\taoProctoring\model\implementation\TestSessionConnectivityStatusService::isOnline()` method which may give inaccurate result.'); } $deliveryExecution = ServiceProxy::singleton()->getDeliveryExecution($sessionId); return $deliveryExecution->getState()->getUri() === DeliveryExecution::STATE_ACTIVE; } /** * @param $sessionId * @return int|null */ public function getLastOnline($sessionId) { if ($this->isOnline($sessionId)) { return microtime(true); } return null; } public function hasOnlineMode() { return ($this->hasOption(self::HAS_ONLINE_MODE)) ? $this->getOption(self::HAS_ONLINE_MODE) : false; } }