/** * @inheritDoc */ protected function init() { $delivery = $this->deliveryExecution->getDelivery(); $runtime = ServiceManager::getServiceManager()->get(AssignmentService::CONFIG_ID)->getRuntime($delivery); $inputParameters = \tao_models_classes_service_ServiceCallHelper::getInputValues($runtime, array()); // set the test parameters $this->setData('testDefinition', $inputParameters['QtiTestDefinition']); $this->setData('testCompilation', $inputParameters['QtiTestCompilation']); $this->setData('serviceCallId', $this->deliveryExecution->getIdentifier()); // set the test runner config $config = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('testRunner'); $bootstrap = isset($config['bootstrap']) ? $config['bootstrap'] : []; $this->setData('bootstrap', $bootstrap); }
/** * 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); }
public static function getServiceApi(tao_models_classes_service_ServiceCall $serviceCall, $serviceCallId, $customParams = array()) { $inputParameters = tao_models_classes_service_ServiceCallHelper::getInputValues($serviceCall, $customParams); $inputParameters['standalone'] = true; return 'new ServiceApi(' . tao_helpers_Javascript::buildObject(tao_models_classes_service_ServiceCallHelper::getBaseUrl($serviceCall->getServiceDefinition())) . ',' . tao_helpers_Javascript::buildObject($inputParameters) . ',' . tao_helpers_Javascript::buildObject($serviceCallId) . ',' . self::getServiceStorage($serviceCallId) . ',' . self::getUserInfoService() . ')'; }
/** * Compile the items referended by $compactDoc. * * @param XmlCompactDocument $compactDoc An XmlCompactDocument object referencing the items of the test. * @throws taoQtiTest_models_classes_QtiTestCompilationFailedException If the test does not refer to at least one item. * @return common_report_Report */ protected function compileItems(XmlCompactDocument $compactDoc) { $report = new common_report_Report(common_report_Report::TYPE_SUCCESS, __('Items Compilation')); $iterator = new QtiComponentIterator($compactDoc->getDocumentComponent(), array('assessmentItemRef')); $itemCount = 0; foreach ($iterator as $assessmentItemRef) { // Each item could take some time to be compiled, making the request to timeout. helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::SHORT); $itemToCompile = new core_kernel_classes_Resource($assessmentItemRef->getHref()); $subReport = $this->subCompile($itemToCompile); $report->add($subReport); if ($subReport->getType() == common_report_Report::TYPE_SUCCESS) { $itemService = $subReport->getdata(); $inputValues = tao_models_classes_service_ServiceCallHelper::getInputValues($itemService, array()); $assessmentItemRef->setHref($inputValues['itemUri'] . '|' . $inputValues['itemPath'] . '|' . $inputValues['itemDataPath']); } else { $report->setType(common_report_Report::TYPE_ERROR); } // Count the item even if it fails to avoid false "no item" error. $itemCount++; common_Logger::t("QTI Item successfully compiled and registered as a service call in the QTI Test Definition."); } if ($itemCount === 0) { $report->setType(common_report_Report::TYPE_ERROR); $report->setMessage(__("A QTI Test must contain at least one QTI Item to be compiled. None found.")); } return $report; }
/** * 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']; }
/** * * @param DeliveryExecution $deliveryExecution * @return array * Example: * <pre> * array( * 'QtiTestCompilation' => 'http://sample/first.rdf#i14369768868163155-|http://sample/first.rdf#i1436976886612156+', * 'QtiTestDefinition' => 'http://sample/first.rdf#i14369752345581135' * ) * </pre> */ public function getRuntimeInputParameters(DeliveryExecution $deliveryExecution) { $compiledDelivery = $deliveryExecution->getDelivery(); $runtime = ServiceManager::getServiceManager()->get(AssignmentService::CONFIG_ID)->getRuntime($compiledDelivery->getUri()); $inputParameters = \tao_models_classes_service_ServiceCallHelper::getInputValues($runtime, array()); return $inputParameters; }