diff --git a/projects/quml-library/package-lock.json b/projects/quml-library/package-lock.json index 79882778..c4c3f97b 100644 --- a/projects/quml-library/package-lock.json +++ b/projects/quml-library/package-lock.json @@ -1,13 +1,13 @@ { "name": "@project-sunbird/sunbird-quml-player", - "version": "7.0.1", + "version": "6.0.0-beta.1", "lockfileVersion": 1, "requires": true, "dependencies": { "@project-sunbird/sunbird-player-sdk-v9": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@project-sunbird/sunbird-player-sdk-v9/-/sunbird-player-sdk-v9-6.0.0.tgz", - "integrity": "sha512-E8ybY5ulxZ7NyBq3Suljz1LsyXHeFsmdJ2NbNZLHKY5WpBF6qtOQDtpjINPTMAPOqlOpR7xAcVMoPxCuP82RGw==", + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/@project-sunbird/sunbird-player-sdk-v9/-/sunbird-player-sdk-v9-5.1.0.tgz", + "integrity": "sha512-Vg3MXOkBC7c1px9pTX58T0wqkseLAw0kWLflA8CpttIUQYFJBxxu5wEB8z8Y5zb6zDFrykxWRbPEcbdYdfOKRw==", "requires": { "ally.js": "1.4.1" } diff --git a/projects/quml-library/package.json b/projects/quml-library/package.json index 3717e5f9..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" @@ -18,7 +18,7 @@ "@project-sunbird/client-services": "4.9.1" }, "dependencies": { - "@project-sunbird/sunbird-player-sdk-v9": "6.0.0" + "@project-sunbird/sunbird-player-sdk-v9": "5.1.0" }, "devDependencies": { "copyfiles": "2.4.1", diff --git a/projects/quml-library/src/lib/main-player/main-player.component.spec.ts b/projects/quml-library/src/lib/main-player/main-player.component.spec.ts index eb0ae510..759e562a 100644 --- a/projects/quml-library/src/lib/main-player/main-player.component.spec.ts +++ b/projects/quml-library/src/lib/main-player/main-player.component.spec.ts @@ -11,7 +11,6 @@ import { TransformationService } from '../services/transformation-service/transf import { fakeMainProgressBar, fakeSections, playerConfig, singleContent } from './main-player.component.spec.data'; import { UtilService } from '../util-service'; import { of } from 'rxjs'; -import { PLAYER_COMPATABILITY_CONFIG } from '../player-constants'; describe('MainPlayerComponent', () => { let component: MainPlayerComponent; @@ -25,7 +24,7 @@ describe('MainPlayerComponent', () => { TestBed.configureTestingModule({ declarations: [MainPlayerComponent], imports: [ - SunbirdPlayerSdkModule.forRoot(PLAYER_COMPATABILITY_CONFIG), + SunbirdPlayerSdkModule, CommonModule ], providers: [QumlLibraryService, QuestionCursor], diff --git a/projects/quml-library/src/lib/player-constants.ts b/projects/quml-library/src/lib/player-constants.ts index 5d0e666b..7b453086 100644 --- a/projects/quml-library/src/lib/player-constants.ts +++ b/projects/quml-library/src/lib/player-constants.ts @@ -5,6 +5,4 @@ export const WARNING_TIME_CONFIG = { SHOW_TIMER: true } -export const PLAYER_COMPATABILITY_CONFIG = { - contentCompatibilityLevel: 6 -} \ 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/quml-library.module.ts b/projects/quml-library/src/lib/quml-library.module.ts index 347e3c0e..e08a1209 100644 --- a/projects/quml-library/src/lib/quml-library.module.ts +++ b/projects/quml-library/src/lib/quml-library.module.ts @@ -38,7 +38,7 @@ import { SafeHtmlPipe } from './pipes/safe-html/safe-html.pipe'; import { MainPlayerComponent } from './main-player/main-player.component'; import { SectionPlayerComponent } from './section-player/section-player.component'; import { ProgressIndicatorsComponent } from './progress-indicators/progress-indicators.component' -import { PLAYER_COMPATABILITY_CONFIG } from './player-constants'; + @NgModule({ declarations: [ QumlLibraryComponent, @@ -80,7 +80,7 @@ import { PLAYER_COMPATABILITY_CONFIG } from './player-constants'; imports: [ CommonModule, CarouselModule, - SunbirdPlayerSdkModule.forRoot(PLAYER_COMPATABILITY_CONFIG) + SunbirdPlayerSdkModule ], providers: [ QumlLibraryService 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 bd1e4865..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 @@ -1,7 +1,7 @@ import { CommonModule } from '@angular/common'; import { ElementRef, EventEmitter, NO_ERRORS_SCHEMA } from '@angular/core'; import { waitForAsync, ComponentFixture, fakeAsync, flush, TestBed, tick } from '@angular/core/testing'; -import { ErrorService, SunbirdPlayerSdkModule } from '@project-sunbird/sunbird-player-sdk-v9'; +import { ErrorService } from '@project-sunbird/sunbird-player-sdk-v9'; import { CarouselComponent } from 'ngx-bootstrap/carousel'; import { of, Subject } from 'rxjs'; import { fakeMainProgressBar } from '../main-player/main-player.component.spec.data'; @@ -11,7 +11,6 @@ import { UtilService } from '../util-service'; import { QuestionCursor } from './../quml-question-cursor.service'; import { SectionPlayerComponent } from './section-player.component'; import { mockSectionPlayerConfig } from './section-player.component.spec.data'; -import { PLAYER_COMPATABILITY_CONFIG } from '../player-constants'; describe('SectionPlayerComponent', () => { @@ -52,14 +51,13 @@ describe('SectionPlayerComponent', () => { TestBed.configureTestingModule({ declarations: [SectionPlayerComponent, CarouselComponent], imports: [ - CommonModule, - SunbirdPlayerSdkModule.forRoot(PLAYER_COMPATABILITY_CONFIG) + CommonModule ], providers: [ QumlLibraryService, QuestionCursor, { provide: ViewerService, useClass: ViewerServiceMock }, - { provide: ElementRef, useClass: ElementRefMock } + { provide: ElementRef, useClass: ElementRefMock }, ], schemas: [NO_ERRORS_SCHEMA] }) @@ -480,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/projects/quml-player-wc/src/app/app.module.ts b/projects/quml-player-wc/src/app/app.module.ts index 8679f9c2..bbe8ab26 100644 --- a/projects/quml-player-wc/src/app/app.module.ts +++ b/projects/quml-player-wc/src/app/app.module.ts @@ -85,7 +85,7 @@ import { ProgressIndicatorsComponent } from '../../../quml-library/src/lib/progr BrowserModule, CommonModule, CarouselModule.forRoot(), - SunbirdPlayerSdkModule.forRoot({ contentCompatibilityLevel: 6 }), + SunbirdPlayerSdkModule, HttpClientModule ], providers: [{ provide: QuestionCursor, useClass: QuestionCursorImplementationService }] 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 1d60db46..86ad6716 100644 --- a/web-component/sunbird-quml-player.js +++ b/web-component/sunbird-quml-player.js @@ -13318,7 +13318,6 @@ module.exports = v4; __webpack_require__.r(__webpack_exports__); /* harmony export */ __webpack_require__.d(__webpack_exports__, { /* harmony export */ "ErrorService": () => (/* binding */ ErrorService), -/* harmony export */ "PLAYER_CONFIG": () => (/* binding */ PLAYER_CONFIG), /* harmony export */ "SunbirdPlayerSdkModule": () => (/* binding */ SunbirdPlayerSdkModule), /* harmony export */ "errorCode": () => (/* binding */ errorCode), /* harmony export */ "errorMessage": () => (/* binding */ errorMessage), @@ -13676,6 +13675,90 @@ const errorMessage = { contentPlayFailTitle: "Refresh and try again later" }; +/** + * @fileoverview added by tsickle + * Generated from: lib/player-utils/service/error/error.service.ts + * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc + */ +class ErrorService { + constructor() { + this.playerContentCompatibiltyLevel = 5; + this.getInternetConnectivityError = new _angular_core__WEBPACK_IMPORTED_MODULE_1__.EventEmitter(); + this.setInternetConnectivityError = + /** + * @return {?} + */ + () => { + /** @type {?} */ + const internetConnectivityError = new Error(); + internetConnectivityError.message = errorMessage.internetConnectivity; + internetConnectivityError.name = errorCode.internetConnectivity; + this.getInternetConnectivityError.emit({ + error: internetConnectivityError + }); + }; + this.initInternetConnectivityError(); + } + /** + * @param {?} currentCompatibilityLevel + * @return {?} + */ + checkContentCompatibility(currentCompatibilityLevel) { + if (currentCompatibilityLevel > this.playerContentCompatibiltyLevel) { + /** @type {?} */ + 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 + }; + } + } + /** + * @return {?} + */ + initInternetConnectivityError() { + window.addEventListener('offline', this.setInternetConnectivityError); + } + /** + * @return {?} + */ + ngOnDestroy() { + window.removeEventListener('offline', this.setInternetConnectivityError); + } +} +ErrorService.ɵfac = function ErrorService_Factory(t) { + return new (t || ErrorService)(); +}; +/** @nocollapse */ +ErrorService.ctorParameters = () => []; +/** @nocollapse */ +ErrorService.ɵprov = (0,_angular_core__WEBPACK_IMPORTED_MODULE_1__["ɵɵdefineInjectable"])({ + factory: function ErrorService_Factory() { + return new ErrorService(); + }, + token: ErrorService, + providedIn: "root" +}); +(function () { + (typeof ngDevMode === "undefined" || ngDevMode) && _angular_core__WEBPACK_IMPORTED_MODULE_1__["ɵsetClassMetadata"](ErrorService, [{ + type: _angular_core__WEBPACK_IMPORTED_MODULE_1__.Injectable, + args: [{ + providedIn: 'root' + }] + }], function () { + return []; + }, null); +})(); +if (false) {} + /** * @fileoverview added by tsickle * Generated from: lib/core/components/download-popup/download-popup.component.ts @@ -14967,23 +15050,7 @@ PlayerUtilsModule.ɵinj = /*@__PURE__*/_angular_core__WEBPACK_IMPORTED_MODULE_1_ * Generated from: lib/sunbird-player-sdk.module.ts * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc */ -/** @type {?} */ -const PLAYER_CONFIG = new _angular_core__WEBPACK_IMPORTED_MODULE_1__.InjectionToken('playerConfig'); -class SunbirdPlayerSdkModule { - /** - * @param {?=} config - * @return {?} - */ - static forRoot(config) { - return { - ngModule: SunbirdPlayerSdkModule, - providers: [{ - provide: PLAYER_CONFIG, - useValue: config - }] - }; - } -} +class SunbirdPlayerSdkModule {} SunbirdPlayerSdkModule.ɵfac = function SunbirdPlayerSdkModule_Factory(t) { return new (t || SunbirdPlayerSdkModule)(); }; @@ -15010,110 +15077,6 @@ SunbirdPlayerSdkModule.ɵinj = /*@__PURE__*/_angular_core__WEBPACK_IMPORTED_MODU }); })(); -/** - * @fileoverview added by tsickle - * Generated from: lib/player-utils/service/error/error.service.ts - * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc - */ -class ErrorService { - /** - * @param {?=} config - */ - constructor(config) { - var _a, _b; - this.config = config; - this.playerContentCompatibiltyLevel = 5; - this.getInternetConnectivityError = new _angular_core__WEBPACK_IMPORTED_MODULE_1__.EventEmitter(); - this.setInternetConnectivityError = - /** - * @return {?} - */ - () => { - /** @type {?} */ - const internetConnectivityError = new Error(); - internetConnectivityError.message = errorMessage.internetConnectivity; - internetConnectivityError.name = errorCode.internetConnectivity; - this.getInternetConnectivityError.emit({ - error: internetConnectivityError - }); - }; - this.initInternetConnectivityError(); - if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.contentCompatibilityLevel) { - this.playerContentCompatibiltyLevel = (_b = this.config) === null || _b === void 0 ? void 0 : _b.contentCompatibilityLevel; - } - } - /** - * @param {?} currentCompatibilityLevel - * @return {?} - */ - checkContentCompatibility(currentCompatibilityLevel) { - if (currentCompatibilityLevel > this.playerContentCompatibiltyLevel) { - /** @type {?} */ - 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 - }; - } - } - /** - * @return {?} - */ - initInternetConnectivityError() { - window.addEventListener('offline', this.setInternetConnectivityError); - } - /** - * @return {?} - */ - ngOnDestroy() { - window.removeEventListener('offline', this.setInternetConnectivityError); - } -} -ErrorService.ɵfac = function ErrorService_Factory(t) { - return new (t || ErrorService)(_angular_core__WEBPACK_IMPORTED_MODULE_1__["ɵɵinject"](PLAYER_CONFIG)); -}; -/** @nocollapse */ -ErrorService.ctorParameters = () => [{ - type: undefined, - decorators: [{ - type: _angular_core__WEBPACK_IMPORTED_MODULE_1__.Inject, - args: [PLAYER_CONFIG] - }] -}]; -/** @nocollapse */ -ErrorService.ɵprov = (0,_angular_core__WEBPACK_IMPORTED_MODULE_1__["ɵɵdefineInjectable"])({ - factory: function ErrorService_Factory() { - return new ErrorService((0,_angular_core__WEBPACK_IMPORTED_MODULE_1__["ɵɵinject"])(PLAYER_CONFIG)); - }, - token: ErrorService, - providedIn: "root" -}); -(function () { - (typeof ngDevMode === "undefined" || ngDevMode) && _angular_core__WEBPACK_IMPORTED_MODULE_1__["ɵsetClassMetadata"](ErrorService, [{ - type: _angular_core__WEBPACK_IMPORTED_MODULE_1__.Injectable, - args: [{ - providedIn: 'root' - }] - }], function () { - return [{ - type: undefined, - decorators: [{ - type: _angular_core__WEBPACK_IMPORTED_MODULE_1__.Inject, - args: [PLAYER_CONFIG] - }] - }]; - }, null); -})(); -if (false) {} - /** * @fileoverview added by tsickle * Generated from: sunbird-player-sdk.interface.ts @@ -85329,8 +85292,8 @@ 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 */ "PLAYER_COMPATABILITY_CONFIG": () => (/* binding */ PLAYER_COMPATABILITY_CONFIG), /* harmony export */ "WARNING_TIME_CONFIG": () => (/* binding */ WARNING_TIME_CONFIG) /* harmony export */ }); const DEFAULT_SCORE = 1; @@ -85338,9 +85301,7 @@ const WARNING_TIME_CONFIG = { DEFAULT_TIME: 75, SHOW_TIMER: true }; -const PLAYER_COMPATABILITY_CONFIG = { - contentCompatibilityLevel: 6 -}; +const COMPATABILITY_LEVEL = 6; /***/ }), @@ -86816,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 */ @@ -87220,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(), @@ -88851,7 +88832,6 @@ __webpack_require__.r(__webpack_exports__); - class AppModule { @@ -88875,9 +88855,7 @@ class AppModule { provide: _quml_library_src_lib_quml_question_cursor_service__WEBPACK_IMPORTED_MODULE_34__.QuestionCursor, useClass: _question_cursor_implementation_service__WEBPACK_IMPORTED_MODULE_35__.QuestionCursorImplementationService }], - imports: [_angular_platform_browser__WEBPACK_IMPORTED_MODULE_39__.BrowserModule, _angular_common__WEBPACK_IMPORTED_MODULE_40__.CommonModule, ngx_bootstrap_carousel__WEBPACK_IMPORTED_MODULE_41__.CarouselModule.forRoot(), _project_sunbird_sunbird_player_sdk_v9__WEBPACK_IMPORTED_MODULE_42__.SunbirdPlayerSdkModule.forRoot({ - contentCompatibilityLevel: 6 - }), _angular_common_http__WEBPACK_IMPORTED_MODULE_43__.HttpClientModule] + imports: [_angular_platform_browser__WEBPACK_IMPORTED_MODULE_39__.BrowserModule, _angular_common__WEBPACK_IMPORTED_MODULE_40__.CommonModule, ngx_bootstrap_carousel__WEBPACK_IMPORTED_MODULE_41__.CarouselModule.forRoot(), _project_sunbird_sunbird_player_sdk_v9__WEBPACK_IMPORTED_MODULE_42__.SunbirdPlayerSdkModule, _angular_common_http__WEBPACK_IMPORTED_MODULE_43__.HttpClientModule] }); } (function () {