From 797427ceae71fcb41c9958ce6f5a9c833c2dfc7d Mon Sep 17 00:00:00 2001 From: jsconan Date: Thu, 24 Oct 2024 14:02:55 +0200 Subject: [PATCH 1/4] fix: add the new area required by the item authoring to the area broker --- views/js/qtiCreator/component/sharedStimulusAuthoring.js | 1 + 1 file changed, 1 insertion(+) diff --git a/views/js/qtiCreator/component/sharedStimulusAuthoring.js b/views/js/qtiCreator/component/sharedStimulusAuthoring.js index 2f15d1f5e..62913365b 100644 --- a/views/js/qtiCreator/component/sharedStimulusAuthoring.js +++ b/views/js/qtiCreator/component/sharedStimulusAuthoring.js @@ -153,6 +153,7 @@ define([ menuRight: $container.find('.menu-right'), contentCreatorPanel: $container.find('#item-editor-panel'), editorBar: $container.find('#item-editor-panel .item-editor-bar'), + editorWrapper: $('#item-editor-wrapper', $container), title: $container.find('#item-editor-panel .item-editor-bar h1'), toolbar: $container.find('#item-editor-panel .item-editor-bar #toolbar-top'), interactionPanel: $container.find('#item-editor-interaction-bar'), From b607254ab34f7d545bc428f8f0d7e681c56a8de4 Mon Sep 17 00:00:00 2001 From: jsconan Date: Thu, 31 Oct 2024 12:18:54 +0100 Subject: [PATCH 2/4] chore: bundle the assets --- views/js/loader/taoMediaManager.min.js | 2 +- views/js/loader/taoMediaManager.min.js.map | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/views/js/loader/taoMediaManager.min.js b/views/js/loader/taoMediaManager.min.js index 0379c6de7..0a1e3a491 100644 --- a/views/js/loader/taoMediaManager.min.js +++ b/views/js/loader/taoMediaManager.min.js @@ -1,2 +1,2 @@ -define("tpl!taoMediaManager/qtiCreator/tpl/relatedItemsPopup",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){function program1(depth0,data){var stack1,buffer="";return buffer+="
  • "+escapeExpression((stack1=depth0&&depth0.label,"function"===typeof stack1?stack1.apply(depth0):stack1))+"
  • ",buffer}this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,buffer="",functionType="function",escapeExpression=this.escapeExpression,self=this;return(helper=helpers.inUsageMessage)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.inUsageMessage,stack1="function"===typeof helper?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"\n\n",(helper=helpers.confirmationMessage)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.confirmationMessage,stack1="function"===typeof helper?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1),buffer})}),define("tpl!taoMediaManager/qtiCreator/tpl/relatedItemsClassPopup",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,options,buffer="",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression,functionType="function";return buffer+=""+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Warning",options):helperMissing.call(depth0,"__","Warning",options)))+"

    \n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"You are about to delete the class",options):helperMissing.call(depth0,"__","You are about to delete the class",options)))+" ",(helper=helpers.name)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.name,stack1="function"===typeof helper?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+", "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"which contains assets that are in use elsewhere.",options):helperMissing.call(depth0,"__","which contains assets that are in use elsewhere.",options)))+"\n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Deleting this class will break the items and the tests that are currently using them.",options):helperMissing.call(depth0,"__","Deleting this class will break the items and the tests that are currently using them.",options)))+"

    \n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Are you sure you want to delete this class and all of its content?",options):helperMissing.call(depth0,"__","Are you sure you want to delete this class and all of its content?",options))),buffer})}),define("tpl!taoMediaManager/qtiCreator/tpl/forbiddenClassAction",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,options,buffer="",helperMissing=helpers.helperMissing,escapeExpression=this.escapeExpression,functionType="function";return buffer+=""+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Forbidden action",options):helperMissing.call(depth0,"__","Forbidden action",options)))+"

    \n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"The class",options):helperMissing.call(depth0,"__","The class",options)))+" ",(helper=helpers.name)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.name,stack1="function"===typeof helper?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+" "+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"you are trying to delete is too large and contains too many subclasses.",options):helperMissing.call(depth0,"__","you are trying to delete is too large and contains too many subclasses.",options)))+"
    \n"+escapeExpression((helper=helpers.__||depth0&&depth0.__,options={hash:{},data:data},helper?helper.call(depth0,"Please delete the subclasses before.",options):helperMissing.call(depth0,"__","Please delete the subclasses before.",options))),buffer})}),define("css!taoMediaManagerCss/media",[],function(){}),define("taoMediaManager/controller/actions",["lodash","jquery","i18n","layout/actions/binder","uri","layout/section","core/request","core/router","core/logger","ui/feedback","ui/dialog/confirm","ui/dialog/alert","util/url","tpl!taoMediaManager/qtiCreator/tpl/relatedItemsPopup","tpl!taoMediaManager/qtiCreator/tpl/relatedItemsClassPopup","tpl!taoMediaManager/qtiCreator/tpl/forbiddenClassAction","css!taoMediaManagerCss/media.css"],function(_,$,__,binder,uri,section,request,router,loggerFactory,feedback,confirmDialog,alertDialog,urlUtil,relatedItemsPopupTpl,relatedItemsClassPopupTpl,forbiddenClassActionTpl){"use strict";function callConfirmModal(actionContext,message,url,data,resolve,reject){confirmDialog(message,()=>accept(actionContext,url,data,resolve,reject),()=>cancel(reject))}function callAlertModal(actionContext,message,reject){alertDialog(message,()=>cancel(reject))}function accept(actionContext,url,data,resolve,reject){return request({url:url,method:"POST",data:data,dataType:"json"}).then(function(response){return response.success&&response.deleted?(feedback().success(response.message||__("Resource deleted")),actionContext.tree&&$(actionContext.tree).trigger("removenode.taotree",[{id:actionContext.uri||actionContext.classUri}]),resolve({uri:actionContext.uri||actionContext.classUri})):void(response.success&&!response.deleted&&($(actionContext.tree).trigger("refresh.taotree"),reject(response.msg||response.message||__("Unable to delete the selected resource because you do not have the required rights to delete part of its content."))),reject(response.msg||response.message||__("Unable to delete the selected resource")))})}function cancel(reject){reject({cancel:!0})}const logger=loggerFactory("taoMediaManager/manageMedia");binder.register("newSharedStimulus",function instanciate(actionContext){const self=this,classUri=uri.decode(actionContext.classUri);return request({url:self.url,data:JSON.stringify({classUri:classUri}),method:"POST"}).then(function(response){return actionContext.tree&&$(actionContext.tree).trigger("addnode.taotree",[{uri:uri.decode(response.data.id),label:response.data.name,parent:uri.decode(actionContext.classUri),cssClass:"node-instance"}]),{uri:uri.decode(response.data.id),label:response.data.name,classUri:uri.decode(actionContext.classUri),type:"instance"}}).catch(err=>{_.isUndefined(err.message)||feedback().error(err.message),logger.error(err)})}),binder.register("sharedStimulusAuthoring",function sharedStimulusAuthoring(actionContext){section.updateContentBlock("").create({id:"authoring",name:__("Authoring"),url:this.url,content:" ",visible:!1}).show();const $panel=$("#panel-authoring");$panel.attr("data-id",actionContext.id),$panel.attr("data-uri",actionContext.uri),router.dispatch(`${this.url}?id=${actionContext.id}`)}),binder.register("deleteSharedStimulus",function remove(actionContext){const self=this;let data={},mediaRelationsData={type:"media"};return"instance"===actionContext.context[0]?mediaRelationsData.sourceId=actionContext.id:mediaRelationsData.classId=actionContext.id,data.uri=uri.decode(actionContext.uri),data.classUri=uri.decode(actionContext.classUri),data.id=actionContext.id,data.signature=actionContext.signature,new Promise(function(resolve,reject){request({url:urlUtil.route("index","ResourceRelations","tao"),data:mediaRelationsData,method:"GET",noToken:!0}).then(function(responseRelated){let message;const haveItemReferences=responseRelated.data.relations,name=$("a.clicked",actionContext.tree).text().trim();"instance"===actionContext.context[0]?0===haveItemReferences.length?message=`${__("Are you sure you want to delete this")} ${name}?`:message=relatedItemsPopupTpl({name,inUsageMessage:__("This \"%s\" is currently used in %d item(s)",name,haveItemReferences.length),confirmationMessage:__("Are you sure you want to delete this \"%s\"?",name),items:haveItemReferences}):"instance"!==actionContext.context[0]&&(0===haveItemReferences.length?message=`${__("Are you sure you want to delete this class and all of its content?")}`:0!==haveItemReferences.length&&(message=relatedItemsClassPopupTpl({name,number:haveItemReferences.length,items:haveItemReferences}))),callConfirmModal(actionContext,message,self.url,data,resolve,reject)}).catch(errorObject=>{let message;"class"===actionContext.context[0]&&999===errorObject.response.code&&(message=forbiddenClassActionTpl()),callAlertModal(actionContext,message,reject)})})})}),define("taoMediaManager/qtiCreator/helper/createDummyItemData",["taoQtiItem/qtiCreator/model/Item"],function(Item){"use strict";const _generateIdentifier=function _generateIdentifier(uri){const pos=uri.lastIndexOf("#");return uri.substr(pos+1)},creatorDummyItemData=function(sharedStimulusData){const newItem=new Item().id(_generateIdentifier(sharedStimulusData.id)).attr("title",sharedStimulusData.name);newItem.data("new",!0),newItem.data("dummy",!0);const itemData=Object.assign({},newItem);return delete itemData.bdy,delete itemData.rootElement,itemData.body=sharedStimulusData.body.body,itemData.qtiClass="assessmentItem",itemData.responseProcessing={attributes:{},qtiClass:"responseProcessing",responseRules:[],serial:`response_${sharedStimulusData.body.serial}`},itemData.response={},sharedStimulusData.body.attributes["xml:lang"]&&(itemData.attributes["xml:lang"]=sharedStimulusData.body.attributes["xml:lang"]),sharedStimulusData.body.attributes.class&&(itemData.attributes.class=sharedStimulusData.body.attributes.class),itemData};return creatorDummyItemData}),define("taoMediaManager/qtiCreator/helper/formatStyles",["jquery"],function($){"use strict";function handleStylesheetLoad(e){const path=e&&e.composedPath&&e.composedPath(),linkTag=path[0];if(linkTag){const stylesheetUrl=linkTag.href.split("&stylesheet="),rdf_styles=stylesheetUrl[0].split("%23").reverse()[0],assets=$(`[data-identifier='${rdf_styles}']`);if(assets.length)return void assets.each((h,asset)=>{const assetClassName=asset.children[0].className.match(/[\w-]*tao-[\w-]*/g)||asset.children[1].className.match(/[\w-]*tao-[\w-]*/g);assetClassName?_formatStyles(linkTag.sheet,assetClassName[0]):_hideStyles(linkTag.sheet)});const stylesheetSerial=linkTag.dataset.serial,passagesItem=$(`div[data-serial*='${stylesheetSerial}']`);if(passagesItem.length)return void passagesItem.each((h,passages)=>{const passageWrapper=$(passages).find(".qti-include > div"),passageItemClassName=passageWrapper[0]&&passageWrapper[0].className&&passageWrapper[0].className.match(/[\w-]*tao-[\w-]*/g);passageItemClassName&&_formatStyles(linkTag.sheet,passageItemClassName[0])});const passagesPreview=$(`[data-href*='${rdf_styles}']`);if(passagesPreview.length)return void passagesPreview.each((h,passages)=>{const passagePreviewClassName=passages.className.match(/[\w-]*tao-[\w-]*/g);passagePreviewClassName&&_formatStyles(linkTag.sheet,passagePreviewClassName[0])})}}function _hideStyles(linkTag){const{cssRules}=linkTag||{},CSSStyleSheet=linkTag||{};cssRules&&Object.values(cssRules).map((index,rule)=>{CSSStyleSheet.deleteRule(index)})}function _formatStyles(linkTag,className){const{cssRules}=linkTag||{},CSSStyleSheet=linkTag||{},classNameFormated=className&&className.length?`.${className}`:"",scopedCssRules=_scopeStyles(cssRules,classNameFormated,["body","html","div.qti-item"]);if(cssRules&&scopedCssRules){Object.values(cssRules).map((index,rule)=>{CSSStyleSheet.deleteRule(index)});const newRules=scopedCssRules.split("\n");Object.values(newRules).map(rule=>{CSSStyleSheet.insertRule(rule)})}}function _scopeStyles(cssRules,scopeSelector,toReplace,replacementSelector){if(!cssRules)return"";replacementSelector||(replacementSelector=scopeSelector);const scopedStyles=Object.values(cssRules).map(rule=>{if(!rule.selectorText)return"";const rulesInBrackets=rule.cssText.substr(rule.selectorText.length).trim(),selectors=rule.selectorText.split(/\s*,\s*/),scopedSelectors=[];for(let singleSelectorText of selectors){if(["html","body","div.qti-item"].includes(singleSelectorText))continue;let numRepeat=0;if(scopeSelector&&toReplace)for(let toReplaceSelector of toReplace)singleSelectorText.includes(toReplaceSelector)&&(00{let loader,itemData;itemData=creatorDummyItemData(values[1]),values[2].children.length&&values[2].children.forEach((stylesheet,index)=>{if("tao-user-styles.css"!==stylesheet.name){const serial=`creator_${index}`,link=urlUtil.route("loadStylesheet","SharedStimulusStyling","taoMediaManager",{uri:config.id,stylesheet:stylesheet.name});itemData.stylesheets[serial]={qtiClass:"stylesheet",attributes:{href:link,media:"all",title:stylesheet.name,type:"text/css",onload:e=>formatStyles.handleStylesheetLoad(e)},serial,getComposingElements:()=>({})}}}),loader=new Loader().setClassesLocation(qtiClasses),loader.loadItemData(itemData,function(loadedItem){let namespaces;namespaces=loadedItem.getNamespaces(),namespaces[""]=qtiNamespace,loadedItem.setNamespaces(namespaces),loadedItem.setSchemaLocations(qtiSchemaLocation),languagesList&&loadedItem.data("languagesList",values[0]),callback(loadedItem,this.getLoadedClasses())})})}}};return creatorLoader}),define("taoMediaManager/qtiCreator/renderers/config",["lodash","taoQtiItem/qtiCommonRenderer/renderers/config","taoItems/assets/manager","taoItems/assets/strategies"],function(_,commonRenderConfig,assetManagerFactory,assetStrategies){"use strict";const assetManager=assetManagerFactory([assetStrategies.taomedia,assetStrategies.external,assetStrategies.base64,assetStrategies.baseUrl],{baseUrl:""}),locations=_.defaults({_container:"taoQtiItem/qtiCreator/renderers/Container",_tooltip:"taoQtiItem/qtiCreator/renderers/Tooltip",assessmentItem:"taoMediaManager/qtiCreator/renderers/Item",figure:"taoMediaManager/qtiCreator/renderers/Figure",img:"taoMediaManager/qtiCreator/renderers/Img",figcaption:"taoMediaManager/qtiCreator/renderers/Figcaption",math:"taoQtiItem/qtiCreator/renderers/Math",object:"taoMediaManager/qtiCreator/renderers/Object",table:"taoMediaManager/qtiCreator/renderers/Table"},commonRenderConfig.locations);return{name:"creatorRenderer",locations:locations,options:{assetManager:assetManager}}}),define("taoMediaManager/qtiCreator/renderers/Renderer",["taoQtiItem/qtiRunner/core/Renderer","taoMediaManager/qtiCreator/renderers/config"],function(Renderer,config){"use strict";return Renderer.build(config.locations,config.name,config.options)}),define("taoMediaManager/qtiCreator/helper/creatorRenderer",["jquery","lodash","taoMediaManager/qtiCreator/renderers/Renderer","taoItems/assets/manager","taoItems/assets/strategies","util/dom"],function($,_,Renderer,assetManagerFactory,assetStrategies,dom){"use strict";let creatorRenderer=null;const get=function(reset,config,areaBroker){let $bodyEltForm;return config=config||{},config.properties=config.properties||{},(!creatorRenderer||reset)&&($bodyEltForm=creatorRenderer?creatorRenderer.getOption("bodyElementOptionForm"):null,(reset||!$bodyEltForm||!$bodyEltForm.length||!dom.contains($bodyEltForm))&&(creatorRenderer=new Renderer({lang:"",uri:"",shuffleChoices:!1,itemOptionForm:$("#item-editor-item-property-bar #sidebar-right-passage-properties .panel"),bodyElementOptionForm:areaBroker.getElementPropertyPanelArea(),textOptionForm:$("#item-editor-text-property-bar #sidebar-right-text-block-properties .panel"),mediaManager:{appendContainer:"#mediaManager",browseUrl:config.properties.getFilesUrl,uploadUrl:config.properties.fileUploadUrl,deleteUrl:config.properties.fileDeleteUrl,downloadUrl:config.properties.fileDownloadUrl,fileExistsUrl:config.properties.fileExistsUrl,path:config.properties.path,root:config.properties.root},qtiCreatorContext:config.qtiCreatorContext,locations:config.properties.locations}),creatorRenderer.getAssetManager().setData({baseUrl:config.properties.baseUrl||""}),creatorRenderer.setAreaBroker(areaBroker),_.assign(creatorRenderer,{getCreatorContext:function getCreatorContext(){return this.getOption("qtiCreatorContext")}}))),creatorRenderer};return{get:get,setOption:function(name,value){return get().setOption(name,value)},setOptions:function(options){return get().setOptions(options)},load:function(qtiClasses,done){return get().load(function(){if(_.isFunction(done)){for(var _len=arguments.length,rest=Array(_len),_key=0;_key<_len;_key++)rest[_key]=arguments[_key];done.apply(this,rest)}},qtiClasses)}}}),define("tpl!taoMediaManager/qtiCreator/tpl/toolbars/cssToggler",["handlebars"],function(hb){return hb.template(function(Handlebars,depth0,helpers,partials,data){this.compilerInfo=[4,">= 1.0.0"],helpers=this.merge(helpers,Handlebars.helpers),data=data||{};var stack1,helper,buffer="",functionType="function",escapeExpression=this.escapeExpression;return buffer+="
  • \n \n ",(helper=helpers.label)?stack1=helper.call(depth0,{hash:{},data:data}):(helper=depth0&&depth0.label,stack1="function"===typeof helper?helper.call(depth0,{hash:{},data:data}):helper),buffer+=escapeExpression(stack1)+"\n \n \n \n
  • ",buffer})}),define("taoMediaManager/qtiCreator/editor/styleEditor/styleEditor",["jquery","lodash","i18n","util/urlParser","core/dataProvider/request","tpl!taoMediaManager/qtiCreator/tpl/toolbars/cssToggler","taoMediaManager/qtiCreator/helper/formatStyles","util/url","services/features","jquery.fileDownload"],function($,_,__,UrlParser,request,cssTpl,formatStyles,urlUtil,featuresService){"use strict";const styleSheetManagerVisibilityKey="taoMediaManager/creator/StyleSheetManager";let itemConfig,globalConfig;const _getUri=function(action){return globalConfig[`${action}CssUrl`]},_basename=function(path){return path.substring(path.lastIndexOf("/")+1)},mainClassSelector="mainClass",hashClassSelector="hashClass",taoHashClassPrefix="tao-";let currentItem,hashClass="",mainClass="",style={},customStylesheet="";const $styleElem=function(){let styleElem=$("#item-editor-user-styles");return styleElem.length?styleElem.empty():(styleElem=$("