コード例 #1
0
 /**
  * Generate a delivery from test uri
  * Test uri has to be set and existing
  */
 public function generate()
 {
     try {
         if (!$this->hasRequestParameter(self::REST_DELIVERY_TEST_ID)) {
             throw new \common_exception_MissingParameter(self::REST_DELIVERY_TEST_ID, $this->getRequestURI());
         }
         $test = new \core_kernel_classes_Resource($this->getRequestParameter(self::REST_DELIVERY_TEST_ID));
         if (!$test->exists()) {
             throw new \common_exception_NotFound('Unable to find a test associated to the given uri.');
         }
         $label = 'Delivery of ' . $test->getLabel();
         $deliveryClass = new \core_kernel_classes_Class(CLASS_COMPILEDDELIVERY);
         /** @var \common_report_Report $report */
         $report = SimpleDeliveryFactory::create($deliveryClass, $test, $label);
         if ($report->getType() == \common_report_Report::TYPE_ERROR) {
             \common_Logger::i('Unable to generate delivery execution ' . 'into taoDeliveryRdf::RestDelivery for test uri ' . $test->getUri());
             throw new \common_Exception('Unable to generate delivery execution.');
         }
         $delivery = $report->getData();
         $this->returnSuccess(array('delivery' => $delivery->getUri()));
     } catch (\Exception $e) {
         $this->returnFailure($e);
     }
 }
コード例 #2
0
 public function wizard()
 {
     try {
         $formContainer = new WizardForm(array('class' => $this->getCurrentClass()));
         $myForm = $formContainer->getForm();
         if ($myForm->isValid() && $myForm->isSubmited()) {
             $label = $myForm->getValue('label');
             $test = new core_kernel_classes_Resource($myForm->getValue('test'));
             $label = __("Delivery of %s", $test->getLabel());
             $deliveryClass = new \core_kernel_classes_Class($myForm->getValue('classUri'));
             $report = SimpleDeliveryFactory::create($deliveryClass, $test, $label);
             $this->returnReport($report);
         } else {
             $this->setData('myForm', $myForm->render());
             $this->setData('formTitle', __('Create a new delivery'));
             $this->setView('form.tpl', 'tao');
         }
     } catch (NoTestsException $e) {
         $this->setView('DeliveryMgmt/wizard_error.tpl');
     }
 }
コード例 #3
0
$userClass = new \core_kernel_classes_Class(CLASS_TAO_USER);
//create delivery
$tests = [];
$testClazz = new core_kernel_classes_Class(TAO_TEST_CLASS);
foreach ($testClazz->getInstances(true) as $instance) {
    $tests[$instance->getUri()] = $instance->getLabel();
}
$testUris = array_keys($tests);
if (!empty($testUris)) {
    $i = 0;
    $delivery = null;
    $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery');
    while (is_null($delivery) && $i < count($testUris)) {
        $test = new core_kernel_classes_Resource($testUris[$i]);
        $label = __("Delivery of %s", $test->getLabel());
        $report = \oat\taoDeliveryRdf\model\SimpleDeliveryFactory::create($deliveryClass, $test, $label);
        /** @var \core_kernel_classes_Resource $delivery */
        $delivery = $report->getData();
        $i++;
    }
    if (is_null($delivery)) {
        echo 'No test compilable';
        die;
    }
} else {
    echo 'No test found';
    die;
}
$i = 0;
$proctorNum = 1;
$ttNum = 1;
コード例 #4
0
 /**
  * @param \core_kernel_classes_Resource $delivery
  * @throws \common_Exception
  * @return \core_kernel_classes_Resource new delivery resource
  */
 private function compileDelivery(\core_kernel_classes_Resource $delivery)
 {
     $testProperty = new \core_kernel_classes_Property('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDeliveryOrigin');
     $classProperty = new \core_kernel_classes_Property(RDF_TYPE);
     $test = $delivery->getOnePropertyValue($testProperty);
     $destinationClass = new \core_kernel_classes_Class($delivery->getOnePropertyValue($classProperty)->getUri());
     $deliveryCreationReport = SimpleDeliveryFactory::create($destinationClass, $test, $delivery->getLabel());
     if ($deliveryCreationReport->getType() == \common_report_Report::TYPE_ERROR) {
         \common_Logger::i('Unable to recompile delivery execution' . $delivery->getUri());
         throw new \common_Exception($deliveryCreationReport->getMessage());
     }
     /** @var \core_kernel_classes_Resource $newDelivery */
     $newDelivery = $deliveryCreationReport->getData();
     foreach (self::$propertiesToCopy as $propertyToCopy) {
         $propertyToCopy = new \core_kernel_classes_Property($propertyToCopy);
         $val = $delivery->getOnePropertyValue($propertyToCopy);
         if ($val) {
             $newDelivery->setPropertyValue($propertyToCopy, $val);
         }
     }
     $this->addPrefixToLabel($delivery);
     return $newDelivery;
 }