diff --git a/projects/quml-library/package.json b/projects/quml-library/package.json index 3717e5f9..8d97c7ab 100644 --- a/projects/quml-library/package.json +++ b/projects/quml-library/package.json @@ -1,6 +1,6 @@ { "name": "@project-sunbird/sunbird-quml-player", - "version": "7.0.2", + "version": "7.0.3", "schematics": "./schematics/collection.json", "ng-add": { "save": "dependencies" diff --git a/projects/quml-library/src/lib/main-player/main-player.component.ts b/projects/quml-library/src/lib/main-player/main-player.component.ts index fa356cc7..021b9e01 100644 --- a/projects/quml-library/src/lib/main-player/main-player.component.ts +++ b/projects/quml-library/src/lib/main-player/main-player.component.ts @@ -230,7 +230,7 @@ export class MainPlayerComponent implements OnInit, OnChanges { max: this.playerConfig.metadata?.maxAttempts, current: this.playerConfig.metadata?.currentAttempt ? this.playerConfig.metadata.currentAttempt + 1 : 1 }; - this.totalScore = this.playerConfig.metadata.outcomeDeclaration.maxScore.defaultValue; + this.totalScore = this.playerConfig.metadata?.outcomeDeclaration?.maxScore?.defaultValue || this.playerConfig.metadata?.maxScore; this.showReplay = this.attempts?.max && this.attempts?.current >= this.attempts.max ? false : true; if (typeof this.playerConfig.metadata?.timeLimits === 'string') { this.playerConfig.metadata.timeLimits = JSON.parse(this.playerConfig.metadata.timeLimits); diff --git a/projects/quml-library/src/lib/services/transformation-service/transformation.service.ts b/projects/quml-library/src/lib/services/transformation-service/transformation.service.ts index a1f5625d..6dabfc6c 100644 --- a/projects/quml-library/src/lib/services/transformation-service/transformation.service.ts +++ b/projects/quml-library/src/lib/services/transformation-service/transformation.service.ts @@ -49,7 +49,7 @@ export class TransformationService { } processBloomsLevel(data) { - if (_.has(data, 'bloomsLevel')) { + if (_.has(data, 'bloomsLevel') && !_.isUndefined(data?.bloomsLevel)) { const bLevel = _.get(data, 'bloomsLevel'); _.unset(data, 'bloomsLevel'); _.set(data, 'complexityLevel', [bLevel.toString()]); diff --git a/web-component/package.json b/web-component/package.json index fc8925de..831f54e6 100644 --- a/web-component/package.json +++ b/web-component/package.json @@ -1,6 +1,6 @@ { "name": "@project-sunbird/sunbird-quml-player-web-component", - "version": "3.0.2", + "version": "3.0.3", "description": "The web component package for the sunbird QuML player", "main": "sunbird-quml-player.js", "scripts": { diff --git a/web-component/sunbird-quml-player.js b/web-component/sunbird-quml-player.js index 52482ab3..4c29e349 100644 --- a/web-component/sunbird-quml-player.js +++ b/web-component/sunbird-quml-player.js @@ -83821,7 +83821,7 @@ class MainPlayerComponent { max: this.playerConfig.metadata?.maxAttempts, current: this.playerConfig.metadata?.currentAttempt ? this.playerConfig.metadata.currentAttempt + 1 : 1 }; - this.totalScore = this.playerConfig.metadata.outcomeDeclaration.maxScore.defaultValue; + this.totalScore = this.playerConfig.metadata?.outcomeDeclaration?.maxScore?.defaultValue || this.playerConfig.metadata?.maxScore; this.showReplay = this.attempts?.max && this.attempts?.current >= this.attempts.max ? false : true; if (typeof this.playerConfig.metadata?.timeLimits === 'string') { this.playerConfig.metadata.timeLimits = JSON.parse(this.playerConfig.metadata.timeLimits); @@ -87684,23 +87684,24 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! lodash-es */ 4607); /* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! lodash-es */ 5899); /* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! lodash-es */ 2941); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! lodash-es */ 4894); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! lodash-es */ 7528); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! lodash-es */ 6190); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lodash-es */ 9724); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! lodash-es */ 8172); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! lodash-es */ 7190); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! lodash-es */ 6011); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! lodash-es */ 3247); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! lodash-es */ 8152); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! lodash-es */ 1751); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! lodash-es */ 7732); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! lodash-es */ 5269); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! lodash-es */ 3795); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! lodash-es */ 3135); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! lodash-es */ 5279); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! lodash-es */ 4894); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! lodash-es */ 7528); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lodash-es */ 6190); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! lodash-es */ 9724); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! lodash-es */ 8172); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! lodash-es */ 7190); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! lodash-es */ 6011); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! lodash-es */ 3247); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! lodash-es */ 8152); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! lodash-es */ 1751); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! lodash-es */ 7732); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! lodash-es */ 5269); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! lodash-es */ 3795); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! lodash-es */ 3135); /* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! uuid */ 9485); /* harmony import */ var uuid__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(uuid__WEBPACK_IMPORTED_MODULE_0__); -/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! @angular/core */ 2560); +/* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! @angular/core */ 2560); @@ -87742,17 +87743,17 @@ class TransformationService { return data; } processBloomsLevel(data) { - if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](data, 'bloomsLevel')) { - const bLevel = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data, 'bloomsLevel'); - lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'bloomsLevel'); - lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](data, 'complexityLevel', [bLevel.toString()]); + if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](data, 'bloomsLevel') && !lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data?.bloomsLevel)) { + const bLevel = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'bloomsLevel'); + lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](data, 'bloomsLevel'); + lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](data, 'complexityLevel', [bLevel.toString()]); } return data; } processBooleanProps(data) { const booleanProps = ["showSolutions", "showFeedback", "showHints", "showTimer"]; const getBooleanValue = str => str === "Yes"; - lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](booleanProps, prop => { + lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](booleanProps, prop => { if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](data, prop)) { const propVal = data[prop]; data[prop] = getBooleanValue(propVal); @@ -87762,8 +87763,8 @@ class TransformationService { } processTimeLimits(data) { let parsedTimeLimits; - if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](data, 'timeLimits') && !lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](data.timeLimits)) { - if (lodash_es__WEBPACK_IMPORTED_MODULE_9__["default"](data.timeLimits)) { + if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](data, 'timeLimits') && !lodash_es__WEBPACK_IMPORTED_MODULE_9__["default"](data.timeLimits)) { + if (lodash_es__WEBPACK_IMPORTED_MODULE_10__["default"](data.timeLimits)) { parsedTimeLimits = JSON.parse(data.timeLimits); } else { parsedTimeLimits = data.timeLimits; @@ -87771,7 +87772,7 @@ class TransformationService { data.timeLimits = { questionSet: { min: 0, - max: parsedTimeLimits?.maxTime ? lodash_es__WEBPACK_IMPORTED_MODULE_10__["default"](parsedTimeLimits.maxTime) : 0 + max: parsedTimeLimits?.maxTime ? lodash_es__WEBPACK_IMPORTED_MODULE_11__["default"](parsedTimeLimits.maxTime) : 0 } }; } @@ -87780,16 +87781,16 @@ class TransformationService { transformChildren(children) { const self = this; if (!lodash_es__WEBPACK_IMPORTED_MODULE_1__["default"](children)) { - lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](children, ch => { + lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](children, ch => { if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](ch, 'version')) { - lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](ch, 'version'); + lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](ch, 'version'); } ch = this.processBloomsLevel(ch); ch = this.processBooleanProps(ch); - if (lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](ch, 'mimeType').toLowerCase() === 'application/vnd.sunbird.questionset') { + if (lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](ch, 'mimeType').toLowerCase() === 'application/vnd.sunbird.questionset') { ch = this.processTimeLimits(ch); ch = this.processInstructions(ch); - const nestedChildren = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](ch, 'children', []); + const nestedChildren = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](ch, 'children', []); self.transformChildren(nestedChildren); } }); @@ -87798,7 +87799,7 @@ class TransformationService { } getTransformedQuestionMetadata(data) { if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](data, 'questions')) { - lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](data.questions, question => { + lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](data.questions, question => { if (!lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](question, 'qumlVersion') || question.qumlVersion != 1.1) { question = this.processResponseDeclaration(question); question = this.processInteractions(question); @@ -87809,7 +87810,7 @@ class TransformationService { question = this.processBooleanProps(question); const ans = this.getAnswer(question); if (!lodash_es__WEBPACK_IMPORTED_MODULE_1__["default"](ans)) { - lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](question, 'answer', ans); + lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](question, 'answer', ans); } } }); @@ -87818,7 +87819,7 @@ class TransformationService { } processResponseDeclaration(data) { let outcomeDeclaration = {}; - if (lodash_es__WEBPACK_IMPORTED_MODULE_11__["default"](lodash_es__WEBPACK_IMPORTED_MODULE_12__["default"](data.primaryCategory), 'subjective question')) { + if (lodash_es__WEBPACK_IMPORTED_MODULE_12__["default"](lodash_es__WEBPACK_IMPORTED_MODULE_13__["default"](data.primaryCategory), 'subjective question')) { data = this.processSubjectiveResponseDeclaration(data); } else { let responseDeclaration = data.responseDeclaration; @@ -87826,15 +87827,15 @@ class TransformationService { for (const key in responseDeclaration) { const responseData = responseDeclaration[key]; const maxScore = { - cardinality: lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](responseData, 'cardinality', ''), - type: lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](responseData, 'type', ''), - defaultValue: lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](responseData, 'maxScore') + cardinality: lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](responseData, 'cardinality', ''), + type: lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](responseData, 'type', ''), + defaultValue: lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](responseData, 'maxScore') }; delete responseData.maxScore; outcomeDeclaration['maxScore'] = maxScore; const correctResp = responseData.correctResponse || {}; delete correctResp.outcomes; - if (lodash_es__WEBPACK_IMPORTED_MODULE_12__["default"](lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](responseData, 'type')) === 'integer' && lodash_es__WEBPACK_IMPORTED_MODULE_12__["default"](lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](responseData, 'cardinality')) === 'single') { + if (lodash_es__WEBPACK_IMPORTED_MODULE_13__["default"](lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](responseData, 'type')) === 'integer' && lodash_es__WEBPACK_IMPORTED_MODULE_13__["default"](lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](responseData, 'cardinality')) === 'single') { const correctKey = correctResp.value; correctResp.value = parseInt(correctKey, 10); } @@ -87851,7 +87852,7 @@ class TransformationService { let outcomeDeclaration = {}; delete subjectiveMetadata.responseDeclaration; delete subjectiveMetadata.interactions; - if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](subjectiveMetadata, 'maxScore') && !lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](subjectiveMetadata.maxScore)) { + if (lodash_es__WEBPACK_IMPORTED_MODULE_3__["default"](subjectiveMetadata, 'maxScore') && !lodash_es__WEBPACK_IMPORTED_MODULE_9__["default"](subjectiveMetadata.maxScore)) { outcomeDeclaration = { maxScore: { cardinality: 'single', @@ -87869,57 +87870,57 @@ class TransformationService { if (!lodash_es__WEBPACK_IMPORTED_MODULE_1__["default"](mappingData)) { const updatedMapping = mappingData.map(mapData => ({ value: mapData.response, - score: lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](mapData, 'outcomes.score', 0) + score: lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](mapData, 'outcomes.score', 0) })); return updatedMapping; } return mappingData; } processInteractions(data) { - const interactions = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data, 'interactions', {}); + const interactions = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'interactions', {}); if (!lodash_es__WEBPACK_IMPORTED_MODULE_1__["default"](interactions)) { - const validation = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](interactions, 'validation', {}); - const resp1 = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](interactions, 'response1', {}); - const resValData = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](interactions, 'response1.validation', {}); + const validation = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](interactions, 'validation', {}); + const resp1 = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](interactions, 'response1', {}); + const resValData = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](interactions, 'response1.validation', {}); if (!lodash_es__WEBPACK_IMPORTED_MODULE_1__["default"](resValData)) { - lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](resValData, (value, key) => { - lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](validation, key, value); + lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](resValData, (value, key) => { + lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](validation, key, value); }); } else { - lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](resp1, 'validation', validation); + lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](resp1, 'validation', validation); } - lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](interactions, 'validation'); - lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](interactions, 'response1', resp1); - lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](data, 'interactions', interactions); + lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](interactions, 'validation'); + lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](interactions, 'response1', resp1); + lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](data, 'interactions', interactions); } return data; } processSolutions(data) { - const solutions = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data, 'solutions', []); + const solutions = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'solutions', []); if (!lodash_es__WEBPACK_IMPORTED_MODULE_1__["default"](solutions)) { - const updatedSolutions = lodash_es__WEBPACK_IMPORTED_MODULE_13__["default"](solutions, (result, solution) => { - result[lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](solution, 'id')] = this.getSolutionString(solution, lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data, 'media', [])); + const updatedSolutions = lodash_es__WEBPACK_IMPORTED_MODULE_14__["default"](solutions, (result, solution) => { + result[lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](solution, 'id')] = this.getSolutionString(solution, lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'media', [])); return result; }, {}); - lodash_es__WEBPACK_IMPORTED_MODULE_6__["default"](data, 'solutions', updatedSolutions); + lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](data, 'solutions', updatedSolutions); } return data; } getSolutionString(data, media) { if (!lodash_es__WEBPACK_IMPORTED_MODULE_1__["default"](data)) { - const type = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data, 'type', ''); + const type = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'type', ''); switch (type) { case 'html': { - return lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data, 'value', ''); + return lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'value', ''); } case 'video': { - const value = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](data, 'value', ''); - const mediaData = lodash_es__WEBPACK_IMPORTED_MODULE_14__["default"](media, item => lodash_es__WEBPACK_IMPORTED_MODULE_11__["default"](value, lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](item, 'id', ''))); + const value = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](data, 'value', ''); + const mediaData = lodash_es__WEBPACK_IMPORTED_MODULE_15__["default"](media, item => lodash_es__WEBPACK_IMPORTED_MODULE_12__["default"](value, lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](item, 'id', ''))); if (mediaData) { - const src = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](mediaData, 'src', ''); - const thumbnail = lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](mediaData, 'thumbnail', ''); + const src = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](mediaData, 'src', ''); + const thumbnail = lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](mediaData, 'thumbnail', ''); const solutionStr = `