public function getProctorableDeliveries(User $proctor)
 {
     $service = \taoDelivery_models_classes_DeliveryAssemblyService::singleton();
     $allDeliveries = array();
     foreach ($service->getRootClass()->getInstances(true) as $deliveryResource) {
         $allDeliveries[] = new \taoDelivery_models_classes_DeliveryRdf($deliveryResource);
     }
     return $allDeliveries;
 }
 /**
  * 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 taoDelivery_models_classes_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());
         $compilationInstance = taoDelivery_models_classes_DeliveryAssemblyService::singleton()->createAssemblyFromServiceCall($deliveryClass, $serviceCall, $properties);
         $report->setData($compilationInstance);
     }
     return $report;
 }
 /**
  * Result Table entry page
  */
 public function index()
 {
     $deliveryService = \taoDelivery_models_classes_DeliveryAssemblyService::singleton();
     if ($this->getRequestParameter('classUri') !== $deliveryService->getRootClass()->getUri()) {
         $filter = $this->getRequestParameter('filter');
         $classUri = $this->getRequestParameter('classUri');
         $this->setData('filter', $filter);
         $this->setData('classUri', $classUri);
         $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');
     }
 }
 /**
  * Edit a delivery instance
  *
  * @access public
  * @author CRP Henri Tudor - TAO Team - {@link http://www.tao.lu}
  * @return void
  */
 public function editDelivery()
 {
     $clazz = $this->getCurrentClass();
     $delivery = $this->getCurrentInstance();
     $formContainer = new taoDelivery_actions_form_Delivery($clazz, $delivery);
     $myForm = $formContainer->getForm();
     $myForm->evaluate();
     if ($myForm->isSubmited()) {
         if ($myForm->isValid()) {
             $propertyValues = $myForm->getValues();
             // then save the property values as usual
             $binder = new tao_models_classes_dataBinding_GenerisFormDataBinder($delivery);
             $delivery = $binder->bind($propertyValues);
             $this->setData("selectNode", tao_helpers_Uri::encode($delivery->getUri()));
             $this->setData('message', __('Delivery saved'));
             $this->setData('reload', true);
         }
     }
     $this->setData('label', $delivery->getLabel());
     // history
     $this->setData('date', taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getCompilationDate($delivery));
     if (taoDelivery_models_classes_execution_ServiceProxy::singleton()->implementsMonitoring()) {
         $execs = taoDelivery_models_classes_execution_ServiceProxy::singleton()->getExecutionsByDelivery($delivery);
         $this->setData('exec', count($execs));
     }
     // define the groups related to the current delivery
     $property = new core_kernel_classes_Property(PROPERTY_GROUP_DELVIERY);
     $tree = tao_helpers_form_GenerisTreeForm::buildReverseTree($delivery, $property);
     $tree->setTitle(__('Assigned to'));
     $tree->setTemplate(Template::getTemplate('widgets/assignGroup.tpl'));
     $this->setData('groupTree', $tree->render());
     // testtaker brick
     $this->setData('assemblyUri', $delivery->getUri());
     // define the subjects excluded from the current delivery
     $property = new core_kernel_classes_Property(TAO_DELIVERY_EXCLUDEDSUBJECTS_PROP);
     $excluded = $delivery->getPropertyValues($property);
     $this->setData('ttexcluded', count($excluded));
     $users = taoDelivery_models_classes_AssignmentService::singleton()->getAssignedUsers($delivery);
     $assigned = array_diff(array_unique($users), $excluded);
     $this->setData('ttassigned', count($assigned));
     $this->setData('formTitle', __('Properties'));
     $this->setData('myForm', $myForm->render());
     if (common_ext_ExtensionsManager::singleton()->isEnabled('taoCampaign')) {
         $this->setData('campaign', taoCampaign_helpers_Campaign::renderCampaignTree($delivery));
     }
     $this->setView('Delivery/editDelivery.tpl');
 }
 public function getAll()
 {
     $resources = array();
     $deliveryService = \taoDelivery_models_classes_DeliveryAssemblyService::singleton();
     foreach ($deliveryService->getAllAssemblies() as $assembly) {
         // delivery uri
         $delivery = $assembly->getUri();
         $implementation = $this->getImplementationClass($assembly);
         // 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;
 }
 /**
  * Action to finish test attempts where the maximum time limit has been reached.
  * To end user will be sent array that contains id's of finished session.
  */
 public function endExpiredTests()
 {
     $started = \taoDelivery_models_classes_DeliveryServerService::singleton()->getResumableDeliveries();
     $resultServer = \taoResultServer_models_classes_ResultServerStateFull::singleton();
     $result = array();
     foreach ($started as $deliveryExecution) {
         $compiledDelivery = $deliveryExecution->getDelivery();
         $runtime = \taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRuntime($compiledDelivery);
         $inputParameters = \tao_models_classes_service_ServiceCallHelper::getInputValues($runtime, array());
         $testDefinition = \taoQtiTest_helpers_Utils::getTestDefinition($inputParameters['QtiTestCompilation']);
         $testResource = new \core_kernel_classes_Resource($inputParameters['QtiTestDefinition']);
         $subjectProp = new \core_kernel_classes_Property(PROPERTY_DELVIERYEXECUTION_SUBJECT);
         $delvieryExecutionSubject = $deliveryExecution->getOnePropertyValue($subjectProp);
         $sessionManager = new \taoQtiTest_helpers_SessionManager($resultServer, $testResource);
         $qtiStorage = new \taoQtiTest_helpers_TestSessionStorage($sessionManager, new BinaryAssessmentTestSeeker($testDefinition), $delvieryExecutionSubject->getUri());
         $session = $qtiStorage->retrieve($testDefinition, $deliveryExecution->getUri());
         $resultServerUri = $compiledDelivery->getOnePropertyValue(new \core_kernel_classes_Property(TAO_DELIVERY_RESULTSERVER_PROP));
         $resultServerObject = new \taoResultServer_models_classes_ResultServer($resultServerUri, array());
         $resultServer->setValue('resultServerUri', $resultServerUri->getUri());
         $resultServer->setValue('resultServerObject', array($resultServerUri->getUri() => $resultServerObject));
         $resultServer->setValue('resultServer_deliveryResultIdentifier', $deliveryExecution->getUri());
         if ($session->isRunning() === false) {
             continue;
         }
         try {
             $session->checkTimeLimits(false, false, false);
         } catch (AssessmentTestSessionException $e) {
             if (AssessmentTestSessionException::ASSESSMENT_TEST_DURATION_OVERFLOW) {
                 $testSessionMetaData = new TestSessionMetaData($session);
                 $testSessionMetaData->save(array('TEST' => array('TEST_EXIT_CODE' => TestSessionMetaData::TEST_CODE_INCOMPLETE), 'SECTION' => array('SECTION_EXIT_CODE' => TestSessionMetaData::SECTION_CODE_TIMEOUT)));
                 $session->endTestSession();
                 $deliveryExecution->setState(INSTANCE_DELIVERYEXEC_FINISHED);
                 \common_Logger::i("Expired test session {$session->getSessionId()} has finished.");
                 $result[] = $session->getSessionId();
             }
         }
     }
     echo json_encode($result);
 }
 /**
  * (non-PHPdoc)
  * @see \oat\taoFrontOffice\model\Delivery::getRuntime()
  */
 public function getRuntime()
 {
     return taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRuntime($this);
 }
/*  
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; under version 2
 * of the License (non-upgradable).
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 * 
 * Copyright (c) 2002-2008 (original work) Public Research Centre Henri Tudor & University of Luxembourg (under the project TAO & TAO2);
 *               2008-2010 (update and modification) Deutsche Institut für Internationale Pädagogische Forschung (under the project TAO-TRANSFER);
 *               2009-2012 (update and modification) Public Research Centre Henri Tudor (under the project TAO-SUSTAIN & TAO-DEV);
 * 
 */
require_once dirname(__FILE__) . '/../includes/raw_start.php';
$parms = $argv;
$script = array_shift($parms);
if (count($parms) != 1) {
    echo "Usage: " . $script . " FILE\n";
} else {
    $file = array_shift($parms);
    $deliveryClass = taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRootClass();
    $report = taoDelivery_models_classes_import_Assembler::importDelivery($deliveryClass, $file);
    var_dump($report);
}
 public function runDeliveryExecution()
 {
     $deliveryExecution = $this->getCurrentDeliveryExecution();
     if ($deliveryExecution->getState()->getUri() != INSTANCE_DELIVERYEXEC_ACTIVE) {
         $this->redirect($this->getReturnUrl());
     }
     $userUri = common_session_SessionManager::getSession()->getUserUri();
     if ($deliveryExecution->getUserIdentifier() != $userUri) {
         throw new common_exception_Error('User ' . $userUri . ' is not the owner of the execution ' . $deliveryExecution->getIdentifier());
     }
     $compiledDelivery = $deliveryExecution->getDelivery();
     $this->initResultServer($compiledDelivery, $deliveryExecution->getIdentifier());
     $runtime = taoDelivery_models_classes_DeliveryAssemblyService::singleton()->getRuntime($compiledDelivery);
     $this->setData('serviceApi', tao_helpers_ServiceJavascripts::getServiceApi($runtime, $deliveryExecution->getIdentifier()));
     $this->setData('userLabel', common_session_SessionManager::getSession()->getUserLabel());
     $this->setData('deliveryExecution', $deliveryExecution->getIdentifier());
     $this->setData('showControls', $this->showControls());
     $this->setData('client_config_url', $this->getClientConfigUrl());
     $this->setData('client_timeout', $this->getClientTimeout());
     $this->setView('runtime/deliveryExecution.tpl', 'taoDelivery');
 }
 /**
  * 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()
 {
     //Properties to filter on
     $properties = array(new \core_kernel_classes_Property(RDFS_LABEL));
     $deliveryService = \taoDelivery_models_classes_DeliveryAssemblyService::singleton();
     $delivery = new core_kernel_classes_Resource(tao_helpers_Uri::decode($this->getRequestParameter('classUri')));
     if ($delivery->getUri() !== $deliveryService->getRootClass()->getUri()) {
         try {
             // display delivery
             $implementation = $this->getClassService()->getReadableImplementation($delivery);
             $this->getClassService()->setImplementation($implementation);
             $model = array();
             foreach ($properties as $property) {
                 $model[] = array('id' => $property->getUri(), 'label' => $property->getLabel(), 'sortable' => true);
             }
             $this->setData('classUri', tao_helpers_Uri::encode($delivery->getUri()));
             $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');
     }
 }