Skip to content

Commit

Permalink
feat: added live tab (#923)
Browse files Browse the repository at this point in the history
Co-authored-by: adeel.tajamul <[email protected]>
  • Loading branch information
muhammadadeeltajamul and adeel.tajamul authored Apr 14, 2022
1 parent 7e7eb83 commit 9b316bd
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 1 deletion.
14 changes: 14 additions & 0 deletions src/course-home/data/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,20 @@ export async function getProctoringInfoData(courseId, username) {
}
}

export async function getLiveTabIframe(courseId) {
const url = `${getConfig().LMS_BASE_URL}/api/course_live/iframe/${courseId}/`;
try {
const { data } = await getAuthenticatedHttpClient().get(url);
return data;
} catch (error) {
const { httpErrorStatus } = error && error.customAttributes;
if (httpErrorStatus === 404) {
return {};
}
throw error;
}
}

export function getTimeOffsetMillis(headerDate, requestTime, responseTime) {
// Time offset computation should move down into the HttpClient wrapper to maintain a global time correction reference
// Requires 'Access-Control-Expose-Headers: Date' on the server response per https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS#access-control-expose-headers
Expand Down
5 changes: 5 additions & 0 deletions src/course-home/data/thunks.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
postWeeklyLearningGoal,
postDismissWelcomeMessage,
postRequestCert,
getLiveTabIframe,
} from './api';

import {
Expand Down Expand Up @@ -79,6 +80,10 @@ export function fetchOutlineTab(courseId) {
return fetchTab(courseId, 'outline', getOutlineTabData);
}

export function fetchLiveTab(courseId) {
return fetchTab(courseId, 'live', getLiveTabIframe);
}

export function fetchDiscussionTab(courseId) {
return fetchTab(courseId, 'discussion');
}
Expand Down
22 changes: 22 additions & 0 deletions src/course-home/live-tab/LiveTab.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { useEffect } from 'react';
import { useSelector } from 'react-redux';

function LiveTab() {
const { courseId } = useSelector(state => state.courseHome);
const liveModel = useSelector(state => state.models.live);
useEffect(() => {
const iframe = document.getElementById('lti-tab-embed');
if (iframe) {
iframe.className += ' vh-100 w-100 border-0';
}
}, []);
return (
<div
id="live_tab"
// eslint-disable-next-line react/no-danger
dangerouslySetInnerHTML={{ __html: liveModel[courseId]?.iframe }}
/>
);
}

export default LiveTab;
8 changes: 7 additions & 1 deletion src/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Switch } from 'react-router-dom';

import { messages as footerMessages } from '@edx/frontend-component-footer';
import { messages as headerMessages } from '@edx/frontend-component-header';
import { fetchDiscussionTab } from './course-home/data/thunks';
import { fetchDiscussionTab, fetchLiveTab } from './course-home/data/thunks';
import DiscussionTab from './course-home/discussion-tab/DiscussionTab';

import appMessages from './i18n';
Expand All @@ -33,6 +33,7 @@ import { fetchCourse } from './courseware/data';
import initializeStore from './store';
import NoticesProvider from './generic/notices';
import PathFixesProvider from './generic/path-fixes';
import LiveTab from './course-home/live-tab/LiveTab';

subscribe(APP_READY, () => {
ReactDOM.render(
Expand All @@ -48,6 +49,11 @@ subscribe(APP_READY, () => {
<OutlineTab />
</TabContainer>
</PageRoute>
<PageRoute path="/course/:courseId/live">
<TabContainer tab="live" fetch={fetchLiveTab} slice="courseHome">
<LiveTab />
</TabContainer>
</PageRoute>
<PageRoute path="/course/:courseId/dates">
<TabContainer tab="dates" fetch={fetchDatesTab} slice="courseHome">
<DatesTab />
Expand Down

0 comments on commit 9b316bd

Please sign in to comment.