* @package taoQtiTest */ class CompilationService extends ConfigurableService { /** * Boolean option to enable/disable css scoping (enabled by default) * @var string */ const OPTION_RUBRIC_BLOCK_CSS_SCOPE = 'rubric-block-stylesheet-scoping'; /** * Boolean option to enable/disable client container for testrunner (enabled by default) * @var string */ const OPTION_CLIENT_TESTRUNNER = 'client-testrunner'; /** * Whenever or not style sheets in rubric blocks should be scoped * @param boolean $boolean */ public function setRubricBlockStyleSheetScoping($boolean) { $this->setOption(self::OPTION_RUBRIC_BLOCK_CSS_SCOPE, (bool)$boolean); } /** * @return \taoQtiTest_models_classes_QtiTestCompiler */ public function getCompiler($resource, $storage) { $compilerClass = $this->getCompilerClass(); $compiler = new $compilerClass($resource, $storage); $this->propagate($compiler); $compiler->setCssScoping($this->getOption(self::OPTION_RUBRIC_BLOCK_CSS_SCOPE)); $compiler->setClientContainer($this->useClientContainer()); return $compiler; } /** * Whenever or not to use client container for test runner * Fallback determined by qtiItem model extension * @return boolean */ public function useClientContainer() { if ($this->hasOption(self::OPTION_CLIENT_TESTRUNNER)) { return $this->getOption(self::OPTION_CLIENT_TESTRUNNER); } else { // fallback to taoQtiItem config $itemModel = $this->getServiceLocator()->get(ItemModel::SERVICE_ID); return $itemModel->getCompilerClass() == QtiJsonItemCompiler::class; } } /** * Class to use for the compiler object, should not need to be exposed anymore * @deprecated * @return string */ public function getCompilerClass() { return \taoQtiTest_models_classes_QtiTestCompiler::class; } }