/** * Returns the options related to the current test context * @param RunnerServiceContext $context The test context * @return mixed */ public function getOptions(RunnerServiceContext $context) { $session = $context->getTestSession(); // Comment allowed? Skipping allowed? Logout or Exit allowed ? $options = ['allowComment' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowComment($session), 'allowSkipping' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowSkipping($session), 'exitButton' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowExit($session), 'logoutButton' => \taoQtiTest_helpers_TestRunnerUtils::doesAllowLogout($session)]; // get the options from the categories owned by the current item $categories = \taoQtiTest_helpers_TestRunnerUtils::getCategories($session); $prefixCategory = 'x-tao-option-'; $prefixCategoryLen = strlen($prefixCategory); foreach ($categories as $category) { if (!strncmp($category, $prefixCategory, $prefixCategoryLen)) { // extract the option name from the category, transform to camelCase if needed $optionName = lcfirst(str_replace(' ', '', ucwords(strtr(substr($category, $prefixCategoryLen), ['-' => ' ', '_' => ' '])))); // the options added by the categories are just flags $options[$optionName] = true; } } return $options; }