diff --git a/projects/quml-library/src/lib/section-player/section-player.component.ts b/projects/quml-library/src/lib/section-player/section-player.component.ts index d79551bc..03c37503 100644 --- a/projects/quml-library/src/lib/section-player/section-player.component.ts +++ b/projects/quml-library/src/lib/section-player/section-player.component.ts @@ -104,6 +104,7 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { if (changes && Object.values(changes)[0].firstChange) { this.subscribeToEvents(); } + this.viewerService.sectionConfig = this.sectionConfig; this.setConfig(); } diff --git a/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.ts b/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.ts index f35e9a65..564b2375 100644 --- a/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.ts +++ b/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.ts @@ -5,6 +5,7 @@ import { QumlLibraryService } from '../../quml-library.service'; import { UtilService } from '../../util-service'; import { QuestionCursor } from '../../quml-question-cursor.service'; import { of, throwError } from 'rxjs'; +import { TransformationService } from '../transformation-service/transformation.service'; describe('ViewerService', () => { class MockQuestionCursor { @@ -205,17 +206,32 @@ describe('ViewerService', () => { service.identifiers = ['do_123', 'do_124']; spyOn(service.questionCursor, 'getQuestion').and.returnValue(of([{ id: 'do_123' }, { id: 'do_124' }] as any)); spyOn(service.qumlQuestionEvent, 'emit'); + service.sectionConfig = mockData.playerConfig; service.getQuestion(); expect(service.qumlQuestionEvent.emit).toHaveBeenCalled(); expect(service.questionCursor.getQuestion).toHaveBeenCalled(); }); + it('should emit transformed question metadata if question body is available', () => { + const service = TestBed.inject(ViewerService); + const sectionChildren = [{ identifier: '1', body: 'Question 1' }]; + const fetchedQuestionData = { questions: [{ identifier: '1', body: 'Question 1' }], count: 1 }; + spyOn(service.transformationService, 'getTransformedQuestionMetadata').and.returnValue(fetchedQuestionData); + spyOn(service.qumlQuestionEvent, 'emit').and.callFake(() => {}); + service.threshold = 1; + service.identifiers = ['1']; + service.sectionConfig = {metadata:{children: sectionChildren}}; + service.getQuestion(); + expect(service.qumlQuestionEvent.emit).toHaveBeenCalledWith(fetchedQuestionData); + }); + it('should call getQuestion and return the error', () => { const service = TestBed.inject(ViewerService); const qumlLibraryService = TestBed.inject(QumlLibraryService); service.identifiers = ['do_123', 'do_124']; spyOn(service.questionCursor, 'getQuestion').and.returnValue(throwError('Error')); spyOn(service.qumlQuestionEvent, 'emit'); + service.sectionConfig = mockData.playerConfig; service.getQuestion(); expect(service.qumlQuestionEvent.emit).toHaveBeenCalled(); expect(service.questionCursor.getQuestion).toHaveBeenCalled(); @@ -226,18 +242,54 @@ describe('ViewerService', () => { const qumlLibraryService = TestBed.inject(QumlLibraryService); service.identifiers = []; spyOn(service.questionCursor, 'getQuestion'); + service.sectionConfig = mockData.playerConfig; service.getQuestion(); expect(service.questionCursor.getQuestion).not.toHaveBeenCalled(); }); + it('should return available questions if sectionChildren is not empty', () => { + const service = TestBed.inject(ViewerService); + const sectionChildren = [{ identifier: '1', body: 'Question 1' }, { identifier: '2', body: 'Question 2' }]; + const questionIdArr = ['1', '2']; + service.getSectionQuestionData(sectionChildren, questionIdArr).subscribe(result => { + expect(result.questions.length).toBe(2); + expect(result.count).toBe(2); + }); + }); + + it('should return questionsIdNotHavingCompleteData if sectionChildren is empty', () => { + const service = TestBed.inject(ViewerService); + const sectionChildren = []; + const questionIdArr = ['1', '2']; + spyOn(service, 'fetchIncompleteQuestionsData').and.returnValue(of({questions: [{ identifier: '1', body: 'Question 1' }, { identifier: '2', body: 'Question 2' }], count: 2})) + service.getSectionQuestionData(sectionChildren, questionIdArr).subscribe(result => { + expect(result.questions.length).toBe(2); + }); + }); + + it('should fetch incomplete questions data and return combined questions', () => { + const service = TestBed.inject(ViewerService); + const availableQuestions = [{ identifier: '1', body: 'Question 1' }]; + const questionsIdNotHavingCompleteData = ['2']; + const questionData = { identifier: '2', body: 'Question 2' } + spyOn(service.questionCursor, 'getQuestions').and.returnValue(of([{ questions: [questionData], count: 1 }] as any)) + service.fetchIncompleteQuestionsData(availableQuestions, questionsIdNotHavingCompleteData).subscribe(result => { + expect(result.questions.length).toBe(2); + expect(result.count).toBe(2); + }); + }); + it('should call getQuestions', () => { const service = TestBed.inject(ViewerService); - service.parentIdentifier = 'do_555'; - service.identifiers = ['do_123', 'do_124']; - spyOn(service.questionCursor, 'getQuestions').and.returnValue(of([{ id: 'do_123' }] as any)); - spyOn(service.qumlQuestionEvent, 'emit'); + service.parentIdentifier = 'do_21348431528472576011'; + service.identifiers = ['do_21348431559137689613', 'do_21348431640099225615']; + spyOn(service, 'getSectionQuestionData').and.returnValue(of([{ id: 'do_21348431559137689613' }] as any)); + const getTransformedQuestionMetadata = TestBed.inject(TransformationService); + spyOn(getTransformedQuestionMetadata, 'getTransformedQuestionMetadata').and.returnValue({questions: [{ id: 'do_21348431559137689613' }], count: 1}) + spyOn(service.qumlQuestionEvent, 'emit').and.callFake(() => {}); + service.sectionConfig = mockData.playerConfig; service.getQuestions(0, 1) - expect(service.questionCursor.getQuestions).toHaveBeenCalled(); + expect(service.getSectionQuestionData).toHaveBeenCalled(); expect(service.qumlQuestionEvent.emit).toHaveBeenCalled(); }); @@ -246,10 +298,11 @@ describe('ViewerService', () => { service.parentIdentifier = 'do_555'; service.identifiers = ['do_123', 'do_124']; service.threshold = 3; - spyOn(service.questionCursor, 'getQuestions').and.returnValue(throwError('Error')); + spyOn(service, 'getSectionQuestionData').and.returnValue(throwError('Error')); spyOn(service.qumlQuestionEvent, 'emit'); + service.sectionConfig = mockData.playerConfig; service.getQuestions() - expect(service.questionCursor.getQuestions).toHaveBeenCalled(); + expect(service.getSectionQuestionData).toHaveBeenCalled(); expect(service.qumlQuestionEvent.emit).toHaveBeenCalled(); }); diff --git a/projects/quml-library/src/lib/services/viewer-service/viewer-service.ts b/projects/quml-library/src/lib/services/viewer-service/viewer-service.ts index 0e251129..6fcc8482 100644 --- a/projects/quml-library/src/lib/services/viewer-service/viewer-service.ts +++ b/projects/quml-library/src/lib/services/viewer-service/viewer-service.ts @@ -6,7 +6,8 @@ import { TransformationService } from '../transformation-service/transformation. import { eventName, TelemetryType } from '../../telemetry-constants'; import { QuestionCursor } from '../../quml-question-cursor.service'; import * as _ from 'lodash-es'; -import { forkJoin } from 'rxjs'; +import { forkJoin, of } from 'rxjs'; +import { switchMap } from 'rxjs/operators'; @Injectable({ providedIn: 'root' @@ -35,7 +36,7 @@ export class ViewerService { questionSetId: string; parentIdentifier: string; sectionQuestions = []; - + sectionConfig:any; constructor( public qumlLibraryService: QumlLibraryService, public utilService: UtilService, @@ -231,8 +232,43 @@ export class ViewerService { this.qumlLibraryService.error(stacktrace, { err: errorCode, errtype: errorType }); } + getSectionQuestionData(sectionChildren, questionIdArr) { + const availableQuestions = []; + let questionsIdNotHavingCompleteData = []; + if (_.isEmpty(sectionChildren)) { + questionsIdNotHavingCompleteData = questionIdArr; + } else { + const foundQuestions = sectionChildren.filter(child => questionIdArr.includes(child.identifier)); + for (const question of foundQuestions) { + if (_.has(question, 'body')) { + availableQuestions.push(question); + } else { + questionsIdNotHavingCompleteData.push(question.identifier); + } + } + } + + if (!_.isEmpty(questionsIdNotHavingCompleteData)) { + return this.fetchIncompleteQuestionsData(availableQuestions, questionsIdNotHavingCompleteData); + } else { + const allQuestions$ = of({ questions: availableQuestions, count: availableQuestions.length }); + return allQuestions$; + } + } + + fetchIncompleteQuestionsData(availableQuestions, questionsIdNotHavingCompleteData) { + return this.questionCursor.getQuestions(questionsIdNotHavingCompleteData, this.parentIdentifier).pipe( + switchMap((questionData: any) => { + const fetchedQuestions = questionData.questions; + const allQuestions = _.concat(availableQuestions, fetchedQuestions); + return of({ questions: allQuestions, count: allQuestions.length }); + }) + ); + } + getQuestions(currentIndex?: number, index?: number) { + const sectionChildren = this.sectionConfig?.metadata?.children; let indentifersForQuestions; if (currentIndex !== undefined && index) { indentifersForQuestions = this.identifiers.splice(currentIndex, index); @@ -240,10 +276,10 @@ export class ViewerService { indentifersForQuestions = this.identifiers.splice(0, this.threshold); } if (!_.isEmpty(indentifersForQuestions)) { - const requests = []; + let requests: any; const chunkArray = _.chunk(indentifersForQuestions, 10); _.forEach(chunkArray, (value) => { - requests.push(this.questionCursor.getQuestions(value, this.parentIdentifier)); + requests = this.getSectionQuestionData(sectionChildren, value) }); forkJoin(requests).subscribe(questions => { _.forEach(questions, (value) => { @@ -259,15 +295,26 @@ export class ViewerService { } getQuestion() { + const sectionChildren = this.sectionConfig?.metadata?.children; if (this.identifiers.length) { let questionIdentifier = this.identifiers.splice(0, this.threshold); - this.questionCursor.getQuestion(questionIdentifier[0]).subscribe((question) => { - this.qumlQuestionEvent.emit(question); - }, (error) => { - this.qumlQuestionEvent.emit({ - error: error + const fetchedQuestion = _.find(sectionChildren, (question) => _.includes(questionIdentifier, question.identifier)); + + if (_.has(fetchedQuestion, 'body')) { + const fetchedQuestionData = {questions: [fetchedQuestion], count: 1 }; + const transformedquestionsList = this.transformationService.getTransformedQuestionMetadata(fetchedQuestionData); + this.qumlQuestionEvent.emit(transformedquestionsList); + } else { + this.questionCursor.getQuestion(questionIdentifier[0]).subscribe((question) => { + const fetchedQuestionData = question; + const transformedquestionsList = this.transformationService.getTransformedQuestionMetadata(fetchedQuestionData); + this.qumlQuestionEvent.emit(transformedquestionsList); + }, (error) => { + this.qumlQuestionEvent.emit({ + error: error + }); }); - }); + } } } 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..1d60db46 100644 --- a/web-component/sunbird-quml-player.js +++ b/web-component/sunbird-quml-player.js @@ -77175,6 +77175,65 @@ function cloneDeep(value) { /***/ }), +/***/ 6480: +/*!******************************************!*\ + !*** ./node_modules/lodash-es/concat.js ***! + \******************************************/ +/***/ ((__unused_webpack___webpack_module__, __webpack_exports__, __webpack_require__) => { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "default": () => (__WEBPACK_DEFAULT_EXPORT__) +/* harmony export */ }); +/* harmony import */ var _arrayPush_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./_arrayPush.js */ 2784); +/* harmony import */ var _baseFlatten_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./_baseFlatten.js */ 3932); +/* harmony import */ var _copyArray_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./_copyArray.js */ 7331); +/* harmony import */ var _isArray_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./isArray.js */ 7191); + + + + + +/** + * Creates a new array concatenating `array` with any additional arrays + * and/or values. + * + * @static + * @memberOf _ + * @since 4.0.0 + * @category Array + * @param {Array} array The array to concatenate. + * @param {...*} [values] The values to concatenate. + * @returns {Array} Returns the new concatenated array. + * @example + * + * var array = [1]; + * var other = _.concat(array, 2, [3], [[4]]); + * + * console.log(other); + * // => [1, 2, 3, [4]] + * + * console.log(array); + * // => [1] + */ +function concat() { + var length = arguments.length; + if (!length) { + return []; + } + var args = Array(length - 1), + array = arguments[0], + index = length; + while (index--) { + args[index - 1] = arguments[index]; + } + return (0,_arrayPush_js__WEBPACK_IMPORTED_MODULE_0__["default"])((0,_isArray_js__WEBPACK_IMPORTED_MODULE_1__["default"])(array) ? (0,_copyArray_js__WEBPACK_IMPORTED_MODULE_2__["default"])(array) : [array], (0,_baseFlatten_js__WEBPACK_IMPORTED_MODULE_3__["default"])(args, 1)); +} +/* harmony default export */ const __WEBPACK_DEFAULT_EXPORT__ = (concat); + +/***/ }), + /***/ 9005: /*!********************************************!*\ !*** ./node_modules/lodash-es/constant.js ***! @@ -85442,7 +85501,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "QumlLibraryService": () => (/* binding */ QumlLibraryService) /* harmony export */ }); -/* harmony import */ var _home_ttpl_rt_66_Documents_inQuiry_player_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ 1670); +/* harmony import */ var _home_ttpl_rt_171_Documents_inQuiry_player_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js */ 1670); /* harmony import */ var _angular_core__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @angular/core */ 2560); /* harmony import */ var _project_sunbird_client_services_telemetry__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @project-sunbird/client-services/telemetry */ 4635); /* harmony import */ var _project_sunbird_client_services_telemetry__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_project_sunbird_client_services_telemetry__WEBPACK_IMPORTED_MODULE_1__); @@ -85463,7 +85522,7 @@ class QumlLibraryService { } initializeTelemetry(config, parentConfig) { var _this = this; - return (0,_home_ttpl_rt_66_Documents_inQuiry_player_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () { + return (0,_home_ttpl_rt_171_Documents_inQuiry_player_node_modules_babel_runtime_helpers_esm_asyncToGenerator_js__WEBPACK_IMPORTED_MODULE_0__["default"])(function* () { if (!lodash_es__WEBPACK_IMPORTED_MODULE_4__["default"](config, 'context') || lodash_es__WEBPACK_IMPORTED_MODULE_5__["default"](config, 'context')) { return; } @@ -86763,6 +86822,7 @@ class SectionPlayerComponent { if (changes && Object.values(changes)[0].firstChange) { this.subscribeToEvents(); } + this.viewerService.sectionConfig = this.sectionConfig; this.setConfig(); } ngAfterViewInit() { @@ -88003,9 +88063,15 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _telemetry_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../telemetry-constants */ 7930); /* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! lodash-es */ 8163); /* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! lodash-es */ 4607); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! lodash-es */ 3089); -/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! lodash-es */ 9724); -/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! rxjs */ 4350); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! lodash-es */ 2941); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! lodash-es */ 6480); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! lodash-es */ 3089); +/* harmony import */ var lodash_es__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! lodash-es */ 9724); +/* 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 */ 3795); +/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! rxjs */ 4139); +/* harmony import */ var rxjs__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! rxjs */ 4350); +/* harmony import */ var rxjs_operators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! rxjs/operators */ 9095); /* harmony import */ var _quml_library_service__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../quml-library.service */ 5669); /* harmony import */ var _util_service__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../util-service */ 2025); /* harmony import */ var _quml_question_cursor_service__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../quml-question-cursor.service */ 8659); @@ -88019,6 +88085,7 @@ __webpack_require__.r(__webpack_exports__); + class ViewerService { constructor(qumlLibraryService, utilService, questionCursor, transformationService) { this.qumlLibraryService = qumlLibraryService; @@ -88209,7 +88276,43 @@ class ViewerService { errtype: errorType }); } + getSectionQuestionData(sectionChildren, questionIdArr) { + const availableQuestions = []; + let questionsIdNotHavingCompleteData = []; + if (lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](sectionChildren)) { + questionsIdNotHavingCompleteData = questionIdArr; + } else { + const foundQuestions = sectionChildren.filter(child => questionIdArr.includes(child.identifier)); + for (const question of foundQuestions) { + if (lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](question, 'body')) { + availableQuestions.push(question); + } else { + questionsIdNotHavingCompleteData.push(question.identifier); + } + } + } + if (!lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](questionsIdNotHavingCompleteData)) { + return this.fetchIncompleteQuestionsData(availableQuestions, questionsIdNotHavingCompleteData); + } else { + const allQuestions$ = (0,rxjs__WEBPACK_IMPORTED_MODULE_9__.of)({ + questions: availableQuestions, + count: availableQuestions.length + }); + return allQuestions$; + } + } + fetchIncompleteQuestionsData(availableQuestions, questionsIdNotHavingCompleteData) { + return this.questionCursor.getQuestions(questionsIdNotHavingCompleteData, this.parentIdentifier).pipe((0,rxjs_operators__WEBPACK_IMPORTED_MODULE_10__.switchMap)(questionData => { + const fetchedQuestions = questionData.questions; + const allQuestions = lodash_es__WEBPACK_IMPORTED_MODULE_11__["default"](availableQuestions, fetchedQuestions); + return (0,rxjs__WEBPACK_IMPORTED_MODULE_9__.of)({ + questions: allQuestions, + count: allQuestions.length + }); + })); + } getQuestions(currentIndex, index) { + const sectionChildren = this.sectionConfig?.metadata?.children; let indentifersForQuestions; if (currentIndex !== undefined && index) { indentifersForQuestions = this.identifiers.splice(currentIndex, index); @@ -88217,13 +88320,13 @@ class ViewerService { indentifersForQuestions = this.identifiers.splice(0, this.threshold); } if (!lodash_es__WEBPACK_IMPORTED_MODULE_7__["default"](indentifersForQuestions)) { - const requests = []; - const chunkArray = lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](indentifersForQuestions, 10); - lodash_es__WEBPACK_IMPORTED_MODULE_9__["default"](chunkArray, value => { - requests.push(this.questionCursor.getQuestions(value, this.parentIdentifier)); + let requests; + const chunkArray = lodash_es__WEBPACK_IMPORTED_MODULE_12__["default"](indentifersForQuestions, 10); + lodash_es__WEBPACK_IMPORTED_MODULE_13__["default"](chunkArray, value => { + requests = this.getSectionQuestionData(sectionChildren, value); }); - (0,rxjs__WEBPACK_IMPORTED_MODULE_10__.forkJoin)(requests).subscribe(questions => { - lodash_es__WEBPACK_IMPORTED_MODULE_9__["default"](questions, value => { + (0,rxjs__WEBPACK_IMPORTED_MODULE_14__.forkJoin)(requests).subscribe(questions => { + lodash_es__WEBPACK_IMPORTED_MODULE_13__["default"](questions, value => { const transformedquestionsList = this.transformationService.getTransformedQuestionMetadata(value); this.qumlQuestionEvent.emit(transformedquestionsList); }); @@ -88235,15 +88338,28 @@ class ViewerService { } } getQuestion() { + const sectionChildren = this.sectionConfig?.metadata?.children; if (this.identifiers.length) { let questionIdentifier = this.identifiers.splice(0, this.threshold); - this.questionCursor.getQuestion(questionIdentifier[0]).subscribe(question => { - this.qumlQuestionEvent.emit(question); - }, error => { - this.qumlQuestionEvent.emit({ - error: error + const fetchedQuestion = lodash_es__WEBPACK_IMPORTED_MODULE_15__["default"](sectionChildren, question => lodash_es__WEBPACK_IMPORTED_MODULE_16__["default"](questionIdentifier, question.identifier)); + if (lodash_es__WEBPACK_IMPORTED_MODULE_8__["default"](fetchedQuestion, 'body')) { + const fetchedQuestionData = { + questions: [fetchedQuestion], + count: 1 + }; + const transformedquestionsList = this.transformationService.getTransformedQuestionMetadata(fetchedQuestionData); + this.qumlQuestionEvent.emit(transformedquestionsList); + } else { + this.questionCursor.getQuestion(questionIdentifier[0]).subscribe(question => { + const fetchedQuestionData = question; + const transformedquestionsList = this.transformationService.getTransformedQuestionMetadata(fetchedQuestionData); + this.qumlQuestionEvent.emit(transformedquestionsList); + }, error => { + this.qumlQuestionEvent.emit({ + error: error + }); }); - }); + } } } generateMaxAttemptEvents(currentattempt, maxLimitExceeded, isLastAttempt) {