/** * constructor: initialize the service and the default data * * @access public * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu} * @return Delivery */ public function __construct() { parent::__construct(); // the service is initialized by default $this->service = DeliveryAssemblyService::singleton(); $this->defaultData(); }
public function __construct() { parent::__construct(); $tzName = $this->getRequestParameter('timeZone') === null ? \common_session_SessionManager::getSession()->getTimeZone() : $this->getRequestParameter('timeZone'); $this->tz = new \DateTimeZone($tzName); $this->scheduleService = DeliveryScheduleService::singleton(); $this->service = DeliveryAssemblyService::singleton(); switch ($this->getRequestMethod()) { case "GET": $this->action = 'get'; break; case "PUT": $this->action = 'update'; break; case "POST": $this->action = 'create'; break; case "DELETE": $this->action = 'deleteDelivery'; break; default: $this->sendData(array('message' => 'Not found'), 404); exit; } }
/** * Creates a new delivery * * @param core_kernel_classes_Class $deliveryClass * @param core_kernel_classes_Resource $test * @param array $properties Array of properties of delivery * @return common_report_Report */ public static function create(\core_kernel_classes_Class $deliveryClass, \core_kernel_classes_Resource $test, $properties = array()) { \common_Logger::i('Creating delivery with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel()); $storage = new TrackedStorage(); $testCompilerClass = \taoTests_models_classes_TestsService::singleton()->getCompilerClass($test); $compiler = new $testCompilerClass($test, $storage); $report = $compiler->compile(); if ($report->getType() == \common_report_Report::TYPE_SUCCESS) { //$tz = new \DateTimeZone(\common_session_SessionManager::getSession()->getTimeZone()); $tz = new \DateTimeZone('UTC'); if (!empty($properties[TAO_DELIVERY_START_PROP])) { $dt = new \DateTime($properties[TAO_DELIVERY_START_PROP], $tz); $properties[TAO_DELIVERY_START_PROP] = (string) $dt->getTimestamp(); } if (!empty($properties[TAO_DELIVERY_END_PROP])) { $dt = new \DateTime($properties[TAO_DELIVERY_END_PROP], $tz); $properties[TAO_DELIVERY_END_PROP] = (string) $dt->getTimestamp(); } $serviceCall = $report->getData(); $properties[PROPERTY_COMPILEDDELIVERY_DIRECTORY] = $storage->getSpawnedDirectoryIds(); $compilationInstance = DeliveryAssemblyService::singleton()->createAssemblyFromServiceCall($deliveryClass, $serviceCall, $properties); $report->setData($compilationInstance); } return $report; }
/** * (non-PHPdoc) * @see \oat\taoDelivery\model\AssignmentService::getRuntime() */ public function getRuntime($deliveryId) { $delivery = new \core_kernel_classes_Resource($deliveryId); if (!$delivery->exists()) { throw new \common_exception_NoContent('Unable to load runtime associated for delivery ' . $deliveryId . ' Delivery probably deleted.'); } return DeliveryAssemblyService::singleton()->getRuntime($delivery); }
/** * tests initialization */ public function setUp() { // load delivery constants, none required for deliveryTemplate common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); TaoPhpUnitTestRunner::initTest(); $this->assemblyService = DeliveryAssemblyService::singleton(); $testsService = taoTests_models_classes_TestsService::singleton(); $this->test = $testsService->createInstance($testsService->getRootclass(), 'deliveryUnitCompilerTest'); $deliveryContentSuperClass = new core_kernel_classes_Class(DeliveryContent::SUPER_CLASS); $this->contentClass = $deliveryContentSuperClass->createSubClass('abstractContentSubclass'); $this->content = $this->contentClass->createInstanceWithProperties(array(DeliveryTemplate::PROPERTY_CONTENT => $this->test->getUri(), RDFS_LABEL => 'contentInstanceUnitTest')); }
/** * * @param unknown $params */ public function __invoke($params) { if (count($params) < 1) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, __('Usage: %s ASSEMBLY_FILE [ASSEMBLY_FILE_2] [ASSEMBLY_FILE_3] ...', __CLASS__)); } \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDeliveryRdf'); $deliveryClass = DeliveryAssemblyService::singleton()->getRootClass()->createSubClass('Import ' . \tao_helpers_Date::displayeDate(time())); $importer = new Assembler(); $report = new \common_report_Report(\common_report_Report::TYPE_INFO, __('Importing %1$s files into \'%2$s\'', count($params), $deliveryClass->getLabel())); while (!empty($params)) { $file = array_shift($params); $report->add($importer->importDelivery($deliveryClass, $file)); } return $report; }
/** * Creates a new simple delivery * * @param core_kernel_classes_Class $deliveryClass * @param core_kernel_classes_Resource $test * @param string $label * @return common_report_Report */ public static function create(core_kernel_classes_Class $deliveryClass, core_kernel_classes_Resource $test, $label) { \common_Logger::i('Creating ' . $label . ' with ' . $test->getLabel() . ' under ' . $deliveryClass->getLabel()); $storage = new TrackedStorage(); $testCompilerClass = \taoTests_models_classes_TestsService::singleton()->getCompilerClass($test); $compiler = new $testCompilerClass($test, $storage); $report = $compiler->compile(); if ($report->getType() == \common_report_Report::TYPE_SUCCESS) { $serviceCall = $report->getData(); $properties = array(RDFS_LABEL => $label, PROPERTY_COMPILEDDELIVERY_DIRECTORY => $storage->getSpawnedDirectoryIds(), DeliveryAssemblyService::PROPERTY_ORIGIN => $test); $compilationInstance = DeliveryAssemblyService::singleton()->createAssemblyFromServiceCall($deliveryClass, $serviceCall, $properties); $report->setData($compilationInstance); } return $report; }
/** * Displays the form to select a delivery */ protected function selectDelivery() { $ltiSession = taoLti_models_classes_LtiService::singleton()->getLtiSession(); if ($ltiSession->getLaunchData()->hasVariable(taoLti_models_classes_LtiLaunchData::RESOURCE_LINK_TITLE)) { $this->setData('linkTitle', $ltiSession->getLaunchData()->getVariable(taoLti_models_classes_LtiLaunchData::RESOURCE_LINK_TITLE)); } $this->setData('link', $ltiSession->getLtiLinkResource()->getUri()); $this->setData('submitUrl', _url('setDelivery')); $deliveries = DeliveryAssemblyService::singleton()->getAllAssemblies(); if (count($deliveries) > 0) { $this->setData('deliveries', $deliveries); $this->setView('instructor/selectDelivery.tpl'); } else { $this->returnError(__('No deliveries available')); } }
/** * Delete items, test & delivery * * @param \core_kernel_classes_Resource $delivery * @param $testUri */ public function removeDeliveryTest(\core_kernel_classes_Resource $delivery, $testUri) { $test = new \core_kernel_classes_Resource($testUri); $items = $this->testService->getItems($test); /** @var \core_kernel_classes_Resource $item */ foreach ($items as $item) { // Delete resource & files $this->itemService->deleteResource($item); $this->assertFalse($item->exists()); } $this->testService->deleteContent($test); $this->testService->deleteResource($test); $this->assertFalse($test->exists()); $this->deliveryService->deleteInstance($delivery); $this->assertFalse($delivery->exists()); }
protected function verifyParams($params) { $this->finalReport = new \common_report_Report(\common_report_Report::TYPE_SUCCESS); $class_uri = array_shift($params); $deliveryRootClass = DeliveryAssemblyService::singleton()->getRootClass(); if (is_null($class_uri)) { $deliveryClass = $deliveryRootClass; } else { $deliveryClass = new \core_kernel_classes_Class($class_uri); if (!$deliveryClass->isSubClassOf($deliveryRootClass)) { $msg = "Usage: php index.php '" . __CLASS__ . "' [CLASS_URI]" . PHP_EOL; $msg .= "CLASS_URI : a valid delivery class uri" . PHP_EOL . PHP_EOL; $msg .= "Uri : " . $class_uri . " is not a valid delivery class" . PHP_EOL; $this->finalReport->add(\common_report_Report::createFailure($msg)); } } $this->deliveryClass = $deliveryClass; }
/** * Result Table entry page * @throws \tao_models_classes_MissingRequestParameterException */ public function index() { $deliveryService = DeliveryAssemblyService::singleton(); if ($this->getRequestParameter('classUri') !== $deliveryService->getRootClass()->getUri()) { $filter = $this->getRequestParameter('filter'); $uri = $this->getRequestParameter('uri'); if (!\common_Utils::isUri(tao_helpers_Uri::decode($uri))) { throw new \tao_models_classes_MissingRequestParameterException('uri'); } $this->setData('filter', $filter); $this->setData('uri', $uri); $this->setView('resultTable.tpl'); } else { $this->setData('type', 'info'); $this->setData('error', __('No tests have been taken yet. As soon as a test-taker will take a test his results will be displayed here.')); $this->setView('index.tpl'); } }
/** * Action called on click on a delivery (class) construct and call the view to see the table of * all delivery execution for a specific delivery */ public function index() { $model = array(array('id' => 'ttaker', 'label' => __('Test Taker'), 'sortable' => false), array('id' => 'time', 'label' => __('Start Time'), 'sortable' => false)); $deliveryService = DeliveryAssemblyService::singleton(); $delivery = new core_kernel_classes_Resource($this->getRequestParameter('id')); if ($delivery->getUri() !== $deliveryService->getRootClass()->getUri()) { try { // display delivery $implementation = $this->getResultStorage($delivery); $this->getClassService()->setImplementation($implementation); $this->setData('uri', tao_helpers_Uri::encode($delivery->getUri())); $this->setData('title', $delivery->getLabel()); $this->setData('model', $model); $this->setView('resultList.tpl'); } catch (\common_exception_Error $e) { $this->setData('type', 'error'); $this->setData('error', $e->getMessage()); $this->setView('index.tpl'); } } else { $this->setData('type', 'info'); $this->setData('error', __('No tests have been taken yet. As soon as a test-taker will take a test his results will be displayed here.')); $this->setView('index.tpl'); } }
public function getAccessibleDeliveries() { $deliveries = DeliveryAssemblyService::singleton()->getRootClass()->searchInstances(array(self::PROPERTY_PROCTOR_ACCESSIBLE => self::CHECK_MODE_ENABLED), array('recursive' => true)); return $deliveries; }
/** * Get all deliveries in time range. * @param integer $from Timestamp * @param integer $to Timestamp * @return core_kernel_classes_Resource[] - delivery resource instances */ public function getAssemblies($from, $to) { $assemblies = DeliveryAssemblyService::singleton()->getAllAssemblies(); $startProp = new \core_kernel_classes_Property(TAO_DELIVERY_START_PROP); $endProp = new \core_kernel_classes_Property(TAO_DELIVERY_END_PROP); $result = array(); $timeZone = new \DateTimeZone('UTC'); $filterStartDate = \DateTime::createFromFormat('U', $from, $timeZone); $filterEndDate = \DateTime::createFromFormat('U', $to, $timeZone); foreach ($assemblies as $delivery) { $deliveryProps = $delivery->getPropertiesValues(array($startProp, $endProp, new \core_kernel_classes_Property(DeliveryScheduleService::TAO_DELIVERY_RRULE_PROP))); if (empty($deliveryProps[TAO_DELIVERY_START_PROP]) || empty($deliveryProps[TAO_DELIVERY_END_PROP])) { continue; } $deliveryStartTs = (int) current($deliveryProps[TAO_DELIVERY_START_PROP])->literal; $deliveryEndTs = (int) current($deliveryProps[TAO_DELIVERY_END_PROP])->literal; $rrule = (string) current($deliveryProps[DeliveryScheduleService::TAO_DELIVERY_RRULE_PROP]); if (empty($rrule)) { if ($deliveryStartTs < $from && $deliveryEndTs < $from || $deliveryStartTs > $to && $deliveryEndTs > $to) { continue; } $result[] = $delivery; } else { $rule = new \Recurr\Rule($rrule); $transformer = new \Recurr\Transformer\ArrayTransformer(); $rEvents = $transformer->transform($rule)->startsBetween($filterStartDate, $filterEndDate); if (count($rEvents) !== 0) { $result[] = $delivery; } } } return $result; }
public function getAll() { $resources = array(); $deliveryService = DeliveryAssemblyService::singleton(); foreach ($deliveryService->getAllAssemblies() as $assembly) { // delivery uri $delivery = $assembly->getUri(); $resultService = $this->getServiceLocator()->get(ResultServerService::SERVICE_ID); $implementation = $resultService->getResultStorage($delivery); // get delivery executions //get all info foreach ($implementation->getResultByDelivery(array($delivery)) as $result) { $result = array_merge($result, array(RDFS_LABEL => $assembly->getLabel())); $properties = array(); foreach ($result as $key => $value) { $property = array(); $type = 'resource'; switch ($key) { case 'deliveryResultIdentifier': $property['predicateUri'] = "http://www.tao.lu/Ontologies/TAOResult.rdf#Identifier"; break; case 'testTakerIdentifier': $property['predicateUri'] = "http://www.tao.lu/Ontologies/TAOResult.rdf#resultOfSubject"; break; case 'deliveryIdentifier': $property['predicateUri'] = "http://www.tao.lu/Ontologies/TAOResult.rdf#resultOfDelivery"; break; default: $property['predicateUri'] = $key; $type = 'literal'; break; } $property['values'] = array('valueType' => $type, 'value' => $value); $properties[] = $property; } $resources[] = array('uri' => $result['deliveryResultIdentifier'], 'properties' => $properties); } } return $resources; }
/** * Test if root class is \core_kernel_classes_Class(CLASS_COMPILEDDELIVERY) */ public function testGetRootClass() { $assemblyService = DeliveryAssemblyService::singleton(); $class = new \core_kernel_classes_Class(CLASS_COMPILEDDELIVERY); $this->assertEquals($class, $assemblyService->getRootClass()); }