@pie-element/ebsr 10.2.11-next.3 → 10.2.11-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/configure/package.json +1 -1
- package/controller/package.json +1 -1
- package/module/configure.js +1 -1
- package/module/element.js +83 -19
- package/module/manifest.json +1 -1
- package/module/print.js +83 -19
- package/package.json +4 -4
package/configure/package.json
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"@material-ui/core": "^3.9.2",
|
|
11
11
|
"@pie-element/multiple-choice": "^9.7.3",
|
|
12
12
|
"@pie-framework/pie-configure-events": "^1.2.0",
|
|
13
|
-
"@pie-lib/pie-toolbox": "2.
|
|
13
|
+
"@pie-lib/pie-toolbox": "2.8.0",
|
|
14
14
|
"lodash": "^4.17.15",
|
|
15
15
|
"prop-types": "^15.6.2",
|
|
16
16
|
"react": "^16.8.1",
|
package/controller/package.json
CHANGED
package/module/configure.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {_dll_react, _dll_prop_types, _dll_lodash, _dll_react_dom} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.1.1/module/index.js";
|
|
2
2
|
import MultipleChoiceConfigure from '@pie-element/multiple-choice/configure/lib';
|
|
3
|
-
import {_dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@5.8.
|
|
3
|
+
import {_dll_pie_lib__pie_toolbox_config_ui} from "../../../@pie-lib/pie-toolbox-module@5.8.1/module/index.js";
|
|
4
4
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
5
5
|
function getDefaultExportFromCjs(x) {
|
|
6
6
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
package/module/element.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.1.1/module/index.js";
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@5.8.
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@5.8.1/module/index.js";
|
|
3
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
4
|
function getDefaultExportFromCjs(x) {
|
|
5
5
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -12694,7 +12694,8 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12694
12694
|
onShowCorrectToggle: PropTypes$1.func,
|
|
12695
12695
|
isSelectionButtonBelow: PropTypes$1.bool,
|
|
12696
12696
|
minSelections: PropTypes$1.number,
|
|
12697
|
-
maxSelections: PropTypes$1.number
|
|
12697
|
+
maxSelections: PropTypes$1.number,
|
|
12698
|
+
autoplayAudioEnabled: PropTypes$1.bool
|
|
12698
12699
|
};
|
|
12699
12700
|
}
|
|
12700
12701
|
constructor(props) {
|
|
@@ -12810,19 +12811,19 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12810
12811
|
__self: this,
|
|
12811
12812
|
__source: {
|
|
12812
12813
|
fileName: _jsxFileName$1,
|
|
12813
|
-
lineNumber:
|
|
12814
|
+
lineNumber: 210
|
|
12814
12815
|
}
|
|
12815
12816
|
}, "Multiple Choice Question") : React$2.createElement('h2', {
|
|
12816
12817
|
className: classes.srOnly,
|
|
12817
12818
|
__self: this,
|
|
12818
12819
|
__source: {
|
|
12819
12820
|
fileName: _jsxFileName$1,
|
|
12820
|
-
lineNumber:
|
|
12821
|
+
lineNumber: 212
|
|
12821
12822
|
}
|
|
12822
12823
|
}, "Multiple Select Question");
|
|
12823
12824
|
}
|
|
12824
12825
|
render() {
|
|
12825
|
-
const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, session} = this.props;
|
|
12826
|
+
const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session} = this.props;
|
|
12826
12827
|
const {showCorrect, maxSelectionsErrorState} = this.state;
|
|
12827
12828
|
const isEvaluateMode = mode === 'evaluate';
|
|
12828
12829
|
const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
|
|
@@ -12838,7 +12839,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12838
12839
|
__self: this,
|
|
12839
12840
|
__source: {
|
|
12840
12841
|
fileName: _jsxFileName$1,
|
|
12841
|
-
lineNumber:
|
|
12842
|
+
lineNumber: 245
|
|
12842
12843
|
}
|
|
12843
12844
|
});
|
|
12844
12845
|
return React$2.createElement('div', {
|
|
@@ -12846,21 +12847,21 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12846
12847
|
__self: this,
|
|
12847
12848
|
__source: {
|
|
12848
12849
|
fileName: _jsxFileName$1,
|
|
12849
|
-
lineNumber:
|
|
12850
|
+
lineNumber: 254
|
|
12850
12851
|
}
|
|
12851
12852
|
}, partLabel && React$2.createElement('h3', {
|
|
12852
12853
|
className: classes.partLabel,
|
|
12853
12854
|
__self: this,
|
|
12854
12855
|
__source: {
|
|
12855
12856
|
fileName: _jsxFileName$1,
|
|
12856
|
-
lineNumber:
|
|
12857
|
+
lineNumber: 255
|
|
12857
12858
|
}
|
|
12858
12859
|
}, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
|
|
12859
12860
|
className: classes.teacherInstructions,
|
|
12860
12861
|
__self: this,
|
|
12861
12862
|
__source: {
|
|
12862
12863
|
fileName: _jsxFileName$1,
|
|
12863
|
-
lineNumber:
|
|
12864
|
+
lineNumber: 260
|
|
12864
12865
|
}
|
|
12865
12866
|
}, !animationsDisabled ? React$2.createElement(Collapsible, {
|
|
12866
12867
|
labels: {
|
|
@@ -12870,24 +12871,25 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12870
12871
|
__self: this,
|
|
12871
12872
|
__source: {
|
|
12872
12873
|
fileName: _jsxFileName$1,
|
|
12873
|
-
lineNumber:
|
|
12874
|
+
lineNumber: 262
|
|
12874
12875
|
}
|
|
12875
12876
|
}, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
|
|
12876
12877
|
className: classes.fieldset,
|
|
12877
12878
|
__self: this,
|
|
12878
12879
|
__source: {
|
|
12879
12880
|
fileName: _jsxFileName$1,
|
|
12880
|
-
lineNumber:
|
|
12881
|
+
lineNumber: 276
|
|
12881
12882
|
}
|
|
12882
12883
|
}, React$2.createElement(PreviewPrompt, {
|
|
12883
12884
|
className: "prompt",
|
|
12884
12885
|
defaultClassName: "prompt",
|
|
12885
12886
|
prompt: prompt,
|
|
12886
12887
|
tagName: 'legend',
|
|
12888
|
+
autoplayAudioEnabled: autoplayAudioEnabled,
|
|
12887
12889
|
__self: this,
|
|
12888
12890
|
__source: {
|
|
12889
12891
|
fileName: _jsxFileName$1,
|
|
12890
|
-
lineNumber:
|
|
12892
|
+
lineNumber: 277
|
|
12891
12893
|
}
|
|
12892
12894
|
}), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
|
|
12893
12895
|
show: showCorrectAnswerToggle,
|
|
@@ -12897,7 +12899,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12897
12899
|
__self: this,
|
|
12898
12900
|
__source: {
|
|
12899
12901
|
fileName: _jsxFileName$1,
|
|
12900
|
-
lineNumber:
|
|
12902
|
+
lineNumber: 286
|
|
12901
12903
|
}
|
|
12902
12904
|
}), React$2.createElement('div', {
|
|
12903
12905
|
className: classNames({
|
|
@@ -12908,7 +12910,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12908
12910
|
__self: this,
|
|
12909
12911
|
__source: {
|
|
12910
12912
|
fileName: _jsxFileName$1,
|
|
12911
|
-
lineNumber:
|
|
12913
|
+
lineNumber: 294
|
|
12912
12914
|
}
|
|
12913
12915
|
}, choices.map((choice, index) => React$2.createElement(StyledChoice, {
|
|
12914
12916
|
choicesLayout: this.props.choicesLayout,
|
|
@@ -12931,14 +12933,14 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12931
12933
|
__self: this,
|
|
12932
12934
|
__source: {
|
|
12933
12935
|
fileName: _jsxFileName$1,
|
|
12934
|
-
lineNumber:
|
|
12936
|
+
lineNumber: 302
|
|
12935
12937
|
}
|
|
12936
12938
|
})))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
|
|
12937
12939
|
className: classes.errorText,
|
|
12938
12940
|
__self: this,
|
|
12939
12941
|
__source: {
|
|
12940
12942
|
fileName: _jsxFileName$1,
|
|
12941
|
-
lineNumber:
|
|
12943
|
+
lineNumber: 326
|
|
12942
12944
|
}
|
|
12943
12945
|
}, translator.t(`translation:multipleChoice:minSelections_${minSelections === 1 ? 'one' : 'other'}`, {
|
|
12944
12946
|
lng: language,
|
|
@@ -12948,7 +12950,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12948
12950
|
__self: this,
|
|
12949
12951
|
__source: {
|
|
12950
12952
|
fileName: _jsxFileName$1,
|
|
12951
|
-
lineNumber:
|
|
12953
|
+
lineNumber: 334
|
|
12952
12954
|
}
|
|
12953
12955
|
}, translator.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
|
|
12954
12956
|
lng: language,
|
|
@@ -13066,7 +13068,10 @@ const {debounce: debounce} = _dll_lodash;
|
|
|
13066
13068
|
const debug$1 = _dll_debug;
|
|
13067
13069
|
const {renderMath: renderMath} = _dll_pie_lib__pie_toolbox_math_rendering;
|
|
13068
13070
|
const log$1 = debug$1('pie-ui:multiple-choice');
|
|
13069
|
-
const isComplete = (session, model) => {
|
|
13071
|
+
const isComplete = (session, model, audioComplete) => {
|
|
13072
|
+
if (!audioComplete) {
|
|
13073
|
+
return false;
|
|
13074
|
+
}
|
|
13070
13075
|
if (!session || !session.value) {
|
|
13071
13076
|
return false;
|
|
13072
13077
|
}
|
|
@@ -13085,6 +13090,7 @@ class MultipleChoice extends HTMLElement {
|
|
|
13085
13090
|
super();
|
|
13086
13091
|
this._model = null;
|
|
13087
13092
|
this._session = null;
|
|
13093
|
+
this.audioComplete = false;
|
|
13088
13094
|
this._rerender = debounce(() => {
|
|
13089
13095
|
if (this._model && this._session) {
|
|
13090
13096
|
var element = React.createElement(Root, {
|
|
@@ -13108,7 +13114,7 @@ class MultipleChoice extends HTMLElement {
|
|
|
13108
13114
|
trailing: true
|
|
13109
13115
|
});
|
|
13110
13116
|
this._dispatchResponseChanged = debounce(() => {
|
|
13111
|
-
this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), isComplete(this._session, this._model)));
|
|
13117
|
+
this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete)));
|
|
13112
13118
|
});
|
|
13113
13119
|
this._dispatchModelSet = debounce(() => {
|
|
13114
13120
|
this.dispatchEvent(new ModelSetEvent_1(this.tagName.toLowerCase(), isComplete(this._session, this._model), this._model !== undefined));
|
|
@@ -13143,8 +13149,66 @@ class MultipleChoice extends HTMLElement {
|
|
|
13143
13149
|
this._dispatchResponseChanged();
|
|
13144
13150
|
this._rerender();
|
|
13145
13151
|
}
|
|
13152
|
+
_createAudioInfoToast() {
|
|
13153
|
+
const info = document.createElement('div');
|
|
13154
|
+
info.id = 'play-audio-info';
|
|
13155
|
+
info.innerHTML = 'Click anywhere to enable audio autoplay. Browser restrictions require user interaction to play audio.';
|
|
13156
|
+
Object.assign(info.style, {
|
|
13157
|
+
position: 'fixed',
|
|
13158
|
+
bottom: '20px',
|
|
13159
|
+
left: '50%',
|
|
13160
|
+
transform: 'translateX(-50%)',
|
|
13161
|
+
backgroundColor: '#333',
|
|
13162
|
+
color: '#fff',
|
|
13163
|
+
padding: '10px 20px',
|
|
13164
|
+
borderRadius: '5px',
|
|
13165
|
+
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
13166
|
+
zIndex: '1000'
|
|
13167
|
+
});
|
|
13168
|
+
return info;
|
|
13169
|
+
}
|
|
13146
13170
|
connectedCallback() {
|
|
13147
13171
|
this._rerender();
|
|
13172
|
+
if (this._model && !this._model.autoplayAudioEnabled) {
|
|
13173
|
+
return;
|
|
13174
|
+
}
|
|
13175
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
13176
|
+
mutationsList.forEach(mutation => {
|
|
13177
|
+
if (mutation.type === 'childList') {
|
|
13178
|
+
const audio = this.querySelector('audio[autoplay]');
|
|
13179
|
+
if (!audio) return;
|
|
13180
|
+
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
13181
|
+
const info = this._createAudioInfoToast();
|
|
13182
|
+
this.appendChild(info);
|
|
13183
|
+
const enableAudio = () => {
|
|
13184
|
+
audio.play();
|
|
13185
|
+
this.removeChild(info);
|
|
13186
|
+
document.removeEventListener('click', enableAudio);
|
|
13187
|
+
};
|
|
13188
|
+
document.addEventListener('click', enableAudio);
|
|
13189
|
+
}
|
|
13190
|
+
const handlePlaying = () => {
|
|
13191
|
+
const info = this.querySelector('#play-audio-info');
|
|
13192
|
+
if (info) {
|
|
13193
|
+
this.removeChild(info);
|
|
13194
|
+
}
|
|
13195
|
+
audio.removeEventListener('playing', handlePlaying);
|
|
13196
|
+
};
|
|
13197
|
+
audio.addEventListener('playing', handlePlaying);
|
|
13198
|
+
const handleEnded = () => {
|
|
13199
|
+
this.audioComplete = true;
|
|
13200
|
+
this._dispatchResponseChanged();
|
|
13201
|
+
audio.removeEventListener('ended', handleEnded);
|
|
13202
|
+
};
|
|
13203
|
+
audio.addEventListener('ended', handleEnded);
|
|
13204
|
+
observer.disconnect();
|
|
13205
|
+
}
|
|
13206
|
+
});
|
|
13207
|
+
});
|
|
13208
|
+
observer.observe(this, {
|
|
13209
|
+
childList: true,
|
|
13210
|
+
subtree: true
|
|
13211
|
+
});
|
|
13148
13212
|
}
|
|
13149
13213
|
}
|
|
13150
13214
|
const {get: get} = _dll_lodash;
|
package/module/manifest.json
CHANGED
package/module/print.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {_dll_react, _dll_prop_types, _dll_classnames, _dll_react_dom, _dll_lodash, _dll_debug, _dll_pie_lib__pie_toolbox_math_rendering} from "../../../@pie-lib/pie-toolbox-math-rendering-module@3.1.1/module/index.js";
|
|
2
|
-
import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@5.8.
|
|
2
|
+
import {_dll_pie_lib__pie_toolbox_render_ui, _dll_pie_lib__pie_toolbox_correct_answer_toggle} from "../../../@pie-lib/pie-toolbox-module@5.8.1/module/index.js";
|
|
3
3
|
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
4
4
|
function getDefaultExportFromCjs(x) {
|
|
5
5
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -12657,7 +12657,8 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12657
12657
|
onShowCorrectToggle: PropTypes$1.func,
|
|
12658
12658
|
isSelectionButtonBelow: PropTypes$1.bool,
|
|
12659
12659
|
minSelections: PropTypes$1.number,
|
|
12660
|
-
maxSelections: PropTypes$1.number
|
|
12660
|
+
maxSelections: PropTypes$1.number,
|
|
12661
|
+
autoplayAudioEnabled: PropTypes$1.bool
|
|
12661
12662
|
};
|
|
12662
12663
|
}
|
|
12663
12664
|
constructor(props) {
|
|
@@ -12773,19 +12774,19 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12773
12774
|
__self: this,
|
|
12774
12775
|
__source: {
|
|
12775
12776
|
fileName: _jsxFileName$1,
|
|
12776
|
-
lineNumber:
|
|
12777
|
+
lineNumber: 210
|
|
12777
12778
|
}
|
|
12778
12779
|
}, "Multiple Choice Question") : React$2.createElement('h2', {
|
|
12779
12780
|
className: classes.srOnly,
|
|
12780
12781
|
__self: this,
|
|
12781
12782
|
__source: {
|
|
12782
12783
|
fileName: _jsxFileName$1,
|
|
12783
|
-
lineNumber:
|
|
12784
|
+
lineNumber: 212
|
|
12784
12785
|
}
|
|
12785
12786
|
}, "Multiple Select Question");
|
|
12786
12787
|
}
|
|
12787
12788
|
render() {
|
|
12788
|
-
const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, session} = this.props;
|
|
12789
|
+
const {mode, disabled, className, choices = [], choiceMode, gridColumns, partLabel, prompt, responseCorrect, teacherInstructions, classes, alwaysShowCorrect, animationsDisabled, language, isSelectionButtonBelow, minSelections, maxSelections, autoplayAudioEnabled, session} = this.props;
|
|
12789
12790
|
const {showCorrect, maxSelectionsErrorState} = this.state;
|
|
12790
12791
|
const isEvaluateMode = mode === 'evaluate';
|
|
12791
12792
|
const showCorrectAnswerToggle = isEvaluateMode && !responseCorrect;
|
|
@@ -12801,7 +12802,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12801
12802
|
__self: this,
|
|
12802
12803
|
__source: {
|
|
12803
12804
|
fileName: _jsxFileName$1,
|
|
12804
|
-
lineNumber:
|
|
12805
|
+
lineNumber: 245
|
|
12805
12806
|
}
|
|
12806
12807
|
});
|
|
12807
12808
|
return React$2.createElement('div', {
|
|
@@ -12809,21 +12810,21 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12809
12810
|
__self: this,
|
|
12810
12811
|
__source: {
|
|
12811
12812
|
fileName: _jsxFileName$1,
|
|
12812
|
-
lineNumber:
|
|
12813
|
+
lineNumber: 254
|
|
12813
12814
|
}
|
|
12814
12815
|
}, partLabel && React$2.createElement('h3', {
|
|
12815
12816
|
className: classes.partLabel,
|
|
12816
12817
|
__self: this,
|
|
12817
12818
|
__source: {
|
|
12818
12819
|
fileName: _jsxFileName$1,
|
|
12819
|
-
lineNumber:
|
|
12820
|
+
lineNumber: 255
|
|
12820
12821
|
}
|
|
12821
12822
|
}, partLabel), this.renderHeading(), teacherInstructions && React$2.createElement('div', {
|
|
12822
12823
|
className: classes.teacherInstructions,
|
|
12823
12824
|
__self: this,
|
|
12824
12825
|
__source: {
|
|
12825
12826
|
fileName: _jsxFileName$1,
|
|
12826
|
-
lineNumber:
|
|
12827
|
+
lineNumber: 260
|
|
12827
12828
|
}
|
|
12828
12829
|
}, !animationsDisabled ? React$2.createElement(Collapsible, {
|
|
12829
12830
|
labels: {
|
|
@@ -12833,24 +12834,25 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12833
12834
|
__self: this,
|
|
12834
12835
|
__source: {
|
|
12835
12836
|
fileName: _jsxFileName$1,
|
|
12836
|
-
lineNumber:
|
|
12837
|
+
lineNumber: 262
|
|
12837
12838
|
}
|
|
12838
12839
|
}, teacherInstructionsDiv) : teacherInstructionsDiv), React$2.createElement('fieldset', {
|
|
12839
12840
|
className: classes.fieldset,
|
|
12840
12841
|
__self: this,
|
|
12841
12842
|
__source: {
|
|
12842
12843
|
fileName: _jsxFileName$1,
|
|
12843
|
-
lineNumber:
|
|
12844
|
+
lineNumber: 276
|
|
12844
12845
|
}
|
|
12845
12846
|
}, React$2.createElement(PreviewPrompt, {
|
|
12846
12847
|
className: "prompt",
|
|
12847
12848
|
defaultClassName: "prompt",
|
|
12848
12849
|
prompt: prompt,
|
|
12849
12850
|
tagName: 'legend',
|
|
12851
|
+
autoplayAudioEnabled: autoplayAudioEnabled,
|
|
12850
12852
|
__self: this,
|
|
12851
12853
|
__source: {
|
|
12852
12854
|
fileName: _jsxFileName$1,
|
|
12853
|
-
lineNumber:
|
|
12855
|
+
lineNumber: 277
|
|
12854
12856
|
}
|
|
12855
12857
|
}), !alwaysShowCorrect && React$2.createElement(CorrectAnswerToggle, {
|
|
12856
12858
|
show: showCorrectAnswerToggle,
|
|
@@ -12860,7 +12862,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12860
12862
|
__self: this,
|
|
12861
12863
|
__source: {
|
|
12862
12864
|
fileName: _jsxFileName$1,
|
|
12863
|
-
lineNumber:
|
|
12865
|
+
lineNumber: 286
|
|
12864
12866
|
}
|
|
12865
12867
|
}), React$2.createElement('div', {
|
|
12866
12868
|
className: classNames({
|
|
@@ -12871,7 +12873,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12871
12873
|
__self: this,
|
|
12872
12874
|
__source: {
|
|
12873
12875
|
fileName: _jsxFileName$1,
|
|
12874
|
-
lineNumber:
|
|
12876
|
+
lineNumber: 294
|
|
12875
12877
|
}
|
|
12876
12878
|
}, choices.map((choice, index) => React$2.createElement(StyledChoice, {
|
|
12877
12879
|
choicesLayout: this.props.choicesLayout,
|
|
@@ -12894,14 +12896,14 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12894
12896
|
__self: this,
|
|
12895
12897
|
__source: {
|
|
12896
12898
|
fileName: _jsxFileName$1,
|
|
12897
|
-
lineNumber:
|
|
12899
|
+
lineNumber: 302
|
|
12898
12900
|
}
|
|
12899
12901
|
})))), choiceMode === 'checkbox' && selections < minSelections && React$2.createElement('div', {
|
|
12900
12902
|
className: classes.errorText,
|
|
12901
12903
|
__self: this,
|
|
12902
12904
|
__source: {
|
|
12903
12905
|
fileName: _jsxFileName$1,
|
|
12904
|
-
lineNumber:
|
|
12906
|
+
lineNumber: 326
|
|
12905
12907
|
}
|
|
12906
12908
|
}, translator$1.t(`translation:multipleChoice:minSelections_${minSelections === 1 ? 'one' : 'other'}`, {
|
|
12907
12909
|
lng: language,
|
|
@@ -12911,7 +12913,7 @@ class MultipleChoice$1 extends React$2.Component {
|
|
|
12911
12913
|
__self: this,
|
|
12912
12914
|
__source: {
|
|
12913
12915
|
fileName: _jsxFileName$1,
|
|
12914
|
-
lineNumber:
|
|
12916
|
+
lineNumber: 334
|
|
12915
12917
|
}
|
|
12916
12918
|
}, translator$1.t(`translation:multipleChoice:maxSelections_${maxSelections === 1 ? 'one' : 'other'}`, {
|
|
12917
12919
|
lng: language,
|
|
@@ -13066,7 +13068,10 @@ const {debounce: debounce} = _dll_lodash;
|
|
|
13066
13068
|
const debug$1 = _dll_debug;
|
|
13067
13069
|
const {renderMath: renderMath} = _dll_pie_lib__pie_toolbox_math_rendering;
|
|
13068
13070
|
const log$1 = debug$1('pie-ui:multiple-choice');
|
|
13069
|
-
const isComplete = (session, model) => {
|
|
13071
|
+
const isComplete = (session, model, audioComplete) => {
|
|
13072
|
+
if (!audioComplete) {
|
|
13073
|
+
return false;
|
|
13074
|
+
}
|
|
13070
13075
|
if (!session || !session.value) {
|
|
13071
13076
|
return false;
|
|
13072
13077
|
}
|
|
@@ -13085,6 +13090,7 @@ class MultipleChoice extends HTMLElement {
|
|
|
13085
13090
|
super();
|
|
13086
13091
|
this._model = null;
|
|
13087
13092
|
this._session = null;
|
|
13093
|
+
this.audioComplete = false;
|
|
13088
13094
|
this._rerender = debounce(() => {
|
|
13089
13095
|
if (this._model && this._session) {
|
|
13090
13096
|
var element = React.createElement(Root, {
|
|
@@ -13108,7 +13114,7 @@ class MultipleChoice extends HTMLElement {
|
|
|
13108
13114
|
trailing: true
|
|
13109
13115
|
});
|
|
13110
13116
|
this._dispatchResponseChanged = debounce(() => {
|
|
13111
|
-
this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), isComplete(this._session, this._model)));
|
|
13117
|
+
this.dispatchEvent(new SessionChangedEvent_1(this.tagName.toLowerCase(), isComplete(this._session, this._model, this.audioComplete)));
|
|
13112
13118
|
});
|
|
13113
13119
|
this._dispatchModelSet = debounce(() => {
|
|
13114
13120
|
this.dispatchEvent(new ModelSetEvent_1(this.tagName.toLowerCase(), isComplete(this._session, this._model), this._model !== undefined));
|
|
@@ -13143,8 +13149,66 @@ class MultipleChoice extends HTMLElement {
|
|
|
13143
13149
|
this._dispatchResponseChanged();
|
|
13144
13150
|
this._rerender();
|
|
13145
13151
|
}
|
|
13152
|
+
_createAudioInfoToast() {
|
|
13153
|
+
const info = document.createElement('div');
|
|
13154
|
+
info.id = 'play-audio-info';
|
|
13155
|
+
info.innerHTML = 'Click anywhere to enable audio autoplay. Browser restrictions require user interaction to play audio.';
|
|
13156
|
+
Object.assign(info.style, {
|
|
13157
|
+
position: 'fixed',
|
|
13158
|
+
bottom: '20px',
|
|
13159
|
+
left: '50%',
|
|
13160
|
+
transform: 'translateX(-50%)',
|
|
13161
|
+
backgroundColor: '#333',
|
|
13162
|
+
color: '#fff',
|
|
13163
|
+
padding: '10px 20px',
|
|
13164
|
+
borderRadius: '5px',
|
|
13165
|
+
boxShadow: '0 4px 6px rgba(0, 0, 0, 0.1)',
|
|
13166
|
+
zIndex: '1000'
|
|
13167
|
+
});
|
|
13168
|
+
return info;
|
|
13169
|
+
}
|
|
13146
13170
|
connectedCallback() {
|
|
13147
13171
|
this._rerender();
|
|
13172
|
+
if (this._model && !this._model.autoplayAudioEnabled) {
|
|
13173
|
+
return;
|
|
13174
|
+
}
|
|
13175
|
+
const observer = new MutationObserver((mutationsList, observer) => {
|
|
13176
|
+
mutationsList.forEach(mutation => {
|
|
13177
|
+
if (mutation.type === 'childList') {
|
|
13178
|
+
const audio = this.querySelector('audio[autoplay]');
|
|
13179
|
+
if (!audio) return;
|
|
13180
|
+
if (audio.paused && !this.querySelector('#play-audio-info')) {
|
|
13181
|
+
const info = this._createAudioInfoToast();
|
|
13182
|
+
this.appendChild(info);
|
|
13183
|
+
const enableAudio = () => {
|
|
13184
|
+
audio.play();
|
|
13185
|
+
this.removeChild(info);
|
|
13186
|
+
document.removeEventListener('click', enableAudio);
|
|
13187
|
+
};
|
|
13188
|
+
document.addEventListener('click', enableAudio);
|
|
13189
|
+
}
|
|
13190
|
+
const handlePlaying = () => {
|
|
13191
|
+
const info = this.querySelector('#play-audio-info');
|
|
13192
|
+
if (info) {
|
|
13193
|
+
this.removeChild(info);
|
|
13194
|
+
}
|
|
13195
|
+
audio.removeEventListener('playing', handlePlaying);
|
|
13196
|
+
};
|
|
13197
|
+
audio.addEventListener('playing', handlePlaying);
|
|
13198
|
+
const handleEnded = () => {
|
|
13199
|
+
this.audioComplete = true;
|
|
13200
|
+
this._dispatchResponseChanged();
|
|
13201
|
+
audio.removeEventListener('ended', handleEnded);
|
|
13202
|
+
};
|
|
13203
|
+
audio.addEventListener('ended', handleEnded);
|
|
13204
|
+
observer.disconnect();
|
|
13205
|
+
}
|
|
13206
|
+
});
|
|
13207
|
+
});
|
|
13208
|
+
observer.observe(this, {
|
|
13209
|
+
childList: true,
|
|
13210
|
+
subtree: true
|
|
13211
|
+
});
|
|
13148
13212
|
}
|
|
13149
13213
|
}
|
|
13150
13214
|
const {cloneDeep: cloneDeep} = _dll_lodash;
|
package/package.json
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pie-element/ebsr",
|
|
3
|
-
"version": "10.2.11-next.
|
|
3
|
+
"version": "10.2.11-next.9+3caa0b4db",
|
|
4
4
|
"description": "",
|
|
5
5
|
"repository": "pie-framework/pie-elements",
|
|
6
6
|
"publishConfig": {
|
|
7
7
|
"access": "public"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@pie-element/multiple-choice": "^9.7.4-next.
|
|
10
|
+
"@pie-element/multiple-choice": "^9.7.4-next.9+3caa0b4db",
|
|
11
11
|
"@pie-framework/pie-player-events": "^0.1.0",
|
|
12
|
-
"@pie-lib/pie-toolbox": "2.
|
|
12
|
+
"@pie-lib/pie-toolbox": "2.8.0",
|
|
13
13
|
"classnames": "^2.2.5",
|
|
14
14
|
"debug": "^4.1.1",
|
|
15
15
|
"lodash": "^4.17.11"
|
|
16
16
|
},
|
|
17
17
|
"author": "pie framework developers",
|
|
18
18
|
"license": "ISC",
|
|
19
|
-
"gitHead": "
|
|
19
|
+
"gitHead": "3caa0b4db682d6e62243f5fced08f82b790db854",
|
|
20
20
|
"scripts": {
|
|
21
21
|
"postpublish": "../../scripts/postpublish"
|
|
22
22
|
},
|