* @package taoQTI */ class ItemModel extends ConfigurableService implements taoItems_models_classes_itemModel, tao_models_classes_export_ExportProvider, tao_models_classes_import_ImportProvider, IndexableItemModel { const SERVICE_ID = 'taoQtiItem/ItemModel'; const MODEL_URI = "http://www.tao.lu/Ontologies/TAOItem.rdf#QTI"; const COMPILER = 'compilerClass'; const IMPORT_HANDLER = 'importHandlers'; const EXPORT_HANDLER = 'exportHandlers'; /** * constructor called by itemService * * @access public * @author Joel Bout, * @return mixed */ public function __construct($options = []) { parent::__construct($options); // ensure qti extension is loaded common_ext_ExtensionsManager::singleton()->getExtensionById('taoQtiItem'); } /** * render used for deploy and preview * * @access public * @param core_kernel_classes_Resource $item * @param $langCode * @return string * @throws \common_Exception * @author Joel Bout, */ public function render(core_kernel_classes_Resource $item, $langCode) { $returnValue = (string)''; $qitService = Service::singleton(); $qtiItem = $qitService->getDataItemByRdfItem($item, $langCode); if (!is_null($qtiItem)) { $returnValue = $qitService->renderQTIItem($qtiItem, $langCode); } else { common_Logger::w('No qti data for item ' . $item->getUri() . ' in ' . __FUNCTION__, 'taoQtiItem'); } return (string)$returnValue; } /** * (non-PHPdoc) * @see taoItems_models_classes_itemModel::getPreviewUrl() */ public function getPreviewUrl(core_kernel_classes_Resource $item, $languageCode) { return _url('index', 'QtiPreview', 'taoQtiItem', ['uri' => $item->getUri(), 'lang' => $languageCode]); } /** * @see taoItems_models_classes_itemModel::getPreviewUrl() */ public function getAuthoringUrl(core_kernel_classes_Resource $item) { return _url('index', 'QtiCreator', 'taoQtiItem', [ 'instance' => $item->getUri(), 'STANDALONE_MODE' => intval(\tao_helpers_Context::check('STANDALONE_MODE')) ]); } public function getExportHandlers() { if ($this->hasOption(self::EXPORT_HANDLER)) { return $this->getOption(self::EXPORT_HANDLER); } else { return []; } } public function getImportHandlers() { if ($this->hasOption(self::IMPORT_HANDLER)) { return $this->getOption(self::IMPORT_HANDLER); } else { return []; } } public function getCompilerClass() { if ($this->hasOption(self::COMPILER)) { return $this->getOption(self::COMPILER); } else { return []; } } public function getPackerClass() { return 'oat\\taoQtiItem\\model\\pack\\QtiItemPacker'; } public function getItemContentTokenizer(): ResourceTokenizer { return $this->getServiceLocator()->get(QtiItemContentTokenizer::SERVICE_ID); } }