@pie-element/multiple-choice 11.4.3-next.4 → 11.4.3-next.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/module/configure.js +1 -1
- package/module/element.js +1 -1
- package/module/manifest.json +2 -2
- package/module/print.js +1 -1
- package/package.json +2 -2
package/module/configure.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{_dll_react as e,_dll_prop_types as t,_dll_material_ui__core_styles as o,_dll_material_ui__core as i,_dll_material_ui__icons as n,_dll_lodash as a,_dll_pie_lib__render_ui as s,_dll_debug as l,_dll_react_dom as r}from"../../../@pie-lib/shared-module@^1.17.3/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^2.23.1/module/index.js";import{_dll_pie_lib__editable_html as d}from"../../../@pie-lib/editable-html-module@^5.9.3/module/index.js";var h={};Object.defineProperty(h,"__esModule",{value:!0});class u extends CustomEvent{constructor(e,t=!1){super(u.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}u.TYPE="model.updated";var p=h.ModelUpdatedEvent=u;class g extends CustomEvent{constructor(e,t){super(g.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}g.TYPE="delete.image";var m=h.DeleteImageEvent=g;class b extends CustomEvent{constructor(e){super(b.TYPE,{bubbles:!0,detail:e}),this.handler=e}}b.TYPE="insert.image";var C=h.InsertImageEvent=b;class _ extends CustomEvent{constructor(e,t){super(_.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}_.TYPE="delete.sound";var f=h.DeleteSoundEvent=_;class E extends CustomEvent{constructor(e){super(E.TYPE,{bubbles:!0,detail:e}),this.handler=e}}E.TYPE="insert.sound";var v=h.InsertSoundEvent=E;const S=e,x=t,{color:y}=s,{withStyles:I}=o,{Button:A}=i,{Tooltip:M}=i,{Typography:P}=i,{Info:T}=n,{merge:w}=a,k=d,{AlertDialog:L}=c,{InputContainer:O}=c,{ChoiceConfiguration:R}=c,{settings:N}=c,{layout:D}=c,{choiceUtils:q}=c;function H(e){let t,o=e[0],i=1;for(;i<e.length;){const n=e[i],a=e[i+1];if(i+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(t=o,o=a(o)):"call"!==n&&"optionalCall"!==n||(o=a(((...e)=>o.call(t,...e))),t=void 0)}return o}const{Panel:B,toggle:W,radio:z,dropdown:Y}=N,j=e=>({promptHolder:{width:"100%",paddingTop:2*e.spacing.unit,marginBottom:2*e.spacing.unit},rationaleHolder:{flex:1,marginTop:1.5*e.spacing.unit,paddingTop:2*e.spacing.unit,marginLeft:3.5*e.spacing.unit},choiceConfigurationHolder:{display:"flex",flexDirection:"column",marginBottom:e.spacing.unit},choiceConfiguration:{width:"100%"},switchElement:{justifyContent:"space-between",margin:0},addButton:{marginTop:e.spacing.unit,float:"right"},disableButton:{cursor:"not-allowed",pointerEvents:"all",backgroundColor:y.disabled(),"&:hover":{backgroundColor:y.disabled()},"&:focus":{backgroundColor:y.disabled()}},flexContainer:{display:"flex",alignItems:"center"},titleText:{fontSize:e.typography.fontSize+2,marginRight:e.spacing.unit},tooltip:{fontSize:e.typography.fontSize-2,whiteSpace:"pre",maxWidth:"500px"},errorText:{fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing.unit}}),$=I(j)((e=>{const{classes:t,model:o,configuration:i,onPromptChanged:n,onChoiceChanged:a,onRemoveChoice:s,onAddChoice:l,imageSupport:r,uploadSoundSupport:c,onChangeModel:d,onConfigurationChanged:h,onTeacherInstructionsChanged:u}=e,{addChoiceButton:p={},contentDimensions:g={},feedback:m={},deleteChoice:b={},choiceMode:C={},choicePrefix:_={},partialScoring:f={},lockChoiceOrder:E={},teacherInstructions:v={},studentInstructions:x={},rationale:y={},scoringType:I={},sequentialChoiceLabels:w={},settingsPanelDisabled:L,choicesLayout:N,spellCheck:q={},gridColumns:j,maxImageWidth:$={},maxImageHeight:U={},prompt:F={},withRubric:G={},mathMlOptions:V={},language:J={},languageChoices:K={}}=i||{};let{maxAnswerChoices:Q}=i||{};const{limitChoicesNumber:X,teacherInstructionsEnabled:Z,rationaleEnabled:ee,feedbackEnabled:te,promptEnabled:oe,spellCheckEnabled:ie,choices:ne,errors:ae,toolbarEditorPosition:se,extraCSSRules:le}=o||{},{answerChoices:re,choices:ce,correctResponse:de,prompt:he,rationale:ue,teacherInstructions:pe}=ae||{},ge=H([ne,"optionalAccess",e=>e.length])?Array.from({length:ne.length},((e,t)=>`${t+1}`)):[],{baseInputConfiguration:me={}}=i,be={position:"top"===se?"top":"bottom"};X&&(Q=9);const Ce=(e={})=>({...me,...e}),_e=(e=>{const{minAnswerChoices:t,maxAnswerChoices:o}=e;return`Validation requirements:\nThere should be at least ${t} `+(o?`and at most ${o} `:"")+"answer choices defined.\nEvery answer choice should be non-blank and unique.\nA correct answer must be defined."})(i),fe=$&&$.prompt,Ee=U&&U.prompt,ve=Q&&H([ne,"optionalAccess",e=>e.length])>=Q?`Only ${Q} allowed maximum`:"",Se={choiceMode:C.settings&&z(C.label,["checkbox","radio"]),"sequentialChoiceLabels.enabled":w.settings&&W(w.label,!0),choicePrefix:_.settings&&z(_.label,["numbers","letters"]),partialScoring:f.settings&&W(f.label),lockChoiceOrder:E.settings&&W(E.label),feedbackEnabled:m.settings&&W(m.label),choicesLayout:N.settings&&Y(N.label,["vertical","grid","horizontal"]),gridColumns:N.settings&&"grid"===o.choicesLayout&&ge.length>0&&Y(j.label,ge),"language.enabled":J.settings&&W(J.label,!0),language:J.settings&&J.enabled&&Y(K.label,K.options)},xe={teacherInstructionsEnabled:v.settings&&W(v.label),studentInstructionsEnabled:x.settings&&W(x.label),promptEnabled:F.settings&&W(F.label),rationaleEnabled:y.settings&&W(y.label),spellCheckEnabled:q.settings&&W(q.label),scoringType:I.settings&&z(I.label,["auto","rubric"]),rubricEnabled:H([G,"optionalAccess",e=>e.settings])&&W(H([G,"optionalAccess",e=>e.label]))};return S.createElement(D.ConfigLayout,{dimensions:g,hideSettings:L,extraCSSRules:le,settings:S.createElement(B,{model:o,onChangeModel:d,configuration:i,onChangeConfiguration:h,groups:{Settings:Se,Properties:xe}})},Z&&S.createElement(O,{label:v.label,className:t.promptHolder},S.createElement(k,{className:t.prompt,markup:o.teacherInstructions||"",onChange:u,imageSupport:r,nonEmpty:!1,error:pe,toolbarOpts:be,pluginProps:Ce(H([i,"optionalAccess",e=>e.teacherInstructions,"optionalAccess",e=>e.inputConfiguration])),spellCheck:ie,maxImageWidth:$&&$.teacherInstructions||fe,maxImageHeight:U&&U.teacherInstructions||Ee,uploadSoundSupport:c,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:V}),pe&&S.createElement("div",{className:t.errorText},pe)),oe&&S.createElement(O,{label:F.label,className:t.promptHolder},S.createElement(k,{className:t.prompt,markup:o.prompt,onChange:n,imageSupport:r,nonEmpty:!1,disableUnderline:!0,error:he,toolbarOpts:be,pluginProps:Ce(H([i,"optionalAccess",e=>e.prompt,"optionalAccess",e=>e.inputConfiguration])),spellCheck:ie,maxImageWidth:$&&$.prompt,maxImageHeight:U&&U.prompt,uploadSoundSupport:c,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:V}),he&&S.createElement("div",{className:t.errorText},he)),S.createElement("div",{className:t.flexContainer},S.createElement(P,{className:t.titleText,component:"div"},"Choices"),S.createElement(M,{classes:{tooltip:t.tooltip},disableFocusListener:!0,disableTouchListener:!0,placement:"right",title:_e},S.createElement(T,{fontSize:"small",color:"primary"}))),ne.map(((e,n)=>S.createElement("div",{key:`choice-${n}`,className:t.choiceConfigurationHolder},S.createElement(R,{key:n,index:n+1,useLetterOrdering:"letters"===o.choicePrefix,className:t.choiceConfiguration,mode:o.choiceMode,data:e,defaultFeedback:{},imageSupport:r,disableImageAlignmentButtons:!0,onDelete:()=>s(n),onChange:e=>a(n,e),allowFeedBack:te,allowDelete:b.settings,noLabels:!0,pluginOpts:Ce(H([i,"optionalAccess",e=>e.choices,"optionalAccess",e=>e.inputConfiguration])),toolbarOpts:be,spellCheck:ie,error:H([ce,"optionalAccess",t=>t[e.value]])||null,noCorrectAnswerError:de,maxImageWidth:$&&$.choices||fe,maxImageHeight:U&&U.choices||Ee,uploadSoundSupport:c,mathMlOptions:V}),ee&&S.createElement(O,{key:`rationale-${n}`,label:y.label,className:t.rationaleHolder},S.createElement(k,{className:t.rationale,markup:e.rationale||"",onChange:t=>a(n,{...e,rationale:t}),imageSupport:r,error:H([ue,"optionalAccess",t=>t[e.value]])||null,toolbarOpts:be,pluginProps:Ce(H([i,"optionalAccess",e=>e.rationale,"optionalAccess",e=>e.inputConfiguration])),spellCheck:ie,maxImageWidth:$&&$.rationale||fe,maxImageHeight:U&&U.rationale||Ee,uploadSoundSupport:c,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:V}),H([ue,"optionalAccess",t=>t[e.value]])&&S.createElement("div",{className:t.errorText},H([ue,"optionalAccess",t=>t[e.value]])))))),de&&S.createElement("div",{className:t.errorText},de),re&&S.createElement("div",{className:t.errorText},re),p.settings&&S.createElement(M,{title:ve,classes:{tooltip:t.tooltip}},S.createElement(A,{classes:{root:Q&&H([ne,"optionalAccess",e=>e.length])>=Q&&t.disableButton},className:t.addButton,variant:"contained",color:"primary",onClick:l},p.label)))}));class U extends S.Component{constructor(...e){super(...e),U.prototype.__init.call(this),U.prototype.__init2.call(this),U.prototype.__init3.call(this),U.prototype.__init4.call(this),U.prototype.__init5.call(this),U.prototype.__init6.call(this),U.prototype.__init7.call(this)}static __initStatic(){this.propTypes={model:x.object.isRequired,configuration:x.object.isRequired,disableSidePanel:x.bool,onModelChanged:x.func.isRequired,onConfigurationChanged:x.func.isRequired,classes:x.object.isRequired,imageSupport:x.shape({add:x.func.isRequired,delete:x.func.isRequired})}}__init(){this.state={showWarning:!1}}__init2(){this.onRemoveChoice=e=>{const{model:t,configuration:o,onModelChanged:i}=this.props,{minAnswerChoices:n}=o||{};n&&t.choices.length===n?this.setState({showWarning:!0}):(t.choices.splice(e,1),i(t))}}__init3(){this.onAddChoice=()=>{const{model:e,configuration:t,onModelChanged:o}=this.props;let{maxAnswerChoices:i}=t||{};const{limitChoicesNumber:n}=e||{};n&&(i=9),i&&e.choices.length>=i||(e.choices.push({label:"",value:q.firstAvailableIndex(e.choices.map((e=>e.value)),0),feedback:{type:"none"}}),o(e))}}__init4(){this.onChoiceChanged=(e,t)=>{const{model:o,onModelChanged:i}=this.props;t.correct&&"radio"===o.choiceMode&&(o.choices=o.choices.map((e=>w({},e,{correct:!1})))),o.choices.splice(e,1,t),i(o)}}__init5(){this.onPromptChanged=e=>{this.props.onModelChanged({...this.props.model,prompt:e})}}__init6(){this.onTeacherInstructionsChanged=e=>{this.props.onModelChanged({...this.props.model,teacherInstructions:e})}}__init7(){this.onModelChanged=(e,t)=>{const{onModelChanged:o}=this.props;if("choiceMode"===t){if("radio"===e.choiceMode){let t=!1;e.choices=e.choices.map((e=>t?(e.correct=!1,e):(e.correct&&(t=!0),e)))}o(e,!0)}else o(e)}}render(){const{configuration:{minAnswerChoices:e}={}}=this.props,{showWarning:t}=this.state;return S.createElement(S.Fragment,null,S.createElement(L,{open:t,title:"Warning",text:`There can't be less than ${e||0} choices.`,onConfirm:()=>this.setState({showWarning:!1})}),S.createElement($,{...this.props,onChangeModel:this.onModelChanged,onRemoveChoice:this.onRemoveChoice,onChoiceChanged:this.onChoiceChanged,onAddChoice:this.onAddChoice,onPromptChanged:this.onPromptChanged,onTeacherInstructionsChanged:this.onTeacherInstructionsChanged}))}}U.__initStatic();const F=I(j)(U);var G={choiceMode:"checkbox",choicePrefix:"letters",choices:[],choicesLayout:"vertical",feedbackEnabled:!1,gridColumns:2,lockChoiceOrder:!0,partialScoring:!0,prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,scoringType:"auto",studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom",selectedAnswerBackgroundColor:"initial",keyboardEventsEnabled:!1},V={baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},choices:{inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}}},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},choicesLayout:{settings:!1,label:"Choices Layout"},gridColumns:{label:"Grid columns"},answerChoiceCount:0,addChoiceButton:{settings:!0,label:"Add a Choice"},choiceMode:{settings:!0,label:"Response Type"},choicePrefix:{settings:!0,label:"Choice Labels"},deleteChoice:{settings:!0},feedback:{settings:!0,label:"Feedback"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},lockChoiceOrder:{settings:!0,label:"Lock Choice Order"},partialScoring:{settings:!1,label:"Allow Partial Scoring"},rationale:{settings:!0,label:"Rationale",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!1}},required:!1},scoringType:{settings:!1,label:"Scoring Type"},studentInstructions:{settings:!1,label:"Student Instructions"},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},toolbarEditorPosition:{settings:!1,label:"Toolbar Editor Position"},minAnswerChoices:2,maxAnswerChoices:5,maxImageWidth:{teacherInstructions:300,prompt:300,rationale:636,choices:900},maxImageHeight:{teacherInstructions:300,prompt:300,rationale:300,choices:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]}};const J=e,K=r,Q=l,{defaults:X}=a,{choiceUtils:Z}=c;function ee(e){let t,o=e[0],i=1;for(;i<e.length;){const n=e[i],a=e[i+1];if(i+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(t=o,o=a(o)):"call"!==n&&"optionalCall"!==n||(o=a(((...e)=>o.call(t,...e))),t=void 0)}return o}const te=Q("multiple-choice:configure"),oe=(e,t=0)=>{if(!e||0===e.length){let e=[];for(let o=0;o<t;o++)e.push({value:`${o}`,label:"",feedback:{type:"none",value:""}});return e}return e},ie=(e,t)=>{const o=X(e,V);return{configuration:o,model:{...t,choices:oe(t&&t.choices||[],o&&o.answerChoiceCount)}}};class ne extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={})=>{const t=Z.normalizeChoices({...G,...e,choices:oe(e&&e.choices||[])});return t.choicesLayout=e.choicesLayout||!1===e.verticalMode&&"horizontal"||G.choicesLayout,t}}constructor(){super(),this._model=ne.createDefaultModel(),this._configuration=V,this.onModelChanged=this.onModelChanged.bind(this),this.onConfigurationChanged=this.onConfigurationChanged.bind(this)}set model(e){this._model=ne.createDefaultModel(e),this._render()}set configuration(e){const t=ie(e,this._model);this.onModelChanged(t.model);const o={...V,...t.configuration};this._configuration=o,ee([o,"optionalAccess",e=>e.language,"optionalAccess",e=>e.enabled])?ee([o,"optionalAccess",e=>e.languageChoices,"optionalAccess",e=>e.options,"optionalAccess",e=>e.length])&&(this._model.language=ee([o,"optionalAccess",e=>e.languageChoices,"access",e=>e.options,"access",e=>e[0],"access",e=>e.value])):o.language.settings&&this._model.language?(this._configuration.language.enabled=!0,this._configuration.languageChoices.options&&this._configuration.languageChoices.options.length||(this._configuration.languageChoices.options=[]),this._configuration.languageChoices.options.find((e=>e.value===this._model.language))||this._configuration.languageChoices.options.push({value:this._model.language,label:this._model.language})):delete this._model.language,this._render()}set disableSidePanel(e){this._disableSidePanel=e,this._render()}dispatchModelUpdated(e){const t=!!e;this.dispatchEvent(new p(this._model,t))}onModelChanged(e,t){this._model=e,this._render(),this.dispatchModelUpdated(t)}onConfigurationChanged(e){this._configuration=ie(e,this._model).configuration,this._model&&this.onModelChanged(this._model),this._render()}insertImage(e){this.dispatchEvent(new C(e))}onDeleteImage(e,t){this.dispatchEvent(new m(e,t))}insertSound(e){this.dispatchEvent(new v(e))}onDeleteSound(e,t){this.dispatchEvent(new f(e,t))}_render(){te("_render");let e=J.createElement(F,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged,onConfigurationChanged:this.onConfigurationChanged,disableSidePanel:this._disableSidePanel,imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});K.render(e,this)}}ne.__initStatic();export{ne as default};
|
|
1
|
+
import{_dll_react as e,_dll_prop_types as t,_dll_material_ui__core_styles as o,_dll_material_ui__core as i,_dll_material_ui__icons as n,_dll_lodash as a,_dll_pie_lib__render_ui as s,_dll_debug as l,_dll_react_dom as r}from"../../../@pie-lib/shared-module@^1.17.4/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^2.23.2/module/index.js";import{_dll_pie_lib__editable_html as d}from"../../../@pie-lib/editable-html-module@^5.9.4/module/index.js";var h={};Object.defineProperty(h,"__esModule",{value:!0});class u extends CustomEvent{constructor(e,t=!1){super(u.TYPE,{bubbles:!0,detail:{update:e,reset:t}}),this.update=e,this.reset=t}}u.TYPE="model.updated";var p=h.ModelUpdatedEvent=u;class g extends CustomEvent{constructor(e,t){super(g.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}g.TYPE="delete.image";var m=h.DeleteImageEvent=g;class b extends CustomEvent{constructor(e){super(b.TYPE,{bubbles:!0,detail:e}),this.handler=e}}b.TYPE="insert.image";var C=h.InsertImageEvent=b;class _ extends CustomEvent{constructor(e,t){super(_.TYPE,{bubbles:!0,detail:{src:e,done:t}}),this.src=e,this.done=t}}_.TYPE="delete.sound";var f=h.DeleteSoundEvent=_;class E extends CustomEvent{constructor(e){super(E.TYPE,{bubbles:!0,detail:e}),this.handler=e}}E.TYPE="insert.sound";var v=h.InsertSoundEvent=E;const S=e,x=t,{color:y}=s,{withStyles:I}=o,{Button:A}=i,{Tooltip:M}=i,{Typography:P}=i,{Info:T}=n,{merge:w}=a,k=d,{AlertDialog:L}=c,{InputContainer:O}=c,{ChoiceConfiguration:R}=c,{settings:N}=c,{layout:D}=c,{choiceUtils:q}=c;function H(e){let t,o=e[0],i=1;for(;i<e.length;){const n=e[i],a=e[i+1];if(i+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(t=o,o=a(o)):"call"!==n&&"optionalCall"!==n||(o=a(((...e)=>o.call(t,...e))),t=void 0)}return o}const{Panel:B,toggle:W,radio:z,dropdown:Y}=N,j=e=>({promptHolder:{width:"100%",paddingTop:2*e.spacing.unit,marginBottom:2*e.spacing.unit},rationaleHolder:{flex:1,marginTop:1.5*e.spacing.unit,paddingTop:2*e.spacing.unit,marginLeft:3.5*e.spacing.unit},choiceConfigurationHolder:{display:"flex",flexDirection:"column",marginBottom:e.spacing.unit},choiceConfiguration:{width:"100%"},switchElement:{justifyContent:"space-between",margin:0},addButton:{marginTop:e.spacing.unit,float:"right"},disableButton:{cursor:"not-allowed",pointerEvents:"all",backgroundColor:y.disabled(),"&:hover":{backgroundColor:y.disabled()},"&:focus":{backgroundColor:y.disabled()}},flexContainer:{display:"flex",alignItems:"center"},titleText:{fontSize:e.typography.fontSize+2,marginRight:e.spacing.unit},tooltip:{fontSize:e.typography.fontSize-2,whiteSpace:"pre",maxWidth:"500px"},errorText:{fontSize:e.typography.fontSize-2,color:e.palette.error.main,paddingTop:e.spacing.unit}}),$=I(j)((e=>{const{classes:t,model:o,configuration:i,onPromptChanged:n,onChoiceChanged:a,onRemoveChoice:s,onAddChoice:l,imageSupport:r,uploadSoundSupport:c,onChangeModel:d,onConfigurationChanged:h,onTeacherInstructionsChanged:u}=e,{addChoiceButton:p={},contentDimensions:g={},feedback:m={},deleteChoice:b={},choiceMode:C={},choicePrefix:_={},partialScoring:f={},lockChoiceOrder:E={},teacherInstructions:v={},studentInstructions:x={},rationale:y={},scoringType:I={},sequentialChoiceLabels:w={},settingsPanelDisabled:L,choicesLayout:N,spellCheck:q={},gridColumns:j,maxImageWidth:$={},maxImageHeight:U={},prompt:F={},withRubric:G={},mathMlOptions:V={},language:J={},languageChoices:K={}}=i||{};let{maxAnswerChoices:Q}=i||{};const{limitChoicesNumber:X,teacherInstructionsEnabled:Z,rationaleEnabled:ee,feedbackEnabled:te,promptEnabled:oe,spellCheckEnabled:ie,choices:ne,errors:ae,toolbarEditorPosition:se,extraCSSRules:le}=o||{},{answerChoices:re,choices:ce,correctResponse:de,prompt:he,rationale:ue,teacherInstructions:pe}=ae||{},ge=H([ne,"optionalAccess",e=>e.length])?Array.from({length:ne.length},((e,t)=>`${t+1}`)):[],{baseInputConfiguration:me={}}=i,be={position:"top"===se?"top":"bottom"};X&&(Q=9);const Ce=(e={})=>({...me,...e}),_e=(e=>{const{minAnswerChoices:t,maxAnswerChoices:o}=e;return`Validation requirements:\nThere should be at least ${t} `+(o?`and at most ${o} `:"")+"answer choices defined.\nEvery answer choice should be non-blank and unique.\nA correct answer must be defined."})(i),fe=$&&$.prompt,Ee=U&&U.prompt,ve=Q&&H([ne,"optionalAccess",e=>e.length])>=Q?`Only ${Q} allowed maximum`:"",Se={choiceMode:C.settings&&z(C.label,["checkbox","radio"]),"sequentialChoiceLabels.enabled":w.settings&&W(w.label,!0),choicePrefix:_.settings&&z(_.label,["numbers","letters"]),partialScoring:f.settings&&W(f.label),lockChoiceOrder:E.settings&&W(E.label),feedbackEnabled:m.settings&&W(m.label),choicesLayout:N.settings&&Y(N.label,["vertical","grid","horizontal"]),gridColumns:N.settings&&"grid"===o.choicesLayout&&ge.length>0&&Y(j.label,ge),"language.enabled":J.settings&&W(J.label,!0),language:J.settings&&J.enabled&&Y(K.label,K.options)},xe={teacherInstructionsEnabled:v.settings&&W(v.label),studentInstructionsEnabled:x.settings&&W(x.label),promptEnabled:F.settings&&W(F.label),rationaleEnabled:y.settings&&W(y.label),spellCheckEnabled:q.settings&&W(q.label),scoringType:I.settings&&z(I.label,["auto","rubric"]),rubricEnabled:H([G,"optionalAccess",e=>e.settings])&&W(H([G,"optionalAccess",e=>e.label]))};return S.createElement(D.ConfigLayout,{dimensions:g,hideSettings:L,extraCSSRules:le,settings:S.createElement(B,{model:o,onChangeModel:d,configuration:i,onChangeConfiguration:h,groups:{Settings:Se,Properties:xe}})},Z&&S.createElement(O,{label:v.label,className:t.promptHolder},S.createElement(k,{className:t.prompt,markup:o.teacherInstructions||"",onChange:u,imageSupport:r,nonEmpty:!1,error:pe,toolbarOpts:be,pluginProps:Ce(H([i,"optionalAccess",e=>e.teacherInstructions,"optionalAccess",e=>e.inputConfiguration])),spellCheck:ie,maxImageWidth:$&&$.teacherInstructions||fe,maxImageHeight:U&&U.teacherInstructions||Ee,uploadSoundSupport:c,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:V}),pe&&S.createElement("div",{className:t.errorText},pe)),oe&&S.createElement(O,{label:F.label,className:t.promptHolder},S.createElement(k,{className:t.prompt,markup:o.prompt,onChange:n,imageSupport:r,nonEmpty:!1,disableUnderline:!0,error:he,toolbarOpts:be,pluginProps:Ce(H([i,"optionalAccess",e=>e.prompt,"optionalAccess",e=>e.inputConfiguration])),spellCheck:ie,maxImageWidth:$&&$.prompt,maxImageHeight:U&&U.prompt,uploadSoundSupport:c,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:V}),he&&S.createElement("div",{className:t.errorText},he)),S.createElement("div",{className:t.flexContainer},S.createElement(P,{className:t.titleText,component:"div"},"Choices"),S.createElement(M,{classes:{tooltip:t.tooltip},disableFocusListener:!0,disableTouchListener:!0,placement:"right",title:_e},S.createElement(T,{fontSize:"small",color:"primary"}))),ne.map(((e,n)=>S.createElement("div",{key:`choice-${n}`,className:t.choiceConfigurationHolder},S.createElement(R,{key:n,index:n+1,useLetterOrdering:"letters"===o.choicePrefix,className:t.choiceConfiguration,mode:o.choiceMode,data:e,defaultFeedback:{},imageSupport:r,disableImageAlignmentButtons:!0,onDelete:()=>s(n),onChange:e=>a(n,e),allowFeedBack:te,allowDelete:b.settings,noLabels:!0,pluginOpts:Ce(H([i,"optionalAccess",e=>e.choices,"optionalAccess",e=>e.inputConfiguration])),toolbarOpts:be,spellCheck:ie,error:H([ce,"optionalAccess",t=>t[e.value]])||null,noCorrectAnswerError:de,maxImageWidth:$&&$.choices||fe,maxImageHeight:U&&U.choices||Ee,uploadSoundSupport:c,mathMlOptions:V}),ee&&S.createElement(O,{key:`rationale-${n}`,label:y.label,className:t.rationaleHolder},S.createElement(k,{className:t.rationale,markup:e.rationale||"",onChange:t=>a(n,{...e,rationale:t}),imageSupport:r,error:H([ue,"optionalAccess",t=>t[e.value]])||null,toolbarOpts:be,pluginProps:Ce(H([i,"optionalAccess",e=>e.rationale,"optionalAccess",e=>e.inputConfiguration])),spellCheck:ie,maxImageWidth:$&&$.rationale||fe,maxImageHeight:U&&U.rationale||Ee,uploadSoundSupport:c,languageCharactersProps:[{language:"spanish"},{language:"special"}],mathMlOptions:V}),H([ue,"optionalAccess",t=>t[e.value]])&&S.createElement("div",{className:t.errorText},H([ue,"optionalAccess",t=>t[e.value]])))))),de&&S.createElement("div",{className:t.errorText},de),re&&S.createElement("div",{className:t.errorText},re),p.settings&&S.createElement(M,{title:ve,classes:{tooltip:t.tooltip}},S.createElement(A,{classes:{root:Q&&H([ne,"optionalAccess",e=>e.length])>=Q&&t.disableButton},className:t.addButton,variant:"contained",color:"primary",onClick:l},p.label)))}));class U extends S.Component{constructor(...e){super(...e),U.prototype.__init.call(this),U.prototype.__init2.call(this),U.prototype.__init3.call(this),U.prototype.__init4.call(this),U.prototype.__init5.call(this),U.prototype.__init6.call(this),U.prototype.__init7.call(this)}static __initStatic(){this.propTypes={model:x.object.isRequired,configuration:x.object.isRequired,disableSidePanel:x.bool,onModelChanged:x.func.isRequired,onConfigurationChanged:x.func.isRequired,classes:x.object.isRequired,imageSupport:x.shape({add:x.func.isRequired,delete:x.func.isRequired})}}__init(){this.state={showWarning:!1}}__init2(){this.onRemoveChoice=e=>{const{model:t,configuration:o,onModelChanged:i}=this.props,{minAnswerChoices:n}=o||{};n&&t.choices.length===n?this.setState({showWarning:!0}):(t.choices.splice(e,1),i(t))}}__init3(){this.onAddChoice=()=>{const{model:e,configuration:t,onModelChanged:o}=this.props;let{maxAnswerChoices:i}=t||{};const{limitChoicesNumber:n}=e||{};n&&(i=9),i&&e.choices.length>=i||(e.choices.push({label:"",value:q.firstAvailableIndex(e.choices.map((e=>e.value)),0),feedback:{type:"none"}}),o(e))}}__init4(){this.onChoiceChanged=(e,t)=>{const{model:o,onModelChanged:i}=this.props;t.correct&&"radio"===o.choiceMode&&(o.choices=o.choices.map((e=>w({},e,{correct:!1})))),o.choices.splice(e,1,t),i(o)}}__init5(){this.onPromptChanged=e=>{this.props.onModelChanged({...this.props.model,prompt:e})}}__init6(){this.onTeacherInstructionsChanged=e=>{this.props.onModelChanged({...this.props.model,teacherInstructions:e})}}__init7(){this.onModelChanged=(e,t)=>{const{onModelChanged:o}=this.props;if("choiceMode"===t){if("radio"===e.choiceMode){let t=!1;e.choices=e.choices.map((e=>t?(e.correct=!1,e):(e.correct&&(t=!0),e)))}o(e,!0)}else o(e)}}render(){const{configuration:{minAnswerChoices:e}={}}=this.props,{showWarning:t}=this.state;return S.createElement(S.Fragment,null,S.createElement(L,{open:t,title:"Warning",text:`There can't be less than ${e||0} choices.`,onConfirm:()=>this.setState({showWarning:!1})}),S.createElement($,{...this.props,onChangeModel:this.onModelChanged,onRemoveChoice:this.onRemoveChoice,onChoiceChanged:this.onChoiceChanged,onAddChoice:this.onAddChoice,onPromptChanged:this.onPromptChanged,onTeacherInstructionsChanged:this.onTeacherInstructionsChanged}))}}U.__initStatic();const F=I(j)(U);var G={choiceMode:"checkbox",choicePrefix:"letters",choices:[],choicesLayout:"vertical",feedbackEnabled:!1,gridColumns:2,lockChoiceOrder:!0,partialScoring:!0,prompt:"",promptEnabled:!0,rationale:"",rationaleEnabled:!0,scoringType:"auto",studentInstructionsEnabled:!0,teacherInstructions:"",teacherInstructionsEnabled:!0,toolbarEditorPosition:"bottom",selectedAnswerBackgroundColor:"initial",keyboardEventsEnabled:!1},V={baseInputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1},textAlign:{disabled:!0},showParagraphs:{disabled:!1},separateParagraphs:{disabled:!0}},choices:{inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}}},spellCheck:{label:"Spellcheck",settings:!1,enabled:!0},choicesLayout:{settings:!1,label:"Choices Layout"},gridColumns:{label:"Grid columns"},answerChoiceCount:0,addChoiceButton:{settings:!0,label:"Add a Choice"},choiceMode:{settings:!0,label:"Response Type"},choicePrefix:{settings:!0,label:"Choice Labels"},deleteChoice:{settings:!0},feedback:{settings:!0,label:"Feedback"},prompt:{settings:!0,label:"Prompt",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},lockChoiceOrder:{settings:!0,label:"Lock Choice Order"},partialScoring:{settings:!1,label:"Allow Partial Scoring"},rationale:{settings:!0,label:"Rationale",inputConfiguration:{audio:{disabled:!0},video:{disabled:!0},image:{disabled:!1}},required:!1},scoringType:{settings:!1,label:"Scoring Type"},studentInstructions:{settings:!1,label:"Student Instructions"},teacherInstructions:{settings:!0,label:"Teacher Instructions",inputConfiguration:{audio:{disabled:!1},video:{disabled:!1},image:{disabled:!1}},required:!1},toolbarEditorPosition:{settings:!1,label:"Toolbar Editor Position"},minAnswerChoices:2,maxAnswerChoices:5,maxImageWidth:{teacherInstructions:300,prompt:300,rationale:636,choices:900},maxImageHeight:{teacherInstructions:300,prompt:300,rationale:300,choices:300},withRubric:{settings:!1,label:"Add Rubric"},mathMlOptions:{mmlOutput:!1,mmlEditing:!1},language:{settings:!1,label:"Specify Language",enabled:!1},languageChoices:{label:"Language Choices",options:[]}};const J=e,K=r,Q=l,{defaults:X}=a,{choiceUtils:Z}=c;function ee(e){let t,o=e[0],i=1;for(;i<e.length;){const n=e[i],a=e[i+1];if(i+=2,("optionalAccess"===n||"optionalCall"===n)&&null==o)return;"access"===n||"optionalAccess"===n?(t=o,o=a(o)):"call"!==n&&"optionalCall"!==n||(o=a(((...e)=>o.call(t,...e))),t=void 0)}return o}const te=Q("multiple-choice:configure"),oe=(e,t=0)=>{if(!e||0===e.length){let e=[];for(let o=0;o<t;o++)e.push({value:`${o}`,label:"",feedback:{type:"none",value:""}});return e}return e},ie=(e,t)=>{const o=X(e,V);return{configuration:o,model:{...t,choices:oe(t&&t.choices||[],o&&o.answerChoiceCount)}}};class ne extends HTMLElement{static __initStatic(){this.createDefaultModel=(e={})=>{const t=Z.normalizeChoices({...G,...e,choices:oe(e&&e.choices||[])});return t.choicesLayout=e.choicesLayout||!1===e.verticalMode&&"horizontal"||G.choicesLayout,t}}constructor(){super(),this._model=ne.createDefaultModel(),this._configuration=V,this.onModelChanged=this.onModelChanged.bind(this),this.onConfigurationChanged=this.onConfigurationChanged.bind(this)}set model(e){this._model=ne.createDefaultModel(e),this._render()}set configuration(e){const t=ie(e,this._model);this.onModelChanged(t.model);const o={...V,...t.configuration};this._configuration=o,ee([o,"optionalAccess",e=>e.language,"optionalAccess",e=>e.enabled])?ee([o,"optionalAccess",e=>e.languageChoices,"optionalAccess",e=>e.options,"optionalAccess",e=>e.length])&&(this._model.language=ee([o,"optionalAccess",e=>e.languageChoices,"access",e=>e.options,"access",e=>e[0],"access",e=>e.value])):o.language.settings&&this._model.language?(this._configuration.language.enabled=!0,this._configuration.languageChoices.options&&this._configuration.languageChoices.options.length||(this._configuration.languageChoices.options=[]),this._configuration.languageChoices.options.find((e=>e.value===this._model.language))||this._configuration.languageChoices.options.push({value:this._model.language,label:this._model.language})):delete this._model.language,this._render()}set disableSidePanel(e){this._disableSidePanel=e,this._render()}dispatchModelUpdated(e){const t=!!e;this.dispatchEvent(new p(this._model,t))}onModelChanged(e,t){this._model=e,this._render(),this.dispatchModelUpdated(t)}onConfigurationChanged(e){this._configuration=ie(e,this._model).configuration,this._model&&this.onModelChanged(this._model),this._render()}insertImage(e){this.dispatchEvent(new C(e))}onDeleteImage(e,t){this.dispatchEvent(new m(e,t))}insertSound(e){this.dispatchEvent(new v(e))}onDeleteSound(e,t){this.dispatchEvent(new f(e,t))}_render(){te("_render");let e=J.createElement(F,{model:this._model,configuration:this._configuration,onModelChanged:this.onModelChanged,onConfigurationChanged:this.onConfigurationChanged,disableSidePanel:this._disableSidePanel,imageSupport:{add:this.insertImage.bind(this),delete:this.onDeleteImage.bind(this)},uploadSoundSupport:{add:this.insertSound.bind(this),delete:this.onDeleteSound.bind(this)}});K.render(e,this)}}ne.__initStatic();export{ne as default};
|