diff --git a/package-lock.json b/package-lock.json index da5b1217..24cf6944 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2251,6 +2251,21 @@ "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", "dev": true }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, "emoji-regex": { "version": "9.2.2", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", @@ -2268,6 +2283,40 @@ "strip-ansi": "^7.0.1" } }, + "string-width-cjs": { + "version": "npm:string-width@4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, "strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", @@ -2277,6 +2326,23 @@ "ansi-regex": "^6.0.1" } }, + "strip-ansi-cjs": { + "version": "npm:strip-ansi@6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + } + } + }, "wrap-ansi": { "version": "8.1.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", @@ -2287,6 +2353,60 @@ "string-width": "^5.0.1", "strip-ansi": "^7.0.1" } + }, + "wrap-ansi-cjs": { + "version": "npm:wrap-ansi@7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.1" + } + } + } } } }, @@ -11841,17 +11961,6 @@ "strip-ansi": "^6.0.1" } }, - "string-width-cjs": { - "version": "npm:string-width@4.2.3", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", - "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.1" - } - }, "string_decoder": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", @@ -11876,15 +11985,6 @@ "ansi-regex": "^5.0.1" } }, - "strip-ansi-cjs": { - "version": "npm:strip-ansi@6.0.1", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", - "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.1" - } - }, "strip-final-newline": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/strip-final-newline/-/strip-final-newline-2.0.0.tgz", @@ -12957,43 +13057,6 @@ } } }, - "wrap-ansi-cjs": { - "version": "npm:wrap-ansi@7.0.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", - "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", - "dev": true, - "requires": { - "ansi-styles": "^4.0.0", - "string-width": "^4.1.0", - "strip-ansi": "^6.0.0" - }, - "dependencies": { - "ansi-styles": { - "version": "4.3.0", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", - "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", - "dev": true, - "requires": { - "color-convert": "^2.0.1" - } - }, - "color-convert": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", - "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", - "dev": true, - "requires": { - "color-name": "~1.1.4" - } - }, - "color-name": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", - "dev": true - } - } - }, "wrappy": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", diff --git a/projects/quml-demo-app/src/app/quml-library-data.ts b/projects/quml-demo-app/src/app/quml-library-data.ts index 5482bd65..de4c9695 100644 --- a/projects/quml-demo-app/src/app/quml-library-data.ts +++ b/projects/quml-demo-app/src/app/quml-library-data.ts @@ -26,7 +26,7 @@ const content = { ], "compatibilityLevel": 4, "audience": [ - "Student" + "Audience1" ], "se_boards": [ "CBSE" @@ -107,7 +107,7 @@ const content = { ], "compatibilityLevel": 4, "audience": [ - "Student" + "Audience1" ], "se_boards": [ "CBSE" @@ -188,7 +188,7 @@ const content = { ], "compatibilityLevel": 4, "audience": [ - "Student" + "Audience1" ], "se_boards": [ "CBSE" @@ -265,7 +265,7 @@ const content = { ], "compatibilityLevel": 4, "audience": [ - "Student" + "Audience1" ], "se_boards": [ "CBSE" @@ -396,7 +396,7 @@ const content = { "allowSkip": "Yes", "compatibilityLevel": 5, "audience": [ - "Student" + "Audience1" ], "se_boards": [ "CBSE" @@ -502,9 +502,9 @@ export const samplePlayerConfig = { 'uid': '', 'channel': '01268904781886259221', 'pdata': { - 'id': 'preprod.diksha.portal', + 'id': 'dev.sunbird.portal', 'ver': '3.3.0', - 'pid': 'sunbird-portal.contentplayer' + 'pid': 'sunbird-portal.qumlplayer' }, 'contextRollup': { 'l1': 'string', diff --git a/projects/quml-library/package.json b/projects/quml-library/package.json index 77b9cfde..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": "6.2.0", + "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.spec.data.ts b/projects/quml-library/src/lib/main-player/main-player.component.spec.data.ts index feb3a163..c25236ac 100644 --- a/projects/quml-library/src/lib/main-player/main-player.component.spec.data.ts +++ b/projects/quml-library/src/lib/main-player/main-player.component.spec.data.ts @@ -1,5 +1,6 @@ const content1 = { + "qumlVersion": 1.1, "instructions": "
  1. Please circle the correct answer
  2. Do not use mobile phones
