@pie-element/multiple-choice 11.3.1 → 11.3.2-next.11
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/CHANGELOG.md +16 -0
- package/configure/CHANGELOG.md +11 -0
- package/configure/package.json +4 -4
- package/controller/CHANGELOG.md +8 -0
- package/controller/package.json +2 -2
- package/module/configure.js +1 -1
- package/module/controller.js +77 -80
- package/module/element.js +1 -1
- package/module/index.html +1 -1
- package/module/manifest.json +6 -2
- package/module/print.html +1 -1
- package/module/print.js +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [11.4.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@11.2.0...@pie-element/multiple-choice@11.4.0) (2025-10-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* bump libs ([2616ab2](https://github.com/pie-framework/pie-elements/commit/2616ab24f776f4df02302f5855c381ee52527665))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Features
|
|
15
|
+
|
|
16
|
+
* **multiple-choice:** add options prop for ebsr print mode detection in MultipleChoice component ([592022a](https://github.com/pie-framework/pie-elements/commit/592022ac33611816e7d983169a8a7eda88470835))
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
6
22
|
## [11.3.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice@11.3.0...@pie-element/multiple-choice@11.3.1) (2025-10-14)
|
|
7
23
|
|
|
8
24
|
|
package/configure/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [8.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@8.2.0...@pie-element/multiple-choice-configure@8.3.0) (2025-10-15)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* bump libs ([2616ab2](https://github.com/pie-framework/pie-elements/commit/2616ab24f776f4df02302f5855c381ee52527665))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
## [8.2.1](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-configure@8.2.0...@pie-element/multiple-choice-configure@8.2.1) (2025-10-14)
|
|
7
18
|
|
|
8
19
|
|
package/configure/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/multiple-choice-configure",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.3.0",
|
|
4
4
|
"private": true,
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -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.
|
|
12
|
-
"@pie-lib/editable-html": "^11.
|
|
13
|
-
"@pie-lib/render-ui": "^4.
|
|
11
|
+
"@pie-lib/config-ui": "^11.29.0",
|
|
12
|
+
"@pie-lib/editable-html": "^11.21.0",
|
|
13
|
+
"@pie-lib/render-ui": "^4.35.0",
|
|
14
14
|
"debug": "^3.1.0",
|
|
15
15
|
"lodash": "^4.17.15",
|
|
16
16
|
"prop-types": "^15.6.2",
|
package/controller/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [6.3.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@6.2.0...@pie-element/multiple-choice-controller@6.3.0) (2025-10-15)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @pie-element/multiple-choice-controller
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
6
14
|
# [6.2.0](https://github.com/pie-framework/pie-elements/compare/@pie-element/multiple-choice-controller@6.0.1...@pie-element/multiple-choice-controller@6.2.0) (2025-10-10)
|
|
7
15
|
|
|
8
16
|
|
package/controller/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/multiple-choice-controller",
|
|
3
3
|
"private": true,
|
|
4
|
-
"version": "6.
|
|
4
|
+
"version": "6.3.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "src/index.js",
|
|
8
8
|
"author": "",
|
|
9
9
|
"license": "ISC",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@pie-lib/controller-utils": "^0.
|
|
11
|
+
"@pie-lib/controller-utils": "^0.22.0",
|
|
12
12
|
"debug": "^3.1.0",
|
|
13
13
|
"lodash": "^4.17.15"
|
|
14
14
|
}
|
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.7/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^2.19.7/module/index.js";import{_dll_pie_lib__editable_html as d}from"../../../@pie-lib/editable-html-module@^5.6.7/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.0/module/index.js";import{_dll_pie_lib__config_ui as c}from"../../../@pie-lib/config-module@^2.22.0/module/index.js";import{_dll_pie_lib__editable_html as d}from"../../../@pie-lib/editable-html-module@^5.9.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};
|
package/module/controller.js
CHANGED
|
@@ -2541,6 +2541,26 @@ 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
|
+
|
|
2544
2564
|
var baseGetTag = _baseGetTag,
|
|
2545
2565
|
isObjectLike = isObjectLike_1;
|
|
2546
2566
|
|
|
@@ -3107,90 +3127,67 @@ function shuffle(collection) {
|
|
|
3107
3127
|
|
|
3108
3128
|
var shuffle_1 = shuffle;
|
|
3109
3129
|
|
|
3110
|
-
|
|
3111
|
-
|
|
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
|
-
|
|
3130
|
+
// eslint-disable-next-line no-console
|
|
3131
|
+
const lg = (n) => console[n].bind(console, 'controller-utils:');
|
|
3137
3132
|
const debug = lg('debug');
|
|
3138
3133
|
const log = lg('log');
|
|
3139
3134
|
const warn = lg('warn');
|
|
3140
3135
|
const error = lg('error');
|
|
3141
|
-
|
|
3136
|
+
|
|
3137
|
+
const compact = (arr) => {
|
|
3142
3138
|
if (Array.isArray(arr)) {
|
|
3143
|
-
return arr.filter(v => v !== null && v !== undefined);
|
|
3139
|
+
return arr.filter((v) => v !== null && v !== undefined);
|
|
3144
3140
|
}
|
|
3145
|
-
|
|
3146
3141
|
return arr;
|
|
3147
3142
|
};
|
|
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
|
-
|
|
3177
|
-
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3143
|
+
|
|
3144
|
+
const getShuffledChoices = (choices, session, updateSession, choiceKey) =>
|
|
3145
|
+
new Promise((resolve) => {
|
|
3146
|
+
log('updateSession type: ', typeof updateSession);
|
|
3147
|
+
log('session: ', session);
|
|
3148
|
+
|
|
3149
|
+
const currentShuffled = compact(session?.data?.shuffledValues || session?.shuffledValues || []);
|
|
3150
|
+
|
|
3151
|
+
if (!session) {
|
|
3152
|
+
// eslint-disable-next-line quotes
|
|
3153
|
+
warn("unable to save shuffled choices because there's no session.");
|
|
3154
|
+
resolve(undefined);
|
|
3155
|
+
} else if (!isEmpty_1(currentShuffled)) {
|
|
3156
|
+
debug('use shuffledValues to sort the choices...', session.data?.shuffledValues);
|
|
3157
|
+
resolve(compact(currentShuffled.map((v) => choices.find((c) => c[choiceKey] === v))));
|
|
3158
|
+
} else {
|
|
3159
|
+
const shuffledChoices = shuffle_1(choices);
|
|
3160
|
+
|
|
3161
|
+
if (updateSession && typeof updateSession === 'function') {
|
|
3162
|
+
try {
|
|
3163
|
+
//Note: session.id refers to the id of the element within a session
|
|
3164
|
+
const shuffledValues = compact(shuffledChoices.map((c) => c[choiceKey]));
|
|
3165
|
+
log('try to save shuffledValues to session...', shuffledValues);
|
|
3166
|
+
log('call updateSession... ', session.id, session.element);
|
|
3167
|
+
if (isEmpty_1(shuffledValues)) {
|
|
3168
|
+
error(
|
|
3169
|
+
`shuffledValues is an empty array? - refusing to call updateSession: shuffledChoices: ${JSON.stringify(
|
|
3170
|
+
shuffledChoices,
|
|
3171
|
+
)}, key: ${choiceKey}`,
|
|
3172
|
+
);
|
|
3173
|
+
} else {
|
|
3174
|
+
updateSession(session.id, session.element, { shuffledValues }).catch((e) =>
|
|
3175
|
+
// eslint-disable-next-line no-console
|
|
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);
|
|
3181
3182
|
}
|
|
3182
|
-
}
|
|
3183
|
-
warn('unable to save shuffled
|
|
3184
|
-
error(e);
|
|
3183
|
+
} else {
|
|
3184
|
+
warn('unable to save shuffled choices, shuffle will happen every time.');
|
|
3185
3185
|
}
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
}
|
|
3189
|
-
|
|
3186
|
+
//save this shuffle to the session for later retrieval
|
|
3187
|
+
resolve(shuffledChoices);
|
|
3188
|
+
}
|
|
3189
|
+
});
|
|
3190
3190
|
|
|
3191
|
-
resolve(shuffledChoices);
|
|
3192
|
-
}
|
|
3193
|
-
});
|
|
3194
3191
|
/**
|
|
3195
3192
|
* If we return:
|
|
3196
3193
|
* - true - that means that the order of the choices will be ordinal (as is created in the configure item)
|
|
@@ -3201,7 +3198,6 @@ const getShuffledChoices = (choices, session, updateSession, choiceKey) => new P
|
|
|
3201
3198
|
* @param env - env to check if we should lock order
|
|
3202
3199
|
* @returns {boolean}
|
|
3203
3200
|
*/
|
|
3204
|
-
|
|
3205
3201
|
const lockChoices = (model, session, env) => {
|
|
3206
3202
|
if (model.lockChoiceOrder) {
|
|
3207
3203
|
return true;
|
|
@@ -3217,16 +3213,17 @@ const lockChoices = (model, session, env) => {
|
|
|
3217
3213
|
|
|
3218
3214
|
if (role === 'instructor') {
|
|
3219
3215
|
// TODO: .. in the future the instructor can toggle between ordinal and shuffled here, so keeping this code until then
|
|
3220
|
-
|
|
3221
3216
|
/*const alreadyShuffled = hasShuffledValues(session);
|
|
3222
|
-
|
|
3217
|
+
|
|
3218
|
+
if (alreadyShuffled) {
|
|
3223
3219
|
return false;
|
|
3224
3220
|
}
|
|
3225
|
-
return true;*/
|
|
3226
|
-
return true;
|
|
3227
|
-
} // here it's a student, so don't lock and it will shuffle if needs be
|
|
3228
3221
|
|
|
3222
|
+
return true;*/
|
|
3223
|
+
return true;
|
|
3224
|
+
}
|
|
3229
3225
|
|
|
3226
|
+
// here it's a student, so don't lock and it will shuffle if needs be
|
|
3230
3227
|
return false;
|
|
3231
3228
|
};
|
|
3232
3229
|
|
|
@@ -3382,7 +3379,7 @@ function outcome(model, session, env) {
|
|
|
3382
3379
|
if (!session || isEmpty_1(session)) {
|
|
3383
3380
|
resolve({ score: 0, empty: true });
|
|
3384
3381
|
} else {
|
|
3385
|
-
const partialScoringEnabled =
|
|
3382
|
+
const partialScoringEnabled = enabled(model, env) && model.choiceMode !== 'radio';
|
|
3386
3383
|
const score = getScore(model, session);
|
|
3387
3384
|
|
|
3388
3385
|
resolve({ score: partialScoringEnabled ? score : score === 1 ? 1 : 0, empty: false });
|