@pie-element/multiple-choice 11.0.1-next.19 → 11.0.1-next.28
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/configure/package.json +3 -3
- package/controller/package.json +1 -1
- package/module/configure.js +1 -1
- package/module/controller.js +80 -77
- package/module/element.js +1 -1
- package/module/manifest.json +1 -5
- package/module/print.js +1 -1
- package/package.json +6 -6
package/configure/package.json
CHANGED
|
@@ -8,9 +8,9 @@
|
|
|
8
8
|
"@material-ui/core": "^3.9.2",
|
|
9
9
|
"@material-ui/icons": "^3.0.1",
|
|
10
10
|
"@pie-framework/pie-configure-events": "^1.3.0",
|
|
11
|
-
"@pie-lib/config-ui": "^11.25.
|
|
12
|
-
"@pie-lib/editable-html": "^11.17.
|
|
13
|
-
"@pie-lib/render-ui": "^4.31.
|
|
11
|
+
"@pie-lib/config-ui": "^11.25.1",
|
|
12
|
+
"@pie-lib/editable-html": "^11.17.1",
|
|
13
|
+
"@pie-lib/render-ui": "^4.31.1",
|
|
14
14
|
"debug": "^3.1.0",
|
|
15
15
|
"lodash": "^4.17.15",
|
|
16
16
|
"prop-types": "^15.6.2",
|
package/controller/package.json
CHANGED
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.14.0/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^2.19.0/module/index.js";import{_dll_pie_lib__editable_html as d}from"../../../@pie-lib/editable-html-module@^5.6.0/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.14.5/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^2.19.5/module/index.js";import{_dll_pie_lib__editable_html as d}from"../../../@pie-lib/editable-html-module@^5.6.5/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};
|
package/module/controller.js
CHANGED
|
@@ -2541,26 +2541,6 @@ var defaults = {
|
|
|
2541
2541
|
keyboardEventsEnabled: false,
|
|
2542
2542
|
};
|
|
2543
2543
|
|
|
2544
|
-
const enabled = (config, env, defaultValue) => {
|
|
2545
|
-
// if model.partialScoring = false
|
|
2546
|
-
// - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
|
|
2547
|
-
// else if model.partialScoring = true || undefined
|
|
2548
|
-
// - if env.partialScoring = false, use dichotomous scoring
|
|
2549
|
-
// - else if env.partialScoring = true, use partial scoring
|
|
2550
|
-
config = config || {};
|
|
2551
|
-
env = env || {};
|
|
2552
|
-
|
|
2553
|
-
if (config.partialScoring === false) {
|
|
2554
|
-
return false;
|
|
2555
|
-
}
|
|
2556
|
-
|
|
2557
|
-
if (env.partialScoring === false) {
|
|
2558
|
-
return false;
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
return typeof defaultValue === 'boolean' ? defaultValue : true;
|
|
2562
|
-
};
|
|
2563
|
-
|
|
2564
2544
|
var baseGetTag = _baseGetTag,
|
|
2565
2545
|
isObjectLike = isObjectLike_1;
|
|
2566
2546
|
|
|
@@ -3127,67 +3107,90 @@ function shuffle(collection) {
|
|
|
3127
3107
|
|
|
3128
3108
|
var shuffle_1 = shuffle;
|
|
3129
3109
|
|
|
3130
|
-
|
|
3131
|
-
|
|
3110
|
+
const enabled = (config, env, defaultValue) => {
|
|
3111
|
+
// if model.partialScoring = false
|
|
3112
|
+
// - if env.partialScoring = false || env.partialScoring = true => use dichotomous scoring
|
|
3113
|
+
// else if model.partialScoring = true || undefined
|
|
3114
|
+
// - if env.partialScoring = false, use dichotomous scoring
|
|
3115
|
+
// - else if env.partialScoring = true, use partial scoring
|
|
3116
|
+
config = config || {};
|
|
3117
|
+
env = env || {};
|
|
3118
|
+
|
|
3119
|
+
if (config.partialScoring === false) {
|
|
3120
|
+
return false;
|
|
3121
|
+
}
|
|
3122
|
+
|
|
3123
|
+
if (env.partialScoring === false) {
|
|
3124
|
+
return false;
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
return typeof defaultValue === 'boolean' ? defaultValue : true;
|
|
3128
|
+
};
|
|
3129
|
+
|
|
3130
|
+
var partialScoring = /*#__PURE__*/Object.freeze({
|
|
3131
|
+
__proto__: null,
|
|
3132
|
+
enabled: enabled
|
|
3133
|
+
});
|
|
3134
|
+
|
|
3135
|
+
const lg = n => console[n].bind(console, 'controller-utils:');
|
|
3136
|
+
|
|
3132
3137
|
const debug = lg('debug');
|
|
3133
3138
|
const log = lg('log');
|
|
3134
3139
|
const warn = lg('warn');
|
|
3135
3140
|
const error = lg('error');
|
|
3136
|
-
|
|
3137
|
-
const compact = (arr) => {
|
|
3141
|
+
const compact = arr => {
|
|
3138
3142
|
if (Array.isArray(arr)) {
|
|
3139
|
-
return arr.filter(
|
|
3143
|
+
return arr.filter(v => v !== null && v !== undefined);
|
|
3140
3144
|
}
|
|
3145
|
+
|
|
3141
3146
|
return arr;
|
|
3142
3147
|
};
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
|
|
3162
|
-
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3168
|
-
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3172
|
-
|
|
3173
|
-
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
console.error('update session failed for: ', session.id, e),
|
|
3177
|
-
);
|
|
3178
|
-
}
|
|
3179
|
-
} catch (e) {
|
|
3180
|
-
warn('unable to save shuffled order for choices');
|
|
3181
|
-
error(e);
|
|
3148
|
+
const getShuffledChoices = (choices, session, updateSession, choiceKey) => new Promise(resolve => {
|
|
3149
|
+
var _session$data;
|
|
3150
|
+
|
|
3151
|
+
log('updateSession type: ', typeof updateSession);
|
|
3152
|
+
log('session: ', session);
|
|
3153
|
+
const currentShuffled = compact((session == null ? void 0 : (_session$data = session.data) == null ? void 0 : _session$data.shuffledValues) || (session == null ? void 0 : session.shuffledValues) || []);
|
|
3154
|
+
|
|
3155
|
+
if (!session) {
|
|
3156
|
+
// eslint-disable-next-line quotes
|
|
3157
|
+
warn("unable to save shuffled choices because there's no session.");
|
|
3158
|
+
resolve(undefined);
|
|
3159
|
+
} else if (!isEmpty_1(currentShuffled)) {
|
|
3160
|
+
var _session$data2;
|
|
3161
|
+
|
|
3162
|
+
debug('use shuffledValues to sort the choices...', (_session$data2 = session.data) == null ? void 0 : _session$data2.shuffledValues);
|
|
3163
|
+
resolve(compact(currentShuffled.map(v => choices.find(c => c[choiceKey] === v))));
|
|
3164
|
+
} else {
|
|
3165
|
+
const shuffledChoices = shuffle_1(choices);
|
|
3166
|
+
|
|
3167
|
+
if (updateSession && typeof updateSession === 'function') {
|
|
3168
|
+
try {
|
|
3169
|
+
//Note: session.id refers to the id of the element within a session
|
|
3170
|
+
const shuffledValues = compact(shuffledChoices.map(c => c[choiceKey]));
|
|
3171
|
+
log('try to save shuffledValues to session...', shuffledValues);
|
|
3172
|
+
log('call updateSession... ', session.id, session.element);
|
|
3173
|
+
|
|
3174
|
+
if (isEmpty_1(shuffledValues)) {
|
|
3175
|
+
error(`shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(shuffledChoices)}, key: ${choiceKey}`);
|
|
3176
|
+
} else {
|
|
3177
|
+
updateSession(session.id, session.element, {
|
|
3178
|
+
shuffledValues
|
|
3179
|
+
}).catch(e => // eslint-disable-next-line no-console
|
|
3180
|
+
console.error('update session failed for: ', session.id, e));
|
|
3182
3181
|
}
|
|
3183
|
-
}
|
|
3184
|
-
warn('unable to save shuffled
|
|
3182
|
+
} catch (e) {
|
|
3183
|
+
warn('unable to save shuffled order for choices');
|
|
3184
|
+
error(e);
|
|
3185
3185
|
}
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
}
|
|
3189
|
-
});
|
|
3186
|
+
} else {
|
|
3187
|
+
warn('unable to save shuffled choices, shuffle will happen every time.');
|
|
3188
|
+
} //save this shuffle to the session for later retrieval
|
|
3190
3189
|
|
|
3190
|
+
|
|
3191
|
+
resolve(shuffledChoices);
|
|
3192
|
+
}
|
|
3193
|
+
});
|
|
3191
3194
|
/**
|
|
3192
3195
|
* If we return:
|
|
3193
3196
|
* - true - that means that the order of the choices will be ordinal (as is created in the configure item)
|
|
@@ -3198,6 +3201,7 @@ const getShuffledChoices = (choices, session, updateSession, choiceKey) =>
|
|
|
3198
3201
|
* @param env - env to check if we should lock order
|
|
3199
3202
|
* @returns {boolean}
|
|
3200
3203
|
*/
|
|
3204
|
+
|
|
3201
3205
|
const lockChoices = (model, session, env) => {
|
|
3202
3206
|
if (model.lockChoiceOrder) {
|
|
3203
3207
|
return true;
|
|
@@ -3213,17 +3217,16 @@ const lockChoices = (model, session, env) => {
|
|
|
3213
3217
|
|
|
3214
3218
|
if (role === 'instructor') {
|
|
3215
3219
|
// TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
|
|
3216
|
-
/*const alreadyShuffled = hasShuffledValues(session);
|
|
3217
3220
|
|
|
3218
|
-
|
|
3221
|
+
/*const alreadyShuffled = hasShuffledValues(session);
|
|
3222
|
+
if (alreadyShuffled) {
|
|
3219
3223
|
return false;
|
|
3220
3224
|
}
|
|
3221
|
-
|
|
3222
|
-
return true;*/
|
|
3225
|
+
return true;*/
|
|
3223
3226
|
return true;
|
|
3224
|
-
}
|
|
3227
|
+
} // here it's a student, so don't lock and it will shuffle if needs be
|
|
3228
|
+
|
|
3225
3229
|
|
|
3226
|
-
// here it's a student, so don't lock and it will shuffle if needs be
|
|
3227
3230
|
return false;
|
|
3228
3231
|
};
|
|
3229
3232
|
|
|
@@ -3379,7 +3382,7 @@ function outcome(model, session, env) {
|
|
|
3379
3382
|
if (!session || isEmpty_1(session)) {
|
|
3380
3383
|
resolve({ score: 0, empty: true });
|
|
3381
3384
|
} else {
|
|
3382
|
-
const partialScoringEnabled = enabled(model, env) && model.choiceMode !== 'radio';
|
|
3385
|
+
const partialScoringEnabled = partialScoring.enabled(model, env) && model.choiceMode !== 'radio';
|
|
3383
3386
|
const score = getScore(model, session);
|
|
3384
3387
|
|
|
3385
3388
|
resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });
|