diff --git a/projects/quml-library/package.json b/projects/quml-library/package.json index d547cb1d..1b282a5a 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/player-constants.ts b/projects/quml-library/src/lib/player-constants.ts index 33757afc..7b453086 100644 --- a/projects/quml-library/src/lib/player-constants.ts +++ b/projects/quml-library/src/lib/player-constants.ts @@ -3,4 +3,6 @@ export const DEFAULT_SCORE: number = 1; export const WARNING_TIME_CONFIG = { DEFAULT_TIME : 75, SHOW_TIMER: true -} \ No newline at end of file +} + +export const COMPATABILITY_LEVEL: number = 6; \ No newline at end of file diff --git a/projects/quml-library/src/lib/section-player/section-player.component.spec.ts b/projects/quml-library/src/lib/section-player/section-player.component.spec.ts index d3a336e0..7c2fa610 100644 --- a/projects/quml-library/src/lib/section-player/section-player.component.spec.ts +++ b/projects/quml-library/src/lib/section-player/section-player.component.spec.ts @@ -478,10 +478,10 @@ describe('SectionPlayerComponent', () => { }); it('should check compatibility of the questionset', () => { - spyOn(errorService, 'checkContentCompatibility').and.returnValue(false); - spyOn(viewerService, 'raiseExceptionLog'); - component['checkCompatibilityLevel'](3); - expect(errorService.checkContentCompatibility).toHaveBeenCalled(); + spyOn(component, 'checkContentCompatibility').and.callThrough(); + spyOn(viewerService, 'raiseExceptionLog').and.callFake(() => {}); + component['checkCompatibilityLevel'](7); + expect(component.checkContentCompatibility).toHaveBeenCalled(); expect(viewerService.raiseExceptionLog).toHaveBeenCalled(); }); 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 03c37503..a4130c58 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 @@ -7,7 +7,7 @@ import { takeUntil } from 'rxjs/operators'; import { QumlPlayerConfig, IParentConfig, IAttempts } from '../quml-library-interface'; import { ViewerService } from '../services/viewer-service/viewer-service'; import { eventName, pageId, TelemetryType, Cardinality, QuestionType } from '../telemetry-constants'; -import { DEFAULT_SCORE } from '../player-constants'; +import { DEFAULT_SCORE, COMPATABILITY_LEVEL } from '../player-constants'; import { UtilService } from '../util-service'; @Component({ @@ -91,6 +91,7 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { isAssessEventRaised = false; isShuffleQuestions = false; shuffleOptions: boolean; + playerContentCompatibiltyLevel = COMPATABILITY_LEVEL; constructor( public viewerService: ViewerService, @@ -560,7 +561,9 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { private checkCompatibilityLevel(compatibilityLevel) { /* istanbul ignore else */ if (compatibilityLevel) { - const checkContentCompatible = this.errorService.checkContentCompatibility(compatibilityLevel); + // TODO: It is a temporary fix for IQ-679 or ED-3398 + // Before these changes we were calling errorService.checkContentCompatibility + const checkContentCompatible = this.checkContentCompatibility(compatibilityLevel); /* istanbul ignore else */ if (!checkContentCompatible.isCompitable) { @@ -570,6 +573,18 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { } } + checkContentCompatibility(currentCompatibilityLevel: number) { + if (currentCompatibilityLevel > this.playerContentCompatibiltyLevel) { + const compatibilityError = new Error(); + compatibilityError.message = `Player supports ${this.playerContentCompatibiltyLevel} + but content compatibility is ${currentCompatibilityLevel}`; + compatibilityError.name = 'contentCompatibily'; + return { error: compatibilityError, isCompitable: false }; + } else { + return { error: null, isCompitable: true }; + } + } + emitSectionEnd(isDurationEnded: boolean = false, jumpToSection?: string) { const eventObj: any = { summary: this.createSummaryObj(), diff --git a/web-component/package.json b/web-component/package.json index 831f54e6..c4609e51 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.3", + "version": "3.0.4", "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 9fbd833e..86ad6716 100644 --- a/web-component/sunbird-quml-player.js +++ b/web-component/sunbird-quml-player.js @@ -85292,6 +85292,7 @@ class SafeHtmlPipe { __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { +/* harmony export */ "COMPATABILITY_LEVEL": () => (/* binding */ COMPATABILITY_LEVEL), /* harmony export */ "DEFAULT_SCORE": () => (/* binding */ DEFAULT_SCORE), /* harmony export */ "WARNING_TIME_CONFIG": () => (/* binding */ WARNING_TIME_CONFIG) /* harmony export */ }); @@ -85300,6 +85301,7 @@ const WARNING_TIME_CONFIG = { DEFAULT_TIME: 75, SHOW_TIMER: true }; +const COMPATABILITY_LEVEL = 6; /***/ }), @@ -86775,6 +86777,7 @@ class SectionPlayerComponent { this.slideDuration = 0; this.isAssessEventRaised = false; this.isShuffleQuestions = false; + this.playerContentCompatibiltyLevel = _player_constants__WEBPACK_IMPORTED_MODULE_1__.COMPATABILITY_LEVEL; } ngOnChanges(changes) { /* istanbul ignore else */ @@ -87179,13 +87182,32 @@ class SectionPlayerComponent { checkCompatibilityLevel(compatibilityLevel) { /* istanbul ignore else */ if (compatibilityLevel) { - const checkContentCompatible = this.errorService.checkContentCompatibility(compatibilityLevel); + // TODO: It is a temporary fix for IQ-679 or ED-3398 + // Before these changes we were calling errorService.checkContentCompatibility + const checkContentCompatible = this.checkContentCompatibility(compatibilityLevel); /* istanbul ignore else */ if (!checkContentCompatible.isCompitable) { this.viewerService.raiseExceptionLog(_project_sunbird_sunbird_player_sdk_v9__WEBPACK_IMPORTED_MODULE_15__.errorCode.contentCompatibility, _project_sunbird_sunbird_player_sdk_v9__WEBPACK_IMPORTED_MODULE_15__.errorMessage.contentCompatibility, checkContentCompatible.error, this.sectionConfig?.config?.traceId); } } } + checkContentCompatibility(currentCompatibilityLevel) { + if (currentCompatibilityLevel > this.playerContentCompatibiltyLevel) { + const compatibilityError = new Error(); + compatibilityError.message = `Player supports ${this.playerContentCompatibiltyLevel} + but content compatibility is ${currentCompatibilityLevel}`; + compatibilityError.name = 'contentCompatibily'; + return { + error: compatibilityError, + isCompitable: false + }; + } else { + return { + error: null, + isCompitable: true + }; + } + } emitSectionEnd(isDurationEnded = false, jumpToSection) { const eventObj = { summary: this.createSummaryObj(),