%PDF- %PDF-
| Direktori : /opt/bitnami/apps/moodle/moodledata/filedir/88/49/ |
| Current File : /opt/bitnami/apps/moodle/moodledata/filedir/88/49/8849287c52809d48cec945f5460e6ff1d1be9cc6 |
(function(e){function t(o){if(a[o])return a[o].exports;var s=a[o]={i:o,l:!1,exports:{}};return e[o].call(s.exports,s,s.exports,t),s.l=!0,s.exports}var a={};return t.m=e,t.c=a,t.d=function(e,a,o){t.o(e,a)||Object.defineProperty(e,a,{enumerable:!0,get:o})},t.r=function(e){'undefined'!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:'Module'}),Object.defineProperty(e,'__esModule',{value:!0})},t.t=function(e,a){if(1&a&&(e=t(e)),8&a)return e;if(4&a&&'object'==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(t.r(o),Object.defineProperty(o,'default',{enumerable:!0,value:e}),2&a&&'string'!=typeof e)for(var s in e)t.d(o,s,function(t){return e[t]}.bind(null,s));return o},t.n=function(e){var a=e&&e.__esModule?function(){return e['default']}:function(){return e};return t.d(a,'a',a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p='',t(t.s=1)})([function(){},function(e,t,a){'use strict';function o(e){return i(e)||r(e)||n(e)||s()}function s(){throw new TypeError('Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.')}function n(e,t){if(e){if('string'==typeof e)return l(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return'Object'===a&&e.constructor&&(a=e.constructor.name),'Map'===a||'Set'===a?Array.from(e):'Arguments'===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?l(e,t):void 0}}function r(e){if('undefined'!=typeof Symbol&&Symbol.iterator in Object(e))return Array.from(e)}function i(e){if(Array.isArray(e))return l(e)}function l(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,o=Array(t);a<t;a++)o[a]=e[a];return o}function p(e){'@babel/helpers - typeof';return p='function'==typeof Symbol&&'symbol'==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&'function'==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?'symbol':typeof e},p(e)}function d(e){if(void 0===e)throw new ReferenceError('this hasn\'t been initialised - super() hasn\'t been called');return e}function c(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var u=Math.min;a.r(t);var m=a(0),y=function(){function e(t,a){var o=2<arguments.length&&void 0!==arguments[2]?arguments[2]:{};this.params=a,this.previousState=o,this.params.audioNotSupported=this.params.audioNotSupported||'Your browser does not support this audio.',this.params.a11y=a.a11y||[],this.params.a11y.play=this.params.a11y.play||'Play',this.params.a11y.playSlowly=this.params.a11y.playSlowly||'Play slowly',this.params.a11y.triesLeft=this.params.a11y.triesLeft||'number of tries left: @number',this.params.a11y.infinite=this.params.a11y.infinite||'infinite',this.params.a11y.sentence=this.params.a11y.sentence||'Sentence',this.params.a11y.solution=this.params.a11y.solution||'Solution',this.params.a11y.enterText=this.params.a11y.enterText||'Enter what you have heard',this.params.type=this.params.type||e.BUTTON_TYPE_NORMAL,this.params.callbacks=this.params.callbacks||{},this.params.callbacks.playAudio=this.params.callbacks.playAudio||function(){},this.triesLeft='undefined'==typeof o.triesLeft?this.params.maxTries:null===o.triesLeft?Infinity:o.triesLeft,this.dom=this.createAudioDOM(t,this.params),null===this.dom.firstChild&&this.dom.appendChild(this.getDummyButtonDOM()),this.status=e.STATUS_ENDED}var t=e.prototype;return t.createAudioDOM=function(t,a){var o=this,s=H5P.jQuery('<div>',{class:e.AUDIO_WRAPPER});if(void 0!==a.sample){var n={files:a.sample,audioNotSupported:a.audioNotSupported},r=new H5P.Audio(n,t,{previousState:this.previousState.audio});r.attach(s),this.button=r.$audioButton.get(0),this.audio=r,a.type===e.BUTTON_TYPE_SLOW?(r.$audioButton.removeClass(e.BUTTON_PLAY).addClass(e.BUTTON_SLOW),this.setLabel(a.a11y.playSlowly)):this.setLabel(a.a11y.play),1>this.triesLeft&&this.audio.disableToggleButton(),this.previousState.audio&&0!==this.previousState.audio.currentTime&&(this.status=e.STATUS_PAUSE,r.$audioButton.addClass(e.BUTTON_PLAY_PAUSED)),r.audio.addEventListener('play',function(){a.type===e.BUTTON_TYPE_SLOW&&r.$audioButton.removeClass(e.BUTTON_SLOW).addClass(e.BUTTON_PAUSE),o.status=e.STATUS_PLAYING,o.params.callbacks.playAudio(o)}),r.audio.addEventListener('pause',function(){a.type===e.BUTTON_TYPE_SLOW&&r.$audioButton.removeClass(e.BUTTON_PAUSE).addClass(e.BUTTON_SLOW),o.status=e.STATUS_PAUSE}),r.audio.addEventListener('ended',function(){o.handlePlayed(),a.type===e.BUTTON_TYPE_SLOW?(r.$audioButton.removeClass(e.BUTTON_PAUSE).addClass(e.BUTTON_SLOW),o.setLabel(o.params.a11y.playSlowly)):o.setLabel(o.params.a11y.play),o.status=e.STATUS_ENDED}),r.audio&&r.audio.preload&&(r.audio.preload='none')}return s.get(0)},t.getDOM=function(){return this.dom},t.getDummyButtonDOM=function(){var t=document.createElement('div');t.classList.add(e.BUTTON),t.classList.add(e.BUTTON_NONE);var a=document.createElement('div');return a.classList.add(e.INNER_CONTAINER),a.appendChild(t),a},t.play=function(){this.status!==e.STATUS_PLAYING&&this.button.click()},t.pause=function(){this.status===e.STATUS_PLAYING&&this.button.click()},t.handlePlayed=function(){this.triesLeft--,0===this.triesLeft&&this.disable()},t.setLabel=function(e){var t=isFinite(this.triesLeft)?this.triesLeft:this.params.a11y.infinite,a=this.params.a11y.triesLeft.replace(/@number/g,t);this.button&&(this.button.setAttribute('aria-label',''.concat(e,'. ').concat(a)),this.button.setAttribute('title',a))},t.reset=function(){this.triesLeft=this.params.maxTries,this.audio&&this.audio.seekTo(0),this.status=e.STATUS_ENDED,this.enable(),this.params.type===e.BUTTON_TYPE_SLOW?this.setLabel(this.params.a11y.playSlowly):this.setLabel(this.params.a11y.play)},t.enable=function(){this.button&&this.audio.enableToggleButton()},t.setUntabbable=function(){this.button&&this.button.setAttribute('tabindex','-1')},t.setTabbable=function(){this.button&&this.button.setAttribute('tabindex','0')},t.disable=function(){this.button&&this.audio.disableToggleButton()},t.isEnabled=function(){return!!this.button&&this.audio.isEnabled()},t.resetAudio=function(){this.audio&&this.audio.audio&&this.audio.audio.load&&this.audio.audio.load(),this.button&&(this.button.classList.remove(e.BUTTON_PAUSE),this.button.classList.remove(e.BUTTON_PLAY_PAUSED),this.params.type===e.BUTTON_TYPE_SLOW?this.button.classList.add(e.BUTTON_SLOW):this.button.classList.add(e.BUTTON_PLAY))},t.getCurrentState=function(){return{audio:this.audio?this.audio.getCurrentState():void 0,triesLeft:this.triesLeft}},t.focus=function(){this.button&&this.button.focus()},e}();y.BUTTON_TYPE_NORMAL=0,y.BUTTON_TYPE_SLOW=1,y.STATUS_PAUSE=0,y.STATUS_PLAYING=1,y.STATUS_ENDED=2,y.AUDIO_WRAPPER='h5p-dictation-audio-wrapper',y.BUTTON='h5p-audio-minimal-button',y.BUTTON_PLAY='h5p-audio-minimal-play',y.BUTTON_PLAY_PAUSED='h5p-audio-minimal-play-paused',y.BUTTON_PAUSE='h5p-audio-minimal-pause',y.BUTTON_SLOW='h5p-audio-minimal-slow',y.BUTTON_NONE='h5p-audio-minimal-none',y.INNER_CONTAINER='h5p-audio-inner';var T=y,h=function(){function e(){}return e.extend=function(){for(var e=1;e<arguments.length;e++)for(var t in arguments[e])arguments[e].hasOwnProperty(t)&&('object'===p(arguments[0][t])&&'object'===p(arguments[e][t])?this.extend(arguments[0][t],arguments[e][t]):arguments[0][t]=arguments[e][t]);return arguments[0]},e.htmlDecode=function(e){var t=new DOMParser().parseFromString(e,'text/html');return t.documentElement.textContent},e.revertRTL=function(t){var a=[],o=[];return t.forEach(function(t){var s=e.containsRTLCharacters(t.solution);s?o.push(t):(a=a.concat(o.reverse()),o=[],a.push(t))}),0!==o.length&&(a=a.concat(o.reverse())),a},e.splitWordAlternatives=function(e){var t=e.split('').reverse().join(''),a=t.split(/\|(?!\\)/);return a.map(function(e){return e.split('').reverse().join('').replace('\\|','|')}).reverse()},e.containsRTLCharacters=function(t){return new RegExp('^[^'+e.RTL+']*?['+e.RTL+']').test(t)},e.buildCombinations=function(e,t){var a=2<arguments.length&&void 0!==arguments[2]?arguments[2]:' ',s=[];return e.forEach(function(e){s.push.apply(s,o(t.map(function(t){return''===t?e:''.concat(t).concat(a).concat(e)})))}),s},e.formatLanguageCode=function(e){if('string'!=typeof e)return e;var t=e.split('-');return t[0]=t[0].toLowerCase(),1<t.length&&(t[1]=t[1].toUpperCase()),e=t.join('-'),e},e}();h.RTL='\u0591-\u08FF';var b=h,g=function(){function e(t){var a=this;this.params=t,this.words=document.createElement('div'),this.words.classList.add(e.SOLUTION_TEXT),this.words.setAttribute('role','list'),this.words.setAttribute('aria-label',this.params.a11y.solution),this.words.setAttribute('aria-expanded','false'),this.words.setAttribute('tabindex','0'),this.words.addEventListener('keydown',function(e){var t=a.words.getAttribute('aria-expanded'),o=a.wordMarked||(a.params.containsRTL?a.words.lastChild:a.words.firstChild);switch(e.keyCode){case 13:case 32:if(e.target!==e.currentTarget)break;'false'===t?(a.words.setAttribute('aria-expanded','true'),o&&o.focus()):(a.words.setAttribute('aria-expanded','false'),o.setAttribute('tabindex','-1'));}}),this.solutionInner=document.createElement('div'),this.solutionInner.classList.add(e.SOLUTION_INNER),this.solutionInner.appendChild(this.words),this.container=document.createElement('div'),this.container.classList.add(e.SOLUTION_CONTAINER),this.container.classList.add(e.HIDE),this.container.appendChild(this.solutionInner)}var t=e.prototype;return t.getDOM=function(){return this.container},t.createSolution=function(e){var t=this;return this.params.containsRTL&&(e.words=b.revertRTL(e.words)),e.words.map(function(a,o){return t.createSolutionWordDOM(o,a,e.words.length-1!==o)})},t.createSolutionWordDOM=function(e,t){var a=!(2<arguments.length&&void 0!==arguments[2])||arguments[2];'first'===this.params.alternateSolution&&'match'!==t.type&&'typo'!==t.type&&(t.solution=t.solution?b.splitWordAlternatives(t.solution)[0]:'');var o=document.createElement('span');!1===this.params.customTypoDisplay&&'typo'===t.type?o.classList.add('h5p-wrapper-wrong'):o.classList.add('h5p-wrapper-'.concat(t.type)),a&&o.classList.add('h5p-spacer'),o.setAttribute('tabindex','-1'),o.setAttribute('role','listitem'),this.addSolutionWordListeners(o);var s=''.concat(this.params.a11y.item,' ').concat(e+1,'.'),n=this.createAriaExplanation(t),r=this.createAriaScore(t.type);return o.setAttribute('aria-label',''.concat(s,' ').concat(n,' ').concat(r)),this.appendExplanationTo(o,t),o},t.addSolutionWordListeners=function(e){var t=this;e.addEventListener('focus',function(e){t.wordMarked=e.target,e.target.setAttribute('tabindex','0')}),e.addEventListener('keydown',function(e){var a=t.params.containsRTL?e.target.parentNode.lastChild:e.target.parentNode.firstChild,o=t.params.containsRTL?e.target.parentNode.firstChild:e.target.parentNode.lastChild;switch(e.keyCode){case 37:case 38:e.preventDefault(),e.target.previousSibling&&(e.target.setAttribute('tabindex','-1'),e.target.previousSibling.focus());break;case 39:case 40:e.preventDefault(),e.target.nextSibling&&(e.target.setAttribute('tabindex','-1'),e.target.nextSibling.focus());break;case 36:e.preventDefault(),e.target!==a&&(e.target.setAttribute('tabindex','-1'),a.focus());break;case 35:e.preventDefault(),e.target!==o&&(e.target.setAttribute('tabindex','-1'),o.focus());}})},t.createAriaExplanation=function(e){var t={match:this.params.a11y.correct,wrong:this.params.a11y.wrong,typo:this.params.a11y.typo,missing:this.params.a11y.missing,added:this.params.a11y.added},a=this.makeReadable(e.answer),o='match'===e.type||'typo'===e.type?b.splitWordAlternatives(e.solution).join(' '.concat(this.params.a11y.or,' ')):e.solution,s=this.makeReadable(o),n=''.concat(a).concat(''===a?'':'. ').concat(t[e.type],'.');return('wrong'===e.type||'typo'===e.type||'missing'===e.type)&&(n+=' '.concat(this.params.a11y.shouldHaveBeen,'. ').concat(s,'.')),n},t.makeReadable=function(e){return void 0===e?'':e.replace(/\./g,this.params.a11y.period).replace(/!/g,this.params.a11y.exclamationPoint).replace(/\?/g,this.params.a11y.questionMark).replace(/,/g,this.params.a11y.comma).replace(/'/g,this.params.a11y.singleQuote).replace(/["\u201C\u201E]/g,this.params.a11y.doubleQuote).replace(/:/g,this.params.a11y.colon).replace(/;/g,this.params.a11y.semicolon).replace(/\+/g,this.params.a11y.plus).replace(/-/g,this.params.a11y.minus).replace(/\*/g,this.params.a11y.asterisk).replace(/\//g,this.params.a11y.forwardSlash)},t.createAriaScore=function(e){var t;if(this.params.zeroMistakeMode?(t=0,'match'===e?t=1:'typo'==e&&(t=1-this.params.typoFactor)):(t=-1,'match'===e?t=0:'typo'==e&&(t*=this.params.typoFactor)),0===t)t='';else{var a=-1===t||1===t?this.params.a11y.point:this.params.a11y.points;t=''.concat(t,' ').concat(a,'.')}return t},t.appendExplanationTo=function(e,t){var a=new H5P.Question.ScorePoints;if('wrong'===t.type||'added'===t.type||'typo'===t.type){var o=document.createElement('span');o.classList.add('h5p-answer-'.concat(t.type)),o.innerHTML=t.answer,e.appendChild(o)}if('added'!==t.type){var s=document.createElement('span');s.classList.add('h5p-solution-'.concat(t.type)),s.innerHTML=t.solution,e.appendChild(s)}if(this.params.zeroMistakeMode){var n=a.getElement(!0);'match'===t.type&&e.appendChild(n),'typo'===t.type&&.5===this.params.typoFactor&&(n.classList.remove('h5p-question-minus-one'),n.classList.add('h5p-question-plus-one-half')),'typo'===t.type&&1>this.params.typoFactor&&e.appendChild(n)}else{var r=a.getElement(!1);'match'!==t.type&&('typo'===t.type&&.5===this.params.typoFactor&&(r.classList.remove('h5p-question-minus-one'),r.classList.add('h5p-question-minus-one-half')),('typo'!==t.type||0<this.params.typoFactor)&&e.appendChild(r))}},t.show=function(t){var a=this,o=this.createSolution(t);0<o.length&&'match'===t.words[o.length-1].type?this.words.classList.add('h5p-solution-last-correct'):this.words.classList.remove('h5p-solution-last-correct'),this.words.firstChild||o.forEach(function(t){a.words.appendChild(t),a.container.classList.remove(e.HIDE)})},t.hide=function(){for(;this.words.firstChild;)this.words.removeChild(this.words.firstChild);this.container.classList.add(e.HIDE)},t.focus=function(){this.words.focus()},t.reset=function(){this.wordMarked=void 0,this.words.setAttribute('aria-expanded','false')},e}();g.SOLUTION_CONTAINER='h5p-solution-container',g.SOLUTION_INNER='h5p-solution-inner',g.SOLUTION_TEXT='h5p-solution-text',g.HIDE='hide';var S=function(){function e(t,a,o){var s=this,n=3<arguments.length&&void 0!==arguments[3]?arguments[3]:{};this.index=t,this.params=a,this.contentId=o,this.maxTries=a.tries,this.maxTriesAlternative=a.triesAlternative,this.params.sentence.description=(this.params.sentence.description||'').trim(),this.params.callbacks=this.params.callbacks||{},this.params.callbacks.playAudio=this.params.callbacks.playAudio||function(){},this.solutionText=b.htmlDecode(a.sentence.text).trim(),this.solutionText=a.ignorePunctuation?e.stripPunctuation(this.solutionText):this.solutionText,this.containsRTL='auto'===this.params.overrideRTL?b.containsRTLCharacters(this.solutionText):'on'===this.params.overrideRTL,this.mistakesMax=e.addSpaces(this.solutionText,this.params.autosplit).split(' ').length,this.content=document.createElement('div'),this.content.setAttribute('role','group'),this.content.setAttribute('aria-label',''.concat(a.a11y.sentence,' ').concat(this.index)),this.content.classList.add(e.CONTENT_WRAPPER);var r=document.createElement('div');r.classList.add(e.CONTENT_DESCRIPTION),r.innerHTML=this.params.sentence.description;var i=document.createElement('div');i.classList.add(e.CONTENT_INTERACTION),this.buttonPlayNormal=new T(o,{sample:a.sentence.sample,audioNotSupported:a.audioNotSupported,type:T.BUTTON_TYPE_NORMAL,maxTries:a.tries,a11y:a.a11y,callbacks:{playAudio:function(e){s.params.callbacks.playAudio(e)}}},n.buttonPlayNormal),i.appendChild(this.buttonPlayNormal.getDOM()),!0===this.params.hasAlternatives&&(this.buttonPlaySlow=new T(o,{sample:a.sentence.sampleAlternative,audioNotSupported:a.audioNotSupported,type:T.BUTTON_TYPE_SLOW,maxTries:a.triesAlternative,a11y:a.a11y,callbacks:{playAudio:function(e){s.params.callbacks.playAudio(e)}}},n.buttonPlaySlow),i.appendChild(this.buttonPlaySlow.getDOM())),r.classList.add(!0===this.params.hasAlternatives?e.CONTENT_DESCRIPTION_TWO_BUTTONS:e.CONTENT_DESCRIPTION_ONE_BUTTON),this.inputField=document.createElement('input'),this.inputField.setAttribute('spellcheck','false'),this.inputField.setAttribute('autocorrect','off'),this.inputField.setAttribute('autocapitalize','off'),this.inputField.setAttribute('aria-label',this.params.a11y.enterText),this.inputField.classList.add(e.INPUT_FIELD),n.userInput&&(this.inputField.value=n.userInput),this.solution=new g({alternateSolution:this.params.alternateSolution,zeroMistakeMode:this.params.zeroMistakeMode,customTypoDisplay:this.params.customTypoDisplay,typoFactor:this.params.typoFactor,containsRTL:this.containsRTL,a11y:{match:this.params.a11y.correct,wrong:this.params.a11y.wrong,typo:this.params.a11y.typo,missing:this.params.a11y.missing,added:this.params.a11y.added,correct:this.params.a11y.correct,point:this.params.a11y.point,points:this.params.a11y.points,item:this.params.a11y.item,solution:this.params.a11y.solution,or:this.params.a11y.or,shouldHaveBeen:this.params.a11y.shouldHaveBeen,period:this.params.a11y.period,exclamationPoint:this.params.a11y.exclamationPoint,questionMark:this.params.a11y.questionMark,comma:this.params.a11y.comma,singleQuote:this.params.a11y.singleQuote,doubleQuote:this.params.a11y.doubleQuote,colon:this.params.a11y.colon,semicolon:this.params.a11y.semicolon,plus:this.params.a11y.plus,minus:this.params.a11y.minus,asterisk:this.params.a11y.asterisk,forwardSlash:this.params.a11y.forwardSlash}}),this.inputWrapper=document.createElement('div'),this.inputWrapper.classList.add(e.INPUT_WRAPPER),this.inputWrapper.appendChild(this.inputField),this.inputWrapper.appendChild(this.solution.getDOM()),i.appendChild(this.inputWrapper),this.content.appendChild(r),this.content.appendChild(i)}var t=e.prototype;return t.getDOM=function(){return this.content},t.getUserInput=function(){return this.inputField.value},t.showSolution=function(e){this.solution.show(e),this.buttonPlayNormal&&this.buttonPlayNormal.setUntabbable(),this.buttonPlaySlow&&this.buttonPlaySlow.setUntabbable()},t.hideSolution=function(){this.solution.hide(),this.buttonPlayNormal&&this.buttonPlayNormal.setTabbable(),this.buttonPlaySlow&&this.buttonPlaySlow.setTabbable()},t.getCorrectText=function(){var t=!!(0<arguments.length&&void 0!==arguments[0])&&arguments[0];return t?e.addSpaces(this.solutionText,this.params.autosplit).split(' '):this.solutionText},t.getCurrentState=function(){return{userInput:this.getUserInput(),buttonPlayNormal:this.buttonPlayNormal?this.buttonPlayNormal.getCurrentState():void 0,buttonPlaySlow:this.buttonPlaySlow?this.buttonPlaySlow.getCurrentState():void 0}},t.getMaxMistakes=function(){return this.mistakesMax},t.getXAPIDescription=function(){return this.params.sentence.description||''?'<p>'.concat(this.params.sentence.description,'</p>'):''},t.reset=function(){this.inputField.value='',this.solution.reset(),this.buttonPlayNormal&&this.buttonPlayNormal.reset(),this.buttonPlaySlow&&this.buttonPlaySlow.reset()},t.disable=function(){this.inputField.disabled=!0,this.buttonPlayNormal&&(this.buttonPlayNormal.disable(),this.buttonPlayNormal.resetAudio()),this.buttonPlaySlow&&(this.buttonPlaySlow.disable(),this.buttonPlaySlow.resetAudio())},t.enable=function(){this.inputField.disabled=!1,this.buttonPlayNormal&&this.buttonPlayNormal.enable(),this.buttonPlaySlow&&this.buttonPlaySlow.enable()},t.pauseButtons=function(e){this.buttonPlayNormal&&this.buttonPlayNormal!==e&&this.buttonPlayNormal.pause(),this.buttonPlaySlow&&this.buttonPlaySlow!==e&&this.buttonPlaySlow.pause()},t.focus=function(){this.buttonPlayNormal&&this.buttonPlayNormal.focus()},e.addSpaces=function(t){var a=1<arguments.length&&void 0!==arguments[1]?arguments[1]:{},o=new RegExp('('.concat(e.WORD,'|^)(').concat(e.PUNCTUATION.replace('\'',''),')( |$)'),'g'),s=new RegExp('( |^)('.concat(e.PUNCTUATION,')(').concat(e.WORD,'|$)'),'g');return t=t.replace(o,'$1 $2 ').replace(s,' $2 $3'),!0===a.autosplit&&(t=t.replace(new RegExp('('.concat(e.AUTOSPLIT,')(?=').concat(e.AUTOSPLIT,')'),'g'),'$1 '),t=t.replace(new RegExp('('.concat(e.AUTOSPLIT,')(?=').concat(e.WORD,'|d|').concat(e.PUNCTUATION,')'),'g'),'$1 '),t=t.replace(new RegExp('('.concat(e.WORD,'|d|').concat(e.PUNCTUATION,')(?=').concat(e.AUTOSPLIT,')'),'g'),'$1 ')),t.trim()},e.stripPunctuation=function(t){var a=!1;'string'==typeof t&&(a=!0,t=[t]);var o=new RegExp('^'.concat(e.PUNCTUATION)),s=new RegExp(''.concat(e.PUNCTUATION,'$')),n=new RegExp(' '.concat(e.PUNCTUATION),'g'),r=new RegExp(''.concat(e.PUNCTUATION.replace('\'',''),' '),'g');return t=t.map(function(e){return e.replace(o,'').replace(s,'').replace(n,' ').replace(r,' ')}),a?t.toString().replace(/[ ]{2}/g,' '):t},t.computeResults=function(){var t=e.addSpaces(this.getCorrectText(),this.params.autosplit).split(' '),a=this.getUserInput();this.params.ignorePunctuation&&(a=e.stripPunctuation(a));var o=''===a.trim()?[]:e.addSpaces(a,this.params.autosplit).split(' '),s=this.alignWords(t,o),n=this.computeScore(s),r=n.scoreTotal,i=n.words;return{score:{added:r[e.TYPE_ADDED],missing:r[e.TYPE_MISSING],typo:r[e.TYPE_TYPO],wrong:r[e.TYPE_WRONG],match:r[e.TYPE_MATCH],total:u(r[e.TYPE_ADDED]+r[e.TYPE_MISSING]+r[e.TYPE_TYPO]+r[e.TYPE_WRONG],this.getMaxMistakes())},words:i}},t.computeScore=function(t){var a=[],o=[];o[e.TYPE_ADDED]=0,o[e.TYPE_MISSING]=0,o[e.TYPE_TYPO]=0,o[e.TYPE_WRONG]=0,o[e.TYPE_MATCH]=0;for(var s=0;s<t.words1.length;s++){var n=t.words1[s],r=t.words2[s],i='';i=void 0===n?e.TYPE_ADDED:void 0===r?e.TYPE_MISSING:r===n?e.TYPE_MATCH:H5P.TextUtilities.areSimilar(n,r)?e.TYPE_TYPO:e.TYPE_WRONG,o[i]++,a.push({solution:n,answer:r,type:i})}return{scoreTotal:o,words:a}},t.alignWords=function(e,t){var a=function(e){return e.words1.map(function(t,a){return t===e.words2[a]||H5P.TextUtilities.areSimilar(t,e.words2[a])||!1})},o=function(e,t){var a,o=!!(2<arguments.length&&void 0!==arguments[2])&&arguments[2];if(void 0!==t){var s=b.splitWordAlternatives(t);return o?s.forEach(function(t){H5P.TextUtilities.areSimilar(t,e)&&(a=a||t)}):s.forEach(function(t){t===e&&(a=a||t)}),a}},s=function(e,t){t=t.map(function(e){return''===e?void 0:e});var a=e.map(function(e){return Array.apply(null,Array(t.length)).concat(e)}).reduce(function(e,t){return e.concat(t)},[]);a=a.concat(Array.apply(null,Array(t.length)));for(var s,n=Array.apply(null,Array(a.length)),r=0,l=0;l<t.length;l++){s=t[l];for(var i=a.length-1;i>=r;i--){var p=o(s,a[i]),d=void 0!==s&&void 0!==p,c=-1===t.slice(l+1).indexOf(s);if(d&&c||i===r){a[i]=p,n[i]=s,r=i+1;break}}}for(var u,m=n.length-1;0<=m;m--)if(u=n[m],void 0!==u&&u!==a[m]){for(var y,T=0,h=0,b=void 0;m+T+1<n.length&&void 0===n[m+T+1];)y=o(u,a[m+T+1]),void 0!==y&&(h=m+T+1,b=y),T++;n[h||m+T]=u,void 0!==b&&(a[h]=b),n[m]=void 0}for(var g,S=0;S<n.length;S++)if(g=n[S],void 0!==g&&g!==a[S]){for(var P,N=0,E=0,A=void 0;0<=S+N-1&&void 0===n[S+N-1];)P=o(g,a[S+N-1],!0),void 0!==P&&(E=S+N-1,A=P),N--;n[E||S+N]=g,void 0!==A&&(a[E]=A),n[S]=void 0}for(var _=a.length-1;0<=_;_--)void 0===a[_]&&void 0===n[_]&&(a.splice(_,1),n.splice(_,1));for(var w=0;w<a.length-1;w++)void 0===a[w]&&void 0===n[w+1]&&(a[w]=a[w+1],a.splice(w+1,1),n.splice(w+1,1));for(var O=0;O<a.length-1;O++)if(n[O]===a[O]&&void 0===a[O+1]&&n[O]!==n[O+1]){for(var I=0;O+I+1<a.length&&void 0===a[O+I+1];)I++;O+I+1<a.length&&-1!==n.slice(O+1,O+I+1).lastIndexOf(n[O])&&(a[O+I+1]=a[O],a[O]=void 0)}a.reverse(),n.reverse();for(var f=0;f<a.length-1;f++)if(n[f]===a[f]&&void 0===a[f+1]&&n[f]!==n[f+1]){for(var L=0;f+L+1<a.length&&void 0===a[f+L+1];)L++;f+L+1<a.length&&-1!==n.slice(f+1,f+L+1).lastIndexOf(n[f])&&(a[f+L+1]=a[f],a[f]=void 0)}return a.reverse(),n.reverse(),{words1:a,words2:n}},n=function(e){return a(e).reduce(function(e,t){return e+(t?1:0)},0)},r=s(e,t),i=s(e.reverse(),t.reverse());n(i)>n(r)&&(r={words1:i.words1.reverse(),words2:i.words2.reverse()});var l=a(r),p=-1,d=l.length-1;do{for(p=l.lastIndexOf(!0,d);void 0===r.words1[p+1]&&void 0===r.words2[d];)r.words1.splice(p+1,1),r.words2.splice(d,1),d-=1;d=p-1}while(0<p);return r},t.focusSolution=function(){this.solution.focus()},e}();S.CONTENT_WRAPPER='h5p-sentence',S.CONTENT_DESCRIPTION='h5p-sentence-description',S.CONTENT_DESCRIPTION_ONE_BUTTON='h5p-sentence-description-one-button',S.CONTENT_DESCRIPTION_TWO_BUTTONS='h5p-sentence-description-two-buttons',S.CONTENT_INTERACTION='h5p-sentence-interaction',S.INPUT_WRAPPER='h5p-input-wrapper',S.INPUT_FIELD='h5p-text-input',S.TYPE_ADDED='added',S.TYPE_MISSING='missing',S.TYPE_WRONG='wrong',S.TYPE_MATCH='match',S.TYPE_TYPO='typo',S.AUTOSPLIT='[\u4E00-\u62FF\u6300-\u77FF\u7800-\u8CFF\u8D00-\u9FFF]',S.PUNCTUATION='[.?!,\'";\\:\\-\\(\\)/\\+\\-\\*\xAB\xBB\xBF\u201C-\u201E\u060C\u061F\u05BE\u05C0\u05C3\u05C6\u2000-\u206F\u22EF\u3000-\u3002\u3008-\u3011\uFF01\uFF08\uFF09\uFF0C\uFF1A\uFF1B\uFF1F\uFF3B\uFF3D\uFE41\uFE42\uFE4F\uFF5E]',S.WORD='\\w|[\xC0-\xD6\xD8-\xF6\xF8-\xFF\u0100-\u02AF\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7-\u060B\u060D-\u061E\u0620-\u08FF]';var P=function(e){function t(a,o,s){var n;n=e.call(this,'dictation')||this,n.params=b.extend({media:{},taskDescription:'Please listen carefully and write what you hear.',sentences:[],behaviour:{alternateSolution:'first',autosplit:!0,enableSolutionsButton:!0,enableRetry:!0,ignorePunctuation:!0,zeroMistakeMode:!1,overrideRTL:'auto',tries:Infinity,triesAlternative:Infinity,customTypoDisplay:!1,typoFactor:'100'},l10n:{generalFeedback:'You have made @total mistake(s).',generalFeedbackZeroMistakesMode:'You have entered @total word(s) correctly and @typo word(s) with minor mistakes.',checkAnswer:'Check',tryAgain:'Retry',showSolution:'Show solution',audioNotSupported:'Your browser does not support this audio.'},a11y:{check:'Check the answers. The responses will be marked as correct, incorrect, or unanswered.',showSolution:'Show the solution. The task will be marked with its correct solution.',retry:'Retry the task. Reset all responses and start the task over again.',play:'Play',playSlowly:'Play slowly',triesLeft:'Number of tries left: @number',infinite:'infinite',enterText:'Enter what you have heard.',yourResult:'You got @score out of @total points',solution:'Solution',sentence:'Sentence',item:'Item',correct:'correct',wrong:'wrong',typo:'small mistake',missing:'missing',added:'added',shouldHaveBeen:'Should have been',or:'or',point:'point',points:'points',period:'period',exclamationPoint:'exclamation point',questionMark:'question mark',comma:'comma',singleQuote:'single quote',doubleQuote:'double quote',colon:'colon',semicolon:'semicolon',plus:'plus',minus:'minus',asterisk:'asterisk',forwardSlash:'forward slash'}},a);var r=s&&s.metadata?s.metadata.defaultLanguage||'en':'en';if(n.languageTag=b.formatLanguageCode(r),'undefined'==typeof n.params.behaviour.enableSolutionsButton&&(n.params.behaviour.enableSolutionsButton=void 0===a.behaviour.enableSolution||a.behaviour.enableSolution),!a)return d(n);n.contentId=o,n.contentData=s||{},n.sentences=[],!window.MSInputMethodContext||!document.documentMode||n.params.sentences.forEach(function(e,t){e.sample&&'audio/x-wav'===e.sample[0].mime&&(console.warn(''.concat(n.params.a11y.sentence,' ').concat(t+1,': ').concat(n.params.l10n.audioNotSupported)),delete e.sample),e.sampleAlternative&&'audio/x-wav'===e.sampleAlternative[0].mime&&(console.warn(''.concat(n.params.a11y.sentence,' ').concat(t+1,': ').concat(n.params.l10n.audioNotSupported)),delete e.sampleAlternative)});var i=n.params.sentences.some(function(e){return void 0!==e.sampleAlternative});return n.params.behaviour.typoFactor=parseInt(n.params.behaviour.typoFactor)/100,n.params.sentences=n.params.sentences.filter(function(e){return void 0!==e.text&&void 0!==e.sample}).forEach(function(e,t){var a=n.contentData.previousState&&n.contentData.previousState.length>=t+1?n.contentData.previousState[t]:void 0;n.sentences.push(new S(t+1,{sentence:e,audioNotSupported:n.params.l10n.audioNotSupported,tries:n.params.behaviour.tries,triesAlternative:n.params.behaviour.triesAlternative,ignorePunctuation:n.params.behaviour.ignorePunctuation,hasAlternatives:i,a11y:n.params.a11y,customTypoDisplay:n.params.behaviour.customTypoDisplay,zeroMistakeMode:n.params.behaviour.zeroMistakeMode,typoFactor:n.params.behaviour.typoFactor,alternateSolution:n.params.behaviour.alternateSolution,overrideRTL:n.params.behaviour.overrideRTL,autosplit:n.params.behaviour.autosplit,callbacks:{playAudio:function(e){n.handlePlayAudio(e)}}},n.contentId,a))}),n.maxMistakes=n.sentences.map(function(e){return e.getMaxMistakes()}).reduce(function(e,t){return e+t},0),n.mistakesCapped=0,n.isAnswered=!1,n.registerDomElements=function(){var e=n.params.media.type;if(e&&e.library){var t=e.library.split(' ')[0];'H5P.Image'===t?e.params.file&&n.setImage(e.params.file.path,{disableImageZooming:n.params.media.disableImageZooming,alt:e.params.alt,title:e.params.title}):'H5P.Video'===t&&e.params.sources&&n.setVideo(e)}n.params.taskDescription&&(n.introduction=document.createElement('div'),n.introduction.innerHTML=n.params.taskDescription,n.setIntroduction(n.introduction));var a=document.createElement('div');if(n.sentences.forEach(function(e){a.appendChild(e.getDOM())}),0===n.sentences.length){var o=document.createElement('div');o.classList.add('h5p-dictation-no-content'),o.innerHTML='I really need at least one sound sample and text for it :-)',a.appendChild(o)}n.setContent(a),0!==n.sentences.length&&n.addButtons()},n.addButtons=function(){n.addButton('show-solution',n.params.l10n.showSolution,function(){n.showSolutions(),n.hideButton('show-solution')},!1,{"aria-label":n.params.a11y.showSolution},{}),n.addButton('check-answer',n.params.l10n.checkAnswer,function(){n.showEvaluation(),n.isAnswered=!0,n.triggerXAPI(),n.params.behaviour.enableRetry&&!n.isPassed()&&n.showButton('try-again')},!0,{"aria-label":n.params.a11y.check},{}),n.addButton('try-again',n.params.l10n.tryAgain,function(){n.resetTask(),n.sentences[0].focus()},!1,{"aria-label":n.params.a11y.retry},{})},n.handlePlayAudio=function(e){n.sentences.forEach(function(t){t.pauseButtons(e)})},n.showEvaluation=function(){n.computedResults=n.sentences.map(function(e){return e.computeResults()}),n.sentences.forEach(function(e){e.disable()});var e=n.computedResults.map(function(e){return e.score}).reduce(function(e,t){return{added:e.added+t.added,missing:e.missing+t.missing,typo:e.typo+t.typo,wrong:e.wrong+t.wrong,match:e.match+t.match}},{added:0,missing:0,typo:0,wrong:0,match:0}),t=e.added+e.missing+e.wrong+e.typo*n.params.behaviour.typoFactor;n.mistakesCapped=u(t,n.maxMistakes),n.correctTotal=e.match+e.typo*(1-n.params.behaviour.typoFactor);var a=n.params.behaviour.zeroMistakeMode?(n.params.l10n.generalFeedbackZeroMistakesMode||'').replace('@added',e.added).replace('@missing',e.missing).replace('@wrong',e.wrong).replace('@typo',e.typo).replace('@matches',e.match).replace('@total',e.match):(n.params.l10n.generalFeedback||'').replace('@added',e.added).replace('@missing',e.missing).replace('@wrong',e.wrong).replace('@typo',e.typo).replace('@matches',e.match).replace('@total',t).replace('@capped',n.mistakesCapped);var o=H5P.Question.determineOverallFeedback(n.params.overallFeedback,n.getScore()/n.getMaxScore()),s=n.params.a11y.yourResult.replace('@score',n.getScore()).replace('@total',n.getMaxScore());n.setFeedback(''.concat(a,' ').concat(o).trim(),n.getScore(),n.getMaxScore(),s),n.hideButton('check-answer'),n.params.behaviour.enableSolutionsButton&&n.showButton('show-solution'),n.trigger('resize')},n.isPassed=function(){return 0===n.mistakesCapped},n.getAnswerGiven=function(){return n.isAnswered||n.sentences.some(function(e){return 0<e.getUserInput().length})},n.getScore=function(){var e=Math.round;return n.params.behaviour.zeroMistakeMode?e(n.correctTotal):e(n.maxMistakes-n.mistakesCapped)},n.getMaxScore=function(){return n.maxMistakes},n.showSolutions=function(){n.sentences.forEach(function(e,t){e.showSolution(n.computedResults[t])}),n.sentences[0].focusSolution(),n.trigger('resize')},n.resetTask=function(){n.sentences.forEach(function(e){e.reset(),e.enable(),e.hideSolution()}),n.removeFeedback(),n.hideButton('try-again'),n.hideButton('show-solution'),n.showButton('check-answer'),n.introduction?n.introduction.focus():n.sentences[0].focus(),n.mistakesCapped=0,n.isAnswered=!1},n.getXAPIData=function(){return{statement:n.getXAPIAnswerEvent().data.statement}},n.triggerXAPI=function(){n.trigger(n.getXAPIAnswerEvent())},n.getXAPIAnswerEvent=function(){n.computedResults=n.sentences.map(function(e){return e.computeResults()});var e=n.createDictationXAPIEvent('answered'),a=e.getVerifiedStatementValue(['object','definition']);if(a.extensions&&a.extensions[t.XAPI_ALTERNATIVE_EXTENSION]){var o=e.getVerifiedStatementValue(['context']);o.extensions=o.extensions||{},o.extensions[t.XAPI_REPORTING_VERSION_EXTENSION]=t.XAPI_REPORTING_VERSION}e.setScoredResult(n.getScore(),n.getMaxScore(),d(n),!0,n.isPassed());var s=n.computedResults.reduce(function(e,t){return e.concat(t.words.reduce(function(e,t){return e.concat(t.answer||'')},[]))},[]).join('[,]');return e.data.statement.result.response=s,e},n.createDictationXAPIEvent=function(e){var t=n.createXAPIEventTemplate(e);return b.extend(t.getVerifiedStatementValue(['object','definition']),n.getxAPIDefinition()),t},n.getxAPIDefinition=function(){var e=n.computedResults.reduce(function(e,a,o){var s=n.sentences[o].getXAPIDescription(),r=a.words.map(function(){return t.FILL_IN_PLACEHOLDER}).join(' ');return''.concat(e).concat(s,'<p>').concat(r,'</p>')},''),a={};a.name={},a.name[n.languageTag]=n.getTitle(),a.name['en-US']=a.name[n.languageTag],a.description={},a.description[n.languageTag]=''.concat(n.getDescription()).concat(e),a.description['en-US']=a.description[n.languageTag],a.type='http://adlnet.gov/expapi/activities/cmi.interaction',a.interactionType='fill-in',a.extensions=a.extensions||{},a.extensions[t.XAPI_CASE_SENSITIVITY]=!0;var o=n.buildCorrectGapVariations();return a.extensions[t.XAPI_ALTERNATIVE_EXTENSION]=o,a.correctResponsesPattern=n.buildxAPICRP(o.slice()),a},n.buildCorrectGapVariations=function(){return n.computedResults.reduce(function(e,t){return e.concat(t.words.map(function(e){return e.solution?e.solution.split('|'):[]}))},[])},n.buildxAPICRP=function(e){var t=!!(1<arguments.length&&void 0!==arguments[1])&&arguments[1],a=[''];return e?(t?(e.forEach(function(e){a=b.buildCombinations(e,a,'[,]')}),a=a.map(function(e){return'{case_matters=true}'.concat(e)})):(a=e.map(function(e){return e[0]}).join('[,]'),a=['{case_matters=true}'.concat(a)]),a):a},n.getCurrentState=function(){return n.sentences.map(function(e){return e.getCurrentState()})},n.getTitle=function(){var e;return n.contentData&&n.contentData.metadata&&(e=n.contentData.metadata.title),e=e||t.DEFAULT_DESCRIPTION,H5P.createTitle(e)},n.getDescription=function(){return n.params.taskDescription||t.DEFAULT_DESCRIPTION},n}return c(t,e),t}(H5P.Question);P.DEFAULT_DESCRIPTION='Dictation',P.XAPI_ALTERNATIVE_EXTENSION='https://h5p.org/x-api/alternatives',P.XAPI_CASE_SENSITIVITY='https://h5p.org/x-api/case-sensitivity',P.XAPI_REPORTING_VERSION_EXTENSION='https://h5p.org/x-api/h5p-reporting-version',P.XAPI_REPORTING_VERSION='1.0.0',P.FILL_IN_PLACEHOLDER='__________';H5P=H5P||{},H5P.Dictation=P}]);