+
+
+
diff --git a/test/unit/model/qti/validator/ItemIdentifierValidatorTest.php b/test/unit/model/qti/validator/ItemIdentifierValidatorTest.php
index 7d81cf158b..73e8515e9d 100644
--- a/test/unit/model/qti/validator/ItemIdentifierValidatorTest.php
+++ b/test/unit/model/qti/validator/ItemIdentifierValidatorTest.php
@@ -24,6 +24,7 @@
use common_exception_Error;
use oat\generis\test\TestCase;
+use oat\tao\model\featureFlag\FeatureFlagChecker;
use oat\taoQtiItem\model\qti\Item;
use oat\taoQtiItem\model\qti\validator\ItemIdentifierValidator;
@@ -35,53 +36,79 @@ class ItemIdentifierValidatorTest extends TestCase
protected function setUp(): void
{
$this->item = $this->createMock(Item::class);
+ $this->featureFlagChecker = $this->createMock(FeatureFlagChecker::class);
+ $this->subject = new ItemIdentifierValidator(
+ $this->featureFlagChecker,
+ '/^[a-zA-Z_]{1}[a-zA-Z0-9_\.-]*$/u',
+ );
}
public function testValidationSuccess(): void
{
- $subject = new ItemIdentifierValidator();
+ $this->featureFlagChecker->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(false);
$this->item->expects($this->once())
->method('getAttributeValue')
->willReturn('some-fake-id-64228-217055');
- $subject->validate($this->item);
+ $this->subject->validate($this->item);
}
public function testValidationSuccessWithDifferentPattern(): void
{
- $subject = new ItemIdentifierValidator('/^[a-zA-Z_]{1}[a-zA-Z0-9_-]*$/u');
+ $this->featureFlagChecker->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(false);
$this->item->expects($this->once())
->method('getAttributeValue')
->willReturn('some-fake-id-64228-217055-not-allowed-dots');
- $subject->validate($this->item);
+ $this->subject->validate($this->item);
}
public function testValidationFailureThrowsException(): void
{
- $this->expectException(common_exception_Error::class);
+ $this->featureFlagChecker->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(false);
- $subject = new ItemIdentifierValidator();
+ $this->expectException(common_exception_Error::class);
$this->item->expects($this->once())
->method('getAttributeValue')
->willReturn('$some.fake.id.64228.217055');
- $subject->validate($this->item);
+ $this->subject->validate($this->item);
}
public function testValidationFailureWithDifferentPatternThrowsException(): void
{
+ $this->featureFlagChecker->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(false);
+
$this->expectException(common_exception_Error::class);
- $subject = new ItemIdentifierValidator('/^[a-zA-Z_]{1}[a-zA-Z0-9_-]*$/u');
+ $this->item->expects($this->once())
+ ->method('getAttributeValue')
+ ->willReturn('some.fake.id.64228.217055!not.allowed.dots');
+
+ $this->subject->validate($this->item);
+ }
+
+ public function testValidationSuccessWithFeatureFlag()
+ {
+ $this->featureFlagChecker->expects($this->once())
+ ->method('isEnabled')
+ ->willReturn(true);
$this->item->expects($this->once())
->method('getAttributeValue')
- ->willReturn('some.fake.id.64228.217055.not.allowed.dots');
+ ->willReturn('999999999');
- $subject->validate($this->item);
+ $this->subject->validate($this->item);
}
}
diff --git a/views/js/loader/taoQtiItem.min.js b/views/js/loader/taoQtiItem.min.js
index 6697966201..0fbd26a45a 100644
--- a/views/js/loader/taoQtiItem.min.js
+++ b/views/js/loader/taoQtiItem.min.js
@@ -1,2 +1,2 @@
-define("taoQtiItem/portableElementRegistry/factory/factory",["lodash","core/promise","core/eventifier"],function(_,Promise,eventifier){"use strict";var _requirejs=window.require,_defaultLoadingOptions={reload:!1},loadModuleConfig=function loadModuleConfig(manifest){return new Promise(function(resolve,reject){var requireConfigAliases={},reqConfigs=[],modules={},baseUrl;return manifest&&manifest.runtime?void(baseUrl=manifest.baseUrl,_.isArray(manifest.runtime.config)&&manifest.runtime.config.length&&_.forEach(manifest.runtime.config,function(pciConfig){_.isString(pciConfig)?reqConfigs.push("json!"+baseUrl+"/"+pciConfig):pciConfig.data?modules=_.defaults(modules,pciConfig.data.paths||{}):pciConfig.file&&reqConfigs.push("json!"+baseUrl+"/"+pciConfig.file)}),require(reqConfigs,function(){var runtimeModules={};requireConfigAliases[manifest.typeIdentifier]=baseUrl,"IMSPCI"===manifest.model&&(modules=_.reduce(arguments,function(acc,conf){return _.defaults(acc,conf.paths||{})},modules),_.forEach(manifest.runtime.modules||{},function(paths,id){paths&&(_.isString(paths)||_.isArray(paths)&&paths.length)&&(runtimeModules[id]=paths)}),modules=_.merge(modules,runtimeModules),_.forEach(modules,function(paths,id){paths=_.isArray(paths)?paths:[paths],requireConfigAliases[id]=_.map(paths,function(path){return baseUrl+"/"+path.replace(/\.js$/,"")})})),resolve(requireConfigAliases)},reject)):reject("invalid manifest")})},isPortableElementProvider=function isPortableElementProvider(provider){return provider&&_.isFunction(provider.load)};return function portableElementRegistry(methods){var _loaded=!1,__providers={};return eventifier(_.defaults(methods||{},{_registry:{},get:function get(typeIdentifier,version){if(this._registry[typeIdentifier])return version?_.find(this._registry[typeIdentifier],{version:version}):_.last(this._registry[typeIdentifier])},registerProvider:function registerProvider(moduleName,provider){return __providers[moduleName]=isPortableElementProvider(provider)?provider:null,_loaded=!1,this},resetProviders:function resetProviders(){return __providers={},_loaded=!1,this},loadProviders:function loadProviders(options){var self=this,loadPromise;return loadPromise=_loaded&&!options.reload?Promise.resolve([]):new Promise(function(resolve,reject){var providerLoadingStack=[];_.forIn(__providers,function(provider,id){null===provider&&providerLoadingStack.push(id)}),_requirejs(providerLoadingStack,function(){_.forEach([].slice.call(arguments),function(provider){isPortableElementProvider(provider)&&(__providers[providerLoadingStack.shift()]=provider)}),resolve(__providers),_loaded=!0,self.trigger("providersloaded",__providers)},reject)}),loadPromise},getAllVersions:function getAllVersions(){var all={};return _.forIn(this._registry,function(versions,id){all[id]=_.map(versions,"version")}),all},getRuntime:function getRuntime(typeIdentifier,version){var portableElement=this.get(typeIdentifier,version);return portableElement?_.assign(portableElement.runtime,{id:portableElement.typeIdentifier,label:portableElement.label,baseUrl:portableElement.baseUrl,model:portableElement.model}):void this.trigger("error",{message:"no portable element runtime found",typeIdentifier:typeIdentifier,version:version})},getCreator:function getCreator(typeIdentifier,version){var portableElement=this.get(typeIdentifier,version);return portableElement&&portableElement.creator?_.assign(portableElement.creator,{id:portableElement.typeIdentifier,label:portableElement.label,baseUrl:portableElement.baseUrl,response:portableElement.response,model:portableElement.model,xmlns:portableElement.xmlns}):void this.trigger("error",{message:"no portable element runtime found",typeIdentifier:typeIdentifier,version:version})},getLatestCreators:function getLatestCreators(){var all={};return _.forIn(this._registry,function(versions,id){var lastVersion=_.last(versions);lastVersion.creator&&lastVersion.creator.hook&&lastVersion.enabled&&(all[id]=lastVersion)}),all},getBaseUrl:function getBaseUrl(typeIdentifier,version){var runtime=this.get(typeIdentifier,version);return runtime?runtime.baseUrl:""},loadRuntimes:function loadRuntimes(options){var self=this,loadPromise;return options=_.defaults(options||{},_defaultLoadingOptions),loadPromise=self.loadProviders(options).then(function(providers){var loadStack=[];return _.forEach(providers,function(provider){provider&&loadStack.push(provider.load())}),Promise.all(loadStack).then(function(results){var configLoadingStack=[];return self._registry=_.reduce(results,function(acc,_pcis){return _.merge(acc,_pcis)},self._registry||{}),_.forIn(self._registry,function(versions,typeIdentifier){return!!(_.isArray(options.include)&&0>_.indexOf(options.include,typeIdentifier))||void configLoadingStack.push(loadModuleConfig(self.get(typeIdentifier)))}),Promise.all(configLoadingStack).then(function(moduleConfigs){var requireConfigAliases=_.reduce(moduleConfigs,function(acc,paths){return _.merge(acc,paths)},{});_requirejs.config({paths:requireConfigAliases})})})}),loadPromise.then(function(){self.trigger("runtimesloaded")}).catch(function(err){self.trigger("error",err)}),loadPromise},loadCreators:function loadCreators(options){var self=this,loadPromise;return options=_.defaults(options||{},_defaultLoadingOptions),loadPromise=self.loadRuntimes(options).then(function(){var requiredCreatorHooks=[];return _.forIn(self._registry,function(versions,typeIdentifier){var portableElementModel=self.get(typeIdentifier);if(portableElementModel.creator&&portableElementModel.creator.hook){if(portableElementModel.enabled){if(_.isArray(options.include)&&0>_.indexOf(options.include,typeIdentifier))return!0;}else if(!_.isArray(options.include)||0>_.indexOf(options.include,typeIdentifier))return!0;requiredCreatorHooks.push(portableElementModel.creator.hook.replace(/\.js$/,""))}}),requiredCreatorHooks.length?new Promise(function(resolve,reject){_requirejs(requiredCreatorHooks,function(){var creators={};_.forEach(arguments,function(creatorHook){var id=creatorHook.getTypeIdentifier(),portableElementModel=self.get(id),i=_.findIndex(self._registry[id],{version:portableElementModel.version});0>i?self.trigger("error","no creator found for id/version "+id+"/"+portableElementModel.version):(self._registry[id][i].creator.module=creatorHook,creators[id]=creatorHook)}),resolve(creators)},reject)}):Promise.resolve({})}),loadPromise.then(function(creators){return self.trigger("creatorsloaded",creators),creators}).catch(function(err){self.trigger("error",err)}),loadPromise},enable:function enable(typeIdentifier,version){var portableElement=this.get(typeIdentifier,version);return portableElement&&(portableElement.enabled=!0),this},disable:function disable(typeIdentifier,version){var portableElement=this.get(typeIdentifier,version);return portableElement&&(portableElement.enabled=!1),this},isEnabled:function isEnabled(typeIdentifier,version){var portableElement=this.get(typeIdentifier,version);return portableElement&&!0===portableElement.enabled}}))}}),define("taoQtiItem/qtiCreator/helper/qtiElements",["jquery","lodash","i18n","services/features"],function($,_,__,featuresService){"use strict";const QtiElements={classes:{itemBody:{parents:["bodyElement"],contains:["block"],abstract:!0},atomicBlock:{parents:["blockStatic","bodyElement","flowStatic"],contains:["inline"],abstract:!0},atomicInline:{parents:["bodyElement","flowStatic","inlineStatic"],contains:["inline"],abstract:!0},simpleBlock:{parents:["blockStatic","bodyElement","flowStatic"],contains:["block"],abstract:!0},simpleInline:{parents:["bodyElement","flowStatic","inlineStatic"],contains:["inline"],abstract:!0},flowStatic:{parents:["flow"],abstract:!0},blockStatic:{parents:["block"],abstract:!0},inlineStatic:{parents:["inline"],abstract:!0},flow:{parents:["objectFlow"],abstract:!0},tableCell:{parents:["bodyElement"],contains:["flow"],abstract:!0},caption:{parents:["bodyElement"],contains:["inline"],xhtml:!0},col:{parents:["bodyElement"],xhtml:!0},colgroup:{parents:["bodyElement"],contains:["col"],xhtml:!0},div:{parents:["blockStatic","bodyElement","flowStatic"],contains:["flow"],xhtml:!0},dl:{parents:["blockStatic","bodyElement","flowStatic"],contains:["dlElement"],xhtml:!0},dt:{parents:["dlElement"],contains:["inline"],xhtml:!0},dd:{parents:["dlElement"],contains:["flow"],xhtml:!0},hr:{parents:["blockStatic","bodyElement","flowStatic"],xhtml:!0},math:{parents:["blockStatic","flowStatic","inlineStatic"],xhtml:!0},li:{parents:["bodyElement"],contains:["flow"],xhtml:!0},ol:{parents:["blockStatic","bodyElement","flowStatic"],contains:["li"],xhtml:!0},ul:{parents:["blockStatic","bodyElement","flowStatic"],contains:["li"],xhtml:!0},object:{parents:["bodyElement","flowStatic","inlineStatic"],contains:["objectFlow"],xhtml:!0},param:{parents:["objectFlow"],xhtml:!0},table:{parents:["blockStatic","bodyElement","flowStatic"],contains:["caption","col","colgroup","thead","tfoot","tbody"],xhtml:!0},tbody:{parents:["bodyElement"],contains:["tr"],xhtml:!0},tfoot:{parents:["bodyElement"],contains:["tr"],xhtml:!0},thead:{parents:["bodyElement"],contains:["tr"],xhtml:!0},td:{parents:["tableCell"],xhtml:!0},th:{parents:["tableCell"],xhtml:!0},tr:{parents:["bodyElement"],contains:["tableCell"],xhtml:!0},a:{parents:["simpleInline"],xhtml:!0},abbr:{parents:["simpleInline"],xhtml:!0},acronym:{parents:["simpleInline"],xhtml:!0},b:{parents:["simpleInline"],xhtml:!0},big:{parents:["simpleInline"],xhtml:!0},cite:{parents:["simpleInline"],xhtml:!0},code:{parents:["simpleInline"],xhtml:!0},dfn:{parents:["simpleInline"],xhtml:!0},em:{parents:["simpleInline"],xhtml:!0},i:{parents:["simpleInline"],xhtml:!0},kbd:{parents:["simpleInline"],xhtml:!0},q:{parents:["simpleInline"],xhtml:!0},samp:{parents:["simpleInline"],xhtml:!0},small:{parents:["simpleInline"],xhtml:!0},span:{parents:["simpleInline"],xhtml:!0},strong:{parents:["simpleInline"],xhtml:!0},sub:{parents:["simpleInline"],xhtml:!0},sup:{parents:["simpleInline"],xhtml:!0},tt:{parents:["simpleInline"],xhtml:!0},var:{parents:["simpleInline"],xhtml:!0},blockquote:{parents:["simpleBlock"],xhtml:!0},address:{parents:["atomicBlock"],xhtml:!0},h1:{parents:["atomicBlock"],xhtml:!0},h2:{parents:["atomicBlock"],xhtml:!0},h3:{parents:["atomicBlock"],xhtml:!0},h4:{parents:["atomicBlock"],xhtml:!0},h5:{parents:["atomicBlock"],xhtml:!0},h6:{parents:["atomicBlock"],xhtml:!0},p:{parents:["atomicBlock"],xhtml:!0},pre:{parents:["atomicBlock"],xhtml:!0},img:{parents:["atomicInline"],xhtml:!0,attributes:["src","alt","longdesc","height","width"]},br:{parents:["atomicInline"],xhtml:!0},infoControl:{parents:["blockStatic","bodyElement","flowStatic"],qti:!0},textRun:{parents:["inlineStatic","flowstatic"],qti:!0},feedbackInline:{parents:["simpleInline","feedbackElement"],qti:!0},feedbackBlock:{parents:["simpleBlock"],qti:!0},rubricBlock:{parents:["simpleBlock"],qti:!0},blockInteraction:{parents:["block","flow","interaction"],qti:!0},inlineInteraction:{parents:["inline","flow","interaction"],qti:!0},gap:{parents:["inlineStatic"],qti:!0},hottext:{parents:["flowstatic","inlineStatic"],contains:["inlineStatic"],qti:!0},printedVariable:{parents:["bodyElement","flowStatic","inlineStatic","textOrVariable"],qti:!0},prompt:{parents:["bodyElement"],contains:["inlineStatic"],qti:!0},templateElement:{parents:["bodyElement"],qti:!0},templateBlock:{parents:["blockStatic","flowStatic","templateElement"],contains:["blockStatic"],qti:!0},templateInline:{parents:["inlineStatic","flowStatic","templateElement"],contains:["inlineStatic"],qti:!0},choiceInteraction:{parents:["blockInteraction"],qti:!0},associateInteraction:{parents:["blockInteraction"],qti:!0},orderInteraction:{parents:["blockInteraction"],qti:!0},matchInteraction:{parents:["blockInteraction"],qti:!0},hottextInteraction:{parents:["blockInteraction"],qti:!0},gapMatchInteraction:{parents:["blockInteraction"],qti:!0},mediaInteraction:{parents:["blockInteraction"],qti:!0},sliderInteraction:{parents:["blockInteraction"],qti:!0},uploadInteraction:{parents:["blockInteraction"],qti:!0},drawingInteraction:{parents:["blockInteraction"],qti:!0},graphicInteraction:{parents:["blockInteraction"],qti:!0},hotspotInteraction:{parents:["graphicInteraction"],qti:!0},graphicAssociateInteraction:{parents:["graphicInteraction"],qti:!0},graphicOrderInteraction:{parents:["graphicInteraction"],qti:!0},graphicGapMatchInteraction:{parents:["graphicInteraction"],qti:!0},selectPointInteraction:{parents:["graphicInteraction"],qti:!0},textEntryInteraction:{parents:["stringInteraction","inlineInteraction"],qti:!0},extendedTextInteraction:{parents:["stringInteraction","blockInteraction"],qti:!0},inlineChoiceInteraction:{parents:["inlineInteraction"],qti:!0},endAttemptInteraction:{parents:["inlineInteraction"],qti:!0},customInteraction:{parents:["block","flow","interaction"],qti:!0},_container:{parents:["block"],qti:!0}},cache:{containable:{},children:{},parents:{}},getAllowedContainersElements(qtiClass,$container){const classes=QtiElements.getAllowedContainers(qtiClass);let jqSelector="";for(let i in classes)classes[i].qti||(jqSelector+=`${classes[i]}, `);return jqSelector&&(jqSelector=jqSelector.substring(0,jqSelector.length-2)),$(jqSelector,$container?$container:$(document)).filter(":not([data-qti-type])")},getAllowedContainers(qtiClass){let ret;if(QtiElements.cache.containable[qtiClass])ret=QtiElements.cache.containable[qtiClass];else{ret=[];const parents=QtiElements.getParentClasses(qtiClass,!0);for(let aClass in QtiElements.classes){const model=QtiElements.classes[aClass];if(model.contains){const intersect=_.intersection(model.contains,parents);intersect.length&&(!model.abstract&&ret.push(aClass),ret=_.union(ret,QtiElements.getChildClasses(aClass,!0)))}}QtiElements.cache.containable[qtiClass]=ret}return ret},getAllowedContents(qtiClass,recursive,checked){let ret=[];checked=checked||{};const model=QtiElements.classes[qtiClass];if(model&&model.contains)for(let i in model.contains){const contain=model.contains[i];if(!checked[contain]){checked[contain]=!0,ret.push(contain);const children=QtiElements.getChildClasses(contain,!0);for(let j in children){const child=children[j];checked[child]||(checked[child]=!0,ret.push(child),recursive&&(ret=_.union(ret,QtiElements.getAllowedContents(child,!0,checked))))}recursive&&(ret=_.union(ret,QtiElements.getAllowedContents(contain,!0,checked)))}}const parents=QtiElements.getParentClasses(qtiClass,!0);for(let i in parents)ret=_.union(ret,QtiElements.getAllowedContents(parents[i],recursive,checked));return _.uniq(ret)},isAllowedClass(qtiContainerClass,qtiContentClass){const allowedClasses=QtiElements.getAllowedContents(qtiContainerClass);return 0<=_.indexOf(allowedClasses,qtiContentClass)},getParentClasses(qtiClass,recursive){let ret;if(recursive&&QtiElements.cache.parents[qtiClass])ret=QtiElements.cache.parents[qtiClass];else{if(ret=[],QtiElements.classes[qtiClass]&&(ret=QtiElements.classes[qtiClass].parents,recursive)){for(let i in ret)ret=_.union(ret,QtiElements.getParentClasses(ret[i],recursive));ret=_.uniq(ret)}QtiElements.cache.parents[qtiClass]=ret}return ret},getChildClasses(qtiClass,recursive,type){let ret;const cacheType=type?type:"all";if(recursive&&QtiElements.cache.children[qtiClass]&&QtiElements.cache.children[qtiClass][cacheType])ret=QtiElements.cache.children[qtiClass][cacheType];else{for(let aClass in ret=[],QtiElements.classes){const model=QtiElements.classes[aClass];0<=_.indexOf(model.parents,qtiClass)&&(type?model[type]&&ret.push(aClass):ret.push(aClass),recursive&&(ret=_.union(ret,QtiElements.getChildClasses(aClass,recursive,type))))}QtiElements.cache.children[qtiClass]||(QtiElements.cache.children[qtiClass]={}),QtiElements.cache.children[qtiClass][cacheType]=ret}return ret},isBlock(qtiClass){return QtiElements.is(qtiClass,"block")},isInline(qtiClass){return QtiElements.is(qtiClass,"inline")},is(qtiClass,topClass){if(qtiClass===topClass)return!0;else{const parents=QtiElements.getParentClasses(qtiClass,!0);return 0<=_.indexOf(parents,topClass)}},isVisible(qtiClass){return this.is(qtiClass,"customInteraction")?featuresService.isVisible(`taoQtiItem/creator/customInteraction/${qtiClass.replace(/Interaction$/,"").replace(/^customInteraction\./,"")}`):!this.is(qtiClass,"interaction")||featuresService.isVisible(`taoQtiItem/creator/interaction/${qtiClass.replace(/Interaction$/,"")}`)},getAvailableAuthoringElements(){const tagTitles={commonInteractions:__("Common Interactions"),inlineInteractions:__("Inline Interactions"),graphicInteractions:__("Graphic Interactions")},authoringElements={choiceInteraction:{label:__("Choice Interaction"),description:__("Select a single (radio buttons) or multiple (check boxes) responses among a set of choices."),icon:"icon-choice",short:__("Choice"),qtiClass:"choiceInteraction",tags:[tagTitles.commonInteractions,"mcq"],group:"common-interactions"},orderInteraction:{label:__("Order Interaction"),icon:"icon-order",description:__("Arrange a list of choices in the correct order."),short:__("Order"),qtiClass:"orderInteraction",tags:[tagTitles.commonInteractions,"ordering"],group:"common-interactions"},associateInteraction:{label:__("Associate Interaction"),icon:"icon-associate",description:__("Create pair(s) from a series of choices."),short:__("Associate"),qtiClass:"associateInteraction",tags:[tagTitles.commonInteractions,"association"],group:"common-interactions"},matchInteraction:{label:__("Match Interaction"),icon:"icon-match",description:__("Create association(s) between two sets of choices displayed in a table (row and column)."),short:__("Match"),qtiClass:"matchInteraction",tags:[tagTitles.commonInteractions,"association"],group:"common-interactions"},hottextInteraction:{label:__("Hottext Interaction"),icon:"icon-hottext",description:__("Select one or more text parts (hottext) within a text."),short:__("Hottext"),qtiClass:"hottextInteraction",tags:[tagTitles.commonInteractions,"text"],group:"common-interactions"},gapMatchInteraction:{label:__("Gap Match Interaction"),icon:"icon-gap-match",description:__(" Fill in the gaps in a text from a set of choices."),short:__("Gap Match"),qtiClass:"gapMatchInteraction",tags:[tagTitles.commonInteractions,"text","association"],group:"common-interactions"},sliderInteraction:{label:__("Slider Interaction"),icon:"icon-slider",description:__("Select a value within a numerical range."),short:__("Slider"),qtiClass:"sliderInteraction",tags:[tagTitles.commonInteractions,"special"],group:"common-interactions"},extendedTextInteraction:{label:__("Extended Text Interaction"),icon:"icon-extended-text",description:__("Collect open-ended information in one or more text area(s) (strings or numeric values)."),short:__("Extended Text"),qtiClass:"extendedTextInteraction",tags:[tagTitles.commonInteractions,"text"],group:"common-interactions"},uploadInteraction:{label:__("File Upload Interaction"),icon:"icon-upload",description:__("Upload a file (e.g. document, picture...) as a response."),short:__("File Upload"),qtiClass:"uploadInteraction",tags:[tagTitles.commonInteractions,"special"],group:"common-interactions"},mediaInteraction:{label:__("Media Interaction"),icon:"icon-media",description:__("Control the playing parameters (auto-start, loop) of a video or audio file and report the number of time it has been played."),short:__("Media"),qtiClass:"mediaInteraction",tags:[tagTitles.commonInteractions,"media"],group:"common-interactions"},_container:{label:__("Text Block"),icon:"icon-font",description:__("Block contains the content (stimulus) of the item such as text or image. It is also required for Inline Interactions."),short:__("Block"),qtiClass:"_container",tags:[tagTitles.inlineInteractions,"text"],group:"inline-interactions"},inlineChoiceInteraction:{label:__("Inline Choice Interaction"),icon:"icon-inline-choice",description:__("Select a choice from a drop-down list."),short:__("Inline Choice"),qtiClass:"inlineChoiceInteraction",tags:[tagTitles.inlineInteractions,"inline-interactions","mcq"],group:"inline-interactions"},textEntryInteraction:{label:__("Text Entry Interaction"),icon:"icon-text-entry",description:__("Collect open-ended information in a short text input (strings or numeric values)."),short:__("Text Entry"),qtiClass:"textEntryInteraction",tags:[tagTitles.inlineInteractions,"inline-interactions","text"],group:"inline-interactions"},endAttemptInteraction:{label:__("End Attempt Interaction"),icon:"icon-end-attempt",description:__("Trigger the end of the item attempt."),short:__("End Attempt"),qtiClass:"endAttemptInteraction",tags:[tagTitles.inlineInteractions,"inline-interactions","button","submit"],group:"inline-interactions"},hotspotInteraction:{label:__("Hotspot Interaction"),icon:"icon-hotspot",description:__("Select one or more areas (hotspots) displayed on an picture."),short:__("Hotspot"),qtiClass:"hotspotInteraction",tags:[tagTitles.graphicInteractions,"mcq"],group:"graphic-interactions"},graphicOrderInteraction:{label:__("Graphic Order Interaction"),icon:"icon-graphic-order",description:__("Order the areas (hotspots) displayed on a picture."),short:__("Order"),qtiClass:"graphicOrderInteraction",tags:[tagTitles.graphicInteractions,"ordering"],group:"graphic-interactions"},graphicAssociateInteraction:{label:__("Graphic Associate Interaction"),icon:"icon-graphic-associate",description:__("Create association(s) between areas (hotspots) displayed on a picture."),short:__("Associate"),qtiClass:"graphicAssociateInteraction",tags:[tagTitles.graphicInteractions,"association"],group:"graphic-interactions"},graphicGapMatchInteraction:{label:__("Graphic Gap Match Interaction"),icon:"icon-graphic-gap",description:__("Fill in the gaps on a picture with a set of image choices."),short:__("Gap Match"),qtiClass:"graphicGapMatchInteraction",tags:[tagTitles.graphicInteractions,"association"],group:"graphic-interactions"},selectPointInteraction:{label:__("Select Point Interaction"),icon:"icon-select-point",description:__("Position one or more points on a picture (response areas are not displayed)."),short:__("Select Point"),qtiClass:"selectPointInteraction",tags:[tagTitles.graphicInteractions],group:"graphic-interactions"}},availableElements={};for(const[elementId,element]of Object.entries(authoringElements))this.isVisible(elementId)&&(availableElements[elementId]=element);return availableElements}};return QtiElements}),define("taoQtiItem/portableElementRegistry/factory/ciRegistry",["lodash","i18n","taoQtiItem/portableElementRegistry/factory/factory","taoQtiItem/qtiCreator/helper/qtiElements"],function(_,__,portableElementRegistry,qtiElements){"use strict";return function customInteractionRegistry(){return portableElementRegistry({getAuthoringData(typeIdentifier){let options=1{const execStack=[];return _.forEach(plugins,plugin=>{_.isFunction(plugin[method])&&execStack.push(plugin[method]())}),Promise.all(execStack)},qtiCreatorContext={init(){return pluginLoader.load().then(()=>{const pluginFactories=pluginLoader.getPlugins();return _.forEach(pluginFactories,pluginFactory=>{const plugin=pluginFactory(this);plugins[plugin.getName()]=plugin}),pluginRun("init").then(()=>{this.trigger("init")})}).catch(err=>{this.trigger("error",err)})},destroy(){return pluginRun("destroy").then(()=>{this.trigger("destroy")}).catch(function(err){this.trigger("error",err)})}};return eventifier(qtiCreatorContext)}}),define("taoQtiItem/qtiItem/core/qtiClasses",[],function(){"use strict";var qtiClasses={_container:"taoQtiItem/qtiItem/core/Container",assessmentItem:"taoQtiItem/qtiItem/core/Item",responseProcessing:"taoQtiItem/qtiItem/core/ResponseProcessing",_simpleFeedbackRule:"taoQtiItem/qtiItem/core/response/SimpleFeedbackRule",stylesheet:"taoQtiItem/qtiItem/core/Stylesheet",math:"taoQtiItem/qtiItem/core/Math",figure:"taoQtiItem/qtiItem/core/Figure",img:"taoQtiItem/qtiItem/core/Img",figcaption:"taoQtiItem/qtiItem/core/Figcaption",object:"taoQtiItem/qtiItem/core/Object",outcomeDeclaration:"taoQtiItem/qtiItem/core/variables/OutcomeDeclaration",responseDeclaration:"taoQtiItem/qtiItem/core/variables/ResponseDeclaration",rubricBlock:"taoQtiItem/qtiItem/core/RubricBlock",associableHotspot:"taoQtiItem/qtiItem/core/choices/AssociableHotspot",gap:"taoQtiItem/qtiItem/core/choices/Gap",gapImg:"taoQtiItem/qtiItem/core/choices/GapImg",gapText:"taoQtiItem/qtiItem/core/choices/GapText",hotspotChoice:"taoQtiItem/qtiItem/core/choices/HotspotChoice",hottext:"taoQtiItem/qtiItem/core/choices/Hottext",inlineChoice:"taoQtiItem/qtiItem/core/choices/InlineChoice",simpleAssociableChoice:"taoQtiItem/qtiItem/core/choices/SimpleAssociableChoice",simpleChoice:"taoQtiItem/qtiItem/core/choices/SimpleChoice",associateInteraction:"taoQtiItem/qtiItem/core/interactions/AssociateInteraction",choiceInteraction:"taoQtiItem/qtiItem/core/interactions/ChoiceInteraction",endAttemptInteraction:"taoQtiItem/qtiItem/core/interactions/EndAttemptInteraction",extendedTextInteraction:"taoQtiItem/qtiItem/core/interactions/ExtendedTextInteraction",gapMatchInteraction:"taoQtiItem/qtiItem/core/interactions/GapMatchInteraction",graphicAssociateInteraction:"taoQtiItem/qtiItem/core/interactions/GraphicAssociateInteraction",graphicGapMatchInteraction:"taoQtiItem/qtiItem/core/interactions/GraphicGapMatchInteraction",graphicOrderInteraction:"taoQtiItem/qtiItem/core/interactions/GraphicOrderInteraction",hotspotInteraction:"taoQtiItem/qtiItem/core/interactions/HotspotInteraction",hottextInteraction:"taoQtiItem/qtiItem/core/interactions/HottextInteraction",inlineChoiceInteraction:"taoQtiItem/qtiItem/core/interactions/InlineChoiceInteraction",matchInteraction:"taoQtiItem/qtiItem/core/interactions/MatchInteraction",mediaInteraction:"taoQtiItem/qtiItem/core/interactions/MediaInteraction",orderInteraction:"taoQtiItem/qtiItem/core/interactions/OrderInteraction",prompt:"taoQtiItem/qtiItem/core/interactions/Prompt",selectPointInteraction:"taoQtiItem/qtiItem/core/interactions/SelectPointInteraction",sliderInteraction:"taoQtiItem/qtiItem/core/interactions/SliderInteraction",textEntryInteraction:"taoQtiItem/qtiItem/core/interactions/TextEntryInteraction",uploadInteraction:"taoQtiItem/qtiItem/core/interactions/UploadInteraction",feedbackBlock:"taoQtiItem/qtiItem/core/feedbacks/FeedbackBlock",feedbackInline:"taoQtiItem/qtiItem/core/feedbacks/FeedbackInline",modalFeedback:"taoQtiItem/qtiItem/core/feedbacks/ModalFeedback",customInteraction:"taoQtiItem/qtiItem/core/interactions/CustomInteraction",infoControl:"taoQtiItem/qtiItem/core/PortableInfoControl",include:"taoQtiItem/qtiItem/core/Include",table:"taoQtiItem/qtiItem/core/Table",printedVariable:"taoQtiItem/qtiItem/core/PrintedVariable",_tooltip:"taoQtiItem/qtiItem/core/Tooltip"};return qtiClasses}),define("taoQtiItem/qtiItem/helper/util",["lodash"],function(_){"use strict";_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_;var util={buildSerial:function buildSerial(prefix){for(var id=prefix||"",chars="abcdefghijklmnopqrstuvwxyz0123456789",i=0;22>i;i++)id+=chars.charAt(Math.floor(Math.random()*chars.length));return id},buildId:function buildId(item,prefix){var i=1,suffix="",exists=!1,id,usedIds;if(!item)throw new TypeError("A item is required to generate a unique identifier");usedIds=item.getUsedIds();do exists=!1,id=prefix+suffix,usedIds&&usedIds.includes(id)&&(exists=!0,suffix="_"+i,i++);while(exists);return id},buildIdentifier:function buildIdentifier(item,prefix,useSuffix){var suffix="",i=1,exists=!1,id,usedIds;if(!item)throw new TypeError("A item is required to generate a unique identifier");if(!prefix)throw new TypeError("Prefix is required to build an identifier");usedIds=item.getUsedIdentifiers(),useSuffix=!!_.isUndefined(useSuffix)||useSuffix,prefix&&(prefix=prefix.replace(/_[0-9]+$/gi,"_").replace(/[^a-zA-Z0-9_]/gi,"_").replace(/(_)+/gi,"_"),useSuffix&&(suffix="_"+i));do exists=!1,id=prefix+suffix,usedIds[id]&&(exists=!0,suffix="_"+i,i++);while(exists);return id},findInCollection:function findInCollection(element,collectionNames,searchedSerial){var found=null;if(_.isString(collectionNames)&&(collectionNames=[collectionNames]),_.isArray(collectionNames))_.forEach(collectionNames,function(collectionName){var collection=element;_.forEach(collectionName.split("."),function(nameToken){collection=collection[nameToken]});var elt=collection[searchedSerial];return elt?(found={parent:element,element:elt},!1):(_.forEach(collection,function(elt){if(_.isFunction(elt.find)&&(found=elt.find(searchedSerial),found))return!1}),!found)&&void 0});else throw new Error("invalid argument : collectionNames must be an array or a string");return found},addMarkupNamespace:function addMarkupNamespace(markup,ns){return ns?(markup=markup.replace(/<(\/)?([a-z:]+)(\s?)([^><]*)>/g,function($0,$1,$2,$3,$4){return 0<$2.indexOf(":")?$0:($1=$1||"",$3=$3||"","<"+$1+ns+":"+$2+$3+$4+">")}),markup):markup},removeMarkupNamespaces:function removeMarkupNamespace(markup){return markup.replace(/<(\/)?(\w*):([^>]*)>/g,"<$1$3>")},getMarkupUsedNamespaces:function getMarkupUsedNamespaces(markup){var namespaces=[];return markup.replace(/<(\/)?(\w*):([^>]*)>/g,function(original,slash,ns,node){return namespaces.push(ns),"<"+slash+node+">"}),_.uniq(namespaces)}};return util}),define("taoQtiItem/qtiItem/helper/rendererConfig",["lodash","jquery"],function(_,$){"use strict";_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,$=$&&Object.prototype.hasOwnProperty.call($,"default")?$["default"]:$;var rendererConfigHelper={getOptionsFromArguments:function(args){var options={data:{},placeholder:null,subclass:"",renderer:null};return _.forEach(args,function(arg){arg&&(arg.isRenderer?options.renderer=arg:arg instanceof $&&arg.length?options.placeholder=arg:_.isString(arg)?options.subclass=arg:_.isPlainObject(arg)?options.data=arg:console.log("invalid arg",arg,args))}),options}};return rendererConfigHelper}),define("taoQtiItem/qtiItem/core/Element",["jquery","lodash","class","core/logger","taoQtiItem/qtiItem/helper/util","taoQtiItem/qtiItem/helper/rendererConfig"],function($,_,_class,loggerFactory,util,rendererConfig){"use strict";$=$&&Object.prototype.hasOwnProperty.call($,"default")?$["default"]:$,_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,loggerFactory=loggerFactory&&Object.prototype.hasOwnProperty.call(loggerFactory,"default")?loggerFactory["default"]:loggerFactory,util=util&&Object.prototype.hasOwnProperty.call(util,"default")?util["default"]:util,rendererConfig=rendererConfig&&Object.prototype.hasOwnProperty.call(rendererConfig,"default")?rendererConfig["default"]:rendererConfig;var _instances={},logger=loggerFactory("taoQtiItem/qtiItem/core/Element"),Element=Class.extend({qtiClass:"",serial:"",rootElement:null,init:function(serial,attributes){if(this.attributes={},this.metaData={},"object"==typeof serial&&(attributes=serial,serial=""),serial||(serial=util.buildSerial(this.qtiClass+"_")),serial&&("string"!=typeof serial||!serial.match(/^[a-z_0-9]*$/i)))throw"invalid QTI serial : ("+typeof serial+") "+serial;if(!_instances[serial])_instances[serial]=this,this.serial=serial,this.setAttributes(attributes||{});else throw"a QTI Element with the same serial already exists "+serial;"function"==typeof this.initContainer&&this.initContainer(arguments[2]||""),"function"==typeof this.initObject&&this.initObject()},is:function(qtiClass){return qtiClass===this.qtiClass},placeholder:function(){return"{{"+this.serial+"}}"},getSerial:function(){return this.serial},getUsedIdentifiers:function(){var usedIds={},elts=this.getComposingElements();for(var i in elts){var elt=elts[i],id=elt.attr("identifier");id&&(usedIds[id]=elt)}return usedIds},getUsedIds:function getUsedIds(){var usedIds=[];return _.forEach(this.getComposingElements(),function(elt){var id=elt.attr("id");id&&!usedIds.includes(id)&&usedIds.push(id)}),usedIds},attr:function(name,value){if(name)if(void 0!==value)this.attributes[name]=value;else if("object"==typeof name)for(var prop in name)this.attr(prop,name[prop]);else if("string"==typeof name)return void 0===this.attributes[name]?void 0:this.attributes[name];return this},data:function(name,value){if(name)if(void 0!==value)this.metaData[name]=value,$(document).trigger("metaChange.qti-widget",{element:this,key:name,value:value});else if("object"==typeof name)for(var prop in name)this.data(prop,name[prop]);else if("string"==typeof name)return void 0===this.metaData[name]?void 0:this.metaData[name];return this},removeData:function(name){return delete this.metaData[name],this},removeAttr:function(name){return this.removeAttributes(name)},setAttributes:function(attributes){return _.isPlainObject(attributes)||logger.warn("attributes should be a plain object"),this.attributes=attributes,this},getAttributes:function(){return _.clone(this.attributes)},removeAttributes:function(attrNames){for(var i in"string"==typeof attrNames&&(attrNames=[attrNames]),attrNames)delete this.attributes[attrNames[i]];return this},getComposingElements:function(){function append(element){elts[element.getSerial()]=element,elts=_.extend(elts,element.getComposingElements())}var elts={};return"function"==typeof this.initContainer&&append(this.getBody()),"function"==typeof this.initObject&&append(this.getObject()),_.forEach(this.metaData,function(v){Element.isA(v,"_container")?append(v):_.isArray(v)&&_.forEach(v,function(v){Element.isA(v,"_container")&&append(v)})}),elts},getUsedClasses:function(){var ret=[this.qtiClass],composingElts=this.getComposingElements();return _.forEach(composingElts,function(elt){ret.push(elt.qtiClass)}),_.uniq(ret)},find:function(serial){var found=null,object,body;return"function"==typeof this.initObject&&(object=this.getObject(),object.serial===serial&&(found={parent:this,element:object,location:"object"})),found||"function"!=typeof this.initContainer||(body=this.getBody(),found=body.serial===serial?{parent:this,element:body,location:"body"}:this.getBody().find(serial,this)),found},parent:function(){var item=this.getRootElement();if(item){var found=item.find(this.getSerial());if(found)return found.parent}return null},setRelatedItem:function(item){logger.warn("Deprecated use of setRelatedItem()"),this.setRootElement(item)},setRootElement:function(item){var composingElts,i;if(Element.isA(item,"assessmentItem"))for(i in this.rootElement=item,composingElts=this.getComposingElements(),composingElts)composingElts[i].setRootElement(item)},getRelatedItem:function(){return logger.warn("Deprecated use of getRelatedItem()"),this.getRootElement()},getRootElement:function(){var ret=null;return Element.isA(this.rootElement,"assessmentItem")&&(ret=this.rootElement),ret},setRenderer:function(renderer){if(renderer&&renderer.isRenderer){this.renderer=renderer;var elts=this.getComposingElements();for(var serial in elts)elts[serial].setRenderer(renderer)}else throw"invalid qti rendering engine"},getRenderer:function(){return this.renderer},render:function render(){var args=rendererConfig.getOptionsFromArguments(arguments),_renderer=args.renderer||this.getRenderer(),tplData={},defaultData={tag:this.qtiClass,serial:this.serial,attributes:this.getAttributes()},rendering;if(!_renderer)throw new Error("render: no renderer found for the element "+this.qtiClass+":"+this.serial);return"function"==typeof this.initContainer&&(defaultData.body=this.getBody().render(args.renderer)),"function"==typeof this.initObject&&(defaultData.object={attributes:this.object.getAttributes()},defaultData.object.attributes.data=_renderer.resolveUrl(this.object.attr("data"))),tplData=_.merge(defaultData,args.data||{}),tplData=_renderer.getData(this,tplData,args.subclass),rendering=_renderer.renderTpl(this,tplData,args.subclass),args.placeholder&&args.placeholder.replaceWith(rendering),rendering},postRender:function(data,altClassName,renderer){var postRenderers=[],_renderer=renderer||this.getRenderer();if("function"==typeof this.initContainer&&(postRenderers=this.getBody().postRender(data,"",renderer)),_renderer)postRenderers.push(_renderer.postRender(this,data,altClassName));else throw"postRender: no renderer found for the element "+this.qtiClass+":"+this.serial;return _.compact(postRenderers)},getContainer:function($scope,subclass){var renderer=this.getRenderer();if(renderer)return renderer.getContainer(this,$scope,subclass);throw"getContainer: no renderer found for the element "+this.qtiClass+":"+this.serial},toArray:function(){var arr={serial:this.serial,type:this.qtiClass,attributes:this.getAttributes()};return"function"==typeof this.initContainer&&(arr.body=this.getBody().toArray()),"function"==typeof this.initObject&&(arr.object=this.object.toArray()),arr},isEmpty:function(){return!1},addClass:function(className){var clazz=this.attr("class")||"";_containClass(clazz,className)||this.attr("class",clazz+(clazz.length?" ":"")+className)},hasClass:function(className){return _containClass(this.attr("class"),className)},removeClass:function(className){var clazz=this.attr("class")||"";if(clazz){var regex=new RegExp("(?:^|\\s)"+className+"(?:\\s|$)");clazz=clazz.replace(regex," ").trim(),clazz?this.attr("class",clazz):this.removeAttr("class")}},toggleClass:function(className,state){return"boolean"==typeof state?state?this.addClass(className):this.removeClass(className):this.hasClass(className)?this.removeClass(className):this.addClass(className)},isset:function(){return Element.issetElement(this.serial)},unset:function(){return Element.unsetElement(this.serial)}}),_containClass=function(allClassStr,className){var regex=new RegExp("(?:^|\\s)"+className+"(?:\\s|$)","");return allClassStr&®ex.test(allClassStr)};return Element.isA=function(qtiElement,qtiClass){return qtiElement instanceof Element&&qtiElement.is(qtiClass)},Element.getElementBySerial=function(serial){return _instances[serial]},Element.issetElement=function(serial){return!!_instances[serial]},Element.unsetElement=function(serial){var element=Element.getElementBySerial(serial);if(element){var composingElements=element.getComposingElements();return _.forEach(composingElements,function(elt){delete _instances[elt.serial]}),delete _instances[element.serial],!0}return!1},Element}),define("taoQtiItem/qtiItem/helper/xmlNsHandler",[],function(){"use strict";function getPrefix(namespaces,html5Ns){let key;for(key in namespaces)if(namespaces[key]===html5Ns)return key;return"qh5"}const prefixed="article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section";var xmlNsHandler={stripNs:function stripNs(body){const pattern="([\\w]+)\\:(article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section)",openRegEx=/(<([\w]+)\:(article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section))/gi,closeRegEx=/(<\/([\w]+)\:(article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section)>)/gi;return body.replace(openRegEx,"<$3").replace(closeRegEx,"$3>")},restoreNs:function restoreNs(xml,namespaces){let ignoreMarkup=!!(2)+)/gim,""));const xmlRe=/(<(article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section)[^>]*>|<\/(article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section)>)/gi,tagRe=/((<)(article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section)([^>]*)(>)|(<\/)(article|aside|bdi|figure|footer|header|nav|rb|rp|rt|rtc|ruby|section)(>))/i,xmlMatch=xmlCopy.match(xmlRe),imsXsd="http://www.imsglobal.org/xsd",html5Ns=imsXsd+"/imsqtiv2p2_html5_v1p0",prefix=getPrefix(namespaces,html5Ns),prefixAtt="xmlns:"+prefix+"=\""+html5Ns+"\"";let i=xmlMatch?xmlMatch.length:0;if(!xmlMatch)return xml;for(;i--;){const tagMatch=xmlMatch[i].match(tagRe);xml=xml.replace(xmlMatch[i],tagMatch[5]?"<"+prefix+":"+tagMatch[3]+tagMatch[4]+">":""+prefix+":"+tagMatch[7]+">")}return xmlMatch.length&&-1===xml.indexOf(prefixAtt)&&(xml=xml.replace("({qtiClass:"responseCondition",responseIf:{qtiClass:"responseIf",expression:{qtiClass:"match",expressions:[{qtiClass:"variable",attributes:{identifier:responseIdentifier}},{qtiClass:"correct",attributes:{identifier:responseIdentifier}}]},responseRules:[{qtiClass:"setOutcomeValue",attributes:{identifier:outcomeIdentifier},expression:{qtiClass:"sum",expressions:[{qtiClass:"variable",attributes:{identifier:outcomeIdentifier}},{qtiClass:"baseValue",attributes:{baseType:"integer"},value:"1"}]}}]}}),MAP_RESPONSE:(responseIdentifier,outcomeIdentifier)=>({qtiClass:"responseCondition",responseIf:{qtiClass:"responseIf",expression:{qtiClass:"not",expressions:[{qtiClass:"isNull",expressions:[{qtiClass:"variable",attributes:{identifier:responseIdentifier}}]}]},responseRules:[{qtiClass:"setOutcomeValue",attributes:{identifier:outcomeIdentifier},expression:{qtiClass:"sum",expressions:[{qtiClass:"variable",attributes:{identifier:outcomeIdentifier}},{qtiClass:"mapResponse",attributes:{identifier:responseIdentifier}}]}}]}}),MAP_RESPONSE_POINT:(responseIdentifier,outcomeIdentifier)=>({qtiClass:"responseCondition",responseIf:{qtiClass:"responseIf",expression:{qtiClass:"not",expressions:[{qtiClass:"isNull",expressions:[{qtiClass:"variable",attributes:{identifier:responseIdentifier}}]}]},responseRules:[{qtiClass:"setOutcomeValue",attributes:{identifier:outcomeIdentifier},expression:{qtiClass:"sum",expressions:[{qtiClass:"variable",attributes:{identifier:outcomeIdentifier}},{qtiClass:"mapResponsePoint",attributes:{identifier:responseIdentifier}}]}}]}})};return responseRules}),define("taoQtiItem/qtiItem/helper/response",["lodash","taoQtiItem/qtiItem/helper/responseRules"],function(_,responseRulesHelper){"use strict";_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,responseRulesHelper=responseRulesHelper&&Object.prototype.hasOwnProperty.call(responseRulesHelper,"default")?responseRulesHelper["default"]:responseRulesHelper;const _templateNames={MATCH_CORRECT:"http://www.imsglobal.org/question/qti_v2p1/rptemplates/match_correct",MAP_RESPONSE:"http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_response",MAP_RESPONSE_POINT:"http://www.imsglobal.org/question/qti_v2p1/rptemplates/map_response_point",NONE:"no_response_processing"};var response={isUsingTemplate(response,tpl){return!!(_.isString(tpl)&&(tpl===response.template||_templateNames[tpl]===response.template))},isValidTemplateName(tplName){return!!this.getTemplateUriFromName(tplName)},getTemplateUriFromName(tplName){return _templateNames[tplName]||""},getTemplateNameFromUri(tplUri){let tplName="";return _.forIn(_templateNames,(uri,name)=>{if(uri===tplUri)return tplName=name,!1}),tplName},getTemplateNameFromResponseRules(responseIdentifier,responseRules){if(!responseRules)return"NONE";const{responseIf:{responseRules:[outcomeRules={}]=[]}={}}=responseRules,{attributes:{identifier:outcomeIdentifier}={}}=outcomeRules;return outcomeIdentifier?Object.keys(responseRulesHelper).find(key=>_.isEqual(responseRules,responseRulesHelper[key](responseIdentifier,outcomeIdentifier))):""}};return response}),define("taoQtiItem/qtiItem/helper/itemScore",[],function(){"use strict";var itemScore=responseIdentifiers=>{const outcomeExpressions=responseIdentifiers.map(outcomeIdentifier=>({qtiClass:"variable",attributes:{identifier:`SCORE_${outcomeIdentifier}`}}));return{qtiClass:"setOutcomeValue",attributes:{identifier:"SCORE"},expression:{qtiClass:"sum",expressions:outcomeExpressions}}};return itemScore}),define("taoQtiItem/qtiItem/core/Loader",["lodash","class","taoQtiItem/qtiItem/core/qtiClasses","taoQtiItem/qtiItem/core/Element","taoQtiItem/qtiItem/helper/xmlNsHandler","core/moduleLoader","taoQtiItem/qtiItem/helper/response","taoQtiItem/qtiItem/helper/itemScore"],function(_,_class,qtiClasses,Element,xmlNsHandler,moduleLoader,responseHelper,itemScoreHelper){"use strict";_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,qtiClasses=qtiClasses&&Object.prototype.hasOwnProperty.call(qtiClasses,"default")?qtiClasses["default"]:qtiClasses,Element=Element&&Object.prototype.hasOwnProperty.call(Element,"default")?Element["default"]:Element,xmlNsHandler=xmlNsHandler&&Object.prototype.hasOwnProperty.call(xmlNsHandler,"default")?xmlNsHandler["default"]:xmlNsHandler,moduleLoader=moduleLoader&&Object.prototype.hasOwnProperty.call(moduleLoader,"default")?moduleLoader["default"]:moduleLoader,responseHelper=responseHelper&&Object.prototype.hasOwnProperty.call(responseHelper,"default")?responseHelper["default"]:responseHelper,itemScoreHelper=itemScoreHelper&&Object.prototype.hasOwnProperty.call(itemScoreHelper,"default")?itemScoreHelper["default"]:itemScoreHelper;const loadPortableCustomElementProperties=(portableElement,rawProperties)=>{var properties={};_.forOwn(rawProperties,(value,key)=>{try{properties[key]=JSON.parse(value)}catch(e){properties[key]=value}}),portableElement.properties=properties},loadPortableCustomElementData=(portableElement,data)=>{portableElement.typeIdentifier=data.typeIdentifier,portableElement.markup=data.markup,portableElement.entryPoint=data.entryPoint,portableElement.libraries=data.libraries,portableElement.setNamespace("",data.xmlns),loadPortableCustomElementProperties(portableElement,data.properties)};var Loader=Class.extend({init(item,classesLocation){this.qti={},this.classesLocation={},this.item=item||null,this.setClassesLocation(classesLocation||qtiClasses)},setClassesLocation(qtiClassesList){return _.extend(this.classesLocation,qtiClassesList),this},getRequiredClasses(data){let ret=[];for(let i in data)"qtiClass"==i&&"_container"!==data[i]&&"rootElement"!==i?ret.push(data[i]):"object"==typeof data[i]&&"responseRules"!==i&&(ret=_.union(ret,this.getRequiredClasses(data[i])));return ret},loadRequiredClasses(data,callback,reload){let requiredClass;const requiredClasses=this.getRequiredClasses(data,reload),required=[];for(let i in requiredClasses)if(requiredClass=requiredClasses[i],this.classesLocation[requiredClass])required.push({module:this.classesLocation[requiredClass],category:"qti"});else throw new Error(`missing qti class location declaration : ${requiredClass}`);moduleLoader([],()=>!0).addList(required).load().then(loadeded=>{loadeded.forEach(QtiClass=>{this.qti[QtiClass.prototype.qtiClass]=QtiClass}),callback.call(this,this.qti)})},getLoadedClasses(){return _.keys(this.qti)},loadItemData(data,callback){this.loadRequiredClasses(data,Qti=>{if("object"==typeof data&&"assessmentItem"===data.qtiClass){for(let i in data.serial&&Element.unsetElement(data.serial),this.item=new Qti.assessmentItem(data.serial,data.attributes||{}),this.loadContainer(this.item.getBody(),data.body),data.outcomes){const outcome=this.buildOutcome(data.outcomes[i]);outcome&&this.item.addOutcomeDeclaration(outcome)}for(let i in data.feedbacks){const feedback=this.buildElement(data.feedbacks[i]);feedback&&this.item.addModalFeedback(feedback)}for(let i in data.stylesheets){const stylesheet=this.buildElement(data.stylesheets[i]);stylesheet&&this.item.addStylesheet(stylesheet)}let responseRules=data.responseProcessing&&data.responseProcessing.responseRules?[...data.responseProcessing.responseRules]:[];for(let i in data.responses){const responseIdentifier=data.responses[i].identifier,responseRuleItemIndex=responseRules.findIndex(_ref=>{let{responseIf:{expression:{expressions:[expression={}]=[]}={}}={}}=_ref;return expression.attributes&&expression.attributes.identifier===responseIdentifier||expression.expressions&&expression.expressions[0]&&expression.expressions[0].attributes&&expression.expressions[0].attributes.identifier===responseIdentifier}),[responseRule]=-1===responseRuleItemIndex?[]:responseRules.splice(responseRuleItemIndex,1),response=this.buildResponse(data.responses[i],responseRule);if(response){this.item.addResponseDeclaration(response);const feedbackRules=data.responses[i].feedbackRules;feedbackRules&&_.forIn(feedbackRules,(fbData,serial)=>{const{attributes:{identifier:feedbackOutcomeIdentifier}={}}=data.outcomes[fbData.feedbackOutcome]||{};response.feedbackRules[serial]=this.buildSimpleFeedbackRule(fbData,response);const feedbackResponseRuleIndex=responseRules.findIndex(_ref2=>{let{responseIf:{responseRules:[setOutcomeResponseRule={}]=[]}={}}=_ref2;const{attributes={},qtiClass}=setOutcomeResponseRule,outcomeIdentifier=attributes.identifier;return feedbackOutcomeIdentifier===outcomeIdentifier&&"setOutcomeValue"===qtiClass});-1!==feedbackResponseRuleIndex&&responseRules.splice(feedbackResponseRuleIndex,1)})}}const responseIdentifiers=Object.keys(this.item.responses||{}).map(responseKey=>this.item.responses[responseKey].attributes.identifier);if(data.responseProcessing){const customResponseProcessing=0!this.item.responses[responseKey].template);this.item.setResponseProcessing(this.buildResponseProcessing(data.responseProcessing,customResponseProcessing))}this.item.setNamespaces(data.namespaces),this.item.setSchemaLocations(data.schemaLocations),this.item.setApipAccessibility(data.apipAccessibility)}"function"==typeof callback&&callback.call(this,this.item)})},loadAndBuildElement(data,callback){this.loadRequiredClasses(data,()=>{const element=this.buildElement(data);"function"==typeof callback&&callback.call(this,element)})},loadElement(element,data,callback){this.loadRequiredClasses(data,()=>{this.loadElementData(element,data),"function"==typeof callback&&callback.call(this,element)})},loadElements(data,callback){if(!this.item)throw new Error("QtiLoader : cannot load elements in empty item");this.loadRequiredClasses(data,()=>{const allElements=this.item.getComposingElements();for(let i in data){const elementData=data[i];elementData&&elementData.qtiClass&&elementData.serial&&allElements[elementData.serial]&&this.loadElementData(allElements[elementData.serial],elementData)}"function"==typeof callback&&callback.call(this,this.item)})},buildResponse(data,responseRule){const response=this.buildElement(data);return response.template=responseHelper.getTemplateUriFromName(responseHelper.getTemplateNameFromResponseRules(data.identifier,responseRule))||data.howMatch||null,response.defaultValue=data.defaultValue||null,response.correctResponse=data.correctResponses||null,response.mapEntries=_.size(data.mapping)?data.mapping:_.size(data.areaMapping)?data.areaMapping:{},response.mappingAttributes=data.mappingAttributes||{},response},buildSimpleFeedbackRule(data,response){const feedbackRule=this.buildElement(data);feedbackRule.setCondition(response,data.condition,data.comparedValue||null),feedbackRule.feedbackOutcome=this.item.outcomes[data.feedbackOutcome]||null,feedbackRule.feedbackThen=this.item.modalFeedbacks[data.feedbackThen]||null,feedbackRule.feedbackElse=this.item.modalFeedbacks[data.feedbackElse]||null;const comparedOutcome=feedbackRule.comparedOutcome;return feedbackRule.feedbackThen&&feedbackRule.feedbackThen.data("relatedResponse",comparedOutcome),feedbackRule.feedbackElse&&feedbackRule.feedbackElse.data("relatedResponse",comparedOutcome),feedbackRule},buildOutcome(data){const outcome=this.buildElement(data);return outcome.defaultValue=data.defaultValue||null,outcome},buildResponseProcessing(data,customResponseProcessing){const rp=this.buildElement(data);return customResponseProcessing?(rp.xml=data.data,rp.processingType="custom"):rp.processingType="templateDriven",rp},loadContainer(bodyObject,bodyData){if(!Element.isA(bodyObject,"_container"))throw new Error("bodyObject must be a QTI Container");if(!(bodyData&&"string"==typeof bodyData.body&&"object"==typeof bodyData.elements))throw new Error("wrong bodydata format");const attributes=_.defaults(bodyData.attributes||{},bodyObject.attributes||{});for(let serial in bodyObject.setAttributes(attributes),bodyData.elements){const eltData=bodyData.elements[serial],element=this.buildElement(eltData);element&&bodyObject.setElement(element,bodyData.body)}bodyObject.body(xmlNsHandler.stripNs(bodyData.body))},buildElement(elementData){if(!(elementData&&elementData.qtiClass&&elementData.serial))throw new Error("wrong elementData format");const className=elementData.qtiClass;if(!this.qti[className])throw new Error(`the qti element class does not exist: ${className}`);const elt=new this.qti[className](elementData.serial);return this.loadElementData(elt,elementData),elt},loadElementData(element,data){const attributes=_.defaults(data.attributes||{},element.attributes||{});element.setAttributes(attributes);let body=data.body;return!body&&data.text&&"inlineChoice"===data.qtiClass&&(body={body:data.text,elements:{}}),element.body&&body&&element.bdy&&this.loadContainer(element.getBody(),body),element.object&&data.object&&element.object&&this.loadObjectData(element.object,data.object),Element.isA(element,"interaction")?this.loadInteractionData(element,data):Element.isA(element,"choice")?this.loadChoiceData(element,data):Element.isA(element,"math")?this.loadMathData(element,data):Element.isA(element,"infoControl")?this.loadPicData(element,data):Element.isA(element,"_tooltip")&&this.loadTooltipData(element,data),element},loadInteractionData(interaction,data){Element.isA(interaction,"blockInteraction")&&data.prompt&&this.loadContainer(interaction.prompt.getBody(),data.prompt),this.buildInteractionChoices(interaction,data),Element.isA(interaction,"customInteraction")&&this.loadPciData(interaction,data)},buildInteractionChoices(interaction,data){if(data.choices){if(Element.isA(interaction,"matchInteraction"))for(let set=0;2>set;set++){if(!data.choices[set])throw new Error(`missing match set #${set}`);const matchSet=data.choices[set];for(let serial in matchSet){const choice=this.buildElement(matchSet[serial]);choice&&interaction.addChoice(choice,set)}}else for(let serial in data.choices){const choice=this.buildElement(data.choices[serial]);choice&&interaction.addChoice(choice)}if(Element.isA(interaction,"graphicGapMatchInteraction")&&data.gapImgs)for(let serial in data.gapImgs){const gapImg=this.buildElement(data.gapImgs[serial]);gapImg&&interaction.addGapImg(gapImg)}}},loadChoiceData(choice,data){if(Element.isA(choice,"textVariableChoice"))choice.val(data.text);else if(Element.isA(choice,"gapImg"));else if(Element.isA(choice,"gapText"))choice.body()||choice.body(data.text);else if(Element.isA(choice,"containerChoice"));},loadObjectData(object,data){object.setAttributes(data.attributes),data._alt&&("object"===data._alt.qtiClass?object._alt=Loader.buildElement(data._alt):object._alt=data._alt)},loadMathData(math,data){math.ns=data.ns||{},math.setMathML(data.mathML||""),_.forIn(data.annotations||{},(value,encoding)=>{math.setAnnotation(encoding,value)})},loadTooltipData(tooltip,data){tooltip.content(data.content)},loadPciData(pci,data){loadPortableCustomElementData(pci,data)},loadPicData(pic,data){loadPortableCustomElementData(pic,data)}});return Loader}),define("taoQtiItem/qtiCreator/model/helper/event",["jquery","lodash"],function($,_){"use strict";var namespace=".qti-creator",namespaceModel=".qti-creator",eventList=["containerBodyChange","containerElementAdded","elementCreated.qti-widget","attributeChange.qti-widget","choiceCreated.qti-widget","correctResponseChange.qti-widget","mapEntryChange.qti-widget","mapEntryRemove.qti-widget","deleted.qti-widget","choiceTextChange.qti-widget","responseTemplateChange.qti-widget","mappingAttributeChange.qti-widget","feedbackRuleConditionChange.qti-widget","feedbackRuleCreated.qti-widget","feedbackRuleRemoved.qti-widget","feedbackRuleElseCreated.qti-widget","feedbackRuleElseRemoved.qti-widget"],event={choiceCreated:function choiceCreated(choice,interaction){$(document).trigger("choiceCreated.qti-widget",{choice:choice,interaction:interaction})},choiceDeleted:function choiceDeleted(choice,interaction){$(document).trigger("choiceDeleted.qti-widget",{choice:choice,interaction:interaction})},deleted:function(element,parent){element.isset()&&element.unset(),$(document).off("."+element.getSerial()),$(document).trigger("deleted.qti-widget",{element:element,parent:parent})},getList:function(addedNamespace){var events=_.clone(eventList);return addedNamespace?_.map(events,function(e){return e+"."+addedNamespace}):events},initElementToWidgetListeners:function(){var ns=".widget-container";$(document).off(".widget-container").on(event.getList(".widget-container").join(" "),function(e,data){var element=data.element||data.container||null,widget=data&&element&&element.data("widget");!widget&&data.parent&&(element=data.parent,widget=element.data("widget")),widget&&widget.$container.trigger(e.type+".qti-creator"+namespaceModel,data)})},getNs:function(){return".qti-creator"},getNsModel:function(){return namespaceModel}};return event}),define("taoQtiItem/qtiCreator/model/helper/invalidator",["lodash"],function(_){"use strict";const invalidator={completelyValid:function(element){const item=element.getRootElement();if(item){const serial=element.getSerial(),invalidElements=item.data("invalid")||{};delete invalidElements[serial],item.data("invalid",invalidElements)}},valid:function(element,key){const item=element.getRootElement(),serial=element.getSerial();if(item){const invalidElements=item.data("invalid")||{};if(key)invalidElements[serial]&&invalidElements[serial][key]&&(delete invalidElements[serial][key],!_.size(invalidElements[serial])&&delete invalidElements[serial],item.data("invalid",invalidElements));else throw new Error("missing required argument \"key\"")}},invalid:function(element,key,message,stateName){const item=element.getRootElement(),serial=element.getSerial();if(item){const invalidElements=item.data("invalid")||{};if(key)invalidElements[serial]||(invalidElements[serial]={}),invalidElements[serial][key]={message:message||"",stateName:stateName||"active"},item.data("invalid",invalidElements);else throw new Error("missing required arguments \"key\"")}},isValid:function(element,key){const item=element.getRootElement(),serial=element.getSerial();if(item){const invalidElements=item.data("invalid")||{};return key?!(invalidElements[serial]&&invalidElements[serial][key]):!invalidElements[serial]}return!0}};return invalidator}),define("taoQtiItem/qtiCreator/model/mixin/editable",["lodash","jquery","core/encoder/entity","taoQtiItem/qtiItem/core/Element","taoQtiItem/qtiCreator/model/helper/event","taoQtiItem/qtiCreator/model/helper/invalidator"],function(_,$,entity,Element,event,invalidator){"use strict";const _removeSelf=function(element){let removed=!1;const related=element.getRootElement();if(related){const found=related.find(element.getSerial());if(found){const parent=found.parent;if(element.getResponseDeclaration){const response=element.getResponseDeclaration();response&&(invalidator.completelyValid(response),Element.unsetElement(response))}Element.isA(parent,"interaction")?("gapImg"===element.qtiClass?parent.removeGapImg(element):Element.isA(element,"choice")&&parent.removeChoice(element),removed=!0):"body"===found.location&&_.isFunction(parent.initContainer)?(_.isFunction(element.beforeRemove)&&element.beforeRemove(),parent.getBody().removeElement(element),removed=!0):Element.isA(parent,"_container")&&(_.isFunction(element.beforeRemove)&&element.beforeRemove(),parent.removeElement(element),removed=!0),removed&&(element.data("removed",!0),invalidator.completelyValid(element),event.deleted(element,parent))}}else throw new Error("no related item found");return removed},_removeElement=function(element,containerPropName,eltToBeRemoved){let targetSerial="",targetElt;return element[containerPropName]&&("string"==typeof eltToBeRemoved?(targetSerial=eltToBeRemoved,targetElt=Element.getElementBySerial(targetSerial)):eltToBeRemoved instanceof Element&&(targetSerial=eltToBeRemoved.getSerial(),targetElt=eltToBeRemoved),targetSerial&&(invalidator.completelyValid(targetElt),delete element[containerPropName][targetSerial],Element.unsetElement(targetSerial))),element},methods={init:function(serial,attributes){const attr={};"object"==typeof serial&&(attributes=serial,serial=""),_.isFunction(this.getDefaultAttributes)&&_.extend(attr,this.getDefaultAttributes()),_.extend(attr,attributes),this._super(serial,attr)},attr:function(key,value){const ret=this._super(key,value);return"undefined"!=typeof key&&"undefined"!=typeof value&&$(document).trigger("attributeChange.qti-widget",{element:this,key:key,value:entity.encode(value)}),_.isString(ret)?entity.decode(ret):ret},removeAttr:function(key){const ret=this._super(key);return $(document).trigger("attributeChange.qti-widget",{element:this,key:key,value:null}),ret},remove:function(){if(0===arguments.length)return _removeSelf(this);if(2===arguments.length)return _removeElement(this,arguments[0],arguments[1]);throw new Error("invalid number of argument given")}};return methods}),define("taoQtiItem/qtiCreator/model/qtiClasses",["lodash","taoQtiItem/qtiItem/core/qtiClasses"],function(_,qtiClasses){"use strict";return _.defaults({assessmentItem:"taoQtiItem/qtiCreator/model/Item",_container:"taoQtiItem/qtiCreator/model/Container",figure:"taoQtiItem/qtiCreator/model/Figure",img:"taoQtiItem/qtiCreator/model/Img",figcaption:"taoQtiItem/qtiCreator/model/Figcaption",math:"taoQtiItem/qtiCreator/model/Math",object:"taoQtiItem/qtiCreator/model/Object",table:"taoQtiItem/qtiCreator/model/Table",rubricBlock:"taoQtiItem/qtiCreator/model/RubricBlock",modalFeedback:"taoQtiItem/qtiCreator/model/feedbacks/ModalFeedback",choiceInteraction:"taoQtiItem/qtiCreator/model/interactions/ChoiceInteraction",orderInteraction:"taoQtiItem/qtiCreator/model/interactions/OrderInteraction",associateInteraction:"taoQtiItem/qtiCreator/model/interactions/AssociateInteraction",matchInteraction:"taoQtiItem/qtiCreator/model/interactions/MatchInteraction",inlineChoiceInteraction:"taoQtiItem/qtiCreator/model/interactions/InlineChoiceInteraction",simpleChoice:"taoQtiItem/qtiCreator/model/choices/SimpleChoice",simpleAssociableChoice:"taoQtiItem/qtiCreator/model/choices/SimpleAssociableChoice",inlineChoice:"taoQtiItem/qtiCreator/model/choices/InlineChoice",mediaInteraction:"taoQtiItem/qtiCreator/model/interactions/MediaInteraction",uploadInteraction:"taoQtiItem/qtiCreator/model/interactions/UploadInteraction",textEntryInteraction:"taoQtiItem/qtiCreator/model/interactions/TextEntryInteraction",sliderInteraction:"taoQtiItem/qtiCreator/model/interactions/SliderInteraction",extendedTextInteraction:"taoQtiItem/qtiCreator/model/interactions/ExtendedTextInteraction",hotspotInteraction:"taoQtiItem/qtiCreator/model/interactions/HotspotInteraction",selectPointInteraction:"taoQtiItem/qtiCreator/model/interactions/SelectPointInteraction",graphicInteraction:"taoQtiItem/qtiCreator/model/interactions/GraphicOrderInteraction",graphicAssociateInteraction:"taoQtiItem/qtiCreator/model/interactions/GraphicAssociateInteraction",graphicGapMatchInteraction:"taoQtiItem/qtiCreator/model/interactions/GraphicGapMatchInteraction",graphicOrderInteraction:"taoQtiItem/qtiCreator/model/interactions/GraphicOrderInteraction",hotspotChoice:"taoQtiItem/qtiCreator/model/choices/HotspotChoice",gapImg:"taoQtiItem/qtiCreator/model/choices/GapImg",associableHotspot:"taoQtiItem/qtiCreator/model/choices/AssociableHotspot",gapMatchInteraction:"taoQtiItem/qtiCreator/model/interactions/GapMatchInteraction",hottextInteraction:"taoQtiItem/qtiCreator/model/interactions/HottextInteraction",hottext:"taoQtiItem/qtiCreator/model/choices/Hottext",gapText:"taoQtiItem/qtiCreator/model/choices/GapText",gap:"taoQtiItem/qtiCreator/model/choices/Gap",responseDeclaration:"taoQtiItem/qtiCreator/model/variables/ResponseDeclaration",responseProcessing:"taoQtiItem/qtiCreator/model/ResponseProcessing",customInteraction:"taoQtiItem/qtiCreator/model/interactions/PortableCustomInteraction",endAttemptInteraction:"taoQtiItem/qtiCreator/model/interactions/EndAttemptInteraction",infoControl:"taoQtiItem/qtiCreator/model/PortableInfoControl",include:"taoQtiItem/qtiCreator/model/Include",printedVariable:"taoQtiItem/qtiCreator/model/PrintedVariable",_tooltip:"taoQtiItem/qtiCreator/model/Tooltip"},qtiClasses)}),define("taoQtiItem/qtiCreator/model/helper/container",["jquery","lodash","taoQtiItem/qtiCreator/model/qtiClasses"],function($,_,qtiClasses){"use strict";var methods={createElements:function(container,body,callback){var regex=/{{([a-z_]+)\.?([a-z_]*):new}}/ig,required={};body.replace(regex,function(original,qtiClass){if(qtiClasses[qtiClass])required[qtiClass]=qtiClasses[qtiClass];else throw new Error("missing required class : "+qtiClass)}),require(_.values(required),function(){var Qti=_.reduce([].slice.call(arguments),function(acc,qtiClassElt){return acc[qtiClassElt.prototype.qtiClass]=qtiClassElt,acc},{}),promises=[],$doc=$(document),newElts={},newBody=body.replace(regex,function(original,qtiClass,subClass){var elt=new Qti[qtiClass];return Qti[qtiClass]?(container.getRenderer()&&elt.setRenderer(container.getRenderer()),newElts[elt.getSerial()]=elt,subClass&&(elt.typeIdentifier=subClass),elt.placeholder()):original});container.setElements(newElts,newBody),_.forEach(newElts,function(elt){_.isFunction(elt.buildIdentifier)&&elt.buildIdentifier(),_.isFunction(elt.afterCreate)&&promises.push(elt.afterCreate())}),"function"==typeof callback&&Promise.all(promises).then(function(){_.forEach(newElts,function(elt){$doc.trigger("elementCreated.qti-widget",{parent:container.parent(),element:elt})}),callback.call(container,newElts)}).catch(function(err){container.getRenderer().getCreatorContext().trigger("error",err)})})}};return methods}),define("taoQtiItem/qtiCreator/model/mixin/editableContainer",["taoQtiItem/qtiCreator/model/helper/container"],function(containerHelper){"use strict";var methods={createElements:function(body,callback){var _this=this;containerHelper.createElements(_this.getBody(),body,function(newElts){callback.call(_this,newElts)})}};return methods}),define("taoQtiItem/qtiItem/core/IdentifiedElement",["taoQtiItem/qtiItem/core/Element","taoQtiItem/qtiItem/helper/util"],function(Element,util){"use strict";Element=Element&&Object.prototype.hasOwnProperty.call(Element,"default")?Element["default"]:Element,util=util&&Object.prototype.hasOwnProperty.call(util,"default")?util["default"]:util;var IdentifiedElement=Element.extend({buildIdentifier:function buildIdentifier(prefix,useSuffix){var item=this.getRootElement(),id=util.buildIdentifier(item,prefix||this.qtiClass,useSuffix);return id&&this.attr("identifier",id),this},id:function id(value){return value||this.attr("identifier")||this.buildIdentifier(this.qtiClass,!0),this.attr("identifier",value)}});return IdentifiedElement}),define("taoQtiItem/qtiItem/mixin/Mixin",[],function(){"use strict";var Mixin={augment:function(targetClass,methods,options){if("function"==typeof targetClass&&"object"==typeof methods)for(var methodName in methods)if(!Object.hasOwnProperty(targetClass.prototype,methodName))targetClass.prototype[methodName]=methods[methodName];else if(options&&options.append){var _parent=targetClass.prototype[methodName];targetClass.prototype[methodName]=function(){return methods[methodName].apply(this,arguments),_parent.apply(this,arguments)}}}};return Mixin}),define("taoQtiItem/qtiItem/core/Container",["jquery","lodash","taoQtiItem/qtiItem/core/Element","taoQtiItem/qtiItem/helper/rendererConfig"],function($,_,Element,rendererConfig){"use strict";$=$&&Object.prototype.hasOwnProperty.call($,"default")?$["default"]:$,_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,Element=Element&&Object.prototype.hasOwnProperty.call(Element,"default")?Element["default"]:Element,rendererConfig=rendererConfig&&Object.prototype.hasOwnProperty.call(rendererConfig,"default")?rendererConfig["default"]:rendererConfig;var Container=Element.extend({qtiClass:"_container",init:function(body){if(this._super(),body&&"string"!=typeof body)throw"the body of a container must be a string";this.bdy=body||"",this.elements={}},body:function(body){if("undefined"==typeof body)return this.bdy;if("string"==typeof body)this.bdy=body,$(document).trigger("containerBodyChange",{body:body,container:this,parent:this.parent()});else throw"body must be a string"},setElements:function(elements,body){var returnValue=!1;for(var i in elements){var elt=elements[i];if(elt instanceof Element)body=body||this.bdy,-1===body.indexOf(elt.placeholder())&&(body+=elt.placeholder()),elt.setRootElement(this.getRootElement()||null),this.elements[elt.getSerial()]=elt,$(document).trigger("containerElementAdded",{element:elt,container:this}),returnValue=!0;else throw returnValue=!1,"expected a qti element"}return this.body(body),returnValue},setElement:function(element,body){return this.setElements([element],body)},removeElement:function(element){var serial="";return"string"==typeof element?serial=element:element instanceof Element&&(serial=element.getSerial()),delete this.elements[serial],this.body(this.body().replace("{{"+serial+"}}","")),this},getElements:function(qtiClass){var elts={};if("string"==typeof qtiClass)for(var serial in this.elements)Element.isA(this.elements[serial],qtiClass)&&(elts[serial]=this.elements[serial]);else elts=_.clone(this.elements);return elts},getElement:function(serial){return this.elements[serial]?this.elements[serial]:null},getComposingElements:function(){var elements=this.getElements(),elts={};for(var serial in elements)elts[serial]=elements[serial],elts=_.extend(elts,elements[serial].getComposingElements());return elts},render:function(){var args=rendererConfig.getOptionsFromArguments(arguments),renderer=args.renderer||this.getRenderer(),elementsData=[],tpl=this.body();for(var serial in this.elements){var elt=this.elements[serial];if("function"==typeof elt.render)"_container"===elt.qtiClass?tpl=tpl.replace(elt.placeholder(),elt.render(renderer)):(tpl=tpl.replace(elt.placeholder(),serial).replace(new RegExp(`{${serial}`),`{${serial}`).replace(serial,"{{{"+serial+"}}}"),elementsData[serial]=elt.render(renderer));else throw"render() is not defined for the qti element: "+serial}if(renderer.isRenderer)return this._super({body:renderer.renderDirect(tpl,elementsData),contentModel:this.contentModel||"flow"},renderer,args.placeholder);throw"invalid qti renderer for qti container"},postRender:function(data,altClassName,renderer){renderer=renderer||this.getRenderer();var res=_(this.elements).filter(function(elt){return"function"==typeof elt.postRender}).map(function(elt){return elt.postRender(data,"",renderer)}).flatten(!0).value().concat(this._super(data,altClassName,renderer));return res},toArray:function(){var arr={serial:this.serial,body:this.bdy,elements:{}};for(var serial in this.elements)arr.elements[serial]=this.elements[serial].toArray();return arr},find:function(serial,parent){var found=null;return this.elements[serial]?found={parent:parent||this,element:this.elements[serial],location:"body"}:_.forEach(this.elements,function(elt){if(found=elt.find(serial),found)return!1}),found},isEmpty:function(){return!this.bdy}});return Container}),define("taoQtiItem/qtiItem/mixin/Container",["taoQtiItem/qtiItem/mixin/Mixin","taoQtiItem/qtiItem/core/Container"],function(Mixin,Container$1){"use strict";Mixin=Mixin&&Object.prototype.hasOwnProperty.call(Mixin,"default")?Mixin["default"]:Mixin,Container$1=Container$1&&Object.prototype.hasOwnProperty.call(Container$1,"default")?Container$1["default"]:Container$1;var methods={initContainer:function(body){this.bdy=new Container$1(body||""),this.bdy.setRootElement(this.getRootElement()||null),this.bdy.contentModel="blockStatic"},getBody:function(){return this.bdy},body:function(body){var ret=this.bdy.body(body);return body?this:ret},setElement:function(element,body){return this.bdy.setElement(element,body),this},removeElement:function(element){return this.bdy.removeElement(element)},getElements:function(qtiClass){return this.bdy.getElements(qtiClass)},getElement:function(serial){return this.bdy.getElement(serial)}},Container={augment:function(targetClass){Mixin.augment(targetClass,methods)},methods:methods};return Container}),define("taoQtiItem/qtiItem/mixin/ContainerItemBody",["taoQtiItem/qtiItem/mixin/Mixin","taoQtiItem/qtiItem/mixin/Container","lodash"],function(Mixin,Container,_){"use strict";Mixin=Mixin&&Object.prototype.hasOwnProperty.call(Mixin,"default")?Mixin["default"]:Mixin,Container=Container&&Object.prototype.hasOwnProperty.call(Container,"default")?Container["default"]:Container,_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_;var methods={};_.extend(methods,Container.methods),_.extend(methods,{initContainer:function(body){Container.methods.initContainer.call(this,body),this.bdy.contentModel="itemBody"}});var ContainerItemBody={augment:function(targetClass){Mixin.augment(targetClass,methods)},methods:methods};return ContainerItemBody}),define("taoQtiItem/qtiItem/core/Item",["taoQtiItem/qtiItem/core/Element","taoQtiItem/qtiItem/core/IdentifiedElement","taoQtiItem/qtiItem/mixin/ContainerItemBody","lodash","jquery","taoQtiItem/qtiItem/helper/util"],function(Element,IdentifiedElement,Container,_,$,util){"use strict";Element=Element&&Object.prototype.hasOwnProperty.call(Element,"default")?Element["default"]:Element,IdentifiedElement=IdentifiedElement&&Object.prototype.hasOwnProperty.call(IdentifiedElement,"default")?IdentifiedElement["default"]:IdentifiedElement,Container=Container&&Object.prototype.hasOwnProperty.call(Container,"default")?Container["default"]:Container,_=_&&Object.prototype.hasOwnProperty.call(_,"default")?_["default"]:_,$=$&&Object.prototype.hasOwnProperty.call($,"default")?$["default"]:$,util=util&&Object.prototype.hasOwnProperty.call(util,"default")?util["default"]:util;var Item=IdentifiedElement.extend({qtiClass:"assessmentItem",init:function init(serial,attributes){this._super(serial,attributes),this.rootElement=this,this.stylesheets={},this.responses={},this.outcomes={},this.modalFeedbacks={},this.namespaces={},this.schemaLocations={},this.responseProcessing=null,this.apipAccessibility=null},getInteractions:function getInteractions(){var interactions=[],elts=this.getComposingElements();for(var serial in elts)Element.isA(elts[serial],"interaction")&&interactions.push(elts[serial]);return interactions},addResponseDeclaration:function addResponseDeclaration(response){if(Element.isA(response,"responseDeclaration"))response.setRootElement(this),this.responses[response.getSerial()]=response;else throw"is not a qti response declaration";return this},getResponseDeclaration:function getResponseDeclaration(identifier){for(var i in this.responses)if(this.responses[i].attr("identifier")===identifier)return this.responses[i];return null},addOutcomeDeclaration:function addOutcomeDeclaration(outcome){if(Element.isA(outcome,"outcomeDeclaration"))outcome.setRootElement(this),this.outcomes[outcome.getSerial()]=outcome;else throw"is not a qti outcome declaration";return this},getOutcomeDeclaration:function getOutcomeDeclaration(identifier){var found;return _.forEach(this.outcomes,function(outcome){if(outcome.id()===identifier)return found=outcome,!1}),found},getOutcomes:function getOutcomes(){return _.clone(this.outcomes)},removeOutcome:function removeOutcome(identifier){var outcome=this.getOutcomeDeclaration(identifier);outcome&&(this.outcomes=_.omit(this.outcomes,outcome.getSerial()))},addModalFeedback:function addModalFeedback(feedback){if(Element.isA(feedback,"modalFeedback"))feedback.setRootElement(this),this.modalFeedbacks[feedback.getSerial()]=feedback;else throw"is not a qti modal feedback";return this},getComposingElements:function getComposingElements(){var elts=this._super(),_this=this;return _.forEach(["responses","outcomes","modalFeedbacks","stylesheets"],function(elementCollection){for(var i in _this[elementCollection]){var elt=_this[elementCollection][i];elts[i]=elt,elts=_.extend(elts,elt.getComposingElements())}}),this.responseProcessing instanceof Element&&(elts[this.responseProcessing.getSerial()]=this.responseProcessing),elts},find:function find(serial){var found=this._super(serial);return found||(found=util.findInCollection(this,["responses","outcomes","modalFeedbacks","stylesheets"],serial)),found},getResponses:function getResponses(){return _.clone(this.responses)},getRootElement:function getRootElement(){return this},addNamespace:function addNamespace(name,uri){this.namespaces[name]=uri},setNamespaces:function setNamespaces(namespaces){this.namespaces=namespaces},getNamespaces:function getNamespaces(){return _.clone(this.namespaces)},setSchemaLocations:function setSchemaLocations(locations){this.schemaLocations=locations},getSchemaLocations:function getSchemaLocations(){return _.clone(this.schemaLocations)},setApipAccessibility:function setApipAccessibility(apip){this.apipAccessibility=apip||null},getApipAccessibility:function getApipAccessibility(){return this.apipAccessibility},addStylesheet:function addStylesheet(stylesheet){if(Element.isA(stylesheet,"stylesheet"))stylesheet.setRootElement(this),this.stylesheets[stylesheet.getSerial()]=stylesheet;else throw"is not a qti stylesheet declaration";return this},removeStyleSheet:function removeStyleSheet(stylesheet){return delete this.stylesheets[stylesheet.getSerial()],this},stylesheetExists:function stylesheetExists(href){var exists=!1;return _.forEach(this.stylesheets,function(stylesheet){if(stylesheet.attr("href")===href)return exists=!0,!1}),exists},setResponseProcessing:function setResponseProcessing(rp){if(Element.isA(rp,"responseProcessing"))rp.setRootElement(this),this.responseProcessing=rp;else throw"is not a response processing";return this},toArray:function toArray(){var arr=this._super(),toArray=function(elt){return elt.toArray()};return arr.namespaces=this.namespaces,arr.schemaLocations=this.schemaLocations,arr.outcomes=_.map(this.outcomes,toArray),arr.responses=_.map(this.responses,toArray),arr.stylesheets=_.map(this.stylesheets,toArray),arr.modalFeedbacks=_.map(this.modalFeedbacks,toArray),arr.responseProcessing=this.responseProcessing.toArray(),arr},isEmpty:function isEmpty(){var body=this.body().trim();if(body){var $dummy=$("