From e6ea2777bd2b22df5f440d372d40e48e68d3bdfe Mon Sep 17 00:00:00 2001 From: vivek kasture Date: Mon, 11 Nov 2024 19:44:42 +0530 Subject: [PATCH] Issue #PS-0000 fix: Fixed v1 player --- app.config.ts | 5 + src/data/player-config.ts | 130 ++++++++++++++++++++++++ src/pages/play/content/[identifier].tsx | 112 ++++++++++---------- 3 files changed, 196 insertions(+), 51 deletions(-) create mode 100644 src/data/player-config.ts diff --git a/app.config.ts b/app.config.ts index 7e160c7f..04c2ee47 100644 --- a/app.config.ts +++ b/app.config.ts @@ -86,4 +86,9 @@ export const RequisiteType = { export const entityList={ TEAM_LEADER: ['center', 'facilitator', 'learner'], TEACHER: ['learner'] +} + +export const MIME_TYPE = { + "QUESTION_SET_MIME_TYPE": "application/vnd.sunbird.questionset", + "INTERACTIVE_MIME_TYPE": ["application/vnd.ekstep.h5p-archive", "application/vnd.ekstep.html-archive"] } \ No newline at end of file diff --git a/src/data/player-config.ts b/src/data/player-config.ts new file mode 100644 index 00000000..45c28e6e --- /dev/null +++ b/src/data/player-config.ts @@ -0,0 +1,130 @@ +import { PlayerConfig } from "@/utils/Interfaces"; + +export const V2PlayerConfig: PlayerConfig = { + context: { + mode: "play", + partner: [], + pdata: { + id: "pratham.admin.portal", + ver: "1.0.0", + pid: "admin-portal", + }, + contentId: "do_12345", + sid: "", + uid: "", + timeDiff: -0.089, + channel: "test-k12-channel", + tags: ["test-k12-channel"], + did: "", + contextRollup: { l1: "test-k12-channel" }, + objectRollup: {}, + userData: { firstName: "Guest", lastName: "User" }, + host: "https://telemetry.prathamdigital.org", + endpoint: "/v1/telemetry", + }, + config: { + showEndPage: false, + endPage: [{ template: "assessment", contentType: ["SelfAssess"] }], + showStartPage: true, + host: "", + overlay: { showUser: false }, + splash: { + text: "", + icon: "", + bgImage: "assets/icons/splacebackground_1.png", + webLink: "", + }, + apislug: "", + repos: ["/sunbird-plugins/renderer"], + plugins: [ + { id: "org.sunbird.iframeEvent", ver: 1, type: "plugin" }, + { id: "org.sunbird.player.endpage", ver: 1.1, type: "plugin" }, + ], + sideMenu: { + showShare: false, + showDownload: true, + showExit: true, + showPrint: false, + showReplay: true, + }, + }, + data: {}, +}; +export const V1PlayerConfig: PlayerConfig = { + config: { + whiteListUrl: [], + showEndPage: true, + endPage: [ + { + template: "assessment", + contentType: ["SelfAssess"], + }, + ], + showStartPage: true, + host: "", + overlay: { + enableUserSwitcher: true, + showOverlay: true, + showNext: true, + showPrevious: true, + showSubmit: false, + showReload: false, + showUser: false, + showExit: true, + menu: { + showTeachersInstruction: false, + }, + }, + splash: { + text: "", + icon: "", + bgImage: "assets/icons/splacebackground_1.png", + webLink: "", + }, + apislug: "", + repos: ["/sunbird-plugins/renderer"], + plugins: [ + { + id: "org.sunbird.iframeEvent", + ver: 1, + type: "plugin", + }, + { + id: "org.sunbird.player.endpage", + ver: 1.1, + type: "plugin", + }, + ], + sideMenu: { + showShare: true, + showDownload: true, + showExit: true, + }, + enableTelemetryValidation: false, + }, + context: { + mode: "play", + // partner: [], + pdata: { + id: "pratham.admin.portal", + ver: "1.0.0", + pid: "admin-portal", + }, + contentId: "do_12345", + sid: "", + uid: "", + timeDiff: -1.129, + contextRollup: {}, + channel: "test-k12-channel", + did: "", + dims: [], + tags: ["test-k12-channel"], + app: ["test-k12-channel"], + cdata: [], + userData: { + firstName: "Guest", + lastName: "User", + }, + }, + data: {} +}; diff --git a/src/pages/play/content/[identifier].tsx b/src/pages/play/content/[identifier].tsx index 54e0c445..e46d4e6f 100644 --- a/src/pages/play/content/[identifier].tsx +++ b/src/pages/play/content/[identifier].tsx @@ -13,6 +13,9 @@ import Loader from '@/components/Loader'; import ArrowBackIcon from "@mui/icons-material/ArrowBack"; import { useTranslation } from 'next-i18next'; import { PlayerConfig } from '@/utils/Interfaces'; +import { MIME_TYPE } from '../../../../app.config'; +import { V1PlayerConfig, V2PlayerConfig } from '@/data/player-config'; +import { MIMEType } from 'util'; // @ts-ignore @@ -20,57 +23,59 @@ const SunbirdPlayers = dynamic(() => import('editor/SunbirdPlayers'), { ssr: false, }); -const playerConfig: PlayerConfig = { - context: { - mode: 'play', - partner: [], - pdata: { - id: 'dev.sunbird.portal', - ver: '5.2.0', - pid: 'sunbird-portal', - }, - contentId: 'do_21374910251798528014586', - sid: '6d1898db-d783-4f83-8b92-4a36636e0d2f', - uid: 'fb6b2e58-0f14-4d4f-90e4-bae092e7a235', - timeDiff: -0.089, - channel: '01269878797503692810', - tags: ['01269878797503692810'], - did: '3ca74a4c5fbce6b7b7f5cd12cebb1682', - contextRollup: { l1: '01269878797503692810' }, - objectRollup: {}, - userData: { firstName: 'Guest', lastName: '' }, +// const playerConfig: PlayerConfig = { +// context: { +// mode: 'play', +// partner: [], +// pdata: { +// id: 'dev.sunbird.portal', +// ver: '5.2.0', +// pid: 'sunbird-portal', +// }, +// contentId: 'do_21374910251798528014586', +// sid: '6d1898db-d783-4f83-8b92-4a36636e0d2f', +// uid: 'fb6b2e58-0f14-4d4f-90e4-bae092e7a235', +// timeDiff: -0.089, +// channel: '01269878797503692810', +// tags: ['01269878797503692810'], +// did: '3ca74a4c5fbce6b7b7f5cd12cebb1682', +// contextRollup: { l1: '01269878797503692810' }, +// objectRollup: {}, +// userData: { firstName: 'Guest', lastName: '' }, - //telemetry - host: 'https://telemetry.prathamdigital.org', - endpoint: '/v1/telemetry', - }, - config: { - showEndPage: false, - endPage: [{ template: 'assessment', contentType: ['SelfAssess'] }], - showStartPage: true, - host: '', - overlay: { showUser: false }, - splash: { - text: '', - icon: '', - bgImage: 'assets/icons/splacebackground_1.png', - webLink: '', - }, - apislug: '', - repos: ['/sunbird-plugins/renderer'], - plugins: [ - { id: 'org.sunbird.iframeEvent', ver: 1, type: 'plugin' }, - { id: 'org.sunbird.player.endpage', ver: 1.1, type: 'plugin' }, - ], - sideMenu: { - showShare: false, - showDownload: true, - showExit: true, - showPrint: false, - showReplay: true, - }, - }, -}; +// //telemetry +// host: 'https://telemetry.prathamdigital.org', +// endpoint: '/v1/telemetry', +// }, +// config: { +// showEndPage: false, +// endPage: [{ template: 'assessment', contentType: ['SelfAssess'] }], +// showStartPage: true, +// host: '', +// overlay: { showUser: false }, +// splash: { +// text: '', +// icon: '', +// bgImage: 'assets/icons/splacebackground_1.png', +// webLink: '', +// }, +// apislug: '', +// repos: ['/sunbird-plugins/renderer'], +// plugins: [ +// { id: 'org.sunbird.iframeEvent', ver: 1, type: 'plugin' }, +// { id: 'org.sunbird.player.endpage', ver: 1.1, type: 'plugin' }, +// ], +// sideMenu: { +// showShare: false, +// showDownload: true, +// showExit: true, +// showPrint: false, +// showReplay: true, +// }, +// }, +// }; + +let playerConfig: PlayerConfig; interface SunbirdPlayerProps { playerConfig: PlayerConfig; @@ -90,7 +95,8 @@ const players: React.FC = () => { console.log('identifier on players page:', identifier); const data = await fetchContent(identifier); console.log('data', data); - if (data.mimeType === 'application/vnd.sunbird.questionset') { + if (data.mimeType === MIME_TYPE.QUESTION_SET_MIME_TYPE) { + playerConfig = V2PlayerConfig; const Q1 = await getHierarchy(identifier); console.log('Q1', Q1?.questionset); const Q2 = await getQumlData(identifier); @@ -98,7 +104,11 @@ const players: React.FC = () => { const metadata = { ...Q1?.questionset, ...Q2?.questionset }; playerConfig.metadata = metadata; console.log('playerConfig', playerConfig); + } else if (MIME_TYPE.INTERACTIVE_MIME_TYPE.includes(data?.mimeType)) { + playerConfig = V1PlayerConfig; + playerConfig.metadata = data; } else { + playerConfig = V2PlayerConfig; playerConfig.metadata = data; } setLoading(false);