From 75ec5c0963183bfd96c1524e9aa0b2c23a289137 Mon Sep 17 00:00:00 2001 From: Rafay Ghafoor Date: Thu, 21 Sep 2023 01:57:05 +0500 Subject: [PATCH] fix: make progress graph respect course settings --- src/course-home/data/api.js | 7 +++++++ src/course-home/data/thunks.js | 13 +++++++++++++ src/course-home/progress-tab/ProgressTab.jsx | 5 ++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/course-home/data/api.js b/src/course-home/data/api.js index b32973ef47..4ef94c7b24 100644 --- a/src/course-home/data/api.js +++ b/src/course-home/data/api.js @@ -193,6 +193,13 @@ export async function getCourseHomeCourseMetadata(courseId, rootSlug) { return normalizeCourseHomeCourseMetadata(data, rootSlug); } +export async function getCourseAdvancedSettings(courseId) { + let url = `${getConfig().STUDIO_BASE_URL}/api/contentstore/v0/advanced_settings/${courseId}`; + url = appendBrowserTimezoneToUrl(url); + const { data } = await getAuthenticatedHttpClient().get(url); + return data; +} + // For debugging purposes, you might like to see a fully loaded dates tab. // Just uncomment the next few lines and the immediate 'return' in the function below // import { Factory } from 'rosie'; diff --git a/src/course-home/data/thunks.js b/src/course-home/data/thunks.js index b7c1c3f9a2..58a15ff95d 100644 --- a/src/course-home/data/thunks.js +++ b/src/course-home/data/thunks.js @@ -3,6 +3,7 @@ import { camelCaseObject } from '@edx/frontend-platform'; import { executePostFromPostEvent, getCourseHomeCourseMetadata, + getCourseAdvancedSettings, getDatesTabData, getOutlineTabData, getProgressTabData, @@ -42,6 +43,18 @@ export function fetchTab(courseId, tab, getTabData, targetUserId) { ...courseHomeCourseMetadata, }, })); + + if (tab === 'progress') { + const courseAdvancedSettings = await getCourseAdvancedSettings(courseId); + dispatch(addModel({ + modelType: 'courseAdvancedSettings', + model: { + id: courseId, + ...courseAdvancedSettings, + }, + })); + } + const tabDataResult = getTabData && await getTabData(courseId, targetUserId); if (tabDataResult) { dispatch(addModel({ diff --git a/src/course-home/progress-tab/ProgressTab.jsx b/src/course-home/progress-tab/ProgressTab.jsx index 3413d3836f..50eee8194d 100644 --- a/src/course-home/progress-tab/ProgressTab.jsx +++ b/src/course-home/progress-tab/ProgressTab.jsx @@ -17,6 +17,9 @@ const ProgressTab = () => { courseId, } = useSelector(state => state.courseHome); + const advancedSettings = useModel('courseAdvancedSettings', courseId); + const disableProgressGraph = advancedSettings.disable_progress_graph; + const { gradesFeatureIsFullyLocked, } = useModel('progress', courseId); @@ -38,7 +41,7 @@ const ProgressTab = () => {
{/* Main body */}
- + {!disableProgressGraph.value && } {!wideScreen && }