Best Atoum code snippet using engine.setVersion
Updater.php
Source:Updater.php
...105 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');106 $config = $extension->getConfig('testRunner');107 $config['test-session'] = $className;108 $extension->setConfig('testRunner', $config);109 $this->setVersion('2.25.0');110 }111 if ($this->isVersion('2.25.0')) {112 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');113 $config = $extension->getConfig('testRunner');114 $config['plugins']['overlay']['full'] = false;115 $extension->setConfig('testRunner', $config);116 $this->setVersion('2.26.0');117 }118 $this->skip('2.26.0', '2.27.0');119 if ($this->isVersion('2.27.0')) {120 $serviceExtension = 'taoQtiTest';121 $serviceController = 'Runner';122 try {123 $deliveryConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoDelivery')->getConfig('testRunner');124 if ($deliveryConfig) {125 $serviceExtension = $deliveryConfig['serviceExtension'];126 $serviceController = $deliveryConfig['serviceController'];127 }128 } catch(\common_ext_ExtensionException $e) {129 }130 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');131 $config = $extension->getConfig('testRunner');132 $config['bootstrap'] = [133 'serviceExtension' => $serviceExtension,134 'serviceController' => $serviceController,135 'communication' => [136 'enabled' => false,137 'type' => 'poll',138 'extension' => null,139 'controller' => null,140 'action' => 'messages',141 'service' => null,142 'params' => []143 ]144 ];145 $extension->setConfig('testRunner', $config);146 try {147 $this->getServiceManager()->get(QtiCommunicationService::CONFIG_ID);148 } catch (ServiceNotFoundException $e) {149 $service = new QtiCommunicationService();150 $service->setServiceManager($this->getServiceManager());151 $this->getServiceManager()->register(QtiCommunicationService::CONFIG_ID, $service);152 }153 $this->setVersion('2.28.0');154 }155 if ($this->isVersion('2.28.0')) {156 $testRunnerConfig = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('testRunner');157 if (array_key_exists('timerWarning', $testRunnerConfig)) {158 foreach ($testRunnerConfig['timerWarning'] as &$value) {159 if ($value !== null && is_int($value)) {160 $value = [$value => 'warning'];161 }162 }163 \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->setConfig('testRunner', $testRunnerConfig);164 }165 $this->setVersion('2.29.0');166 }167 if ($this->isVersion('2.29.0')) {168 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');169 $config = $extension->getConfig('testRunner');170 $config['bootstrap']['timeout'] = 0;171 $extension->setConfig('testRunner', $config);172 $this->setVersion('2.30.0');173 }174 if ($this->isVersion('2.30.0')) {175 try {176 $service = $this->getServiceManager()->get(QtiCommunicationService::CONFIG_ID);177 } catch (ServiceNotFoundException $e) {178 $service = new QtiCommunicationService();179 }180 $service->setServiceManager($this->getServiceManager());181 $service->attachChannel(new TestStateChannel(), QtiCommunicationService::CHANNEL_TYPE_OUTPUT);182 $this->getServiceManager()->register(QtiCommunicationService::CONFIG_ID, $service);183 $this->setVersion('2.31.0');184 }185 if ($this->isVersion('2.31.0')) {186 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');187 $config = $extension->getConfig('testRunner');188 if (!isset($config['bootstrap']) || (isset($config['bootstrap']['timeout']) && count($config['bootstrap']) == 1)) {189 $config['bootstrap'] = array_merge($config['bootstrap'], [190 'serviceExtension' => 'taoQtiTest',191 'serviceController' => 'Runner',192 'communication' => [193 'enabled' => false,194 'type' => 'poll',195 'extension' => null,196 'controller' => null,197 'action' => 'messages',198 'service' => null,199 'params' => []200 ],201 ]);202 $extension->setConfig('testRunner', $config);203 }204 $this->setVersion('2.31.1');205 }206 $this->skip('2.31.1', '3.0.0');207 if ($this->isVersion('3.0.0')) {208 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');209 $config = $extension->getConfig('testRunner');210 $config['enable-allow-skipping'] = false;211 $extension->setConfig('testRunner', $config);212 $this->setVersion('3.1.0');213 }214 $this->skip('3.1.0', '3.4.0');215 if ($this->isVersion('3.4.0')) {216 $ext = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');217 $uri = $ext->getConfig(\taoQtiTest_models_classes_QtiTestService::CONFIG_QTITEST_FILESYSTEM);218 $fileResource = new \core_kernel_classes_Resource($uri);219 if ($fileResource->exists()) {220 $fileSystem = $fileResource->getOnePropertyValue(new \core_kernel_classes_Property('http://www.tao.lu/Ontologies/generis.rdf#FileRepository'));221 if (!empty($fileSystem) && $fileSystem instanceof \core_kernel_classes_Literal) {222 \taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestFileSystem((string) $fileSystem);223 }224 }225 $this->setVersion('4.0.0');226 }227 $this->skip('4.0.0', '4.6.0');228 if ($this->isVersion('4.6.0')) {229 $registry = TestRunnerClientConfigRegistry::getRegistry();230 $runnerConfig = $registry->get(TestRunnerClientConfigRegistry::RUNNER);231 if(isset($runnerConfig['plugins']) && is_array($runnerConfig['plugins']) ) {232 foreach($runnerConfig['plugins'] as $plugin){233 //if the plugin is registered234 if($plugin['module'] == 'taoQtiTest/runner/plugins/controls/disableRightClick'){235 //we migrate the category236 $registry->removePlugin('taoQtiTest/runner/plugins/controls/disableRightClick', 'controls', null);237 $registry->registerPlugin('taoQtiTest/runner/plugins/security/disableRightClick', 'security', null);238 break;239 }240 }241 }242 $this->setVersion('4.7.0');243 }244 $this->skip('4.7.0', '4.8.2');245 if ($this->isVersion('4.8.2')) {246 //regsiter the core plugins into taoTests247 $registerCorePlugins = new RegisterTestRunnerPlugins();248 $registerCorePlugins([]);249 $registry = PluginRegistry::getRegistry();250 //list the installed plugins251 $oldRegistry = TestRunnerClientConfigRegistry::getRegistry();252 $runnerConfig = $oldRegistry->get(TestRunnerClientConfigRegistry::RUNNER);253 if(isset($runnerConfig['plugins']) && is_array($runnerConfig['plugins']) ) {254 foreach($runnerConfig['plugins'] as $plugin){255 //if they are not yet in the config, migrate them automatically256 if( ! $registry->isRegistered($plugin['module']) ) {257 $pluginId = basename($plugin['module']);258 $pluginName = ucfirst(join(preg_split('/(?=[A-Z])/', $pluginId), ' '));259 $registry->register(TestPlugin::fromArray([260 'id' => $pluginId,261 'name' => $pluginName,262 'module' => $plugin['module'],263 'category' => $plugin['category'],264 'position' => $plugin['position'],265 'active' => true266 ]));267 }268 }269 }270 //then remove the old config271 $registry->remove(TestRunnerClientConfigRegistry::RUNNER);272 $registry->remove(TestRunnerClientConfigRegistry::RUNNER_PROD);273 $this->setVersion('5.0.0');274 }275 $this->skip('5.0.0', '5.4.0');276 if ($this->isVersion('5.4.0')) {277 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');278 $config = $extension->getConfig('testRunner');279 $config['plugins']['collapser'] = [280 'collapseTools' => true,281 'collapseNavigation' => false,282 'hover' => false283 ];284 $extension->setConfig('testRunner', $config);285 $this->setVersion('5.5.0');286 }287 $this->skip('5.5.0', '5.5.3');288 if ($this->isVersion('5.5.3')) {289 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');290 $config = $extension->getConfig('testRunner');291 $config['force-branchrules'] = false;292 $config['force-preconditions'] = false;293 $config['path-tracking'] = false;294 $extension->setConfig('testRunner', $config);295 $this->setVersion('5.6.0');296 }297 if ($this->isVersion('5.6.0')) {298 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');299 $config = $extension->getConfig('testRunner');300 $config['always-allow-jumps'] = false;301 $extension->setConfig('testRunner', $config);302 $this->setVersion('5.7.0');303 }304 $this->skip('5.7.0', '5.8.4');305 if ($this->isVersion('5.8.4')) {306 OntologyUpdater::syncModels();307 $testModelService = new TestModelService(array(308 'exportHandlers' => array(309 new \taoQtiTest_models_classes_export_TestExport(),310 new \taoQtiTest_models_classes_export_TestExport22()311 ),312 'importHandlers' => array(313 new \taoQtiTest_models_classes_import_TestImport()314 )315 ));316 $testModelService->setServiceManager($this->getServiceManager());317 $this->getServiceManager()->register(TestModelService::SERVICE_ID, $testModelService);318 $this->setVersion('5.9.0');319 }320 $this->skip('5.9.0', '5.10.2');321 if ($this->isVersion('5.10.2')) {322 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');323 $config = $extension->getConfig('testRunner');324 $config['check-informational'] = false;325 $extension->setConfig('testRunner', $config);326 $this->setVersion('5.11.0');327 }328 if ($this->isVersion('5.11.0')) {329 $registry = PluginRegistry::getRegistry();330 $registry->register(TestPlugin::fromArray([331 'id' => 'modalFeedback',332 'name' => 'QTI modal feedbacks',333 'module' => 'taoQtiTest/runner/plugins/content/modalFeedback/modalFeedback',334 'description' => 'Display Qti modalFeedback element',335 'category' => 'content',336 'active' => true,337 'tags' => [ 'core', 'qti', 'required' ]338 ]));339 $this->setVersion('5.12.0');340 }341 $this->skip('5.12.0', '5.16.2');342 if ($this->isVersion('5.16.2')) {343 $service = new TestExporter();344 $service->setServiceManager($this->getServiceManager());345 $this->getServiceManager()->register(TestMetadataExporter::SERVICE_ID, $service);346 $this->setVersion('5.17.0');347 }348 $this->skip('5.17.0', '5.17.3');349 if ($this->isVersion('5.17.3')) {350 \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->setConfig('TestCompiler', array(351 'enable-category-rules-generation' => false352 ));353 $categoryRulesService = new TestCategoryRulesService(354 array(355 'score-variable-identifier' => 'SCORE',356 'weight-identifier' => 'WEIGHT',357 'category-exclusions' => array(358 '/x-tao-/'359 ),360 'flags' => TestCategoryRulesGenerator::COUNT | TestCategoryRulesGenerator::CORRECT | TestCategoryRulesGenerator::SCORE361 )362 );363 $categoryRulesService->setServiceManager($this->getServiceManager());364 $this->getServiceManager()->register(TestCategoryRulesService::SERVICE_ID, $categoryRulesService);365 $this->setVersion('5.18.0');366 }367 $this->skip('5.18.0', '5.23.0');368 if ($this->isVersion('5.23.0')) {369 $ext = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');370 $uri = $ext->getConfig(\taoQtiTest_models_classes_QtiTestService::CONFIG_QTITEST_FILESYSTEM);371 if (!is_string($uri)) {372 if (is_object($uri) && $uri instanceof \core_kernel_classes_Resource) {373 \taoQtiTest_models_classes_QtiTestService::singleton()->setQtiTestFileSystem($uri->getUri());374 } else {375 throw new \common_exception_InconsistentData('Invalid qti test storage directory configuration');376 }377 }378 $this->setVersion('5.23.1');379 }380 $this->skip('5.23.1', '5.25.1');381 if ($this->isVersion('5.25.1')) {382 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');383 $config = $extension->getConfig('testRunner');384 $config['test-taker-unanswered-items-message'] = true;385 $extension->setConfig('testRunner', $config);386 $this->setVersion('5.26.0');387 }388 if ($this->isVersion('5.26.0')) {389 $registry = PluginRegistry::getRegistry();390 $registry->register(TestPlugin::fromArray([391 'id' => 'documentViewer',392 'name' => 'Document Viewer',393 'module' => 'taoQtiTest/runner/plugins/tools/documentViewer/documentViewer',394 'description' => 'Display a document as requested by an event',395 'category' => 'tools',396 'active' => false,397 'tags' => []398 ]));399 $this->setVersion('5.27.0');400 }401 if ($this->isVersion('5.27.0')) {402 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');403 $config = $extension->getConfig('testRunner');404 $config['keep-timer-up-to-timeout'] = false;405 $extension->setConfig('testRunner', $config);406 $this->setVersion('5.28.0');407 }408 $this->skip('5.28.0', '5.30.1');409 if ($this->isVersion('5.30.1')) {410 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');411 $config = $extension->getConfig('testRunner');412 $config['allow-shortcuts'] = true;413 $extension->setConfig('testRunner', $config);414 $this->setVersion('5.31.0');415 }416 $this->skip('5.31.0', '5.31.1');417 if ($this->isVersion('5.31.1')) {418 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');419 $config = $extension->getConfig('testRunner');420 $config['shortcuts'] = [421 'calculator' => [422 'toggle' => 'C',423 ],424 'zoom' => [425 'in' => 'I',426 'out' => 'O'427 ],428 'comment' => [429 'toggle' => 'A',430 ],431 'itemThemeSwitcher' => [432 'toggle' => 'T',433 ],434 'review' => [435 'toggle' => 'R',436 'flag' => 'M'437 ]438 ];439 $extension->setConfig('testRunner', $config);440 $this->setVersion('5.32.0');441 }442 $this->skip('5.32.0', '5.32.1');443 if ($this->isVersion('5.32.1')) {444 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');445 $config = $extension->getConfig('testRunner');446 $config['shortcuts']['next'] = [447 'trigger' => 'J',448 ];449 $config['shortcuts']['previous'] = [450 'trigger' => 'K',451 ];452 $extension->setConfig('testRunner', $config);453 $this->setVersion('5.33.0');454 }455 if ($this->isVersion('5.33.0')) {456 $registry = PluginRegistry::getRegistry();457 $registry->register(TestPlugin::fromArray([458 'id' => 'responsesAccess',459 'name' => 'Shortcuts to access the item responses',460 'module' => 'taoQtiTest/runner/plugins/content/accessibility/responsesAccess',461 'description' => 'Provide a way to navigate between item responses using the keyboard',462 'category' => 'content',463 'active' => true,464 'tags' => [ 'core', 'qti' ]465 ]));466 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');467 $config = $extension->getConfig('testRunner');468 $config['shortcuts']['responsesAccess'] = [469 'previous' => 'Shift+Tab',470 'next' => 'Tab'471 ];472 $extension->setConfig('testRunner', $config);473 $this->setVersion('5.34.0');474 }475 $this->skip('5.34.0', '5.36.0');476 if ($this->isVersion('5.36.0')) {477 $registry = PluginRegistry::getRegistry();478 $registry->register(TestPlugin::fromArray([479 'id' => 'highlighter',480 'name' => 'Text Highlighter',481 'module' => 'taoQtiTest/runner/plugins/tools/highlighter/plugin',482 'description' => 'Allows the test taker to highlight text',483 'category' => 'tools',484 'active' => true,485 'tags' => []486 ]));487 $this->setVersion('5.37.0');488 }489 if ($this->isVersion('5.37.0')) {490 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');491 $config = $extension->getConfig('testRunner');492 $config['shortcuts']['itemThemeSwitcher'] = [493 'toggle' => 'T',494 'loop' => 'Y',495 'select' => 'U'496 ];497 $extension->setConfig('testRunner', $config);498 $this->setVersion('5.37.1');499 }500 $this->skip('5.37.1', '5.38.1');501 if ($this->isVersion('5.38.1')) {502 $registry = PluginRegistry::getRegistry();503 $registry->register(TestPlugin::fromArray([504 'id' => 'highlighter',505 'name' => 'Text Highlighter',506 'module' => 'taoQtiTest/runner/plugins/tools/highlighter/plugin',507 'description' => 'Allows the test taker to highlight text',508 'category' => 'tools',509 'active' => false,510 'tags' => []511 ]));512 $this->setVersion('5.38.2');513 }514 $this->skip('5.38.2', '5.40.0');515 if ($this->isVersion('5.40.0')) {516 $registry = PluginRegistry::getRegistry();517 $registry->remove('taoQtiTest/runner/plugins/content/accessibility/responsesAccess');518 $registry->register(TestPlugin::fromArray([519 'id' => 'keyNavigation',520 'name' => 'Using key to navigate item content',521 'module' => 'taoQtiTest/runner/plugins/content/accessibility/keyNavigation',522 'description' => 'Provide a way to navigate within item with the keyboard',523 'category' => 'content',524 'active' => true,525 'tags' => [ 'core', 'qti' ]526 ]));527 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');528 $config = $extension->getConfig('testRunner');529 unset($config['shortcuts']['responsesAccess']);530 $config['shortcuts']['keyNavigation'] = [531 'previous' => 'Shift+Tab',532 'next' => 'Tab'533 ];534 $extension->setConfig('testRunner', $config);535 $this->setVersion('5.41.0');536 }537 if ($this->isVersion('5.41.0')) {538 $fsService = $this->getServiceManager()->get(FileSystemService::SERVICE_ID);539 $fsService->createFileSystem('taoQtiTestSessionFilesystem');540 $this->getServiceManager()->register(FileSystemService::SERVICE_ID, $fsService);541 $service = new QtiFlysystemFileManager();542 $service->setServiceManager($this->getServiceManager());543 $this->getServiceManager()->register(QtiFlysystemFileManager::SERVICE_ID, $service);544 $this->setVersion('5.42.0');545 }546 $this->skip('5.42.0', '5.44.0');547 if ($this->isVersion('5.44.0')) {548 $registry = PluginRegistry::getRegistry();549 $registry->register(TestPlugin::fromArray([550 'id' => 'magnifier',551 'name' => 'Magnifier',552 'module' => 'taoQtiTest/runner/plugins/tools/magnifier/magnifier',553 'description' => 'Gives student access to a magnification tool',554 'category' => 'tools',555 'active' => false,556 'tags' => [ ]557 ]));558 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');559 $config = $extension->getConfig('testRunner');560 $config['shortcuts']['magnifier'] = [561 'toggle' => 'L',562 'in' => 'Shift+I',563 'out' => 'Shift+O',564 'close' => 'esc'565 ];566 $config['plugins']['magnifier'] = [567 'zoomMin' => 2,568 'zoomMax' => 8,569 'zoomStep' => .5570 ];571 $extension->setConfig('testRunner', $config);572 $this->setVersion('5.45.0');573 }574 $this->skip('5.45.0', '5.46.2');575 if ($this->isVersion('5.46.2')) {576 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');577 $config = $extension->getConfig('testRunner');578 $config['shortcuts']['dialog'] = [579 'accept' => 'Enter',580 'reject' => 'Esc'581 ];582 $extension->setConfig('testRunner', $config);583 $this->setVersion('5.47.0');584 }585 if ($this->isVersion('5.47.0')) {586 $qtiTest = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');587 $config = $qtiTest->getConfig('testRunner');588 $config = array_merge($config, array(589 'test-taker-review-show-legend' => true,590 'test-taker-review-default-open' => true,591 ));592 $qtiTest->setConfig('testRunner', $config);593 $this->setVersion('5.48.0');594 }595 $this->skip('5.48.0', '5.49.0');596 if ($this->isVersion('5.49.0')) {597 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');598 $config = $extension->getConfig('testRunner');599 $config['shortcuts']['itemThemeSwitcher'] = [600 'toggle' => 'T',601 'up' => 'ArrowUp',602 'down' => 'ArrowDown',603 'select' => 'Enter'604 ];605 $extension->setConfig('testRunner', $config);606 $this->setVersion('5.49.1');607 }608 if ($this->isVersion('5.49.1')) {609 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');610 $config = $extension->getConfig('testRunner');611 $config['test-taker-review-use-title'] = true;612 $extension->setConfig('testRunner', $config);613 $this->setVersion('5.50.0');614 }615 if ($this->isVersion('5.50.0')) {616 $registry = PluginRegistry::getRegistry();617 if (!$registry->isRegistered('taoQtiTest/runner/plugins/tools/magnifier/magnifier')) {618 $registry->register(TestPlugin::fromArray([619 'id' => 'magnifier',620 'name' => 'Magnifier',621 'module' => 'taoQtiTest/runner/plugins/tools/magnifier/magnifier',622 'description' => 'Gives student access to a magnification tool',623 'category' => 'tools',624 'active' => false,625 'tags' => [ ]626 ]));627 }628 $this->setVersion('5.50.1');629 }630 $this->skip('5.50.1', '5.58.3');631 if ($this->isVersion('5.58.3')) {632 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');633 $config = $extension->getConfig('testRunner');634 $config['shortcuts']['area-masking'] = [635 'toggle' => 'Y'636 ];637 $extension->setConfig('testRunner', $config);638 $this->setVersion('5.59.0');639 }640 $this->skip('5.59.0', '6.0.0');641 if($this->isVersion('6.0.0')){642 $registry = PluginRegistry::getRegistry();643 $registry->remove('taoQtiTest/runner/plugins/content/accessibility/responsesAccess');644 $registry->register(TestPlugin::fromArray([645 'id' => 'keyNavigation',646 'name' => 'Using key to navigate test runner',647 'module' => 'taoQtiTest/runner/plugins/content/accessibility/keyNavigation',648 'description' => 'Provide a way to navigate within the test runner with the keyboard',649 'category' => 'content',650 'active' => true,651 'tags' => [ 'core', 'qti' ]652 ]));653 $this->setVersion('6.1.0');654 }655 $this->skip('6.1.0', '6.3.0');656 if ($this->isVersion('6.3.0')) {657 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');658 $config = $extension->getConfig('testRunner');659 $config['shortcuts']['itemThemeSwitcher'] = [660 'toggle' => 'T'661 ];662 $extension->setConfig('testRunner', $config);663 $this->setVersion('6.3.1');664 }665 $this->skip('6.3.1', '6.4.3');666 if ($this->isVersion('6.4.3')) {667 $service = new QtiRunnerConfig();668 $service->setServiceManager($this->getServiceManager());669 $this->getServiceManager()->register(QtiRunnerConfig::SERVICE_ID, $service);670 $this->setVersion('6.5.0');671 }672 $this->skip('6.5.0', '6.9.0');673 if ($this->isVersion('6.9.0')) {674 //removes the shortcut from dialog675 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');676 $config = $extension->getConfig('testRunner');677 $config['shortcuts']['dialog'] = [];678 $extension->setConfig('testRunner', $config);679 $this->setVersion('6.10.0');680 }681 if ($this->isVersion('6.10.0')) {682 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');683 $config = $extension->getConfig('testRunner');684 $config['test-session-storage'] = '\taoQtiTest_helpers_TestSessionStorage';685 $extension->setConfig('testRunner', $config);686 $this->setVersion('6.11.0');687 }688 $this->skip('6.11.0', '6.13.0');689 if ($this->isVersion('6.13.0')) {690 /** @var ImportersService $importersService */691 $importersService = $this->getServiceManager()->get(ImportersService::SERVICE_ID);692 if ($importersService->hasOption(ImportersService::OPTION_IMPORTERS)) {693 $importers = $importersService->getOption(ImportersService::OPTION_IMPORTERS);694 } else {695 $importers = [];696 }697 $importers[QtiTestImporter::IMPORTER_ID] = QtiTestImporter::class;698 $importersService->setOption(ImportersService::OPTION_IMPORTERS, $importers);699 $this->getServiceManager()->register(ImportersService::SERVICE_ID, $importersService);700 $this->setVersion('6.14.0');701 }702 $this->skip('6.14.0', '6.16.0');703 if($this->isVersion('6.16.0')){704 // Register line reader plugin705 $registry = PluginRegistry::getRegistry();706 $registry->remove('taoQtiTest/runner/plugins/content/accessibility/responsesAccess');707 $registry->register(TestPlugin::fromArray([708 'id' => 'lineReader',709 'name' => 'Line Reader',710 'module' => 'taoQtiTest/runner/plugins/tools/lineReader/plugin',711 'description' => 'Display a customisable mask with a customisable hole in it!',712 'category' => 'tools',713 'active' => true,714 'tags' => [ ]715 ]));716 // Register line reader shortcut717 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');718 $config = $extension->getConfig('testRunner');719 $config['shortcuts']['line-reader'] = [720 'toggle' => 'G'721 ];722 $extension->setConfig('testRunner', $config);723 $this->setVersion('6.17.0');724 }725 $this->skip('6.17.0', '6.17.2');726 if ($this->isVersion('6.17.2')) {727 $this->getServiceManager()->register(ExtendedStateService::SERVICE_ID, new ExtendedStateService());728 $this->getServiceManager()->register(TestSessionService::SERVICE_ID, new TestSessionService());729 $this->getServiceManager()->register(QtiTestListenerService::SERVICE_ID, new QtiTestListenerService());730 $this->getServiceManager()->register(QtiRunnerMessageService::SERVICE_ID, new QtiRunnerMessageService());731 $this->runExtensionScript(SetupEventListeners::class);732 $this->setVersion(('6.18.0'));733 }734 $this->skip('6.18.0', '7.4.1');735 if($this->isVersion('7.4.1')){736 // Register item trace variables plugin737 $registry = PluginRegistry::getRegistry();738 $registry->remove('taoQtiTest/runner/plugins/controls/trace/itemTraceVariables');739 $registry->register(TestPlugin::fromArray([740 'id' => 'itemTraceVariables',741 'name' => 'Item trace variables',742 'module' => 'taoQtiTest/runner/plugins/controls/trace/itemTraceVariables',743 'description' => 'Send item trace variables',744 'category' => 'controls',745 'active' => false,746 'tags' => [ 'core', 'technical' ]747 ]));748 $this->setVersion('7.5.0');749 }750 $this->skip('7.5.0', '7.5.6');751 if ($this->isVersion('7.5.6')) {752 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');753 $config = $extension->getConfig('testRunner');754 $config['test-taker-review-display-subsection-title'] = true;755 $extension->setConfig('testRunner', $config);756 $this->setVersion('7.6.0');757 }758 $this->skip('7.6.0', '8.0.0');759 if($this->isVersion('8.0.0')){760 // Register answer masking plugin761 $registry = PluginRegistry::getRegistry();762 $registry->register(TestPlugin::fromArray([763 'id' => 'answerMasking',764 'name' => 'Answer Masking',765 'module' => 'taoQtiTest/runner/plugins/tools/answerMasking/plugin',766 'description' => 'Hide all answers of a choice interaction and allow revealing them',767 'category' => 'tools',768 'active' => true,769 'tags' => [ ]770 ]));771 // Register answer masking shortcut772 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');773 $config = $extension->getConfig('testRunner');774 $config['shortcuts']['answer-masking'] = [775 'toggle' => 'D'776 ];777 $extension->setConfig('testRunner', $config);778 $this->setVersion('8.1.0');779 }780 $this->skip('8.1.0', '9.1.3');781 if($this->isVersion('9.1.3')){782 $registry = PluginRegistry::getRegistry();783 foreach($registry->getMap() as $module => $plugin){784 if(preg_match("/^taoQtiTest/", $module) && is_null($plugin['bundle'])){785 $plugin['bundle'] = 'taoQtiTest/loader/testPlugins.min';786 $registry->register(TestPlugin::fromArray($plugin));787 }788 }789 $this->setVersion('9.2.0');790 }791 $this->skip('9.2.0', '9.3.2');792 if ($this->isVersion('9.3.2')) {793 if (!$this->getServiceManager()->has(TestCategoryPresetProvider::SERVICE_ID)) {794 $this->getServiceManager()->register(TestCategoryPresetProvider::SERVICE_ID, new TestCategoryPresetProvider());795 }796 $this->setVersion('9.3.3');797 }798 $this->skip('9.3.3', '9.5.0');799 // display 'item x' instead of 'item x of y' in the progress bar800 if ($this->isVersion('9.5.0')) {801 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');802 $config = $extension->getConfig('testRunner');803 $config['progress-indicator-show-total'] = true;804 $extension->setConfig('testRunner', $config);805 $this->setVersion('9.6.0');806 }807 $this->skip('9.6.0', '9.9.1');808 if ($this->isVersion('9.9.1')) {809 $registry = TestCategoryPresetRegistry::getRegistry();810 $registry->set('taoQtiTest', '\oat\taoQtiTest\models\QtiCategoryPresetProvider');811 $this->setVersion('9.10.0');812 }813 $this->skip('9.10.0', '9.11.2');814 if ($this->isVersion('9.11.2')) {815 $testModelService = $this->getServiceManager()->get(TestModelService::SERVICE_ID);816 $exportHandlers = $testModelService->getOption('exportHandlers');817 array_unshift($exportHandlers, new TestMetadataByClassExportHandler());818 $testModelService->setOption('exportHandlers', $exportHandlers);819 $this->getServiceManager()->register(TestModelService::SERVICE_ID, $testModelService);820 $this->setVersion('9.12.0');821 }822 $this->skip('9.12.0', '9.14.1');823 if ($this->isVersion('9.14.1')) {824 /* deprecated as of 25.8.0825 $testModelService = $this->getServiceManager()->get(TestModelService::SERVICE_ID);826 $testModelService->setOption('testCompilerClass', 'taoQtiTest_models_classes_QtiTestCompiler');827 $this->getServiceManager()->register(TestModelService::SERVICE_ID, $testModelService);828 */829 $this->setVersion('9.15.0');830 }831 $this->skip('9.15.0', '9.17.0');832 if ($this->isVersion('9.17.0')) {833 $this->getServiceManager()->register(SectionPauseService::SERVICE_ID, new SectionPauseService());834 $this->setVersion('9.18.0');835 }836 $this->skip('9.18.0', '9.19.0');837 if( $this->isVersion('9.19.0') ){838 $registry = PluginRegistry::getRegistry();839 $registry->register(TestPlugin::fromArray([840 'id' => 'preventSkipping',841 'name' => 'Prevent Skipping',842 'module' => 'taoQtiTest/runner/plugins/navigation/preventSkipping',843 'bundle' => 'taoQtiTest/loader/testPlugins.min',844 'description' => 'Prevent to submit empty responses',845 'category' => 'navigation',846 'active' => true,847 'tags' => [ 'core', 'qti' ]848 ]));849 $this->setVersion('10.0.0');850 }851 if ($this->isVersion('10.0.0')) {852 $service = new QtiRunnerMap();853 $this->getServiceManager()->propagate($service);854 $this->getServiceManager()->register(QtiRunnerMap::SERVICE_ID, $service);855 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');856 $config = $extension->getConfig('testRunner');857 $config['item-cache-size'] = 3;858 $extension->setConfig('testRunner', $config);859 $this->setVersion('10.1.0');860 }861 $this->skip('10.1.0', '10.3.0');862 if ($this->isVersion('10.3.0')) {863 $registry = DeliveryContainerRegistry::getRegistry();864 $registry->setServiceLocator($this->getServiceManager());865 $registry->registerContainerType('qtiTest', new QtiTestDeliveryContainer());866 $this->setVersion('10.4.0');867 }868 $this->skip('10.4.0', '10.5.1');869 if ($this->isVersion('10.5.1')) {870 $registry = PluginRegistry::getRegistry();871 $registry->remove('taoQtiTest/runner/plugins/tools/highlighter/plugin');872 $registry->remove('taoQtiTest/runner/plugins/tools/magnifier/magnifier');873 $registry->register(TestPlugin::fromArray([874 'id' => 'highlighter',875 'name' => 'Text Highlighter',876 'module' => 'taoQtiTest/runner/plugins/tools/highlighter/plugin',877 'bundle' => 'taoQtiTest/loader/testPlugins.min',878 'description' => 'Allows the test taker to highlight text',879 'category' => 'tools',880 'active' => true,881 'tags' => [ ]882 ]));883 $registry->register(TestPlugin::fromArray([884 'id' => 'magnifier',885 'name' => 'Magnifier',886 'module' => 'taoQtiTest/runner/plugins/tools/magnifier/magnifier',887 'bundle' => 'taoQtiTest/loader/testPlugins.min',888 'description' => 'Gives student access to a magnification tool',889 'category' => 'tools',890 'active' => true,891 'tags' => [ ]892 ]));893 $registry->register(TestPlugin::fromArray([894 'id' => 'eliminator',895 'name' => 'Eliminate choices',896 'module' => 'taoQtiTest/runner/plugins/tools/answerElimination/eliminator',897 'bundle' => 'taoQtiTest/loader/testPlugins.min',898 'description' => 'Allows student to eliminate choices',899 'category' => 'tools',900 'active' => true,901 'tags' => [ ]902 ]));903 $registry->register(TestPlugin::fromArray([904 'id' => 'area-masking',905 'name' => 'Area Masking',906 'module' => 'taoQtiTest/runner/plugins/tools/areaMasking/areaMasking',907 'bundle' => 'taoQtiTest/loader/testPlugins.min',908 'description' => 'Mask areas of the item',909 'category' => 'tools',910 'active' => true,911 'tags' => [ ]912 ]));913 $this->setVersion('10.6.0');914 }915 if ($this->isVersion('10.6.0')) {916 // Install the synchronisation service917 $this->runExtensionScript(SetSynchronisationService::class);918 // Install the Sync Channel919 $this->runExtensionScript(SyncChannelInstaller::class);920 $this->setVersion('10.7.0');921 }922 $this->skip('10.7.0', '10.10.0');923 if ($this->isVersion('10.10.0')) {924 $qtiListenerService = $this->getServiceManager()->get(QtiTestListenerService::SERVICE_ID);925 $qtiListenerService->setOption(QtiTestListenerService::OPTION_ARCHIVE_EXCLUDE, []);926 $this->getServiceManager()->register(QtiTestListenerService::SERVICE_ID, $qtiListenerService);927 $this->setVersion('10.11.0');928 }929 if ($this->isVersion('10.11.0')) {930 $registry = PluginRegistry::getRegistry();931 $registry->remove('taoQtiTest/runner/plugins/tools/zoom');932 $registry->register(TestPlugin::fromArray([933 'id' => 'zoom',934 'name' => 'Zoom',935 'module' => 'taoQtiTest/runner/plugins/tools/zoom',936 'bundle' => 'taoQtiTest/loader/testPlugins.min',937 'description' => 'Allows Test-taker to zoom in and out the item content',938 'category' => 'tools',939 'active' => true,940 'tags' => [ ]941 ]));942 $this->setVersion('10.11.1');943 }944 $this->skip('10.11.1', '10.14.1');945 if ($this->isVersion('10.14.1')) {946 // Default is now EchoAdapt. This should change in the futre.947 $catService = new CatService([948 CatService::OPTION_ENGINE_ENDPOINTS => [949 'http://URL_SERVER/cat/api/' => [950 CatService::OPTION_ENGINE_CLASS => EchoAdaptEngine::class,951 CatService::OPTION_ENGINE_ARGS => []952 ]953 ]954 ]);955 $this->getServiceManager()->register(CatService::SERVICE_ID, $catService);956 $this->setVersion('10.15.0');957 }958 $this->skip('10.15.0', '10.15.2');959 if ($this->isVersion('10.15.2')) {960 $this->getServiceManager()->register(QtiRunnerRubric::SERVICE_ID, new QtiRunnerRubric());961 $this->setVersion('10.16.0');962 }963 if ($this->isVersion('10.16.0')) {964 OntologyUpdater::syncModels();965 $this->setVersion('10.17.0');966 }967 $this->skip('10.17.0', '11.0.0');968 if ($this->isVersion('11.0.0')) {969 $registerCreatorService = new RegisterCreatorServices();970 $registerCreatorService->setServiceLocator($this->getServiceManager());971 $registerCreatorService([]);972 $this->setVersion('11.1.0');973 }974 $this->skip('11.1.0', '11.5.1');975 if ($this->isVersion('11.5.1')) {976 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');977 $config = $extension->getConfig('testRunner');978 $config['enable-validate-responses'] = false;979 $extension->setConfig('testRunner', $config);980 $registry = PluginRegistry::getRegistry();981 $registry->remove('taoQtiTest/runner/plugins/navigation/preventSkipping');982 $registry->register(TestPlugin::fromArray([983 'id' => 'allowSkipping',984 'name' => 'Allow Skipping',985 'module' => 'taoQtiTest/runner/plugins/navigation/allowSkipping',986 'bundle' => 'taoQtiTest/loader/testPlugins.min',987 'description' => 'Allow submission of null/default responses',988 'category' => 'navigation',989 'active' => true,990 'tags' => [ 'core', 'qti' ]991 ]));992 $registry->register(TestPlugin::fromArray([993 'id' => 'validateResponses',994 'name' => 'Validate Responses',995 'module' => 'taoQtiTest/runner/plugins/navigation/validateResponses',996 'bundle' => 'taoQtiTest/loader/testPlugins.min',997 'description' => 'Prevent submission of invalid responses',998 'category' => 'navigation',999 'active' => true,1000 'tags' => [ 'core', 'qti' ]1001 ]));1002 $this->setVersion('11.6.0');1003 }1004 $this->skip('11.6.0', '11.8.1');1005 if($this->isVersion('11.8.1')){1006 $registry = PluginRegistry::getRegistry();1007 $registry->register(TestPlugin::fromArray([1008 'id' => 'warnBeforeLeaving',1009 'name' => 'Warn before leaving',1010 'module' => 'taoQtiTest/runner/plugins/navigation/warnBeforeLeaving',1011 'bundle' => 'taoQtiTest/loader/testPlugins.min',1012 'description' => 'Warn the test taker when closing the browser',1013 'category' => 'navigation',1014 'active' => false, //registered by but activated1015 'tags' => [ ]1016 ]));1017 $this->setVersion('11.9.0');1018 }1019 $this->skip('11.9.0', '11.16.0');1020 if ($this->isVersion('11.16.0')) {1021 /** @var CatService $catService */1022 $catService = $this->getServiceManager()->get(CatService::SERVICE_ID);1023 $engines = $catService->getOption(CatService::OPTION_ENGINE_ENDPOINTS);1024 if (!isset($engines['http://YOUR_URL_OAUTH/cat/api/'])) {1025 $oauthOptions = [1026 CatService::OPTION_ENGINE_CLASS => EchoAdaptEngine::class,1027 CatService::OPTION_ENGINE_ARGS => [1028 CatService::OPTION_ENGINE_VERSION => 'v1.1',1029 CatService::OPTION_ENGINE_CLIENT => [1030 'class' => 'oat\taoOauth\model\OAuthClient',1031 'options' => [1032 'client_id' => '',1033 'client_secret' => '',1034 'resource_owner_details_url' => false,1035 'authorize_url' => false,1036 'http_client_options' => array(),1037 'token_url' => '',1038 'token_key' => '',1039 'tokenParameters' => array(1040 'audience' => ''1041 ),1042 'token_storage' => 'cache'1043 ]1044 ],1045 ]1046 ];1047 $engines['http://YOUR_URL_OAUTH/cat/api/'] = $oauthOptions;1048 $catService->setOption(CatService::OPTION_ENGINE_ENDPOINTS, $engines);1049 $this->getServiceManager()->register(CatService::SERVICE_ID, $catService);1050 }1051 $this->setVersion('12.0.0');1052 }1053 $this->skip('12.0.0', '13.1.0');1054 if ($this->isVersion('13.1.0')) {1055 $config = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->getConfig('TestCompiler');1056 $config['enable-rubric-block-stylesheet-scoping'] = true;1057 \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest')->setConfig('TestCompiler', $config);1058 $this->setVersion('13.2.0');1059 }1060 $this->skip('13.2.0', '14.1.4');1061 if($this->isVersion('14.1.4')) {1062 /** @var CreatorItems $creatorItemsService */1063 $creatorItemsService = $this->getServiceManager()->get(CreatorItems::SERVICE_ID);1064 $creatorItemsService->setOption(CreatorItems::ITEM_MODEL_SEARCH_OPTION, CreatorItems::ITEM_MODEL_QTI_URI);1065 $creatorItemsService->setOption(CreatorItems::ITEM_CONTENT_SEARCH_OPTION, '*');1066 $this->getServiceManager()->register(CreatorItems::SERVICE_ID, $creatorItemsService);1067 $this->setVersion('14.1.5');1068 }1069 $this->skip('14.1.5', '16.0.1');1070 if($this->isVersion('16.0.1')) {1071 // Update the synchronisation service1072 $this->runExtensionScript(SetSynchronisationService::class);1073 $this->setVersion('16.1.0');1074 }1075 $this->skip('16.1.0', '16.1.1');1076 if ($this->isVersion('16.1.1')) {1077 $this->getServiceManager()->register(1078 PhpCodeCompilationDataService::SERVICE_ID,1079 new PhpCodeCompilationDataService()1080 );1081 $this->setVersion('16.2.0');1082 }1083 $this->skip('16.2.0', '16.3.3');1084 if ($this->isVersion('16.3.3')) {1085 $qtiTimerFactory = new QtiTimerFactory([1086 QtiTimerFactory::OPTION_TIMER_CLASS => QtiTimer::class,1087 QtiTimerFactory::OPTION_STORAGE_CLASS => QtiTimeStorage::class,1088 QtiTimerFactory::OPTION_STORAGE_FORMAT_CLASS => QtiTimeStoragePackedFormat::class,1089 ]);1090 $this->getServiceManager()->register(QtiTimerFactory::SERVICE_ID, $qtiTimerFactory);1091 $this->setVersion('17.0.0');1092 }1093 $this->skip('17.0.0', '17.1.0');1094 if ($this->isVersion('17.1.0')) {1095 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');1096 $config = $extension->getConfig('testRunner');1097 $config['bootstrap']['communication']['syncActions'] = ['move', 'skip', 'storeTraceData', 'timeout', 'exitTest'];1098 $extension->setConfig('testRunner', $config);1099 $this->setVersion('17.2.0');1100 }1101 $this->skip('17.2.0', '17.5.1');1102 if ($this->isVersion('17.5.1')) {1103 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1104 $config = $extension->getConfig('testRunner');1105 $config['bootstrap']['communication']['syncActions'][] = 'getNextItemData';1106 $extension->setConfig('testRunner', $config);1107 /** @var SynchronisationService $synchronisationService */1108 $synchronisationService = $this->getServiceManager()->get(SynchronisationService::SERVICE_ID);1109 $actions = $synchronisationService->getAvailableActions();1110 $actions['getNextItemData'] = NextItemData::class;1111 $synchronisationService->setAvailableActions($actions);1112 $this->getServiceManager()->register(SynchronisationService::SERVICE_ID, $synchronisationService);1113 $this->setVersion('17.6.0');1114 }1115 $this->skip('17.6.0', '17.7.1');1116 if ($this->isVersion('17.7.1')) {1117 $registry = PluginRegistry::getRegistry();1118 $registry->register(1119 TestPlugin::fromArray(1120 [1121 'id' => 'collapser',1122 'name' => 'Collapser',1123 'module' => 'taoQtiTest/runner/plugins/content/responsiveness/collapser',1124 'description' => 'Reduce the size of the tools when the available space is not enough',1125 'category' => 'content',1126 'active' => true,1127 'tags' => [ 'core' ]1128 ]1129 )1130 );1131 $this->setVersion('17.8.0');1132 }1133 $this->skip('17.8.0', '17.9.0');1134 if ($this->isVersion('17.9.0')) {1135 $storageManager = new StorageManager();1136 $this->getServiceManager()->register(StorageManager::SERVICE_ID, $storageManager);1137 $this->setVersion('17.10.0');1138 }1139 $this->skip('17.10.0', '17.16.0');1140 if ($this->isVersion('17.16.0')) {1141 $synchronisationService = $this->getServiceManager()->get(SynchronisationService::SERVICE_ID);1142 $actions = $synchronisationService->getAvailableActions();1143 $actions['pause'] = Pause::class;1144 $synchronisationService->setAvailableActions($actions);1145 $this->getServiceManager()->register(SynchronisationService::SERVICE_ID, $synchronisationService);1146 $this->setVersion('17.17.0');1147 }1148 $this->skip('17.17.0', '17.17.6');1149 if ($this->isVersion('17.17.6')) {1150 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1151 $config = $extension->getConfig('testRunner');1152 $config['catEngineWarning'] = [1153 'echoDelayUpdate' => 15,1154 'echoPauseLimit' => 120,1155 'echoExceptionName' => 'CatEngine'1156 ];1157 $extension->setConfig('testRunner', $config);1158 $this->setVersion('17.18.0');1159 }1160 $this->skip('17.18.0', '17.18.2');1161 if ($this->isVersion('17.18.2')) {1162 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1163 $config = $extension->getConfig('testRunner');1164 unset($config['catEngineWarning']);1165 $extension->setConfig('testRunner', $config);1166 $this->setVersion('17.19.0');1167 }1168 $this->skip('17.19.0', '18.5.1');1169 if ($this->isVersion('18.5.1')) {1170 $registry = ProviderRegistry::getRegistry();1171 $registry->register(1172 TestProvider::fromArray(1173 [1174 'id' => 'qti',1175 'name' => 'QTI runner',1176 'module' => 'taoQtiTest/runner/provider/qti',1177 'bundle' => 'taoQtiTest/loader/qtiTestRunner.min',1178 'description' => 'QTI implementation of the test runner',1179 'category' => 'runner',1180 'active' => true,1181 'tags' => [ 'core', 'qti', 'runner' ]1182 ]1183 )1184 );1185 $this->setVersion('18.6.0');1186 }1187 $this->skip('18.6.0', '18.9.4');1188 if ($this->isVersion('18.9.4')) {1189 AclProxy::applyRule(new AccessRule('grant', 'http://www.tao.lu/Ontologies/TAOTest.rdf#TestsManagerRole', array('ext'=>'taoQtiTest', 'mod' => 'RestQtiTests')));1190 $this->setVersion('18.9.5');1191 }1192 $this->skip('18.9.5', '23.2.0');1193 if ($this->isVersion('23.2.0')) {1194 $registry = PluginRegistry::getRegistry();1195 if ($registry->isRegistered('taoQtiTest/runner/plugins/tools/textToSpeech/plugin')) {1196 $registry->remove('taoQtiTest/runner/plugins/tools/textToSpeech/plugin');1197 }1198 $this->setVersion('23.2.1');1199 }1200 $this->skip('23.2.1', '23.4.0');1201 if ($this->isVersion('23.4.0')) {1202 $extension = \common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiTest');1203 $config = $extension->getConfig('testRunner');1204 $config['guidedNavigation'] = false;1205 $extension->setConfig('testRunner', $config);1206 $registry = PluginRegistry::getRegistry();1207 $registry->remove('taoQtiTest/runner/plugins/controls/timer/timer');1208 $registry->register(TestPlugin::fromArray([1209 'id' => 'timer',1210 'name' => 'Timer indicator',1211 'module' => 'taoQtiTest/runner/plugins/controls/timer/plugin',1212 'bundle' => 'taoQtiTest/loader/testPlugins.min',1213 'description' => 'Add countdown when remaining time',1214 'category' => 'controls',1215 'active' => true,1216 'tags' => [ 'core', 'qti' ]1217 ]));1218 $this->setVersion('24.0.0');1219 }1220 $this->skip('24.0.0', '24.1.0');1221 if ($this->isVersion('24.1.0')) {1222 AclProxy::applyRule(new AccessRule('grant', TaoRoles::REST_PUBLISHER, array('ext'=>'taoQtiTest', 'mod' => 'RestQtiTests')));1223 $this->setVersion('24.2.0');1224 }1225 $this->skip('24.2.0', '24.7.0');1226 if ($this->isVersion('24.7.0')) {1227 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1228 $config = $extension->getConfig('testRunner');1229 $config['progress-indicator-renderer'] = 'percentage';1230 $config['progress-indicator-show-label'] = 'true';1231 // as the percentage indicator now takes care of the scope, ensure the legacy is respected1232 if ($config['progress-indicator'] == 'percentage') {1233 $config['progress-indicator-scope'] = 'test';1234 }1235 $extension->setConfig('testRunner', $config);1236 $this->setVersion('24.8.0');1237 }1238 $this->skip('24.8.0', '24.8.4');1239 if ($this->isVersion('24.8.4')) {1240 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1241 $config = $extension->getConfig('testRunner');1242 $config['progress-categories'] = [];1243 $extension->setConfig('testRunner', $config);1244 $this->setVersion('24.9.0');1245 }1246 $this->skip('24.9.0', '25.1.0');1247 if ($this->isVersion('25.1.0')) {1248 $registry = PluginRegistry::getRegistry();1249 $registry->register(TestPlugin::fromArray([1250 'id' => 'focusOnFirstField',1251 'name' => 'Focus on first form field',1252 'module' => 'taoQtiTest/runner/plugins/content/accessibility/focusOnFirstField',1253 'bundle' => 'taoQtiTest/loader/testPlugins.min',1254 'description' => 'Sets focus on first form field',1255 'category' => 'content',1256 'active' => true,1257 'tags' => []1258 ]));1259 $this->setVersion('25.2.0');1260 }1261 $this->skip('25.2.0', '25.5.1');1262 if ($this->isVersion('25.5.1')){1263 $timerLabel = new TimerLabelFormatterService([1264 TimerLabelFormatterService::OPTION_DEFAULT_TIMER_LABEL => 'Time Remaining'1265 ]);1266 $this->getServiceManager()->register(TimerLabelFormatterService::SERVICE_ID, $timerLabel);1267 $this->setVersion('25.6.0');1268 }1269 $this->skip('25.6.0', '25.7.2');1270 if ($this->isVersion('25.7.2')) {1271 /** @var TimerLabelFormatterService $timerLabel */1272 $timerLabel = $this->getServiceManager()->get(TimerLabelFormatterService::SERVICE_ID);1273 $timerLabel->setOption(TimerLabelFormatterService::OPTION_DEFAULT_TIMER_LABEL, 'timer_name_translation_token');1274 $this->getServiceManager()->register(TimerLabelFormatterService::SERVICE_ID, $timerLabel);1275 $this->setVersion('25.7.3');1276 }1277 $this->skip('25.7.3', '25.7.5');1278 if ($this->isVersion('25.7.5')) {1279 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1280 $config = $extension->getConfig('testRunner');1281 $config['enable-allow-skipping'] = true;1282 $extension->setConfig('testRunner', $config);1283 $this->setVersion('25.7.6');1284 }1285 $this->skip('25.7.6', '25.8.0');1286 if ($this->isVersion('25.8.0')) {1287 /** @var TaskLogInterface|ConfigurableService $taskLogService */1288 $taskLogService = $this->getServiceManager()->get(TaskLogInterface::SERVICE_ID);1289 $taskLogService->linkTaskToCategory(ImportQtiTest::class, TaskLogInterface::CATEGORY_IMPORT);1290 $this->getServiceManager()->register(TaskLogInterface::SERVICE_ID, $taskLogService);1291 $this->setVersion('25.9.0');1292 }1293 $this->skip('25.9.0', '25.9.2');1294 // test compiler settings refactoring1295 if ($this->isVersion('25.9.2')) {1296 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1297 $config = $extension->getConfig('TestCompiler');1298 $model = $this->getServiceManager()->get(TestModelService::SERVICE_ID);1299 $model->setOption(TestModelService::SUBSERVICE_COMPILATION, new CompilationService([1300 CompilationService::OPTION_RUBRIC_BLOCK_CSS_SCOPE => $config['enable-rubric-block-stylesheet-scoping']1301 ]));1302 $this->getServiceManager()->register(TestModelService::SERVICE_ID, $model);1303 $this->setVersion('25.10.0');1304 }1305 if ($this->isVersion('25.10.0')) {1306 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1307 $config = $extension->getConfig('testRunner');1308 $config['restore-timer-from-client'] = true;1309 $extension->setConfig('testRunner', $config);1310 $this->setVersion('25.10.1');1311 }1312 $this->skip('25.10.1', '26.1.1');1313 if ($this->isVersion('26.1.1')){1314 /** @var TimerLabelFormatterService $timerLabel */1315 $timerLabel = $this->getServiceManager()->get(TimerLabelFormatterService::SERVICE_ID);1316 $timerLabel->setOption(TimerLabelFormatterService::OPTION_DEFAULT_TIMER_LABEL, '');1317 $this->getServiceManager()->register(TimerLabelFormatterService::SERVICE_ID, $timerLabel);1318 $this->setVersion('26.1.2');1319 }1320 $this->skip('26.1.2', '29.6.1');1321 if ($this->isVersion('29.6.1')) {1322 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1323 $config = $extension->getConfig('testRunner');1324 $config['test-taker-review-skipahead'] = false;1325 $extension->setConfig('testRunner', $config);1326 $this->setVersion('29.7.0');1327 }1328 $this->skip('29.7.0', '29.7.3');1329 if ($this->isVersion('29.7.3')) {1330 $this->getServiceManager()->register(1331 ToolsStateStorage::SERVICE_ID,1332 new NoStorage([])1333 );1334 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1335 $config = $extension->getConfig('testRunner');1336 $config['tool-state-server-storage'] = [];1337 $extension->setConfig('testRunner', $config);1338 $this->setVersion('29.8.0');1339 }1340 $this->skip('29.8.0', '30.4.0');1341 if ($this->isVersion('30.4.0')) {1342 $registry = PluginRegistry::getRegistry();1343 $registry->register(TestPlugin::fromArray([1344 'id' => 'linearNextItemWarning',1345 'name' => 'Linear next item warning',1346 'module' => 'taoQtiTest/runner/plugins/navigation/next/linearNextItemWarning',1347 'bundle' => 'taoQtiTest/loader/testPlugins.min',1348 'description' => 'Displays a dialog before next item in linear test parts',1349 'category' => 'navigation',1350 'active' => false,1351 'tags' => [ ]1352 ]));1353 $extension = $this->getServiceManager()->get(\common_ext_ExtensionsManager::SERVICE_ID)->getExtensionById('taoQtiTest');1354 $config = $extension->getConfig('testRunner');1355 $config['force-enable-linear-next-item-warning'] = false;1356 $config['enable-linear-next-item-warning-checkbox'] = true;1357 $extension->setConfig('testRunner', $config);1358 $this->setVersion('30.5.0');1359 }1360 $this->skip('30.5.0', '30.5.3');1361 }1362}...
Browser.php
Source:Browser.php
...44 /**45 * Set the version of the browser46 * @param $version47 */48 public function setVersion($version) {49 $this->version = preg_replace('/[^0-9,.,a-z,A-Z-]/', '', $version);50 }51 /**52 * The name of the browser. All return types are from the class constants53 * @return string Name of the browser54 */55 public function getBrowser() {56 return $this->name;57 }58 /**59 * Set the name of the browser60 * @param $browser61 */62 public function setBrowser($browser) {63 $this->name = $browser;64 }65 /**66 * Get the engine name67 * @return string the engine name68 */69 public function getEngine() {70 return $this->engine;71 }72 /**73 * Set the engine name74 * @param string $engine the engine name75 */76 public function setEngine($engine) {77 $this->engine = $engine;78 }79 /**80 * Retrieve the discovered browser type81 * @return string82 */83 public function getBrowserType() {84 if ($this->isDesktop) {85 return self::BROWSER_IS_DESKTOP;86 }87 else if ($this->isMobile || $this->isTablet) {88 return self::BROWSER_IS_MOBILE;89 }90 else if ($this->isTv) {91 return self::BROWSER_IS_TV;92 }93 else if ($this->isRobot) {94 return self::BROWSER_IS_BOT;95 }96 return '';97 }98 /**99 * Routine to determine the browser type100 * @return bool101 */102 protected function checkBrowsers() {103 // Find engine104 $pattern = '#'.join('|', $this->getKnownEngines()).'#i';105 if (preg_match($pattern, $this->agent, $match)) {106 if (isset($match[0])) {107 $this->engine = $match[0];108 }109 }110 /**111 * well-known, well-used112 * Special Notes:113 * (1) Opera must be checked before FireFox due to the odd114 * user agents used in some older versions of Opera115 * (2) WebTV is strapped onto Internet Explorer so we must116 * check for WebTV before IE117 * (3) (deprecated) Galeon is based on Firefox and needs to be118 * tested before Firefox is tested119 * (4) OmniWeb is based on Safari so OmniWeb check must occur120 * before Safari121 * (5) Netscape 9+ is based on Firefox so Netscape checks122 * before FireFox are necessary123 */124 return125 $this->checkBrowserWebTv() ||126 $this->checkBrowserInternetExplorer() ||127 $this->checkBrowserOpera() ||128 $this->checkBrowserGaleon() ||129 $this->checkBrowserNetscapeNavigator9Plus() ||130 $this->checkBrowserFirefox() ||131 $this->checkBrowserChrome() ||132 $this->checkBrowserOmniWeb() ||133 // common mobile134 $this->checkBrowserAndroid() ||135 $this->checkBrowseriPad() ||136 $this->checkBrowseriPod() ||137 $this->checkBrowseriPhone() ||138 $this->checkBrowserBlackBerry() ||139 $this->checkBrowserNokia() ||140 // common bots141 $this->checkBrowserGoogleBot() ||142 $this->checkBrowserMSNBot() ||143 $this->checkBrowserBingBot() ||144 $this->checkBrowserSlurp() ||145 // check for facebook external hit when loading URL146 $this->checkFacebookExternalHit() ||147 // WebKit base check (post mobile and others)148 $this->checkBrowserSafari() ||149 // everyone else150 $this->checkBrowserNetPositive() ||151 $this->checkBrowserFirebird() ||152 $this->checkBrowserKonqueror() ||153 $this->checkBrowserIcab() ||154 $this->checkBrowserPhoenix() ||155 $this->checkBrowserAmaya() ||156 $this->checkBrowserLynx() ||157 $this->checkBrowserShiretoko() ||158 $this->checkBrowserIceCat() ||159 $this->checkBrowserIceweasel() ||160 $this->checkBrowserW3CValidator() ||161 $this->checkBrowserMozilla() /* Mozilla is such an open standard that you must check it last */162 ;163 }164 /**165 * Get known engines166 * @return array the engines167 */168 protected function getKnownEngines() {169 return [170 'gecko',171 'webkit',172 'trident',173 'presto',174 'khtml',175 'blink'176 ];177 }178 /**179 * Determine if the browser is Amaya or not (last updated 1.7)180 * @return boolean True if the browser is Amaya otherwise false181 */182 protected function checkBrowserAmaya() {183 if (stripos($this->agent, 'amaya') !== false) {184 $result = explode('/', stristr($this->agent, 'Amaya'));185 $version = explode(' ', $result[1]);186 $this->setVersion($version[0]);187 $this->name = self::BROWSER_AMAYA;188 return true;189 }190 return false;191 }192 /**193 * Determine if the browser is Android194 * @return bool195 */196 protected function checkBrowserAndroid() {197 if (stripos($this->agent, 'Android') !== false) {198 $result = explode(' ', stristr($this->agent, 'Android'));199 if (isset($result[1])) {200 $aversion = explode(' ', $result[1]);201 $this->setVersion($aversion[0]);202 }203 else {204 $this->setVersion(self::VERSION_UNKNOWN);205 }206 $this->isDesktop = false;207 if (stripos($this->agent, 'Mobile') !== false) {208 $this->isMobile = true;209 }210 else {211 $this->isTablet = true;212 }213 $this->name = self::BROWSER_ANDROID;214 return true;215 }216 return false;217 }218 /**219 * Determine if the browser is the BingBot220 * @return bool221 */222 protected function checkBrowserBingBot() {223 if (stripos($this->agent, "bingbot") !== false) {224 $result = explode("/", stristr($this->agent, "bingbot"));225 $version = explode(" ", $result[1]);226 $this->setVersion(str_replace(";", "", $version[0]));227 $this->name = self::BROWSER_BINGBOT;228 $this->isDesktop = false;229 $this->isRobot = true;230 return true;231 }232 return false;233 }234 /**235 * Determine if the user is using a BlackBerry236 * @return bool237 */238 protected function checkBrowserBlackBerry() {239 if (stripos($this->agent, 'blackberry') !== false) {240 $result = explode("/", stristr($this->agent, "BlackBerry"));241 $version = explode(' ', $result[1]);242 $this->setVersion($version[0]);243 $this->name = self::BROWSER_BLACKBERRY;244 $this->isDesktop = false;245 $this->isMobile = true;246 return true;247 }248 return false;249 }250 /**251 * Determine if the browser is Chrome252 * @return bool253 */254 protected function checkBrowserChrome() {255 if (stripos($this->agent, 'Chrome') !== false) {256 $result = explode('/', stristr($this->agent, 'Chrome'));257 $version = explode(' ', $result[1]);258 $this->setVersion($version[0]);259 $this->name = self::BROWSER_CHROME;260 //Chrome on Android261 if (stripos($this->agent, 'Android') !== false) {262 $this->isDesktop = false;263 if (stripos($this->agent, 'Mobile') !== false) {264 $this->isMobile = true;265 }266 else {267 $this->isTablet = true;268 }269 }270 return true;271 }272 return false;273 }274 /**275 * Determine if the browser is Firebird276 * @return boolean True if the browser is Firebird otherwise false277 */278 protected function checkBrowserFirebird() {279 if (stripos($this->agent, 'Firebird') !== false) {280 $version = explode('/', stristr($this->agent, 'Firebird'));281 $this->setVersion($version[1]);282 $this->name = self::BROWSER_FIREBIRD;283 return true;284 }285 return false;286 }287 /**288 * Determine if the browser is Firefox289 * @return bool290 */291 protected function checkBrowserFirefox() {292 if (stripos($this->agent, 'safari') === false) {293 if (preg_match("/Firefox[\/ \(]([^ ;\)]+)/i", $this->agent, $matches)) {294 $this->setVersion($matches[1]);295 $this->name = self::BROWSER_FIREFOX;296 //Firefox on Android297 if (stripos($this->agent, 'Android') !== false) {298 $this->isDesktop = false;299 if (stripos($this->agent, 'Mobile') !== false) {300 $this->isMobile = true;301 }302 else {303 $this->isTablet = true;304 }305 }306 return true;307 }308 else if (preg_match("/Firefox$/i", $this->agent, $matches)) {309 $this->name = self::BROWSER_FIREFOX;310 return true;311 }312 else if (stripos($this->agent, 'Firefox') !== false) {313 $resultant = stristr($this->agent, 'Firefox');314 if (preg_match('/\//', $resultant)) {315 $result = explode('/', str_replace("(", " ", $resultant));316 $version = explode(' ', $result[1]);317 $this->setVersion($version[0]);318 }319 $this->name = self::BROWSER_FIREFOX;320 return true;321 }322 }323 return false;324 }325 /**326 * Determine if the browser is Galeon327 * @return bool328 */329 protected function checkBrowserGaleon() {330 if (stripos($this->agent, 'galeon') !== false) {331 $result = explode(' ', stristr($this->agent, 'galeon'));332 $version = explode('/', $result[0]);333 $this->setVersion($version[1]);334 $this->name = self::BROWSER_GALEON;335 return true;336 }337 return false;338 }339 /**340 * Determine if the browser is the GoogleBot341 * @return bool342 */343 protected function checkBrowserGoogleBot() {344 if (stripos($this->agent, 'googlebot') !== false) {345 $result = explode('/', stristr($this->agent, 'googlebot'));346 $version = explode(' ', $result[1]);347 $this->setVersion(str_replace(';', '', $version[0]));348 $this->name = self::BROWSER_GOOGLEBOT;349 $this->isDesktop = false;350 $this->isRobot = true;351 return true;352 }353 return false;354 }355 /**356 * Determine if the browser is iCab357 * @return bool358 */359 protected function checkBrowserIcab() {360 if (stripos($this->agent, 'icab') !== false) {361 $aversion = explode(' ', stristr(str_replace('/', ' ', $this->agent), 'icab'));362 $this->setVersion($aversion[1]);363 $this->name = self::BROWSER_ICAB;364 return true;365 }366 return false;367 }368 /**369 * Determine if the browser is Ice Cat (http://en.wikipedia.org/wiki/GNU_IceCat)370 * @return bool371 */372 protected function checkBrowserIceCat() {373 if (stripos($this->agent, 'Mozilla') !== false && preg_match('/IceCat\/([^ ]*)/i', $this->agent, $matches)) {374 $this->setVersion($matches[1]);375 $this->name = self::BROWSER_ICECAT;376 return true;377 }378 return false;379 }380 /**381 * Determine if the browser is Iceweasel382 * @return bool383 */384 protected function checkBrowserIceweasel() {385 if (stripos($this->agent, 'Iceweasel') !== false) {386 $result = explode('/', stristr($this->agent, 'Iceweasel'));387 $version = explode(' ', $result[1]);388 $this->setVersion($version[0]);389 $this->name = self::BROWSER_ICEWEASEL;390 return true;391 }392 return false;393 }394 /**395 * Determine if the browser is Internet Explorer396 * @return bool397 */398 protected function checkBrowserInternetExplorer() {399 // Test for v1 - v1.5 IE400 if (stripos($this->agent, 'microsoft internet explorer') !== false) {401 $this->name = self::BROWSER_IE;402 $this->setVersion('1.0');403 $result = stristr($this->agent, '/');404 if (preg_match('/308|425|426|474|0b1/i', $result)) {405 $this->setVersion('1.5');406 }407 return true;408 } // Test for versions > 1.5409 else if (stripos($this->agent, 'msie') !== false && stripos($this->agent, 'opera') === false) {410 // See if the browser is the odd MSN Explorer411 if (stripos($this->agent, 'msnb') !== false) {412 $result = explode(' ', stristr(str_replace(';', '; ', $this->agent), 'MSN'));413 $this->name = self::BROWSER_MSN;414 $this->setVersion(str_replace(array('(',415 ')',416 ';'417 ), '', $result[1]));418 return true;419 }420 $result = explode(' ', stristr(str_replace(';', '; ', $this->agent), 'msie'));421 $this->name = self::BROWSER_IE;422 $this->setVersion(str_replace(array('(',423 ')',424 ';'425 ), '', $result[1]));426 if (stripos($this->agent, 'IEMobile') !== false) {427 $this->name = self::BROWSER_POCKET_IE;428 $this->isDesktop = false;429 $this->isMobile = true;430 }431 return true;432 } // Test for versions > IE 10433 else if (stripos($this->agent, 'trident') !== false) {434 $this->name = self::BROWSER_IE;435 $result = explode('rv:', $this->agent);436 $this->setVersion(preg_replace('/[^0-9.]+/', '', $result[1]));437 $this->agent = str_replace(array("Mozilla",438 "Gecko"439 ), "MSIE", $this->agent);440 } // Test for Pocket IE441 else if (stripos($this->agent, 'mspie') !== false || stripos($this->agent, 'pocket') !== false) {442 $result = explode(' ', stristr($this->agent, 'mspie'));443 $this->name = self::BROWSER_POCKET_IE;444 $this->isDesktop = false;445 $this->isMobile = true;446 if (stripos($this->agent, 'mspie') !== false) {447 $this->setVersion($result[1]);448 }449 else {450 $version = explode('/', $this->agent);451 $this->setVersion($version[1]);452 }453 return true;454 }455 return false;456 }457 /**458 * Determine if the browser is iPad459 * @return bool460 */461 protected function checkBrowseriPad() {462 if (stripos($this->agent, 'iPad') !== false) {463 $this->setVersion(self::VERSION_UNKNOWN);464 $this->name = self::BROWSER_IPAD;465 $this->getSafariVersionOnIos();466 $this->getChromeVersionOnIos();467 $this->checkForFacebookIos();468 $this->isDesktop = false;469 $this->isTablet = true;470 return true;471 }472 return false;473 }474 /**475 * Determine if the browser is iPhone476 * @return boolean True if the browser is iPhone otherwise false477 */478 protected function checkBrowseriPhone() {479 if (stripos($this->agent, 'iPhone') !== false) {480 $this->setVersion(self::VERSION_UNKNOWN);481 $this->name = self::BROWSER_IPHONE;482 $this->getSafariVersionOnIos();483 $this->getChromeVersionOnIos();484 $this->checkForFacebookIos();485 $this->isDesktop = false;486 $this->isMobile = true;487 return true;488 }489 return false;490 }491 /**492 * Determine if the browser is iPod493 * @return bool494 */495 protected function checkBrowseriPod() {496 if (stripos($this->agent, 'iPod') !== false) {497 $this->setVersion(self::VERSION_UNKNOWN);498 $this->name = self::BROWSER_IPOD;499 $this->getSafariVersionOnIos();500 $this->getChromeVersionOnIos();501 $this->checkForFacebookIos();502 $this->isDesktop = false;503 $this->isMobile = true;;504 return true;505 }506 return false;507 }508 /**509 * Determine if the browser is Konqueror510 * @return boolean True if the browser is Konqueror otherwise false511 */512 protected function checkBrowserKonqueror() {513 if (stripos($this->agent, 'Konqueror') !== false) {514 $result = explode(' ', stristr($this->agent, 'Konqueror'));515 $version = explode('/', $result[0]);516 $this->setVersion($version[1]);517 $this->name = self::BROWSER_KONQUEROR;518 return true;519 }520 return false;521 }522 /**523 * Determine if the browser is Lynx or not (last updated 1.7)524 * @return boolean True if the browser is Lynx otherwise false525 */526 protected function checkBrowserLynx() {527 if (stripos($this->agent, 'lynx') !== false) {528 $result = explode('/', stristr($this->agent, 'Lynx'));529 $version = explode(' ', (isset($result[1]) ? $result[1] : ""));530 $this->setVersion($version[0]);531 $this->name = self::BROWSER_LYNX;532 return true;533 }534 return false;535 }536 /**537 * Determine if the browser is Mozilla538 * @return boolean True if the browser is Mozilla otherwise false539 */540 protected function checkBrowserMozilla() {541 if (stripos($this->agent, 'mozilla') !== false && preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->agent) && stripos($this->agent, 'netscape') === false) {542 $aversion = explode(' ', stristr($this->agent, 'rv:'));543 preg_match('/rv:[0-9].[0-9][a-b]?/i', $this->agent, $aversion);544 $this->setVersion(str_replace('rv:', '', $aversion[0]));545 $this->name = self::BROWSER_MOZILLA;546 return true;547 }548 else if (stripos($this->agent, 'mozilla') !== false && preg_match('/rv:[0-9]\.[0-9]/i', $this->agent) && stripos($this->agent, 'netscape') === false) {549 $aversion = explode('', stristr($this->agent, 'rv:'));550 $this->setVersion(str_replace('rv:', '', $aversion[0]));551 $this->name = self::BROWSER_MOZILLA;552 return true;553 }554 else if (stripos($this->agent, 'mozilla') !== false && preg_match('/mozilla\/([^ ]*)/i', $this->agent, $matches) && stripos($this->agent, 'netscape') === false) {555 $this->setVersion($matches[1]);556 $this->name = self::BROWSER_MOZILLA;557 return true;558 }559 return false;560 }561 /**562 * Determine if the browser is the MSNBot563 * @return bool564 */565 protected function checkBrowserMSNBot() {566 if (stripos($this->agent, "msnbot") !== false) {567 $result = explode("/", stristr($this->agent, "msnbot"));568 $version = explode(" ", $result[1]);569 $this->setVersion(str_replace(";", "", $version[0]));570 $this->name = self::BROWSER_MSNBOT;571 $this->isDesktop = false;572 $this->isRobot = true;573 return true;574 }575 return false;576 }577 /**578 * Determine if the browser is NetPositive579 * @return bool580 */581 protected function checkBrowserNetPositive() {582 if (stripos($this->agent, 'NetPositive') !== false) {583 $result = explode('/', stristr($this->agent, 'NetPositive'));584 $version = explode(' ', $result[1]);585 $this->setVersion(str_replace(array('(',586 ')',587 ';'588 ), '', $version[0]));589 $this->name = self::BROWSER_NETPOSITIVE;590 return true;591 }592 return false;593 }594 /**595 * Determine if the browser is Netscape Navigator 9+596 * NOTE: (http://browser.netscape.com/ - Official support ended on March 1st, 2008)597 * @return bool598 */599 protected function checkBrowserNetscapeNavigator9Plus() {600 if (stripos($this->agent, 'Firefox') !== false && preg_match('/Navigator\/([^ ]*)/i', $this->agent, $matches)) {601 $this->setVersion($matches[1]);602 $this->name = self::BROWSER_NETSCAPE_NAVIGATOR;603 return true;604 }605 else if (stripos($this->agent, 'Firefox') === false && preg_match('/Netscape6?\/([^ ]*)/i', $this->agent, $matches)) {606 $this->setVersion($matches[1]);607 $this->name = self::BROWSER_NETSCAPE_NAVIGATOR;608 return true;609 }610 return false;611 }612 /**613 * Determine if the browser is Nokia or not (last updated 1.7)614 * @return boolean True if the browser is Nokia otherwise false615 */616 protected function checkBrowserNokia() {617 if (preg_match("/Nokia([^\/]+)\/([^ SP]+)/i", $this->agent, $matches)) {618 $this->setVersion($matches[2]);619 if (stripos($this->agent, 'Series60') !== false || strpos($this->agent, 'S60') !== false) {620 $this->name = self::BROWSER_NOKIA_S60;621 }622 else {623 $this->name = self::BROWSER_NOKIA;624 }625 $this->isMobile = true;626 return true;627 }628 return false;629 }630 /**631 * Determine if the browser is OmniWeb632 * @return bool633 */634 protected function checkBrowserOmniWeb() {635 if (stripos($this->agent, 'omniweb') !== false) {636 $result = explode('/', stristr($this->agent, 'omniweb'));637 $version = explode(' ', isset($result[1]) ? $result[1] : "");638 $this->setVersion($version[0]);639 $this->name = self::BROWSER_OMNIWEB;640 return true;641 }642 return false;643 }644 /**645 * Determine if the browser is Opera646 * @return bool647 */648 protected function checkBrowserOpera() {649 if (stripos($this->agent, 'opera mini') !== false) {650 $resultant = stristr($this->agent, 'opera mini');651 if (preg_match('/\//', $resultant)) {652 $result = explode('/', $resultant);653 $version = explode(' ', $result[1]);654 $this->setVersion($version[0]);655 }656 else {657 $aversion = explode(' ', stristr($resultant, 'opera mini'));658 $this->setVersion($aversion[1]);659 }660 $this->name = self::BROWSER_OPERA_MINI;661 $this->isDesktop = false;662 $this->isMobile = true;663 return true;664 }665 else if (stripos($this->agent, 'opera') !== false) {666 $resultant = stristr($this->agent, 'opera');667 if (preg_match('/Version\/(1*.*)$/', $resultant, $matches)) {668 $this->setVersion($matches[1]);669 }670 else if (preg_match('/\//', $resultant)) {671 $result = explode('/', str_replace("(", " ", $resultant));672 $version = explode(' ', $result[1]);673 $this->setVersion($version[0]);674 }675 else {676 $version = explode(' ', stristr($resultant, 'opera'));677 $this->setVersion(isset($version[1]) ? $version[1] : "");678 }679 if (stripos($this->agent, 'Opera Mobi') !== false) {680 $this->isDesktop = false;681 $this->isMobile = true;682 }683 $this->name = self::BROWSER_OPERA;684 return true;685 }686 else if (stripos($this->agent, 'OPR') !== false) {687 $resultant = stristr($this->agent, 'OPR');688 if (preg_match('/\//', $resultant)) {689 $result = explode('/', str_replace("(", " ", $resultant));690 $version = explode(' ', $result[1]);691 $this->setVersion($version[0]);692 }693 if (stripos($this->agent, 'Mobile') !== false) {694 $this->isDesktop = false;695 $this->isMobile = true;696 }697 $this->name = self::BROWSER_OPERA;698 return true;699 }700 return false;701 }702 /**703 * Determine if the browser is Phoenix704 * @return bool705 */706 protected function checkBrowserPhoenix() {707 if (stripos($this->agent, 'Phoenix') !== false) {708 $aversion = explode('/', stristr($this->agent, 'Phoenix'));709 $this->setVersion($aversion[1]);710 $this->name = self::BROWSER_PHOENIX;711 return true;712 }713 return false;714 }715 /**716 * Determine if the browser is Safari717 * @return bool718 */719 protected function checkBrowserSafari() {720 if (stripos($this->agent, 'Safari') !== false && stripos($this->agent, 'iPhone') === false && stripos($this->agent, 'iPod') === false) {721 $result = explode('/', stristr($this->agent, 'Version'));722 if (isset($result[1])) {723 $aversion = explode(' ', $result[1]);724 $this->setVersion($aversion[0]);725 }726 else {727 $this->setVersion(self::VERSION_UNKNOWN);728 }729 $this->name = self::BROWSER_SAFARI;730 return true;731 }732 return false;733 }734 /**735 * Determine if the browser is Shiretoko (https://wiki.mozilla.org/Projects/shiretoko)736 * @return bool737 */738 protected function checkBrowserShiretoko() {739 if (stripos($this->agent, 'Mozilla') !== false && preg_match('/Shiretoko\/([^ ]*)/i', $this->agent, $matches)) {740 $this->setVersion($matches[1]);741 $this->name = self::BROWSER_SHIRETOKO;742 return true;743 }744 return false;745 }746 /**747 * Determine if the browser is the Yahoo! Slurp Robot748 * @return bool749 */750 protected function checkBrowserSlurp() {751 if (stripos($this->agent, 'slurp') !== false) {752 $result = explode('/', stristr($this->agent, 'Slurp'));753 $version = explode(' ', $result[1]);754 $this->setVersion($version[0]);755 $this->name = self::BROWSER_SLURP;756 $this->isDesktop = false;757 $this->isMobile = false;758 $this->isRobot = true;759 return true;760 }761 return false;762 }763 /**764 * Determine if the browser is the W3C Validator765 * @return boolean True if the browser is the W3C Validator otherwise false766 */767 protected function checkBrowserW3CValidator() {768 $this->isDesktop = false;769 if (stripos($this->agent, 'W3C-checklink') !== false) {770 $result = explode('/', stristr($this->agent, 'W3C-checklink'));771 $version = explode(' ', $result[1]);772 $this->setVersion($version[0]);773 $this->name = self::BROWSER_W3CVALIDATOR;774 return true;775 }776 else if (stripos($this->agent, 'W3C_Validator') !== false) {777 // Some of the Validator versions do not delineate w/ a slash - add it back in778 $ua = str_replace("W3C_Validator ", "W3C_Validator/", $this->agent);779 $result = explode('/', stristr($ua, 'W3C_Validator'));780 $version = explode(' ', $result[1]);781 $this->setVersion($version[0]);782 $this->name = self::BROWSER_W3CVALIDATOR;783 return true;784 }785 else if (stripos($this->agent, 'W3C-mobileOK') !== false) {786 $this->name = self::BROWSER_W3CVALIDATOR;787 $this->isMobile = true;788 return true;789 }790 return false;791 }792 /**793 * Determine if the browser is WebTv794 * @return bool795 */796 protected function checkBrowserWebTv() {797 if (stripos($this->agent, 'webtv') !== false) {798 $result = explode('/', stristr($this->agent, 'webtv'));799 $version = explode(' ', $result[1]);800 $this->setVersion($version[0]);801 $this->name = self::BROWSER_WEBTV;802 $this->isDesktop = false;803 $this->isTv = true;804 return true;805 }806 return false;807 }808 /**809 * Detect if URL is loaded from FacebookExternalHit810 * @return bool811 */812 protected function checkFacebookExternalHit() {813 if (stristr($this->agent, 'FacebookExternalHit')) {814 $this->isDesktop = false;815 $this->isRobot = true;816 $this->isFacebook = true;817 return true;818 }819 return false;820 }821 /**822 * Detect if URL is being loaded from internal Facebook browser823 * @return boolean True if it detects internal Facebook browser otherwise false824 */825 protected function checkForFacebookIos() {826 if (stristr($this->agent, 'FBIOS')) {827 $this->isFacebook = true;828 return true;829 }830 return false;831 }832 /**833 * Detect Version for the Chrome browser on iOS devices834 * @return boolean True if it detects the version correctly otherwise false835 */836 protected function getChromeVersionOnIos() {837 $result = explode('/', stristr($this->agent, 'CriOS'));838 if (isset($result[1])) {839 $version = explode(' ', $result[1]);840 $this->setVersion($version[0]);841 $this->name = self::BROWSER_CHROME;842 return true;843 }844 return false;845 }846 /**847 * Detect Version for the Safari browser on iOS devices848 * @return bool849 */850 protected function getSafariVersionOnIos() {851 $result = explode('/', stristr($this->agent, 'Version'));852 if (isset($result[1])) {853 $version = explode(' ', $result[1]);854 $this->setVersion($version[0]);855 return true;856 }857 return false;858 }859} ...
setVersion
Using AI Code Generation
1$engine = new engine();2$engine->setVersion(1.0);3echo $engine->getVersion();4$engine = new engine();5$engine->setVersion(2.0);6echo $engine->getVersion();7$_SESSION['variable_name'] = value;8session_start();9$_SESSION["favcolor"] = "green";10$_SESSION["favanimal"] = "cat";11echo "Session variables are set.";12session_start();13echo "Favorite color is " . $_SESSION["favcolor"] . ".<br>";14echo "Favorite animal is " . $_SESSION["favanimal"] . ".";15setcookie(name, value, expire, path, domain, secure, httponly);
setVersion
Using AI Code Generation
1require_once('engine.php');2$engine = new engine();3$engine->setVersion('1.1');4require_once('engine.php');5$engine = new engine();6echo $engine->getVersion();7include 'file';8include('engine.php');9$engine = new engine();10$engine->setVersion('1.1');11include('engine.php');12$engine = new engine();13echo $engine->getVersion();
setVersion
Using AI Code Generation
1include('engine.php');2$engine = new engine();3$engine->setVersion(1);4include('engine.php');5$engine = new engine();6$engine->setVersion(2);7include('engine.php');8$engine = new engine();9$engine->setVersion(3);10include('engine.php');11$engine = new engine();12$engine->setVersion(4);13include('engine.php');14$engine = new engine();15$engine->setVersion(5);16include('engine.php');17$engine = new engine();18$engine->setVersion(6);19include('engine.php');20$engine = new engine();21$engine->setVersion(7);22include('engine.php');23$engine = new engine();24$engine->setVersion(8);25include('engine.php');26$engine = new engine();27$engine->setVersion(9);28include('engine.php');29$engine = new engine();30$engine->setVersion(10);31include('engine.php');32$engine = new engine();33$engine->setVersion(11);34include('engine.php');35$engine = new engine();36$engine->setVersion(12);37include('engine
setVersion
Using AI Code Generation
1require_once 'engine.php';2$engine = new Engine();3$engine->setVersion(1);4require_once 'engine.php';5$engine = new Engine();6$engine->setVersion(2);7require_once 'engine.php';8$engine = new Engine();9$engine->setVersion(3);10require_once 'engine.php';11$engine = new Engine();12$engine->setVersion(4);13require_once 'engine.php';14$engine = new Engine();15$engine->setVersion(5);16require_once 'engine.php';17$engine = new Engine();18$engine->setVersion(6);19require_once 'engine.php';20$engine = new Engine();21$engine->setVersion(7);22require_once 'engine.php';23$engine = new Engine();24$engine->setVersion(8);25require_once 'engine.php';26$engine = new Engine();27$engine->setVersion(9);28require_once 'engine.php';29$engine = new Engine();30$engine->setVersion(10);31require_once 'engine.php';32$engine = new Engine();33$engine->setVersion(11);34require_once 'engine.php';35$engine = new Engine();36$engine->setVersion(12);
setVersion
Using AI Code Generation
1$engine = new engine();2$engine->setVersion(2);3$engine = new engine();4echo $engine->getVersion();5$engine = new engine();6echo $engine->getVersion();
setVersion
Using AI Code Generation
1$engine = new Engine();2$engine->setVersion(1.2);3echo $engine->getVersion();4$engine = new Engine();5$engine->setVersion(1.3);6echo $engine->getVersion();7{8 public static $version = 1.1;9 public function setVersion($version)10 {11 self::$version = $version;12 }13 public function getVersion()14 {15 return self::$version;16 }17}18$engine = new Engine();19$engine->setVersion(1.2);20echo $engine->getVersion();21$engine = new Engine();22$engine->setVersion(1.3);23echo $engine->getVersion();
setVersion
Using AI Code Generation
1 include 'engine.php';2 $engine = new engine();3 $engine->setVersion('1.0');4 echo $engine->getVersion();5 include 'engine.php';6 $engine = new engine();7 echo $engine->getVersion();8{9}10{11}
setVersion
Using AI Code Generation
1$engine = new engine();2$engine->setVersion('1.0');3$engine = new engine();4echo $engine->getVersion();5$engine = new engine();6$engine->setVersion('1.0');7$engine = new engine();8echo $engine->getVersion();
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Execute automation tests with setVersion on a cloud-based Grid of 3000+ real browsers and operating systems for both web and mobile applications.
Test now for FreeGet 100 minutes of automation test minutes FREE!!