/** * Verify that a given delivery execution is allowed to be executed * * @param DeliveryExecution $deliveryExecution * @param User $user * @throws \common_exception_Unauthorized */ public function verifyResumeAuthorization(DeliveryExecution $deliveryExecution, User $user) { $stateId = $deliveryExecution->getState()->getUri(); if (!in_array($stateId, $this->getResumableStates())) { \common_Logger::w('Unexpected state "' . $stateId); throw new \common_exception_Unauthorized(); } }
/** * DeliveryMonitoringData constructor. * @param DeliveryExecution $deliveryExecution */ public function __construct(DeliveryExecution $deliveryExecution) { $this->deliveryExecution = $deliveryExecution; $deliveryExecutionId = $this->deliveryExecution->getIdentifier(); $data = ServiceManager::getServiceManager()->get(DeliveryMonitoringService::CONFIG_ID)->find([[DeliveryMonitoringService::DELIVERY_EXECUTION_ID => $deliveryExecutionId]], ['asArray' => true], true); if (empty($data)) { $this->addValue('delivery_execution_id', $deliveryExecutionId); } else { $this->data = $data[0]; } }
/** * (non-PHPdoc) * @see \oat\taoDelivery\model\authorization\AuthorizationProvider::verifyResumeAuthorization() */ public function verifyResumeAuthorization(DeliveryExecution $deliveryExecution, User $user) { $eligibilityService = $this->getEligibilityService(); $testCenter = $eligibilityService->getTestCenter($deliveryExecution->getDelivery(), $user); if (!empty($testCenter)) { $eligibility = $eligibilityService->getEligibility($testCenter, $deliveryExecution->getDelivery()); $state = $deliveryExecution->getState()->getUri(); if (in_array($state, [ProctoredDeliveryExecution::STATE_FINISHED, ProctoredDeliveryExecution::STATE_TERMINATED])) { throw new UnAuthorizedException(_url('index', 'DeliveryServer', 'taoProctoring'), 'Terminated/Finished delivery cannot be resumed'); } if (!$eligibilityService->canByPassProctor($eligibility)) { // proctoring is required if ($state !== ProctoredDeliveryExecution::STATE_AUTHORIZED) { $errorPage = _url('awaitingAuthorization', 'DeliveryServer', 'taoProctoring', array('deliveryExecution' => $deliveryExecution->getIdentifier())); throw new UnAuthorizedException($errorPage, 'Proctor authorization missing'); } } } }
/** * @param DeliveryExecution $deliveryExecution * @return \oat\taoDelivery\model\DeliveryContainer * @throws common_Exception */ public function getDeliveryContainer(DeliveryExecution $deliveryExecution) { $containerClass = $this->getOption('deliveryContainer'); $container = new $containerClass($deliveryExecution); if (!$container instanceof \oat\taoDelivery\model\DeliveryContainer) { throw new common_Exception('A delivery container must be an instance of oat\\taoDelivery\\model\\DeliveryContainer'); } $container->setData('deliveryExecution', $deliveryExecution->getIdentifier()); $container->setData('deliveryServerConfig', $this->getJsConfig($deliveryExecution->getDelivery())); return $container; }
/** * Compare two deliveryExecution by their start timestamp. * CAUTION: getStartTime() is not cached at this moment, so it request the DB on each call * @param DeliveryExecution $a * @param DeliveryExecution $b * @return int */ public function cmpDeliveryExecution($a, $b) { return DateHelper::getTimeStamp($b->getStartTime()) - DateHelper::getTimeStamp($a->getStartTime()); }
/** * Get the container test compilation * @param DeliveryExecution $execution * @return string the testCompilation */ public function getTestCompilation(DeliveryExecution $deliveryExecution) { //FIXME this shouldn't be a service call anymore, a delivery property instead $delivery = $deliveryExecution->getDelivery(); $runtime = ServiceManager::getServiceManager()->get(AssignmentService::CONFIG_ID)->getRuntime($delivery); $inputParameters = \tao_models_classes_service_ServiceCallHelper::getInputValues($runtime, array()); return $inputParameters['QtiTestCompilation']; }
/** * @return string */ private function getDeliveryLog($eventId = null) { $deliveryLogService = ServiceManager::getServiceManager()->get(DeliveryLog::SERVICE_ID); return $deliveryLogService->get($this->deliveryExecution->getIdentifier(), $eventId); }
/** * Get last test takers event from delivery log * @param DeliveryExecution $deliveryExecution * @return array|null */ protected function getLastTestTakersEvent(DeliveryExecution $deliveryExecution) { $deliveryLogService = ServiceManager::getServiceManager()->get(DeliveryLog::SERVICE_ID); $testTakerIdentifier = $deliveryExecution->getUserIdentifier(); $events = array_reverse($deliveryLogService->get($deliveryExecution->getIdentifier())); $lastTestTakersEvent = null; foreach ($events as $event) { if ($event[DeliveryLog::CREATED_BY] === $testTakerIdentifier) { $lastTestTakersEvent = $event; break; } } return $lastTestTakersEvent; }
public function verifyResumeAuthorization(DeliveryExecution $deliveryExecution, User $user) { $this->validateClient($deliveryExecution->getDelivery()->getUri()); }
/** * Update the collection of deliveries * * @param DeliveryExecution $deliveryExecution * @param string $old * @param string $new */ public function updateDeliveryExecutionStatus(DeliveryExecution $deliveryExecution, $old, $new) { $userId = $deliveryExecution->getUserIdentifier(); if ($old != null) { $oldReferences = $this->getDeliveryExecutionsByStatus($userId, $old); foreach (array_keys($oldReferences) as $key) { if ($oldReferences[$key]->getIdentifier() == $deliveryExecution->getIdentifier()) { unset($oldReferences[$key]); } } $this->setDeliveryExecutions($userId, $old, $oldReferences); } $newReferences = $this->getDeliveryExecutionsByStatus($userId, $new); $newReferences[] = $deliveryExecution; $this->setDeliveryExecutions($userId, $new, $newReferences); }
/** * Return delivery execution as xml of testtaker based on delivery * * @return string */ public function getDeliveryExecutionXml(DeliveryExecutionInterface $deliveryExecution) { return $this->getQtiResultXml($deliveryExecution->getDelivery()->getUri(), $deliveryExecution->getUri()); }
protected function revoke(DeliveryExecution $deliveryExecution) { if ($deliveryExecution->getState()->getUri() != DeliveryExecutionState::STATE_PAUSED) { /** @var DeliveryExecutionStateService $deliveryExecutionStateService */ $deliveryExecutionStateService = $this->getServiceManager()->get(DeliveryExecutionStateService::SERVICE_ID); $deliveryExecutionStateService->pauseExecution($deliveryExecution, ['reasons' => ['category' => 'focus-loss'], 'comment' => __('Assessment has been paused due to attempt to switch to another window/tab.')]); } }