", "copyright": "tn", "lastStatusChangedOn": "2022-02-28T07:56:09.733+0000", @@ -36,7 +37,7 @@ const content1 = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -114,7 +115,7 @@ const content1 = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -239,7 +240,7 @@ const content1 = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -313,7 +314,7 @@ const content1 = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -441,7 +442,7 @@ const content1 = { "allowSkip": "Yes", "compatibilityLevel": 5, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -533,9 +534,9 @@ export const playerConfig = { 'uid': '', 'channel': '01268904781886259221', 'pdata': { - 'id': 'preprod.diksha.portal', + 'id': 'dev.sunbird.portal', 'ver': '3.3.0', - 'pid': 'sunbird-portal.contentplayer' + 'pid': 'sunbird-portal.qumlplayer' }, 'contextRollup': { 'l1': 'string', @@ -637,9 +638,9 @@ export const fakeSections = [ "uid": "", "channel": "01268904781886259221", "pdata": { - "id": "preprod.diksha.portal", + "id": "dev.sunbird.portal", "ver": "3.3.0", - "pid": "sunbird-portal.contentplayer" + "pid": "sunbird-portal.qumlplayer" }, "contextRollup": { "l1": "string", @@ -694,7 +695,7 @@ export const fakeSections = [ ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -772,7 +773,7 @@ export const fakeSections = [ ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -909,9 +910,9 @@ export const fakeSections = [ "uid": "", "channel": "01268904781886259221", "pdata": { - "id": "preprod.diksha.portal", + "id": "dev.sunbird.portal", "ver": "3.3.0", - "pid": "sunbird-portal.contentplayer" + "pid": "sunbird-portal.qumlplayer" }, "contextRollup": { "l1": "string", @@ -966,7 +967,7 @@ export const fakeSections = [ ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -1040,7 +1041,7 @@ export const fakeSections = [ ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -1201,7 +1202,7 @@ export const singleContent = { ], 'compatibilityLevel': 4, 'audience': [ - 'Student' + 'Audience1' ], 'primaryCategory': 'Multiple Choice Question', 'medium': [ @@ -1257,7 +1258,7 @@ export const singleContent = { 'contentEncoding': 'gzip', 'showSolutions': true, 'identifier': 'do_213257772024733696115', - 'audience': ['Student'], + 'audience': ['Audience1'], 'visibility': 'Default', 'showTimer': true, 'author': 'Adarsh', 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 b0373557..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 @@ -7,6 +7,7 @@ import { QumlLibraryService } from '../quml-library.service'; import { MainPlayerComponent } from './main-player.component'; import { ViewerService } from '../services/viewer-service/viewer-service'; +import { TransformationService } from '../services/transformation-service/transformation.service'; import { fakeMainProgressBar, fakeSections, playerConfig, singleContent } from './main-player.component.spec.data'; import { UtilService } from '../util-service'; import { of } from 'rxjs'; @@ -36,7 +37,7 @@ describe('MainPlayerComponent', () => { fixture = TestBed.createComponent(MainPlayerComponent); component = fixture.componentInstance; component.playerConfig = playerConfig; - fixture.detectChanges(); + // fixture.detectChanges(); }); it('should create', () => { @@ -51,7 +52,9 @@ describe('MainPlayerComponent', () => { }); it('should accept the stringified input as well', () => { + const transformationService = TestBed.inject(TransformationService); component.playerConfig = JSON.stringify(playerConfig) as any; + spyOn(transformationService, 'getTransformedHierarchy').and.returnValue(playerConfig); spyOn(component, 'setConfig'); spyOn(component, 'initializeSections'); component.ngOnInit(); 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 e14f7366..fa356cc7 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 @@ -5,6 +5,7 @@ import * as _ from 'lodash-es'; import { SectionPlayerComponent } from '../section-player/section-player.component'; import { IAttempts, IParentConfig, ISummary, QumlPlayerConfig } from './../quml-library-interface'; import { ViewerService } from './../services/viewer-service/viewer-service'; +import { TransformationService } from '../services/transformation-service/transformation.service'; import { eventName, pageId, TelemetryType, MimeType } from './../telemetry-constants'; import { UtilService } from './../util-service'; import { fromEvent, Subscription } from 'rxjs'; @@ -84,7 +85,10 @@ export class MainPlayerComponent implements OnInit, OnChanges { disabledHandle: any; subscription: Subscription; - constructor(public viewerService: ViewerService, private utilService: UtilService) { } + constructor( + public viewerService: ViewerService, + private utilService: UtilService, + private transformationService: TransformationService) { } @HostListener('document:TelemetryEvent', ['$event']) onTelemetryEvent(event) { @@ -102,6 +106,10 @@ export class MainPlayerComponent implements OnInit, OnChanges { console.error('Invalid playerConfig: ', error); } } + if(!_.has(this.playerConfig.metadata, 'qumlVersion') && _.get(this.playerConfig.metadata, 'qumlVersion') != 1.1) { + this.playerConfig.metadata = this.transformationService.getTransformedHierarchy(this.playerConfig.metadata) + } + console.log('playerConfig::', this.playerConfig); this.isLoading = true; this.setConfig(); this.initializeSections(); diff --git a/projects/quml-library/src/lib/mcq/mcq.component.spec.ts b/projects/quml-library/src/lib/mcq/mcq.component.spec.ts index 26518b3d..27fe026b 100644 --- a/projects/quml-library/src/lib/mcq/mcq.component.spec.ts +++ b/projects/quml-library/src/lib/mcq/mcq.component.spec.ts @@ -81,7 +81,7 @@ describe('McqComponent', () => { ], "identifier": "do_21348431640099225615", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", 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/quml-library.service.spec.data.ts b/projects/quml-library/src/lib/quml-library.service.spec.data.ts index 672eb664..55a0e9b9 100644 --- a/projects/quml-library/src/lib/quml-library.service.spec.data.ts +++ b/projects/quml-library/src/lib/quml-library.service.spec.data.ts @@ -22,7 +22,7 @@ export const mockQumlLibraryServiceData = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -100,7 +100,7 @@ export const mockQumlLibraryServiceData = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -264,9 +264,9 @@ export const mockQumlLibraryServiceData = { }, channel: "01268904781886259221", pdata: { - "id": "preprod.diksha.portal", + "id": "dev.sunbird.portal", "ver": "3.3.0", - "pid": "sunbird-portal.contentplayer" + "pid": "sunbird-portal.qumlplayer" }, sid: "913b3c6c-2874-26dd-ed0c-c23ddc00b718", uid: "", @@ -289,9 +289,9 @@ export const telemetryContext = { "uid": "", "channel": "01268904781886259221", "pdata": { - "id": "preprod.diksha.portal", + "id": "dev.sunbird.portal", "ver": "3.3.0", - "pid": "sunbird-portal.contentplayer" + "pid": "sunbird-portal.qumlplayer" }, "contextRollup": { "l1": "string", diff --git a/projects/quml-library/src/lib/sa/sa.component.spec.ts b/projects/quml-library/src/lib/sa/sa.component.spec.ts index e8f108f8..b1ad553a 100644 --- a/projects/quml-library/src/lib/sa/sa.component.spec.ts +++ b/projects/quml-library/src/lib/sa/sa.component.spec.ts @@ -49,7 +49,7 @@ describe('SaComponent', () => { ], "identifier": "do_21348431719053721619", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", diff --git a/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts b/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts index 0e8f78dc..0e550a56 100644 --- a/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts +++ b/projects/quml-library/src/lib/section-player/section-player.component.spec.data.ts @@ -93,7 +93,7 @@ export const mockSectionPlayerConfig = { ], "identifier": "do_21348431640099225615", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", @@ -240,7 +240,7 @@ export const mockSectionPlayerConfig = { ], "identifier": "do_21348431559137689613", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", @@ -315,9 +315,9 @@ export const mockSectionPlayerConfig = { "uid": "", "channel": "01268904781886259221", "pdata": { - "id": "preprod.diksha.portal", + "id": "dev.sunbird.portal", "ver": "3.3.0", - "pid": "sunbird-portal.contentplayer" + "pid": "sunbird-portal.qumlplayer" }, "contextRollup": { "l1": "string", @@ -373,7 +373,7 @@ export const mockSectionPlayerConfig = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -451,7 +451,7 @@ export const mockSectionPlayerConfig = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -747,7 +747,7 @@ export const mockSectionPlayerConfig = { ], "identifier": "do_21348431640099225615", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", 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 d79551bc..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, @@ -104,6 +105,7 @@ export class SectionPlayerComponent implements OnChanges, AfterViewInit { if (changes && Object.values(changes)[0].firstChange) { this.subscribeToEvents(); } + this.viewerService.sectionConfig = this.sectionConfig; this.setConfig(); } @@ -559,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) { @@ -569,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-library/src/lib/services/transformation-service/transformation.service.spec.data.ts b/projects/quml-library/src/lib/services/transformation-service/transformation.service.spec.data.ts new file mode 100644 index 00000000..5bb4e523 --- /dev/null +++ b/projects/quml-library/src/lib/services/transformation-service/transformation.service.spec.data.ts @@ -0,0 +1,682 @@ +export const mockData = { + questionsetV1Hierarchy: { + "copyright": "NIT123", + "lastStatusChangedOn": "2023-11-02T07:08:08.299+0000", + "timeLimits": "{\"maxTime\":\"300\"}", + "author": "Creator1", + "children": [ + { + "lastStatusChangedOn": "2023-11-02T07:08:08.207+0000", + "parent": "do_21391745429720268811", + "children": [ + { + "copyright": "NIT123", + "lastStatusChangedOn": "2023-11-02T07:13:51.010+0000", + "parent": "do_21391745570741452812", + "author": "Creator1", + "name": "Short MCQ", + "createdOn": "2023-11-02T07:03:26.776+0000", + "channel": "01345815127107174426", + "maxScore": 1, + "lastUpdatedOn": "2023-11-02T07:13:51.010+0000", + "subject": [ + "English" + ], + "showTimer": "No", + "identifier": "do_213917459306708992110", + "gradeLevel": [ + "Class 4" + ], + "compatibilityLevel": 4, + "audience": [ + "Student" + ], + "se_boards": [ + "CBSE" + ], + "primaryCategory": "Multiple Choice Question", + "se_mediums": [ + "Hindi" + ], + "downloadUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/short-mcq_1698909230306_do_213917459306708992110_1.ecar", + "se_subjects": [ + "English" + ], + "medium": [ + "Hindi" + ], + "interactionTypes": [ + "choice" + ], + "framework": "ekstep_ncert_k-12", + "versionKey": "1698908606787", + "mimeType": "application/vnd.sunbird.question", + "code": "44b65672-8529-4410-8000-d4eab50d5fce", + "license": "CC BY 4.0", + "version": 1, + "prevStatus": "Draft", + "templateId": "mcq-vertical", + "language": [ + "English" + ], + "board": "CBSE", + "showFeedback": "No", + "objectType": "Question", + "status": "Live", + "createdBy": "56c84dee-7149-47af-902d-0138e080cec0", + "contentEncoding": "gzip", + "depth": 2, + "lastPublishedBy": "ddb6579c-be43-49e6-9de4-585315a1d926", + "se_gradeLevels": [ + "Class 4" + ], + "se_FWIds": [ + "ekstep_ncert_k-12" + ], + "allowAnonymousAccess": "Yes", + "contentDisposition": "inline", + "artifactUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/do_213917459306708992110_1698909229669.zip", + "visibility": "Parent", + "qType": "MCQ", + "showSolutions": "No", + "variants": { + "full": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/short-mcq_1698909230306_do_213917459306708992110_1.ecar", + "size": "64043" + }, + "online": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/short-mcq_1698909230782_do_213917459306708992110_1_ONLINE.ecar", + "size": "1691" + } + }, + "index": 1, + "pkgVersion": 1 + }, + { + "copyright": "NIT123", + "lastStatusChangedOn": "2023-11-02T07:13:53.556+0000", + "parent": "do_21391745570741452812", + "author": "Creator1", + "name": "Subjective", + "createdOn": "2023-11-02T07:05:11.024+0000", + "channel": "01345815127107174426", + "maxScore": 1, + "lastUpdatedOn": "2023-11-02T07:13:53.556+0000", + "subject": [ + "English" + ], + "showTimer": "No", + "identifier": "do_213917460160708608112", + "gradeLevel": [ + "Class 4" + ], + "compatibilityLevel": 4, + "audience": [ + "Student" + ], + "se_boards": [ + "CBSE" + ], + "primaryCategory": "Subjective Question", + "se_mediums": [ + "Hindi" + ], + "downloadUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/subjective_1698909231618_do_213917460160708608112_1.ecar", + "se_subjects": [ + "English" + ], + "medium": [ + "Hindi" + ], + "framework": "ekstep_ncert_k-12", + "versionKey": "1698908711033", + "mimeType": "application/vnd.sunbird.question", + "code": "beb3dcee-f8b8-4b32-a58a-b17585faed18", + "license": "CC BY 4.0", + "version": 1, + "prevStatus": "Draft", + "language": [ + "English" + ], + "board": "CBSE", + "showFeedback": "No", + "objectType": "Question", + "status": "Live", + "createdBy": "56c84dee-7149-47af-902d-0138e080cec0", + "contentEncoding": "gzip", + "depth": 2, + "lastPublishedBy": "ddb6579c-be43-49e6-9de4-585315a1d926", + "se_gradeLevels": [ + "Class 4" + ], + "se_FWIds": [ + "ekstep_ncert_k-12" + ], + "allowAnonymousAccess": "Yes", + "contentDisposition": "inline", + "artifactUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/do_213917460160708608112_1698909231286.zip", + "visibility": "Parent", + "qType": "SA", + "showSolutions": "No", + "variants": { + "full": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/subjective_1698909231618_do_213917460160708608112_1.ecar", + "size": "10365908" + }, + "online": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/subjective_1698909233512_do_213917460160708608112_1_ONLINE.ecar", + "size": "1291" + } + }, + "index": 2, + "pkgVersion": 1 + } + ], + "name": "Section-1", + "navigationMode": "non-linear", + "createdOn": "2023-11-02T06:56:07.409+0000", + "channel": "01345815127107174426", + "generateDIALCodes": "No", + "lastUpdatedOn": "2023-11-02T07:08:08.207+0000", + "showTimer": "No", + "identifier": "do_21391745570741452812", + "description": "Section-1", + "containsUserData": "No", + "allowSkip": "Yes", + "compatibilityLevel": 5, + "trackable": { + "enabled": "No", + "autoBatch": "No" + }, + "primaryCategory": "Practice Question Set", + "setType": "materialised", + "languageCode": [ + "en" + ], + "attributions": [], + "scoreCutoffType": "AssessmentLevel", + "versionKey": "1698908167409", + "mimeType": "application/vnd.sunbird.questionset", + "code": "b7836846-bc19-49d8-bd0e-420f9424833e", + "license": "CC BY 4.0", + "version": 1, + "prevStatus": "Draft", + "showHints": "No", + "language": [ + "English" + ], + "showFeedback": "Yes", + "objectType": "QuestionSet", + "status": "Live", + "requiresSubmit": "No", + "shuffle": true, + "contentEncoding": "gzip", + "depth": 1, + "allowAnonymousAccess": "Yes", + "contentDisposition": "inline", + "allowBranching": "No", + "visibility": "Parent", + "showSolutions": "Yes", + "index": 1 + } + ], + "name": "Short Text Questionset", + "navigationMode": "non-linear", + "createdOn": "2023-11-02T06:53:15.275+0000", + "createdFor": [ + "01345815127107174426" + ], + "channel": "01345815127107174426", + "pdfUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/questionset/do_21391745429720268811/do_21391745429720268811_pdf_1698909234889.pdf", + "generateDIALCodes": "No", + "maxScore": 2, + "lastUpdatedOn": "2023-11-02T07:08:08.308+0000", + "subject": [ + "English" + ], + "size": 5223136, + "showTimer": "Yes", + "identifier": "do_21391745429720268811", + "instructions": { + "default": "

This is Simple Questionset for testing short text Questionset

" + }, + "description": "Short Text Questionset", + "gradeLevel": [ + "Class 4" + ], + "containsUserData": "No", + "allowSkip": "Yes", + "compatibilityLevel": 5, + "audience": [ + "Student" + ], + "trackable": "{\"enabled\":\"No\",\"autoBatch\":\"No\"}", + "se_boards": [ + "CBSE" + ], + "primaryCategory": "Practice Question Set", + "setType": "materialised", + "appIcon": "https://obj.stage.sunbirded.org/sunbird-content-staging/questionset/do_21391745429720268811/artifact/sunbird.thumb.jpeg", + "se_mediums": [ + "Hindi" + ], + "downloadUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/questionset/do_21391745429720268811/short-text-questionset_1698909234107_do_21391745429720268811_1.ecar", + "se_subjects": [ + "English" + ], + "medium": [ + "Hindi" + ], + "attributions": [], + "scoreCutoffType": "AssessmentLevel", + "framework": "ekstep_ncert_k-12", + "posterImage": "https://obj.stage.sunbirded.org/sunbird-content-staging/content/assets/do_21391745470538547211/sunbird.jpeg", + "versionKey": "1698908888308", + "mimeType": "application/vnd.sunbird.questionset", + "code": "ec843eee-9e9d-4ab2-b559-df71f1e4a3f5", + "license": "CC BY 4.0", + "version": 1, + "prevStatus": "Draft", + "showHints": "No", + "summaryType": "Complete", + "language": [ + "English" + ], + "board": "CBSE", + "showFeedback": "No", + "lastPublishedOn": "2023-11-02T07:13:53.602+0000", + "objectType": "QuestionSet", + "status": "Live", + "targetFWIds": [ + "ekstep_ncert_k-12" + ], + "createdBy": "56c84dee-7149-47af-902d-0138e080cec0", + "requiresSubmit": "No", + "shuffle": true, + "contentEncoding": "gzip", + "depth": 0, + "consumerId": "cb069f8d-e4e1-46c5-831f-d4a83b323ada", + "lastPublishedBy": "ddb6579c-be43-49e6-9de4-585315a1d926", + "se_gradeLevels": [ + "Class 4" + ], + "se_FWIds": [ + "ekstep_ncert_k-12" + ], + "allowAnonymousAccess": "Yes", + "contentDisposition": "inline", + "additionalCategories": [], + "allowBranching": "No", + "previewUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/questionset/do_21391745429720268811/do_21391745429720268811_html_1698909234889.html", + "childNodes": [ + "do_213917459306708992110", + "do_21391745570741452812", + "do_213917460160708608112" + ], + "visibility": "Default", + "showSolutions": "No", + "variants": { + "spine": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/questionset/do_21391745429720268811/short-text-questionset_1698909233836_do_21391745429720268811_1_SPINE.ecar", + "size": "7215" + }, + "online": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/questionset/do_21391745429720268811/short-text-questionset_1698909234067_do_21391745429720268811_1_ONLINE.ecar", + "size": "4027" + }, + "full": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/questionset/do_21391745429720268811/short-text-questionset_1698909234107_do_21391745429720268811_1.ecar", + "size": "5223136" + } + }, + "pkgVersion": 1 + }, + v1Questions: [ + { + "copyright": "NIT123", + "subject": [ + "English" + ], + "channel": "01345815127107174426", + "downloadUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/short-mcq_1698909230306_do_213917459306708992110_1.ecar", + "responseDeclaration": { + "response1": { + "maxScore": 1, + "cardinality": "single", + "type": "integer", + "correctResponse": { + "value": "1", + "outcomes": { + "SCORE": 1 + } + }, + "mapping": [] + } + }, + "language": [ + "English" + ], + "mimeType": "application/vnd.sunbird.question", + "variants": { + "full": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/short-mcq_1698909230306_do_213917459306708992110_1.ecar", + "size": "64043" + }, + "online": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/short-mcq_1698909230782_do_213917459306708992110_1_ONLINE.ecar", + "size": "1691" + } + }, + "body": "

Which is the capital of India?

", + "editorState": { + "options": [ + { + "answer": false, + "value": { + "body": "

Bangalore

\"test\"
", + "value": 0 + } + }, + { + "answer": true, + "value": { + "body": "

Delhi 

\"test\"
", + "value": 1 + } + }, + { + "answer": false, + "value": { + "body": "

MP 

\"test\"
", + "value": 2 + } + }, + { + "answer": false, + "value": { + "body": "

Tamilnadu 

\"test\"
", + "value": 3 + } + } + ], + "question": "

Which is the capital of India?

", + "solutions": [ + { + "id": "2ec72bb7-993e-45c7-a645-972bead37985", + "type": "html", + "value": "

New Delhi 

\"test\"
" + } + ] + }, + "templateId": "mcq-vertical", + "objectType": "Question", + "se_mediums": [ + "Hindi" + ], + "gradeLevel": [ + "Class 4" + ], + "primaryCategory": "Multiple Choice Question", + "contentEncoding": "gzip", + "artifactUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917459306708992110/do_213917459306708992110_1698909229669.zip", + "se_gradeLevels": [ + "Class 4" + ], + "showSolutions": "No", + "identifier": "do_213917459306708992110", + "audience": [ + "Student" + ], + "visibility": "Parent", + "showTimer": "No", + "author": "Creator1", + "solutions": [ + { + "id": "2ec72bb7-993e-45c7-a645-972bead37985", + "type": "html", + "value": "

New Delhi 

\"test\"
" + } + ], + "qType": "MCQ", + "maxScore": 1, + "lastPublishedBy": "ddb6579c-be43-49e6-9de4-585315a1d926", + "languageCode": [ + "en" + ], + "version": 1, + "se_subjects": [ + "English" + ], + "license": "CC BY 4.0", + "interactionTypes": [ + "choice" + ], + "name": "Short MCQ", + "status": "Live", + "code": "44b65672-8529-4410-8000-d4eab50d5fce", + "prevStatus": "Draft", + "medium": [ + "Hindi" + ], + "media": [ + { + "id": "do_21391745639510016012", + "type": "image", + "src": "/assets/public/content/assets/do_21391745639510016012/test.png", + "baseUrl": "https://staging.sunbirded.org" + }, + { + "id": "do_21391745677380812813", + "type": "image", + "src": "/assets/public/content/assets/do_21391745677380812813/test.png", + "baseUrl": "https://staging.sunbirded.org" + }, + { + "id": "do_21391745700057907214", + "type": "image", + "src": "/assets/public/content/assets/do_21391745700057907214/test.png", + "baseUrl": "https://staging.sunbirded.org" + }, + { + "id": "do_21391745723300249615", + "type": "image", + "src": "/assets/public/content/assets/do_21391745723300249615/test.png", + "baseUrl": "https://staging.sunbirded.org" + }, + { + "id": "do_21391745765224448016", + "type": "image", + "src": "/assets/public/content/assets/do_21391745765224448016/test.png", + "baseUrl": "https://staging.sunbirded.org" + } + ], + "createdOn": "2023-11-02T07:03:26.776+0000", + "interactions": { + "response1": { + "type": "choice", + "options": [ + { + "label": "

Bangalore

\"test\"
", + "value": 0 + }, + { + "label": "

Delhi 

\"test\"
", + "value": 1 + }, + { + "label": "

MP 

\"test\"
", + "value": 2 + }, + { + "label": "

Tamilnadu 

\"test\"
", + "value": 3 + } + ] + }, + "validation": { + "required": "Yes" + } + }, + "se_boards": [ + "CBSE" + ], + "contentDisposition": "inline", + "lastUpdatedOn": "2023-11-02T07:13:51.010+0000", + "allowAnonymousAccess": "Yes", + "lastStatusChangedOn": "2023-11-02T07:13:51.010+0000", + "se_FWIds": [ + "ekstep_ncert_k-12" + ], + "pkgVersion": 1, + "versionKey": "1698908606787", + "showFeedback": "No", + "framework": "ekstep_ncert_k-12", + "answer": "1", + "createdBy": "56c84dee-7149-47af-902d-0138e080cec0", + "compatibilityLevel": 4, + "board": "CBSE" + }, + { + "copyright": "NIT123", + "subject": [ + "English" + ], + "channel": "01345815127107174426", + "downloadUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/subjective_1698909231618_do_213917460160708608112_1.ecar", + "responseDeclaration": { + "response1": { + "type": "string", + "cardinality": "single" + } + }, + "language": [ + "English" + ], + "mimeType": "application/vnd.sunbird.question", + "variants": { + "full": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/subjective_1698909231618_do_213917460160708608112_1.ecar", + "size": "10365908" + }, + "online": { + "ecarUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/subjective_1698909233512_do_213917460160708608112_1_ONLINE.ecar", + "size": "1291" + } + }, + "body": "

Who is the captain of India?

", + "editorState": { + "answer": "

Dhoni- Born in ranchi and won 3 ICC trophy

", + "question": "

Who is the captain of India?

", + "solutions": [ + { + "id": "5505d866-b8e3-4c1d-b6d2-7ddf5b7ff765", + "type": "video", + "value": "do_21391745981619404817" + } + ] + }, + "objectType": "Question", + "se_mediums": [ + "Hindi" + ], + "gradeLevel": [ + "Class 4" + ], + "primaryCategory": "Subjective Question", + "contentEncoding": "gzip", + "artifactUrl": "https://obj.stage.sunbirded.org/sunbird-content-staging/question/do_213917460160708608112/do_213917460160708608112_1698909231286.zip", + "se_gradeLevels": [ + "Class 4" + ], + "showSolutions": "No", + "identifier": "do_213917460160708608112", + "audience": [ + "Student" + ], + "visibility": "Parent", + "showTimer": "No", + "author": "Creator1", + "solutions": [ + { + "id": "5505d866-b8e3-4c1d-b6d2-7ddf5b7ff765", + "type": "video", + "value": "do_21391745981619404817" + } + ], + "qType": "SA", + "maxScore": 1, + "lastPublishedBy": "ddb6579c-be43-49e6-9de4-585315a1d926", + "languageCode": [ + "en" + ], + "version": 1, + "se_subjects": [ + "English" + ], + "license": "CC BY 4.0", + "name": "Subjective", + "status": "Live", + "code": "beb3dcee-f8b8-4b32-a58a-b17585faed18", + "prevStatus": "Draft", + "medium": [ + "Hindi" + ], + "media": [ + { + "id": "do_21391745981619404817", + "src": "/assets/public/content/assets/do_21391745981619404817/bathroom-drama-talking-angela-cartoon-short.mp4", + "type": "video", + "assetId": "do_21391745981619404817", + "name": "bathroom-drama-talking-angela-cartoon-short", + "baseUrl": "https://staging.sunbirded.org" + } + ], + "createdOn": "2023-11-02T07:05:11.024+0000", + "interactions": { + "validation": { + "required": "Yes" + } + }, + "se_boards": [ + "CBSE" + ], + "contentDisposition": "inline", + "lastUpdatedOn": "2023-11-02T07:13:53.556+0000", + "allowAnonymousAccess": "Yes", + "lastStatusChangedOn": "2023-11-02T07:13:53.556+0000", + "se_FWIds": [ + "ekstep_ncert_k-12" + ], + "pkgVersion": 1, + "versionKey": "1698908711033", + "showFeedback": "No", + "framework": "ekstep_ncert_k-12", + "answer": "

Dhoni- Born in ranchi and won 3 ICC trophy

", + "createdBy": "56c84dee-7149-47af-902d-0138e080cec0", + "compatibilityLevel": 4, + "board": "CBSE" + } + ], + v1responseDeclaration: { + "response1": { + "maxScore": 1, + "cardinality": "single", + "type": "integer", + "correctResponse": { + "value": "0", + "outcomes": { + "SCORE": 1 + } + }, + "mapping": [ + { + "response": 0, + "outcomes": { + "score": 1 + } + } + ] + } + } + } + \ No newline at end of file diff --git a/projects/quml-library/src/lib/services/transformation-service/transformation.service.spec.ts b/projects/quml-library/src/lib/services/transformation-service/transformation.service.spec.ts new file mode 100644 index 00000000..49ecc8f8 --- /dev/null +++ b/projects/quml-library/src/lib/services/transformation-service/transformation.service.spec.ts @@ -0,0 +1,66 @@ +import { TestBed } from '@angular/core/testing'; +import { TransformationService } from './transformation.service'; +import { mockData } from './transformation.service.spec.data'; + +describe('TransformationService', () => { + let service: TransformationService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(TransformationService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); + + it('#getTransformedHierarchy() should return transformed hierarchy', () => { + spyOn(service, 'getTransformedHierarchy').and.callThrough(); + let v1Hierarchy = mockData.questionsetV1Hierarchy; + spyOn(service, 'getTransformedQuestionSetMetadata').and.callThrough(); + spyOn(service, 'transformChildren').and.callThrough(); + const transformedData = service.getTransformedHierarchy(v1Hierarchy); + expect(transformedData.instructions).toBe("

This is Simple Questionset for testing short text Questionset

"); + expect(transformedData.children[0].children[0].showTimer).toBeFalsy(); + }); + + it('#processBloomsLevel() should set complexityLevel', () => { + spyOn(service, 'processBloomsLevel').and.callThrough(); + const data = {bloomsLevel: 'apply'}; + const complexityLevelData = service.processBloomsLevel(data); + expect(complexityLevelData.complexityLevel.length).toEqual(1); + }) + + it('#getTransformedQuestionMetadata() should return transformed MCQ question data', () => { + spyOn(service, 'getTransformedQuestionMetadata').and.callThrough(); + const questionsList = {questions: mockData.v1Questions}; + const transformedquestionsList = service.getTransformedQuestionMetadata(questionsList); + }); + + it('#processSubjectiveResponseDeclaration() should return data if maxScore not exists', () => { + spyOn(service, 'processSubjectiveResponseDeclaration').and.callThrough(); + const subjectQData = { + "body": "

What is capital of India?

", + "answer": "

New Delhi

", + } + const processedData = service.processSubjectiveResponseDeclaration(subjectQData); + expect(processedData.outcomeDeclaration).toBeUndefined(); + }); + + it('#getUpdatedMapping() should return updated mapping', () => { + spyOn(service, 'getUpdatedMapping').and.callThrough(); + const updatedMapping = service.getUpdatedMapping(mockData.v1responseDeclaration.response1); + expect(updatedMapping[0].value).toEqual(0); + expect(updatedMapping[0].score).toEqual(1); + }); + + it('#processHints() should return updated hints', () => { + const data = { + hints: ['math question', 'class 4'] + } + spyOn(service, 'processHints').and.callThrough(); + let updatedHints = undefined; + updatedHints = service.processHints(data); + expect(updatedHints).toBeDefined(); + }) +}); 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 new file mode 100644 index 00000000..a1f5625d --- /dev/null +++ b/projects/quml-library/src/lib/services/transformation-service/transformation.service.ts @@ -0,0 +1,313 @@ +import { Injectable } from '@angular/core'; +import * as _ from 'lodash-es'; +import { v4 as uuidv4 } from 'uuid'; + +@Injectable({ + providedIn: 'root' +}) +export class TransformationService { + + getTransformedHierarchy(questionsetMetadata) { + let updatedMetadata = this.getTransformedQuestionSetMetadata(questionsetMetadata); + if (!_.isEmpty(updatedMetadata, 'children')) { + updatedMetadata.children = this.transformChildren(updatedMetadata.children); + } + return updatedMetadata; + } + + getTransformedQuestionSetMetadata(data) { + data = this.processMaxScoreProperty(data); + data = _.omit(data, 'version'); + data = this.processInstructions(data); + data = this.processBloomsLevel(data); + data = this.processBooleanProps(data); + data = this.processTimeLimits(data); + return data; + } + + processMaxScoreProperty(data) { + if (_.has(data, 'maxScore')) { + const outcomeDeclaration = { + maxScore: { + cardinality: 'single', + type: 'integer', + defaultValue: data.maxScore + } + } + data = _.omit(data, 'maxScore'); + data['outcomeDeclaration'] = outcomeDeclaration; + } + + return data; + } + + processInstructions(data) { + if (_.has(data, 'instructions.default')) { + data.instructions = data.instructions.default; + } + return data; + } + + processBloomsLevel(data) { + if (_.has(data, 'bloomsLevel')) { + const bLevel = _.get(data, 'bloomsLevel'); + _.unset(data, 'bloomsLevel'); + _.set(data, 'complexityLevel', [bLevel.toString()]); + } + return data; + } + + processBooleanProps(data: any) { + const booleanProps = ["showSolutions", "showFeedback", "showHints", "showTimer"]; + const getBooleanValue = (str: any) => str === "Yes"; + + _.forEach(booleanProps, (prop: any) => { + if (_.has(data, prop)) { + const propVal = data[prop]; + data[prop] = getBooleanValue(propVal); + } + }); + + return data; + } + + processTimeLimits(data) { + let parsedTimeLimits; + if (_.has(data, 'timeLimits') && !_.isNull(data.timeLimits)) { + if (_.isString(data.timeLimits)) { + parsedTimeLimits = JSON.parse(data.timeLimits); + } else { + parsedTimeLimits = data.timeLimits; + } + + data.timeLimits = { + questionSet: { + min: 0, + max: parsedTimeLimits?.maxTime ? _.toInteger(parsedTimeLimits.maxTime) : 0 + } + }; + } + + return data; +} + + transformChildren(children: any) { + const self = this; + if (!_.isEmpty(children)) { + _.forEach(children, (ch) => { + if (_.has(ch, 'version')) { + _.unset(ch, 'version'); + } + ch = this.processBloomsLevel(ch); + ch = this.processBooleanProps(ch); + if (_.get(ch, 'mimeType').toLowerCase() === 'application/vnd.sunbird.questionset') { + ch = this.processTimeLimits(ch); + ch = this.processInstructions(ch); + const nestedChildren = _.get(ch, 'children', []); + self.transformChildren(nestedChildren); + } + }); + } + return children; + } + + getTransformedQuestionMetadata(data) { + if (_.has(data, 'questions')) { + _.forEach(data.questions, (question) => { + if (!_.has(question, 'qumlVersion') || question.qumlVersion != 1.1) { + question = this.processResponseDeclaration(question); + question = this.processInteractions(question); + question = this.processSolutions(question); + question = this.processInstructions(question); + question = this.processHints(question); + question = this.processBloomsLevel(question); + question = this.processBooleanProps(question); + const ans = this.getAnswer(question) + if (!_.isEmpty(ans)) { + _.set(question, 'answer', ans); + } + } + }); + return data; + } + } + + processResponseDeclaration(data) { + let outcomeDeclaration = {}; + if (_.isEqual(_.toLower(data.primaryCategory), 'subjective question')) { + data = this.processSubjectiveResponseDeclaration(data); + } else { + let responseDeclaration = data.responseDeclaration; + if (!_.isEmpty(responseDeclaration)) { + for (const key in responseDeclaration) { + const responseData = responseDeclaration[key]; + const maxScore = { + cardinality: _.get(responseData, 'cardinality', ''), + type: _.get(responseData, 'type', ''), + defaultValue: _.get(responseData, 'maxScore'), + }; + delete responseData.maxScore; + outcomeDeclaration['maxScore'] = maxScore; + const correctResp = responseData.correctResponse || {}; + delete correctResp.outcomes; + if (_.toLower(_.get(responseData, 'type')) === 'integer' && _.toLower(_.get(responseData, 'cardinality')) === 'single') { + const correctKey = correctResp.value; + correctResp.value = parseInt(correctKey, 10); + } + responseData.mapping = this.getUpdatedMapping(responseData); + responseDeclaration[key] = responseData; + } + data.responseDeclaration = responseDeclaration; + data['outcomeDeclaration'] = outcomeDeclaration; + } + } + return data; + } + + processSubjectiveResponseDeclaration(subjectiveMetadata) { + let outcomeDeclaration = {}; + delete subjectiveMetadata.responseDeclaration; + delete subjectiveMetadata.interactions; + if (_.has(subjectiveMetadata, 'maxScore') && !_.isNull(subjectiveMetadata.maxScore)) { + outcomeDeclaration = { + maxScore: { + cardinality: 'single', + type: 'integer', + defaultValue: subjectiveMetadata.maxScore + } + }; + subjectiveMetadata.outcomeDeclaration = outcomeDeclaration; + return subjectiveMetadata; + } + return subjectiveMetadata; + } + + getUpdatedMapping(responseData) { + const mappingData = responseData.mapping || []; + if (!_.isEmpty(mappingData)) { + const updatedMapping = mappingData.map(mapData => ({ + value: mapData.response, + score: _.get(mapData, 'outcomes.score', 0), + })); + return updatedMapping; + } + return mappingData; + } + + processInteractions(data: any) { + const interactions: any = _.get(data, 'interactions', {}); + if (!_.isEmpty(interactions)) { + const validation: any = _.get(interactions, 'validation', {}); + const resp1: any = _.get(interactions, 'response1', {}); + const resValData: any = _.get(interactions, 'response1.validation', {}); + if (!_.isEmpty(resValData)) { + _.forEach(resValData, (value, key) => { + _.set(validation, key, value) + }); + } else { + _.set(resp1, 'validation', validation); + } + _.unset(interactions, 'validation'); + _.set(interactions, 'response1', resp1); + _.set(data, 'interactions', interactions); + } + return data; + } + + processSolutions(data) { + const solutions = _.get(data, 'solutions', []); + + if (!_.isEmpty(solutions)) { + const updatedSolutions = _.reduce(solutions, (result, solution) => { + result[_.get(solution, 'id')] = this.getSolutionString(solution, _.get(data, 'media', [])); + return result; + }, {}); + + _.set(data, 'solutions', updatedSolutions); + } + return data; + } + + getSolutionString(data, media) { + if (!_.isEmpty(data)) { + const type = _.get(data, 'type', ''); + + switch (type) { + case 'html': { + return _.get(data, 'value', ''); + } + + case 'video': { + const value = _.get(data, 'value', ''); + const mediaData = _.find(media, (item) => _.isEqual(value, _.get(item, 'id', ''))); + + if (mediaData) { + const src = _.get(mediaData, 'src', ''); + const thumbnail = _.get(mediaData, 'thumbnail', ''); + + const solutionStr = ``.replace('media_identifier', value).replace('thumbnail_url', thumbnail).replace(/media_source_url/g, src); + + return solutionStr; + } + return ''; + } + + default: { + return ''; + } + } + } + + return ''; + } + + processHints(data) { + const hints = _.get(data, 'hints', []); + let updatedHints = {}; + if (!_.isEmpty(hints)) { + _.forEach(hints, (hint) => { + _.merge(updatedHints, {[uuidv4()]: hint}); + }) + + _.set(data, 'hints', updatedHints); + } + return data; + } + + getAnswer(data) { + const interactions = _.get(data, 'interactions', {}); + + if (!_.isEqual(_.get(data, 'primaryCategory'), 'Subjective Question') && !_.isEmpty(interactions)) { + const responseData = _.get(data, 'responseDeclaration.response1', {}); + const options = _.get(interactions, 'response1.options', {}); + let formatedAnswer = ''; + + let answerData = _.get(responseData, 'cardinality'); + + if (answerData === 'single') { + const correctResp = _.get(_.get(responseData, 'correctResponse', {}), 'value', 0); + const label = options[correctResp]; + + formatedAnswer = `
${label.label}
`; + } else { + const correctResp = _.get(responseData, 'correctResponse.value'); + let singleAns = '
answer_html
'; + const answerList = []; + _.forEach(options, (option) => { + if (_.includes(correctResp, option.value,)) { + const replAns = _.replace(singleAns, 'answer_html', _.get(option, 'label')) + answerList.push(replAns) + } + }) + formatedAnswer = `
${answerList.join('')}
`; + } + return formatedAnswer; + } + else { + return _.get(data, 'answer', ''); + } + } +} diff --git a/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.data.ts b/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.data.ts index 701a8fe5..efbc5c5d 100644 --- a/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.data.ts +++ b/projects/quml-library/src/lib/services/viewer-service/viewer-service.spec.data.ts @@ -9,9 +9,9 @@ export const mockData = { "uid": "", "channel": "01268904781886259221", "pdata": { - "id": "preprod.diksha.portal", + "id": "dev.sunbird.portal", "ver": "3.3.0", - "pid": "sunbird-portal.contentplayer" + "pid": "sunbird-portal.qumlplayer" }, "contextRollup": { "l1": "string", @@ -66,7 +66,7 @@ export const mockData = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -144,7 +144,7 @@ export const mockData = { ], "compatibilityLevel": 4, "audience": [ - "Teacher" + "Audience2" ], "se_boards": [ "State (Tamil Nadu)" @@ -415,7 +415,7 @@ export const mockData = { ], "identifier": "do_21348431640099225615", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", @@ -551,7 +551,7 @@ export const mockData = { ], "identifier": "do_21348431559137689613", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", @@ -768,7 +768,7 @@ export const mockData = { ], "identifier": "do_21348431640099225615", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", @@ -906,7 +906,7 @@ export const mockData = { ], "identifier": "do_21348431559137689613", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", @@ -1016,7 +1016,7 @@ export const mockData = { ], "identifier": "do_21348431719053721619", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", @@ -1137,7 +1137,7 @@ export const mockData = { ], "identifier": "do_213484318131216384111", "audience": [ - "Teacher" + "Audience2" ], "visibility": "Parent", "author": "Vivek", 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 16d192e0..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 @@ -2,10 +2,12 @@ import { EventEmitter, Injectable } from '@angular/core'; import { IParentConfig, QumlPlayerConfig } from '../../quml-library-interface'; import { QumlLibraryService } from '../../quml-library.service'; import { UtilService } from '../../util-service'; +import { TransformationService } from '../transformation-service/transformation.service'; 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' @@ -34,11 +36,12 @@ export class ViewerService { questionSetId: string; parentIdentifier: string; sectionQuestions = []; - + sectionConfig:any; constructor( public qumlLibraryService: QumlLibraryService, public utilService: UtilService, - public questionCursor: QuestionCursor + public questionCursor: QuestionCursor, + public transformationService: TransformationService ) { } initialize(config: QumlPlayerConfig, threshold: number, questionIds: string[], parentConfig: IParentConfig) { @@ -229,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); @@ -238,14 +276,15 @@ 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) => { - this.qumlQuestionEvent.emit(value); + const transformedquestionsList = this.transformationService.getTransformedQuestionMetadata(value); + this.qumlQuestionEvent.emit(transformedquestionsList); }); }, (error) => { this.qumlQuestionEvent.emit({ @@ -256,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-examples/react-app/package-lock.json b/web-component-examples/react-app/package-lock.json index eefa950d..06fa794a 100644 --- a/web-component-examples/react-app/package-lock.json +++ b/web-component-examples/react-app/package-lock.json @@ -2056,9 +2056,9 @@ } }, "@project-sunbird/sunbird-quml-player-web-component": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/@project-sunbird/sunbird-quml-player-web-component/-/sunbird-quml-player-web-component-1.0.0.tgz", - "integrity": "sha512-YI4GGj4GlSSqR87EAfEj/NJw8AzloZJN0xH0TZ2HKcwpD5Zae3jQxwv0HvXvCAyxSSyOkszJeKik5Pwaqh4Iuw==" + "version": "3.0.0-beta.0", + "resolved": "https://registry.npmjs.org/@project-sunbird/sunbird-quml-player-web-component/-/sunbird-quml-player-web-component-3.0.0-beta.0.tgz", + "integrity": "sha512-eV9liRsuDp08xQulYpoAh0WcJBTNwJ5jush4CNUBAwdoP16+QOApvKcvZs8EOkWuTLW0YUGQAuU4PoRLAxI+OQ==" }, "@rollup/plugin-babel": { "version": "5.3.1", diff --git a/web-component-examples/react-app/package.json b/web-component-examples/react-app/package.json index 349a46c2..306cc0f3 100644 --- a/web-component-examples/react-app/package.json +++ b/web-component-examples/react-app/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "dependencies": { - "@project-sunbird/sunbird-quml-player-web-component": "^1.0.0", + "@project-sunbird/sunbird-quml-player-web-component": "3.0.0-beta.0", "cra-template": "1.2.0", "jquery": "^3.6.1", "react": "^18.2.0", diff --git a/web-component-examples/react-app/src/data.js b/web-component-examples/react-app/src/data.js index a96420de..8d7663d6 100644 --- a/web-component-examples/react-app/src/data.js +++ b/web-component-examples/react-app/src/data.js @@ -1,416 +1,309 @@ const sectionContent = { - showStartPage: true, "copyright": "NIT123", - "lastStatusChangedOn": "2022-12-12T11:21:38.818+0000", - "author": "N11", + "lastStatusChangedOn": "2023-08-30T09:11:32.642+0000", + "timeLimits": { + "questionSet": { + "max": 300, + "min": 0 + } + }, + "author": "Creator1", "children": [ - { - "lastStatusChangedOn": "2022-12-12T11:21:38.792+0000", - "parent": "do_21368754222912307211", - "children": [ - { - "copyright": "NIT123", - "lastStatusChangedOn": "2022-12-12T11:22:08.424+0000", - "parent": "do_21368754291126272012", - "author": "N11", - "name": "Capital of Country", - "createdOn": "2022-12-12T11:06:10.502+0000", - "channel": "01309282781705830427", - "maxScore": 1, - "lastUpdatedOn": "2022-12-12T11:22:08.424+0000", - "subject": [ - "Hindi" - ], - "showTimer": false, - "identifier": "do_21368754725275238414", - "gradeLevel": [ - "Class 4" - ], - "compatibilityLevel": 4, - "audience": [ - "Student" - ], - "se_boards": [ - "CBSE" - ], - "primaryCategory": "Multiple Choice Question", - "se_mediums": [ - "English" - ], - "downloadUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368754725275238414/capital-of-country_1670844127836_do_21368754725275238414_1.ecar", - "se_subjects": [ - "Hindi" - ], - "medium": [ - "English" - ], - "interactionTypes": [ - "choice" - ], - "framework": "inquiry_k-12", - "versionKey": "1670843170532", - "mimeType": "application/vnd.sunbird.question", - "code": "311dcf33-1374-71d5-bc17-163b0f780a15", - "license": "CC BY 4.0", - "prevStatus": "Draft", - "templateId": "mcq-vertical", - "language": [ - "English" - ], - "board": "CBSE", - "showFeedback": false, - "objectType": "Question", - "status": "Live", - "createdBy": "5a587cc1-e018-4859-a0a8-e842650b9d64", - "contentEncoding": "gzip", - "depth": 2, - "lastPublishedBy": "ae94b68c-a535-4dce-8e7a-fb9662b0ad68", - "se_gradeLevels": [ - "Class 4" - ], - "se_FWIds": [ - "inquiry_k-12" - ], - "allowAnonymousAccess": "Yes", - "contentDisposition": "inline", - "artifactUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368754725275238414/do_21368754725275238414_1670844126738.zip", - "visibility": "Parent", - "qType": "MCQ", - "showSolutions": false, - "variants": { - "full": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368754725275238414/capital-of-country_1670844127836_do_21368754725275238414_1.ecar", - "size": "597400" - }, - "online": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368754725275238414/capital-of-country_1670844128179_do_21368754725275238414_1_ONLINE.ecar", - "size": "1789" - } + { + "lastStatusChangedOn": "2023-08-30T09:11:32.617+0000", + "timeLimits": { + "questionSet": { + "max": 0, + "min": 0 + } }, - "index": 1, - "pkgVersion": 1 - }, - { - "copyright": "NIT123", - "lastStatusChangedOn": "2022-12-12T11:22:08.692+0000", - "parent": "do_21368754291126272012", - "author": "N11", - "name": "MCQ-text1", - "createdOn": "2022-12-12T11:15:55.372+0000", + "parent": "do_2138622515299368961170", + "children": [ + { + "copyright": "NIT123", + "lastStatusChangedOn": "2023-08-30T09:12:28.557+0000", + "parent": "do_2138622518926049281171", + "author": "Creator1", + "name": "Short MCQ", + "createdOn": "2023-08-16T07:06:01.009+0000", + "channel": "01309282781705830427", + "maxScore": 1, + "lastUpdatedOn": "2023-08-30T09:12:28.557+0000", + "subject": [ + "Science" + ], + "showTimer": false, + "identifier": "do_2138622530437857281173", + "gradeLevel": [ + "Class 7" + ], + "compatibilityLevel": 5, + "audience": [ + "Student" + ], + "se_boards": [ + "ICSE" + ], + "primaryCategory": "Multiple Choice Question", + "se_mediums": [ + "Hindi" + ], + "downloadUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622530437857281173/short-mcq_1693386748000_do_2138622530437857281173_3.ecar", + "se_subjects": [ + "Science" + ], + "medium": [ + "Hindi" + ], + "interactionTypes": [ + "choice" + ], + "framework": "inquiry_k-12", + "versionKey": "1692178403868", + "mimeType": "application/vnd.sunbird.question", + "code": "d6519354-5c05-4e75-a279-af9b64eb12c1", + "license": "CC BY 4.0", + "qumlVersion": 1.1, + "prevStatus": "Draft", + "showHints": false, + "templateId": "mcq-vertical", + "language": [ + "English" + ], + "board": "ICSE", + "showFeedback": false, + "objectType": "Question", + "status": "Live", + "createdBy": "5a587cc1-e018-4859-a0a8-e842650b9d64", + "contentEncoding": "gzip", + "depth": 2, + "lastPublishedBy": "ae94b68c-a535-4dce-8e7a-fb9662b0ad68", + "se_gradeLevels": [ + "Class 7" + ], + "se_FWIds": [ + "inquiry_k-12" + ], + "allowAnonymousAccess": "Yes", + "contentDisposition": "inline", + "schemaVersion": "1.1", + "artifactUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622530437857281173/do_2138622530437857281173_1692183887410.zip", + "complexityLevel": [], + "visibility": "Parent", + "qType": "MCQ", + "showSolutions": false, + "variants": { + "full": { + "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622530437857281173/short-mcq_1693386748000_do_2138622530437857281173_3.ecar", + "size": "1242316" + }, + "online": { + "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622530437857281173/short-mcq_1693386748491_do_2138622530437857281173_3_ONLINE.ecar", + "size": "1804" + } + }, + "index": 1, + "pkgVersion": 3 + }, + { + "copyright": "NIT123", + "lastStatusChangedOn": "2023-08-30T09:12:29.391+0000", + "parent": "do_2138622518926049281171", + "author": "Creator1", + "name": "Subjective", + "createdOn": "2023-08-16T07:13:07.109+0000", + "channel": "01309282781705830427", + "maxScore": 1, + "lastUpdatedOn": "2023-08-30T09:12:29.391+0000", + "subject": [ + "Science" + ], + "showTimer": false, + "identifier": "do_2138622565343969281175", + "gradeLevel": [ + "Class 7" + ], + "compatibilityLevel": 5, + "audience": [ + "Student" + ], + "se_boards": [ + "ICSE" + ], + "primaryCategory": "Subjective Question", + "se_mediums": [ + "Hindi" + ], + "downloadUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622565343969281175/subjective_1693386748619_do_2138622565343969281175_3.ecar", + "se_subjects": [ + "Science" + ], + "medium": [ + "Hindi" + ], + "framework": "inquiry_k-12", + "versionKey": "1692178377383", + "mimeType": "application/vnd.sunbird.question", + "code": "ad9e1786-125e-4a03-8536-f5919ed9714a", + "license": "CC BY 4.0", + "qumlVersion": 1.1, + "prevStatus": "Draft", + "showHints": false, + "language": [ + "English" + ], + "board": "ICSE", + "showFeedback": false, + "objectType": "Question", + "status": "Live", + "createdBy": "5a587cc1-e018-4859-a0a8-e842650b9d64", + "contentEncoding": "gzip", + "depth": 2, + "lastPublishedBy": "ae94b68c-a535-4dce-8e7a-fb9662b0ad68", + "se_gradeLevels": [ + "Class 7" + ], + "se_FWIds": [ + "inquiry_k-12" + ], + "allowAnonymousAccess": "Yes", + "contentDisposition": "inline", + "schemaVersion": "1.1", + "artifactUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622565343969281175/do_2138622565343969281175_1692183887887.zip", + "complexityLevel": [ + "create" + ], + "visibility": "Parent", + "qType": "SA", + "showSolutions": false, + "variants": { + "full": { + "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622565343969281175/subjective_1693386748619_do_2138622565343969281175_3.ecar", + "size": "10366351" + }, + "online": { + "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_2138622565343969281175/subjective_1693386749349_do_2138622565343969281175_3_ONLINE.ecar", + "size": "1542" + } + }, + "index": 2, + "pkgVersion": 3 + } + ], + "name": "Section-1", + "navigationMode": "non-linear", + "createdOn": "2023-08-16T07:03:40.484+0000", "channel": "01309282781705830427", - "maxScore": 1, - "lastUpdatedOn": "2022-12-12T11:22:08.692+0000", - "subject": [ - "Hindi" - ], + "generateDIALCodes": "No", + "lastUpdatedOn": "2023-08-30T09:11:32.618+0000", "showTimer": false, - "identifier": "do_21368755204399923216", - "gradeLevel": [ - "Class 4" - ], - "compatibilityLevel": 4, - "audience": [ - "Student" - ], - "se_boards": [ - "CBSE" - ], - "primaryCategory": "Multiple Choice Question", - "se_mediums": [ - "English" - ], - "downloadUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755204399923216/mcq-text1_1670844128569_do_21368755204399923216_1.ecar", - "se_subjects": [ - "Hindi" - ], - "medium": [ - "English" - ], - "interactionTypes": [ - "choice" - ], - "framework": "inquiry_k-12", - "versionKey": "1670843755400", - "mimeType": "application/vnd.sunbird.question", - "code": "d48899c0-f93f-09b7-720d-9649d6967da2", - "license": "CC BY 4.0", - "prevStatus": "Draft", - "templateId": "mcq-vertical", - "language": [ - "English" - ], - "board": "CBSE", - "showFeedback": false, - "objectType": "Question", - "status": "Live", - "createdBy": "5a587cc1-e018-4859-a0a8-e842650b9d64", - "contentEncoding": "gzip", - "depth": 2, - "lastPublishedBy": "ae94b68c-a535-4dce-8e7a-fb9662b0ad68", - "se_gradeLevels": [ - "Class 4" - ], - "se_FWIds": [ - "inquiry_k-12" - ], - "allowAnonymousAccess": "Yes", - "contentDisposition": "inline", - "artifactUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755204399923216/do_21368755204399923216_1670844128534.zip", - "visibility": "Parent", - "qType": "MCQ", - "showSolutions": false, - "variants": { - "full": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755204399923216/mcq-text1_1670844128569_do_21368755204399923216_1.ecar", - "size": "21482" - }, - "online": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755204399923216/mcq-text1_1670844128639_do_21368755204399923216_1_ONLINE.ecar", - "size": "2414" - } + "identifier": "do_2138622518926049281171", + "description": "Section-1", + "containsUserData": "No", + "allowSkip": "Yes", + "compatibilityLevel": 6, + "trackable": { + "enabled": "No", + "autoBatch": "No" }, - "index": 2, - "pkgVersion": 1 - } - ], - "name": "Section-1", - "navigationMode": "non-linear", - "createdOn": "2022-12-12T10:57:20.535+0000", - "channel": "01309282781705830427", - "generateDIALCodes": "No", - "lastUpdatedOn": "2022-12-12T11:21:38.792+0000", - "showTimer": false, - "identifier": "do_21368754291126272012", - "description": "Section", - "containsUserData": "No", - "allowSkip": "Yes", - "compatibilityLevel": 5, - "trackable": { - "enabled": "No", - "autoBatch": "No" - }, - "primaryCategory": "Practice Question Set", - "setType": "materialised", - "languageCode": [ - "en" - ], - "attributions": [], - "scoreCutoffType": "AssessmentLevel", - "versionKey": "1670842640535", - "mimeType": "application/vnd.sunbird.questionset", - "code": "358766e3-35e2-13e7-e9d2-6bb0f82771a5", - "license": "CC BY 4.0", - "prevStatus": "Draft", - "showHints": false, - "language": [ - "English" - ], - "showFeedback": false, - "objectType": "QuestionSet", - "status": "Live", - "requiresSubmit": "No", - "shuffle": true, - "contentEncoding": "gzip", - "depth": 1, - "allowAnonymousAccess": "Yes", - "contentDisposition": "inline", - "allowBranching": "No", - "visibility": "Parent", - "showSolutions": false, - "index": 1 - }, - { - "lastStatusChangedOn": "2022-12-12T11:21:38.793+0000", - "parent": "do_21368754222912307211", - "children": [ - { - "copyright": "NIT123", - "lastStatusChangedOn": "2022-12-12T11:22:08.940+0000", - "parent": "do_21368755318300672013", - "author": "N11", - "name": "MCQ1", - "createdOn": "2022-12-12T11:19:53.268+0000", - "channel": "01309282781705830427", - "maxScore": 1, - "lastUpdatedOn": "2022-12-12T11:22:08.940+0000", - "subject": [ - "Hindi" - ], - "showTimer": false, - "identifier": "do_21368755399285145618", - "gradeLevel": [ - "Class 4" - ], - "compatibilityLevel": 4, - "audience": [ - "Student" - ], - "se_boards": [ - "CBSE" - ], - "primaryCategory": "Multiple Choice Question", - "se_mediums": [ - "English" - ], - "downloadUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755399285145618/mcq1_1670844128817_do_21368755399285145618_1.ecar", - "se_subjects": [ - "Hindi" - ], - "medium": [ - "English" - ], - "interactionTypes": [ - "choice" - ], - "framework": "inquiry_k-12", - "versionKey": "1670843993296", - "mimeType": "application/vnd.sunbird.question", - "code": "a9c65881-65c6-847d-8d08-407f2bbbd9b9", + "primaryCategory": "Practice Question Set", + "setType": "materialised", + "languageCode": [ + "en" + ], + "attributions": [], + "scoreCutoffType": "AssessmentLevel", + "versionKey": "1692169420484", + "mimeType": "application/vnd.sunbird.questionset", + "code": "129b3974-5116-4a45-ac29-844118fc197a", "license": "CC BY 4.0", + "qumlVersion": 1.1, "prevStatus": "Draft", - "templateId": "mcq-vertical", + "showHints": false, "language": [ - "English" + "English" ], - "board": "CBSE", - "showFeedback": false, - "objectType": "Question", + "showFeedback": true, + "objectType": "QuestionSet", "status": "Live", - "createdBy": "5a587cc1-e018-4859-a0a8-e842650b9d64", + "requiresSubmit": "No", + "shuffle": true, "contentEncoding": "gzip", - "depth": 2, - "lastPublishedBy": "ae94b68c-a535-4dce-8e7a-fb9662b0ad68", - "se_gradeLevels": [ - "Class 4" - ], - "se_FWIds": [ - "inquiry_k-12" - ], + "depth": 1, "allowAnonymousAccess": "Yes", "contentDisposition": "inline", - "artifactUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755399285145618/do_21368755399285145618_1670844128780.zip", + "schemaVersion": "1.1", + "allowBranching": "No", "visibility": "Parent", - "qType": "MCQ", - "showSolutions": false, - "variants": { - "full": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755399285145618/mcq1_1670844128817_do_21368755399285145618_1.ecar", - "size": "17177" - }, - "online": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/question/do_21368755399285145618/mcq1_1670844128886_do_21368755399285145618_1_ONLINE.ecar", - "size": "2522" - } - }, - "index": 1, - "pkgVersion": 1 - } - ], - "name": "Section-2", - "navigationMode": "non-linear", - "createdOn": "2022-12-12T11:18:14.410+0000", - "channel": "01309282781705830427", - "generateDIALCodes": "No", - "lastUpdatedOn": "2022-12-12T11:21:38.793+0000", - "showTimer": false, - "identifier": "do_21368755318300672013", - "containsUserData": "No", - "allowSkip": "Yes", - "compatibilityLevel": 5, - "trackable": { - "enabled": "No", - "autoBatch": "No" - }, - "primaryCategory": "Practice Question Set", - "setType": "materialised", - "languageCode": [ - "en" - ], - "attributions": [], - "scoreCutoffType": "AssessmentLevel", - "versionKey": "1670843894410", - "mimeType": "application/vnd.sunbird.questionset", - "code": "685a65af-d1ce-4611-059c-0ec5ad5ef477", - "license": "CC BY 4.0", - "prevStatus": "Draft", - "showHints": false, - "language": [ - "English" - ], - "showFeedback": false, - "objectType": "QuestionSet", - "status": "Live", - "requiresSubmit": "No", - "shuffle": true, - "contentEncoding": "gzip", - "depth": 1, - "allowAnonymousAccess": "Yes", - "contentDisposition": "inline", - "allowBranching": "No", - "visibility": "Parent", - "showSolutions": false, - "index": 2 - } + "showSolutions": true, + "index": 1 + } ], - "name": "MCQ Question Set 1", + "name": "Short Text Questionset", "navigationMode": "non-linear", - "createdOn": "2022-12-12T10:55:57.311+0000", + "createdOn": "2023-08-16T07:02:56.221+0000", "createdFor": [ - "01309282781705830427" + "01309282781705830427" ], "channel": "01309282781705830427", - "pdfUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_21368754222912307211/do_21368754222912307211_pdf_1670844129483.pdf", + "pdfUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_2138622515299368961170/do_2138622515299368961170_pdf_1693386750069.pdf", "generateDIALCodes": "No", - "lastUpdatedOn": "2022-12-12T11:21:38.843+0000", + "lastUpdatedOn": "2023-08-30T09:11:32.657+0000", "subject": [ - "Hindi" + "Science" ], - "size": 337995, - "showTimer": false, - "identifier": "do_21368754222912307211", - "description": "MCQ Question Set 1", + "size": 5812722, + "showTimer": true, + "identifier": "do_2138622515299368961170", + "description": "Short Text Questionset.", "gradeLevel": [ - "Class 4" + "Class 7" ], "containsUserData": "No", "allowSkip": "Yes", "compatibilityLevel": 5, "audience": [ - "Student" + "Student" ], - "trackable": "{\"enabled\":\"No\",\"autoBatch\":\"No\"}", + "trackable": { + "enabled": "No", + "autoBatch": "No" + }, "se_boards": [ - "CBSE" + "ICSE" ], "primaryCategory": "Practice Question Set", "setType": "materialised", - "appIcon": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/content/assets/do_2136875423378145281221/apple.jpeg", + "appIcon": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_2138622515299368961170/artifact/sunbird.thumb.jpeg", "se_mediums": [ - "English" + "Hindi" ], - "downloadUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_21368754222912307211/mcq-question-set-1_1670844129320_do_21368754222912307211_1.ecar", + "downloadUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_2138622515299368961170/short-text-questionset_1693386749669_do_2138622515299368961170_3.ecar", "se_subjects": [ - "Hindi" + "Science" ], "medium": [ - "English" + "Hindi" ], "attributions": [], "scoreCutoffType": "AssessmentLevel", "framework": "inquiry_k-12", - "versionKey": "1670844098843", + "posterImage": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/content/assets/do_2138623258587217921213/sunbird.jpeg", + "versionKey": "1693386692657", "mimeType": "application/vnd.sunbird.questionset", "code": "7d5aaa70-ffb8-d062-ba10-1db445a11dbc", "license": "CC BY 4.0", + "qumlVersion": 1.1, "prevStatus": "Draft", "showHints": false, + "summaryType": "Complete", "language": [ - "English" + "English" ], - "board": "CBSE", + "board": "ICSE", "showFeedback": false, - "lastPublishedOn": "2022-12-12T11:22:09.041+0000", - "objectType": "QuestionSet", + "lastPublishedOn": "2023-08-30T09:12:29.460+0000", + "objectType": "QuestionSetImage", "status": "Live", "createdBy": "5a587cc1-e018-4859-a0a8-e842650b9d64", "requiresSubmit": "No", @@ -420,47 +313,46 @@ const sectionContent = { "consumerId": "6968004d-c67e-434a-a350-773aa1e068a3", "lastPublishedBy": "ae94b68c-a535-4dce-8e7a-fb9662b0ad68", "se_gradeLevels": [ - "Class 4" + "Class 7" ], "se_FWIds": [ - "inquiry_k-12" + "inquiry_k-12" ], "allowAnonymousAccess": "Yes", "contentDisposition": "inline", + "schemaVersion": "1.1", "additionalCategories": [], "allowBranching": "No", - "previewUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_21368754222912307211/do_21368754222912307211_html_1670844129483.html", + "previewUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_2138622515299368961170/do_2138622515299368961170_html_1693386750069.html", "childNodes": [ - "do_21368754725275238414", - "do_21368754291126272012", - "do_21368755204399923216", - "do_21368755399285145618", - "do_21368755318300672013" + "do_2138622530437857281173", + "do_2138622518926049281171", + "do_2138622565343969281175" ], "visibility": "Default", "showSolutions": false, "variants": { - "spine": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_21368754222912307211/mcq-question-set-1_1670844129213_do_21368754222912307211_1_SPINE.ecar", - "size": "19859" - }, - "online": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_21368754222912307211/mcq-question-set-1_1670844129277_do_21368754222912307211_1_ONLINE.ecar", - "size": "4348" - }, - "full": { - "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_21368754222912307211/mcq-question-set-1_1670844129320_do_21368754222912307211_1.ecar", - "size": "337995" - } + "spine": { + "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_2138622515299368961170/short-text-questionset_1693386749581_do_2138622515299368961170_3_SPINE.ecar", + "size": "7469" + }, + "online": { + "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_2138622515299368961170/short-text-questionset_1693386749632_do_2138622515299368961170_3_ONLINE.ecar", + "size": "4276" + }, + "full": { + "ecarUrl": "https://sunbirddevbbpublic.blob.core.windows.net/sunbird-content-staging/questionset/do_2138622515299368961170/short-text-questionset_1693386749669_do_2138622515299368961170_3.ecar", + "size": "5812722" + } }, - "pkgVersion": 1, - "instructions": "

This is a sample instructions

", + "pkgVersion": 3, + "instructions": "

This is Simple Questionset for testing short text Questionset

", "outcomeDeclaration": { - "maxScore": { - "cardinality": "single", - "type": "integer", - "defaultValue": 3 - } + "maxScore": { + "cardinality": "single", + "type": "integer", + "defaultValue": 2 + } } } export const playerConfig = { @@ -473,9 +365,9 @@ export const playerConfig = { uid: "", channel: "01268904781886259221", pdata: { - id: "preprod.diksha.portal", + id: "dev.sunbird.portal", ver: "3.3.0", - pid: "sunbird-portal.contentplayer", + pid: "sunbird-portal.qumlplayer", }, contextRollup: { l1: "string", diff --git a/web-component-examples/vanilla-js/index.html b/web-component-examples/vanilla-js/index.html index 7f7c15f7..f42deee1 100644 --- a/web-component-examples/vanilla-js/index.html +++ b/web-component-examples/vanilla-js/index.html @@ -32,8 +32,8 @@