Skip to content

Commit

Permalink
Issue #PS-0000 fix: Fixed v1 player
Browse files Browse the repository at this point in the history
  • Loading branch information
itsvick committed Nov 11, 2024
1 parent b0be9b8 commit e6ea277
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 51 deletions.
5 changes: 5 additions & 0 deletions app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
}
130 changes: 130 additions & 0 deletions src/data/player-config.ts
Original file line number Diff line number Diff line change
@@ -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: {}
};
112 changes: 61 additions & 51 deletions src/pages/play/content/[identifier].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,64 +13,69 @@ 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
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;
Expand All @@ -90,15 +95,20 @@ const players: React.FC<SunbirdPlayerProps> = () => {
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);
console.log('Q2', Q2?.questionset);
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);
Expand Down

0 comments on commit e6ea277

Please sign in to comment.