/** * Create a new SessionManager object. * * @param taoResultServer_models_classes_ResultServerStateFull $resultServer The ResultServer to be set to the AssessmentTestSession to be built. * @param core_kernel_classes_Resource $test The TAO Resource describing the Test definition to be set to the AssessmentTestSession to be built. */ public function __construct(taoResultServer_models_classes_ResultServerStateFull $resultServer, core_kernel_classes_Resource $test) { parent::__construct(); $this->setAcceptableLatency(new QtiDuration(taoQtiTest_models_classes_QtiTestService::singleton()->getQtiTestAcceptableLatency())); $this->setResultServer($resultServer); $this->setTest($test); }
/** * Create a new instance of QtiTestExport. * * @param core_kernel_classes_Resource $test The Resource in the ontology representing the QTI Test to be exported. * @param ZipArchive $zip An instance of ZipArchive were components of the QTI Test will be stored into. * @param DOMDocument $manifest A DOMDocument representing the IMS Manifest to be populated during the Test Export. */ public function __construct(core_kernel_classes_Resource $test, ZipArchive $zip, DOMDocument $manifest) { parent::__construct($test, $zip); $this->setTestService(taoQtiTest_models_classes_QtiTestService::singleton()); $this->setTestDocument($this->getTestService()->getDoc($test)); $this->setItems($this->getTestService()->getItems($test)); $this->setManifest($manifest); }
public static function getBaseDir(core_kernel_classes_Resource $test) { $testFile = taoQtiTest_models_classes_QtiTestService::singleton()->getTestFile($test); if (is_null($testFile)) { throw new common_Exception('No test folder found for ' . $test->getUri()); } $baseDir = $testFile->getAbsolutePath() . '/'; return $baseDir; }
public function run() { taoUpdate_helpers_ExtensionConfigUpdater::update('taoQtiTest', ROOT_PATH . 'taoQtiTest/includes/config.php'); taoUpdate_helpers_ExtensionConfigUpdater::update('taoItems', ROOT_PATH . 'taoItems/includes/config.php'); taoUpdate_helpers_ExtensionConfigUpdater::update('tao', ROOT_PATH . 'tao/includes/config.php'); taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestAcceptableLatency('PT5S'); taoDelivery_models_classes_execution_ServiceProxy::singleton()->setImplementation('taoDelivery_models_classes_execution_OntologyService'); $resultServer = new core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAOResult.rdf#taoResultServer'); taoResultServer_models_classes_ResultServerAuthoringService::singleton()->setDefaultResultServer($resultServer); }
/** * * @author Rashid Mumtaz & Absar - PCG Team - {absar.gilani6@gmail.com & rashid.mumtaz372@gmail.com} * @param array $propertiesValues * @return common_report_Report */ public function importQtiTest($uploadedFile, $class = null) { //test versioning try { //The zip extraction is a long process that can exceed the 30s timeout helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG); $class = is_null($class) ? new core_kernel_classes_Class(TAO_TEST_CLASS) : $class; $report = taoQtiTest_models_classes_QtiTestService::singleton()->importMultipleTests($class, $uploadedFile); helpers_TimeOutHelper::reset(); return $report; } catch (common_exception_UserReadableException $e) { return new common_report_Report(common_report_Report::TYPE_ERROR, __($e->getUserMessage())); } }
public function getIdentifier() { $response = array(); if ($this->getRequest()->accept('application/json')) { //we need the model as well to keep consistency with the client if ($this->hasRequestParameter('model') && $this->hasRequestParameter('qti-type')) { $parameters = $this->getRequest()->getRawParameters(); $qtiTestService = taoQtiTest_models_classes_QtiTestService::singleton(); $doc = $qtiTestService->fromJson($parameters['model']); $identifier = $qtiTestService->getIdentifierFor($doc, $this->getRequestParameter('qti-type')); $response = array('identifier' => $identifier); } } $this->setContentHeader('application/json', 'UTF-8'); echo json_encode($response); }
/** * 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()); }
/** * (non-PHPdoc) * @see tao_models_classes_import_ImportHandler::import() */ public function import($class, $form) { try { $fileInfo = $form->getValue('source'); if (isset($fileInfo['uploaded_file'])) { $uploadedFile = $fileInfo['uploaded_file']; // The zip extraction is a long process that can exceed the 30s timeout helpers_TimeOutHelper::setTimeOutLimit(helpers_TimeOutHelper::LONG); $report = taoQtiTest_models_classes_QtiTestService::singleton()->importMultipleTests($class, $uploadedFile); helpers_TimeOutHelper::reset(); tao_helpers_File::remove($uploadedFile); } else { throw new common_exception_Error('No source file for import'); } return $report; } catch (Exception $e) { return common_report_Report::createFailure($e->getMessage()); } }
public function __invoke($params) { // load constants... \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->load(); if (empty($params[0]) === true) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Test URI not provided as parameter 1.'); } if (empty($params[1]) === true) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'AssessmentItemRefIdentifier not provided as parameter 2.'); } $testResource = new \core_kernel_classes_Resource($params[0]); if ($testResource->exists() === false) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No RDFS Resource found for URI ' . $params[0] . '.'); } $qtiService = \taoQtiTest_models_classes_QtiTestService::singleton(); $testDoc = $qtiService->getDoc($testResource); $test = $testDoc->getDocumentComponent(); $assessmentItemRef = $test->getComponentByIdentifier($params[1]); if (!$assessmentItemRef) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI assessmentItemRef with identifier ' . $params[1] . ' found in the QTI Test definition.'); } $input = file_get_contents('php://stdin'); if (empty($input) === true) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI-XML input provided in stdin.'); } else { $dom = new \DOMDocument('1.0', 'UTF-8'); if (@$dom->loadXML($input)) { $element = $dom->documentElement; $marshallerFactory = new MarshallerFactory(); $marshaller = $marshallerFactory->createMarshaller($element); $component = $marshaller->unmarshall($element); if (!$component instanceof BranchRule) { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'No QTI branchRule component found in stdin.'); } $assessmentItemRef->setBranchRules(new BranchRuleCollection(array($component))); $qtiService->getQtiTestFile($testResource)->update($testDoc->saveToString()); } else { return new \common_report_Report(\common_report_Report::TYPE_ERROR, 'Invalid QTI-XML input provided in stdin.'); } } return new \common_report_Report(\common_report_Report::TYPE_SUCCESS, "BranchRule found in stdin successfully appended to assessmentItemRef '" . $params[1] . "' part of QTI Test with URI '" . $params[0] . "'."); }
/** * * @param string $initialVersion * @return string $versionUpdatedTo */ public function update($initialVersion) { $currentVersion = $initialVersion; // add testrunner config if ($currentVersion == '2.6') { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->setConfig('testRunner', array('progress-indicator' => 'percentage', 'timerWarning' => array('assessmentItemRef' => null, 'assessmentSection' => 300, 'testPart' => null))); $currentVersion = '2.6.1'; } if ($currentVersion == '2.6.1') { $config = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('testRunner'); $config['exitButton'] = false; \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->setConfig('testRunner', $config); $currentVersion = '2.6.2'; } // add testrunner review screen config if ($currentVersion == '2.6.2') { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $extension->setConfig('testRunner', array_merge($config, array('test-taker-review' => false, 'test-taker-review-region' => 'left', 'test-taker-review-section-only' => false, 'test-taker-review-prevents-unseen' => true))); $currentVersion = '2.6.3'; } // adjust testrunner config if ($currentVersion == '2.6.3') { $defaultConfig = array('timerWarning' => array('assessmentItemRef' => null, 'assessmentSection' => null, 'testPart' => null), 'progress-indicator' => 'percentage', 'progress-indicator-scope' => 'testSection', 'test-taker-review' => false, 'test-taker-review-region' => 'left', 'test-taker-review-section-only' => false, 'test-taker-review-prevents-unseen' => true, 'exitButton' => false); $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); foreach ($defaultConfig as $key => $value) { if (!isset($config[$key])) { $config[$key] = $value; } } $extension->setConfig('testRunner', $config); $currentVersion = '2.6.4'; } if ($currentVersion == '2.6.4') { $currentVersion = '2.7.0'; } // add markForReview button if ($currentVersion === '2.7.0') { $registry = TestRunnerClientConfigRegistry::getRegistry(); $registry->registerQtiTools('markForReview', array('label' => 'Mark for review', 'icon' => 'anchor', 'hook' => 'taoQtiTest/testRunner/actionBar/markForReview')); $currentVersion = '2.8.0'; } // adjust testrunner config: set the review scope if ($currentVersion == '2.8.0') { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['test-taker-review-scope'] = 'test'; unset($config['test-taker-review-section-only']); $extension->setConfig('testRunner', $config); $currentVersion = '2.9.0'; } // add show/hide button // adjust testrunner config: set the "can collapse" option if ($currentVersion == '2.9.0') { $registry = TestRunnerClientConfigRegistry::getRegistry(); $registry->registerQtiTools('collapseReview', array('title' => 'Show/Hide the review screen', 'label' => 'Review', 'icon' => 'mobile-menu', 'hook' => 'taoQtiTest/testRunner/actionBar/collapseReview', 'order' => -1)); $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['test-taker-review-can-collapse'] = false; $extension->setConfig('testRunner', $config); $currentVersion = '2.10.0'; } // adjust testrunner config: set the item sequence number options if ($currentVersion == '2.10.0') { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['test-taker-review-force-title'] = false; $config['test-taker-review-item-title'] = 'Item %d'; $extension->setConfig('testRunner', $config); $currentVersion = '2.11.0'; } if ($currentVersion == '2.11.0') { $currentVersion = '2.11.1'; } // adjust testrunner config: set the force progress indicator display if ($currentVersion == '2.11.1') { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['progress-indicator-forced'] = false; $extension->setConfig('testRunner', $config); $currentVersion = '2.12.0'; } // update the test taker review action buttons if ($currentVersion == '2.12.0') { $registry = TestRunnerClientConfigRegistry::getRegistry(); $registry->registerQtiTools('collapseReview', array('hook' => 'taoQtiTest/testRunner/actionBar/collapseReview', 'order' => 'first', 'title' => null, 'label' => null, 'icon' => null)); $registry->registerQtiTools('markForReview', array('hook' => 'taoQtiTest/testRunner/actionBar/markForReview', 'order' => 'last', 'title' => null, 'label' => null, 'icon' => null)); $currentVersion = '2.13.0'; } // adjust testrunner config: set the next section button display if ($currentVersion == '2.13.0') { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['next-section'] = false; $extension->setConfig('testRunner', $config); $currentVersion = '2.14.0'; } if ($currentVersion === '2.14.0') { try { $this->getServiceManager()->get('taoQtiTest/SessionStateService'); } catch (ServiceNotFoundException $e) { $sessionStateService = new SessionStateService(); $sessionStateService->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register('taoQtiTest/SessionStateService', $sessionStateService); } $currentVersion = '2.15.0'; } if ($currentVersion === '2.15.0') { $registry = TestRunnerClientConfigRegistry::getRegistry(); $registry->registerQtiTools('comment', array('hook' => 'taoQtiTest/testRunner/actionBar/comment')); $currentVersion = '2.16.0'; } $this->setVersion($currentVersion); if ($this->isBetween('2.16.0', '2.17.0')) { $proctorRole = new \core_kernel_classes_Resource('http://www.tao.lu/Ontologies/TAO.rdf#DeliveryRole'); $accessService = \funcAcl_models_classes_AccessService::singleton(); $accessService->grantModuleAccess($proctorRole, 'taoQtiTest', 'Runner'); try { $this->getServiceManager()->get(QtiRunnerService::CONFIG_ID); } catch (ServiceNotFoundException $e) { $service = new QtiRunnerService(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(QtiRunnerService::CONFIG_ID, $service); } $this->setVersion('2.17.0'); } $this->skip('2.17.0', '2.19.1'); if ($this->isVersion('2.19.1')) { // sets default plugin options $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); if (!array_key_exists('plugins', $config)) { $config['plugins'] = null; } $extension->setConfig('testRunner', $config); $this->setVersion('2.20.0'); } $this->skip('2.20.0', '2.21.1'); if ($this->isVersion('2.21.1')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $extension->setConfig('testRunner', array_merge($config, array('csrf-token' => true))); $this->setVersion('2.22.0'); } if ($this->isVersion('2.22.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['timer']['target'] = 'server'; $extension->setConfig('testRunner', $config); $this->setVersion('2.23.0'); } $this->skip('2.23.0', '2.24.0'); if ($this->isVersion('2.24.0')) { $className = \taoQtiTest_helpers_SessionManager::DEFAULT_TEST_SESSION; try { $deliveryConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery')->getConfig('deliveryServer'); if ($deliveryConfig) { $deliveryContainer = $deliveryConfig->getOption('deliveryContainer'); if (false !== strpos($deliveryContainer, 'DeliveryClientContainer')) { $className = 'oat\\taoQtiTest\\models\\runner\\session\\TestSession'; } } } catch (\common_ext_ExtensionException $e) { } $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['test-session'] = $className; $extension->setConfig('testRunner', $config); $this->setVersion('2.25.0'); } if ($this->isVersion('2.25.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['plugins']['overlay']['full'] = false; $extension->setConfig('testRunner', $config); $this->setVersion('2.26.0'); } $this->skip('2.26.0', '2.27.0'); if ($this->isVersion('2.27.0')) { $serviceExtension = 'taoQtiTest'; $serviceController = 'Runner'; try { $deliveryConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery')->getConfig('testRunner'); if ($deliveryConfig) { $serviceExtension = $deliveryConfig['serviceExtension']; $serviceController = $deliveryConfig['serviceController']; } } catch (\common_ext_ExtensionException $e) { } $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['bootstrap'] = ['serviceExtension' => $serviceExtension, 'serviceController' => $serviceController, 'communication' => ['enabled' => false, 'type' => 'poll', 'extension' => null, 'controller' => null, 'action' => 'messages', 'service' => null, 'params' => []]]; $extension->setConfig('testRunner', $config); try { $this->getServiceManager()->get(QtiCommunicationService::CONFIG_ID); } catch (ServiceNotFoundException $e) { $service = new QtiCommunicationService(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(QtiCommunicationService::CONFIG_ID, $service); } $this->setVersion('2.28.0'); } if ($this->isVersion('2.28.0')) { $testRunnerConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('testRunner'); if (array_key_exists('timerWarning', $testRunnerConfig)) { foreach ($testRunnerConfig['timerWarning'] as &$value) { if ($value !== null && is_int($value)) { $value = [$value => 'warning']; } } \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->setConfig('testRunner', $testRunnerConfig); } $this->setVersion('2.29.0'); } if ($this->isVersion('2.29.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['bootstrap']['timeout'] = 0; $extension->setConfig('testRunner', $config); $this->setVersion('2.30.0'); } if ($this->isVersion('2.30.0')) { try { $service = $this->getServiceManager()->get(QtiCommunicationService::CONFIG_ID); } catch (ServiceNotFoundException $e) { $service = new QtiCommunicationService(); } $service->setServiceManager($this->getServiceManager()); $service->attachChannel(new TestStateChannel(), QtiCommunicationService::CHANNEL_TYPE_OUTPUT); $this->getServiceManager()->register(QtiCommunicationService::CONFIG_ID, $service); $this->setVersion('2.31.0'); } if ($this->isVersion('2.31.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); if (!isset($config['bootstrap']) || isset($config['bootstrap']['timeout']) && count($config['bootstrap']) == 1) { $config['bootstrap'] = array_merge($config['bootstrap'], ['serviceExtension' => 'taoQtiTest', 'serviceController' => 'Runner', 'communication' => ['enabled' => false, 'type' => 'poll', 'extension' => null, 'controller' => null, 'action' => 'messages', 'service' => null, 'params' => []]]); $extension->setConfig('testRunner', $config); } $this->setVersion('2.31.1'); } $this->skip('2.31.1', '3.0.0'); if ($this->isVersion('3.0.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['enable-allow-skipping'] = false; $extension->setConfig('testRunner', $config); $this->setVersion('3.1.0'); } $this->skip('3.1.0', '3.4.0'); if ($this->isVersion('3.4.0')) { $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $uri = $ext->getConfig(\taoQtiTest_models_classes_QtiTestService::CONFIG_QTITEST_FILESYSTEM); $dir = new \core_kernel_file_File($uri); $fs = $dir->getFileSystem(); \taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestFileSystem($fs->getUri()); $this->setVersion('4.0.0'); } $this->skip('4.0.0', '4.6.0'); if ($this->isVersion('4.6.0')) { $registry = TestRunnerClientConfigRegistry::getRegistry(); $runnerConfig = $registry->get(TestRunnerClientConfigRegistry::RUNNER); if (isset($runnerConfig['plugins']) && is_array($runnerConfig['plugins'])) { foreach ($runnerConfig['plugins'] as $plugin) { //if the plugin is registered if ($plugin['module'] == 'taoQtiTest/runner/plugins/controls/disableRightClick') { //we migrate the category $registry->removePlugin('taoQtiTest/runner/plugins/controls/disableRightClick', 'controls', null); $registry->registerPlugin('taoQtiTest/runner/plugins/security/disableRightClick', 'security', null); break; } } } $this->setVersion('4.7.0'); } $this->skip('4.7.0', '4.8.2'); if ($this->isVersion('4.8.2')) { //regsiter the core plugins into taoTests $registerCorePlugins = new RegisterTestRunnerPlugins(); $registerCorePlugins([]); $registry = PluginRegistry::getRegistry(); //list the installed plugins $oldRegistry = TestRunnerClientConfigRegistry::getRegistry(); $runnerConfig = $oldRegistry->get(TestRunnerClientConfigRegistry::RUNNER); if (isset($runnerConfig['plugins']) && is_array($runnerConfig['plugins'])) { foreach ($runnerConfig['plugins'] as $plugin) { //if they are not yet in the config, migrate them automatically if (!$registry->isRegistered($plugin['module'])) { $pluginId = basename($plugin['module']); $pluginName = ucfirst(join(preg_split('/(?=[A-Z])/', $pluginId), ' ')); $registry->register(TestPlugin::fromArray(['id' => $pluginId, 'name' => $pluginName, 'module' => $plugin['module'], 'category' => $plugin['category'], 'position' => $plugin['position'], 'active' => true])); } } } //then remove the old config $registry->remove(TestRunnerClientConfigRegistry::RUNNER); $registry->remove(TestRunnerClientConfigRegistry::RUNNER_PROD); $this->setVersion('5.0.0'); } $this->skip('5.0.0', '5.4.0'); if ($this->isVersion('5.4.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['plugins']['collapser'] = ['collapseTools' => true, 'collapseNavigation' => false, 'hover' => false]; $extension->setConfig('testRunner', $config); $this->setVersion('5.5.0'); } $this->skip('5.5.0', '5.5.3'); if ($this->isVersion('5.5.3')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['force-branchrules'] = false; $config['force-preconditions'] = false; $config['path-tracking'] = false; $extension->setConfig('testRunner', $config); $this->setVersion('5.6.0'); } if ($this->isVersion('5.6.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['always-allow-jumps'] = false; $extension->setConfig('testRunner', $config); $this->setVersion('5.7.0'); } $this->skip('5.7.0', '5.8.4'); if ($this->isVersion('5.8.4')) { OntologyUpdater::syncModels(); $testModelService = new TestModelService(array('exportHandlers' => array(new \taoQtiTest_models_classes_export_TestExport(), new \taoQtiTest_models_classes_export_TestExport22()), 'importHandlers' => array(new \taoQtiTest_models_classes_import_TestImport()))); $testModelService->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(TestModelService::SERVICE_ID, $testModelService); $this->setVersion('5.9.0'); } $this->skip('5.9.0', '5.10.2'); if ($this->isVersion('5.10.2')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['check-informational'] = false; $extension->setConfig('testRunner', $config); $this->setVersion('5.11.0'); } if ($this->isVersion('5.11.0')) { $registry = PluginRegistry::getRegistry(); $registry->register(TestPlugin::fromArray(['id' => 'modalFeedback', 'name' => 'QTI modal feedbacks', 'module' => 'taoQtiTest/runner/plugins/content/modalFeedback/modalFeedback', 'description' => 'Display Qti modalFeedback element', 'category' => 'content', 'active' => true, 'tags' => ['core', 'qti', 'required']])); $this->setVersion('5.12.0'); } $this->skip('5.12.0', '5.16.2'); if ($this->isVersion('5.16.2')) { $service = new TestExporter(); $service->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(TestMetadataExporter::SERVICE_ID, $service); $this->setVersion('5.17.0'); } $this->skip('5.17.0', '5.17.3'); if ($this->isVersion('5.17.3')) { \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->setConfig('TestCompiler', array('enable-category-rules-generation' => false)); $categoryRulesService = new TestCategoryRulesService(array('score-variable-identifier' => 'SCORE', 'weight-identifier' => 'WEIGHT', 'category-exclusions' => array('/x-tao-/'), 'flags' => TestCategoryRulesGenerator::COUNT | TestCategoryRulesGenerator::CORRECT | TestCategoryRulesGenerator::SCORE)); $categoryRulesService->setServiceManager($this->getServiceManager()); $this->getServiceManager()->register(TestCategoryRulesService::SERVICE_ID, $categoryRulesService); $this->setVersion('5.18.0'); } $this->skip('5.18.0', '5.23.0'); if ($this->isVersion('5.23.0')) { $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $uri = $ext->getConfig(\taoQtiTest_models_classes_QtiTestService::CONFIG_QTITEST_FILESYSTEM); if (!is_string($uri)) { if (is_object($uri) && $uri instanceof \core_kernel_classes_Resource) { \taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestFileSystem($uri->getUri()); } else { throw new \common_exception_InconsistentData('Invalid qti test storage directory configuration'); } } $this->setVersion('5.23.1'); } $this->skip('5.23.1', '5.25.1'); if ($this->isVersion('5.25.1')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['test-taker-unanswered-items-message'] = true; $extension->setConfig('testRunner', $config); $this->setVersion('5.26.0'); } if ($this->isVersion('5.26.0')) { $registry = PluginRegistry::getRegistry(); $registry->register(TestPlugin::fromArray(['id' => 'documentViewer', 'name' => 'Document Viewer', 'module' => 'taoQtiTest/runner/plugins/tools/documentViewer/documentViewer', 'description' => 'Display a document as requested by an event', 'category' => 'tools', 'active' => false, 'tags' => []])); $this->setVersion('5.27.0'); } if ($this->isVersion('5.27.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['keep-timer-up-to-timeout'] = false; $extension->setConfig('testRunner', $config); $this->setVersion('5.28.0'); } $this->skip('5.28.0', '5.30.1'); if ($this->isVersion('5.30.1')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['allow-shortcuts'] = true; $extension->setConfig('testRunner', $config); $this->setVersion('5.31.0'); } $this->skip('5.31.0', '5.31.1'); if ($this->isVersion('5.31.1')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['shortcuts'] = ['calculator' => ['toggle' => 'C'], 'zoom' => ['in' => 'I', 'out' => 'O'], 'comment' => ['toggle' => 'A'], 'itemThemeSwitcher' => ['toggle' => 'T'], 'review' => ['toggle' => 'R', 'flag' => 'M']]; $extension->setConfig('testRunner', $config); $this->setVersion('5.32.0'); } $this->skip('5.32.0', '5.32.1'); if ($this->isVersion('5.32.1')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['shortcuts']['next'] = ['trigger' => 'J']; $config['shortcuts']['previous'] = ['trigger' => 'K']; $extension->setConfig('testRunner', $config); $this->setVersion('5.33.0'); } if ($this->isVersion('5.33.0')) { $registry = PluginRegistry::getRegistry(); $registry->register(TestPlugin::fromArray(['id' => 'responsesAccess', 'name' => 'Shortcuts to access the item responses', 'module' => 'taoQtiTest/runner/plugins/content/accessibility/responsesAccess', 'description' => 'Provide a way to navigate between item responses using the keyboard', 'category' => 'content', 'active' => true, 'tags' => ['core', 'qti']])); $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['shortcuts']['responsesAccess'] = ['previous' => 'Shift+Tab', 'next' => 'Tab']; $extension->setConfig('testRunner', $config); $this->setVersion('5.34.0'); } $this->skip('5.34.0', '5.36.0'); if ($this->isVersion('5.36.0')) { $registry = PluginRegistry::getRegistry(); $registry->register(TestPlugin::fromArray(['id' => 'highlighter', 'name' => 'Text Highlighter', 'module' => 'taoQtiTest/runner/plugins/tools/highlighter/plugin', 'description' => 'Allows the test taker to highlight text', 'category' => 'tools', 'active' => true, 'tags' => []])); $this->setVersion('5.37.0'); } if ($this->isVersion('5.37.0')) { $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest'); $config = $extension->getConfig('testRunner'); $config['shortcuts']['itemThemeSwitcher'] = ['toggle' => 'T', 'loop' => 'Y', 'select' => 'U']; $extension->setConfig('testRunner', $config); $this->setVersion('5.37.1'); } $this->skip('5.37.1', '5.38.1'); if ($this->isVersion('5.38.1')) { $registry = PluginRegistry::getRegistry(); $registry->register(TestPlugin::fromArray(['id' => 'highlighter', 'name' => 'Text Highlighter', 'module' => 'taoQtiTest/runner/plugins/tools/highlighter/plugin', 'description' => 'Allows the test taker to highlight text', 'category' => 'tools', 'active' => false, 'tags' => []])); $this->setVersion('5.38.2'); } $this->skip('5.38.2', '5.39.1'); }
/** * Copy the test resources (e.g. images) that will be availabe at delivery time * in the public compilation directory. * */ protected function copyPublicResources() { $testService = taoQtiTest_models_classes_QtiTestService::singleton(); $testDefinitionDir = $testService->getQtiTestDir($this->getResource()); $publicCompiledDocDir = $this->getPublicDirectory(); $iterator = $testDefinitionDir->getFlyIterator(Directory::ITERATOR_RECURSIVE | Directory::ITERATOR_FILE); foreach ($iterator as $file) { /** @var \oat\oatbox\filesystem\File $file */ $mime = $file->getMimeType(); $pathinfo = pathinfo($file->getBasename()); if (in_array($mime, self::getPublicMimeTypes()) === true && $pathinfo['extension'] !== 'php') { $publicPathFile = $testDefinitionDir->getRelPath($file); try { common_Logger::d('Public ' . $file->getPrefix() . '(' . $mime . ') to ' . $publicPathFile); $publicCompiledDocDir->getFile($publicPathFile)->write($file->readStream()); } catch (FileExistsException $e) { common_Logger::w('File ' . $publicPathFile . ' copied twice to public test folder during compilation'); } } } }
* 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); * */ /* * This post-installation script creates a fodler for the QTI Tests */ $dataPath = FILES_PATH . 'taoQtiTest' . DIRECTORY_SEPARATOR; if (file_exists($dataPath)) { helpers_File::emptyDirectory($dataPath); } $source = tao_models_classes_FileSourceService::singleton()->addLocalSource('QTI test datasource', $dataPath); mkdir($dataPath . 'testData'); $directory = new core_kernel_file_File($source->createFile('', 'testData')); taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestDirectory($directory);
protected function isExportable(array $formData) { /** @var \core_kernel_classes_Resource $model */ $model = \taoQtiTest_models_classes_QtiTestService::singleton()->getTestModel($formData['instance']); return $model->getUri() == INSTANCE_TEST_MODEL_QTI; }
<?php /* * 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) 2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); * * @author Jérôme Bogaerts <*****@*****.**> */ /* * This post-installation script configures the acceptable latency time when qti:timeLimits->maxTime * and/or qti:timeLimits->minTime are in force. */ taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestAcceptableLatency('PT5S');
<?php /* * 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) 2013-2014 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); * */ $testClass = taoQtiTest_models_classes_QtiTestService::singleton()->getRootClass(); $file = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'qtiv2p1Examples.zip'; try { $report = taoQtiTest_models_classes_QtiTestService::singleton()->importMultipleTests(new core_kernel_classes_Class(TAO_TEST_CLASS), $file); } catch (Exception $e) { common_Logger::e('An error occured while importing QTI Test Example. The system reported the following error: ' . $e->getMessage()); throw $e; }
/** * Clone a QTI Test Resource. * * @param core_kernel_classes_Resource $source The resource to be cloned. * @param core_kernel_classes_Resource $destination An existing resource to be filled as the clone of $source. */ public function cloneContent(core_kernel_classes_Resource $source, core_kernel_classes_Resource $destination) { $contentProperty = new core_kernel_classes_Property(TEST_TESTCONTENT_PROP); $existingDir = new core_kernel_file_File($source->getUniquePropertyValue($contentProperty)); $service = taoQtiTest_models_classes_QtiTestService::singleton(); $dir = $service->createContent($destination, false); if ($existingDir->fileExists()) { tao_helpers_File::copy($existingDir->getAbsolutePath(), $dir->getAbsolutePath(), true, false); } else { common_Logger::w('Test "' . $source->getUri() . '" had no content, nothing to clone'); } }
} else { $userData = DataGeneration::createUser($toAdd, $lang); try { $persistence->insert('redis', array('subject' => $userData['uri'], 'predicate' => PROPERTY_USER_LOGIN, 'object' => $userData[PROPERTY_USER_LOGIN])); // insert user data to statements as well to be able to show the user label on the results page $persistence->insert('statements', array('modelid' => 1, 'subject' => $userData['uri'], 'predicate' => RDFS_LABEL, 'object' => $userData[PROPERTY_USER_LOGIN], 'l_language' => $lang)); } catch (PDOException $e) { echo 'please make sure that called redis exists with subject,predicate,object' . "\n"; echo 'insert as first line : ' . $userData['uri'] . " , " . PROPERTY_USER_LOGIN . " , " . $userData[PROPERTY_USER_LOGIN]; die(1); } } } $row++; } fclose($handle); echo PHP_EOL . $row . ' test takers imported.' . PHP_EOL; } //----------- Import test from ZIP package echo 'Importing test...' . PHP_EOL; $report = \taoQtiTest_models_classes_QtiTestService::singleton()->importMultipleTests(new \core_kernel_classes_Class("http://www.tao.lu/Ontologies/TAOTest.rdf#Test"), $test_package); foreach ($report as $r) { $test = $r->getData()->rdfsResource; } $label = __("Benchmark test"); $deliveryClass = new \core_kernel_classes_Class('http://www.tao.lu/Ontologies/TAODelivery.rdf#AssembledDelivery'); $report = \oat\taoDeliveryRdf\model\SimpleDeliveryFactory::create($deliveryClass, $test, $label); $delivery = $report->getData(); $property = new \core_kernel_classes_Property(PROPERTY_GROUP_DELVIERY); $group->setPropertyValue($property, $delivery); echo 'Test successfully imported.' . PHP_EOL;
* 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); * */ /* * This post-installation script creates a fodler for the QTI Tests */ $dataPath = FILES_PATH . 'taoQtiTest' . DIRECTORY_SEPARATOR . 'testData' . DIRECTORY_SEPARATOR; if (file_exists($dataPath)) { helpers_File::emptyDirectory($dataPath); } $serviceManager = oat\oatbox\service\ServiceManager::getServiceManager(); $fsService = $serviceManager->get(oat\oatbox\filesystem\FileSystemService::SERVICE_ID); $fsService->createFileSystem('taoQtiTest'); $serviceManager->register(oat\oatbox\filesystem\FileSystemService::SERVICE_ID, $fsService); taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestFileSystem('taoQtiTest');
/** * Copy the resources (e.g. images) of the test to the private compilation directory. */ protected function copyPrivateResources() { $testService = taoQtiTest_models_classes_QtiTestService::singleton(); $testPath = $testService->getTestContent($this->getResource())->getAbsolutePath(); $subContent = tao_helpers_File::scandir($testPath, array('recursive' => false, 'absolute' => true)); $privateDirPath = $this->getPrivateDirectory()->getPath(); // Recursive copy of each root level resources. foreach ($subContent as $subC) { tao_helpers_File::copy($subC, $privateDirPath . basename($subC)); } // Append the qti_base.css to copied files. $ds = DIRECTORY_SEPARATOR; $qtiBaseStylesheetPath = dirname(__FILE__) . $ds . '..' . $ds . '..' . $ds . 'views' . $ds . 'css' . $ds . 'qti_base.css'; $qtiBaseStylesheetDestPath = $privateDirPath . trim($this->getExtraPath(), $ds) . $ds . 'qti_base.css'; tao_helpers_File::copy($qtiBaseStylesheetPath, $qtiBaseStylesheetDestPath); }
/** * Copy the resources (e.g. images) of the test to the private compilation directory. */ protected function copyPrivateResources() { $testService = taoQtiTest_models_classes_QtiTestService::singleton(); $testPath = $testService->getTestContent($this->getResource())->getAbsolutePath(); $subContent = tao_helpers_File::scandir($testPath, array('recursive' => false, 'absolute' => true)); $privateDirPath = $this->getPrivateDirectory()->getPath(); // Recursive copy of each root level resources. foreach ($subContent as $subC) { tao_helpers_File::copy($subC, $privateDirPath . basename($subC)); } }
/** * Fetch assessment item data * * @return array */ protected function getAssessmentData() { if (empty($this->assessmentItemData)) { $xml = \taoQtiTest_models_classes_QtiTestService::singleton()->getDoc($this->getResource($this->assessmentUri)); $testPartCollection = $xml->getDocumentComponent()->getComponentsByClassName(self::TEST_PART); /** @var TestPart $testPart */ foreach ($testPartCollection as $testPart) { $sectionCollection = $testPart->getAssessmentSections(); /** @var AssessmentSection $section */ foreach ($sectionCollection as $section) { $itemCollection = $section->getComponentsByClassName(self::TEST_ITEM); $order = 1; /** @var AssessmentItemRef $item */ foreach ($itemCollection as $item) { $this->assessmentItemData[$item->getHref()] = [self::TEST_PART => $testPart->getIdentifier(), self::TEST_SECTION => $section->getIdentifier(), self::ITEM_SHUFFLE => is_null($section->getOrdering()) ? 0 : (int) $section->getOrdering()->getShuffle(), self::ITEM_ORDER => $order]; $order++; } } } } return $this->assessmentItemData; }
/** * Clone a QTI Test Resource. * * @param \core_kernel_classes_Resource $source The resource to be cloned. * @param \core_kernel_classes_Resource $destination An existing resource to be filled as the clone of $source. */ public function cloneContent(\core_kernel_classes_Resource $source, \core_kernel_classes_Resource $destination) { $service = \taoQtiTest_models_classes_QtiTestService::singleton(); $existingDir = $service->getQtiTestDir($source); $destinationDir = $service->getQtiTestDir($destination, false); if ($existingDir->exists()) { $iterator = $existingDir->getFlyIterator(Directory::ITERATOR_FILE | Directory::ITERATOR_RECURSIVE); /** @var File $file */ foreach ($iterator as $file) { $destinationDir->getFile($existingDir->getRelPath($file))->write($file->readStream()); } } else { \common_Logger::w('Test "' . $source->getUri() . '" had no content, nothing to clone'); } }