From 373955fcdf9169e8fdbc556063d5eff64b147007 Mon Sep 17 00:00:00 2001 From: "kshitij.sobti" Date: Tue, 8 Oct 2024 19:33:51 +0530 Subject: [PATCH 1/3] feat: Add support for toggling more parts of the progress page on or off. --- src/pages-and-resources/progress/Settings.jsx | 95 ++++++++++++++----- src/pages-and-resources/progress/messages.js | 24 +++++ 2 files changed, 97 insertions(+), 22 deletions(-) diff --git a/src/pages-and-resources/progress/Settings.jsx b/src/pages-and-resources/progress/Settings.jsx index f9326aee8d..3e16a0f61d 100644 --- a/src/pages-and-resources/progress/Settings.jsx +++ b/src/pages-and-resources/progress/Settings.jsx @@ -1,19 +1,32 @@ -import { injectIntl, intlShape } from '@edx/frontend-platform/i18n'; +import { getConfig } from '@edx/frontend-platform'; +import { useIntl } from '@edx/frontend-platform/i18n'; import PropTypes from 'prop-types'; import React from 'react'; import * as Yup from 'yup'; -import { getConfig } from '@edx/frontend-platform'; +import messages from './messages'; import FormSwitchGroup from '../../generic/FormSwitchGroup'; import { useAppSetting } from '../../utils'; import AppSettingsModal from '../app-settings-modal/AppSettingsModal'; -import messages from './messages'; -const ProgressSettings = ({ intl, onClose }) => { +const ProgressSettings = ({ onClose }) => { + const intl = useIntl(); const [disableProgressGraph, saveSetting] = useAppSetting('disableProgressGraph'); - const showProgressGraphSetting = getConfig().ENABLE_PROGRESS_GRAPH_SETTINGS.toLowerCase() === 'true'; + const [otherCourseSettings, saveOtherCourseSettings] = useAppSetting('otherCourseSettings'); + const showProgressGraphSetting = getConfig().ENABLE_PROGRESS_GRAPH_SETTINGS.toString().toLowerCase() === 'true'; - const handleSettingsSave = (values) => { - if (showProgressGraphSetting) { saveSetting(!values.enableProgressGraph); } + const handleSettingsSave = async (values) => { + if (showProgressGraphSetting) { + await saveSetting(!values.enableProgressGraph); + } + const updatedOtherCourseSettings = { + ...otherCourseSettings, + progressPage: { + showGrades: values.showGrades, + showGradeSummary: values.showGradeSummary, + showRelatedLinks: values.showRelatedLinks, + }, + }; + await saveOtherCourseSettings(updatedOtherCourseSettings); }; return ( @@ -24,23 +37,62 @@ const ProgressSettings = ({ intl, onClose }) => { enableAppLabel={intl.formatMessage(messages.enableProgressLabel)} learnMoreText={intl.formatMessage(messages.enableProgressLink)} onClose={onClose} - initialValues={{ enableProgressGraph: !disableProgressGraph }} - validationSchema={{ enableProgressGraph: Yup.boolean() }} + initialValues={{ + enableProgressGraph: !disableProgressGraph, + showGrades: !!otherCourseSettings?.progressPage?.showGrades, + showGradeSummary: !!otherCourseSettings?.progressPage?.showGradeSummary, + showRelatedLinks: !!otherCourseSettings?.progressPage?.showRelatedLinks, + }} + validationSchema={{ + enableProgressGraph: Yup.boolean(), + showGrades: Yup.boolean(), + showGradeSummary: Yup.boolean(), + showRelatedLinks: Yup.boolean(), + }} onSettingsSave={handleSettingsSave} > { ({ handleChange, handleBlur, values }) => ( - showProgressGraphSetting && ( - - ) + <> + {showProgressGraphSetting && ( + + )} + + + + ) } @@ -48,8 +100,7 @@ const ProgressSettings = ({ intl, onClose }) => { }; ProgressSettings.propTypes = { - intl: intlShape.isRequired, onClose: PropTypes.func.isRequired, }; -export default injectIntl(ProgressSettings); +export default ProgressSettings; diff --git a/src/pages-and-resources/progress/messages.js b/src/pages-and-resources/progress/messages.js index 6bf0f6f36e..8ee155920b 100644 --- a/src/pages-and-resources/progress/messages.js +++ b/src/pages-and-resources/progress/messages.js @@ -28,6 +28,30 @@ const messages = defineMessages({ id: 'course-authoring.pages-resources.progress.enable-graph.help', defaultMessage: 'If enabled, students can view the progress graph', }, + showGradesLabel: { + id: 'course-authoring.pages-resources.progress.show-grades.label', + defaultMessage: 'Show grades', + }, + showGradesHelp: { + id: 'course-authoring.pages-resources.progress.show-grades.help', + defaultMessage: 'If enabled, students can see their grades on the progress page.', + }, + showGradeSummaryLabel: { + id: 'course-authoring.pages-resources.progress.show-grade-summary.label', + defaultMessage: 'Show grades Summary', + }, + showGradeSummaryHelp: { + id: 'course-authoring.pages-resources.progress.show-grade-summary.help', + defaultMessage: 'If enabled, students can see a summary of their grades on the progress page.', + }, + showRelatedLinksLabel: { + id: 'course-authoring.pages-resources.progress.show-related-links.label', + defaultMessage: 'Show Related Links', + }, + showRelatedLinksHelp: { + id: 'course-authoring.pages-resources.progress.show-related-links.help', + defaultMessage: 'If enabled, students can see related links in the sidebar on the progress page.', + }, }); export default messages; From 45a4cf44878d73859bd2d106bb6f4ae917e0f548 Mon Sep 17 00:00:00 2001 From: "kshitij.sobti" Date: Tue, 15 Oct 2024 16:11:51 +0530 Subject: [PATCH 2/3] fixup! feat: Add support for toggling more parts of the progress page on or off. --- src/pages-and-resources/progress/Settings.jsx | 32 +++++++++++++------ src/pages-and-resources/progress/messages.js | 20 ++++++++---- 2 files changed, 36 insertions(+), 16 deletions(-) diff --git a/src/pages-and-resources/progress/Settings.jsx b/src/pages-and-resources/progress/Settings.jsx index 3e16a0f61d..f02af8a17d 100644 --- a/src/pages-and-resources/progress/Settings.jsx +++ b/src/pages-and-resources/progress/Settings.jsx @@ -22,8 +22,9 @@ const ProgressSettings = ({ onClose }) => { ...otherCourseSettings, progressPage: { showGrades: values.showGrades, - showGradeSummary: values.showGradeSummary, + showGradeBreakdown: values.showGradeBreakdown, showRelatedLinks: values.showRelatedLinks, + showCertificateStatus: values.showCertificateStatus, }, }; await saveOtherCourseSettings(updatedOtherCourseSettings); @@ -39,15 +40,17 @@ const ProgressSettings = ({ onClose }) => { onClose={onClose} initialValues={{ enableProgressGraph: !disableProgressGraph, - showGrades: !!otherCourseSettings?.progressPage?.showGrades, - showGradeSummary: !!otherCourseSettings?.progressPage?.showGradeSummary, - showRelatedLinks: !!otherCourseSettings?.progressPage?.showRelatedLinks, + showGrades: otherCourseSettings?.progressPage?.showGrades ?? true, + showGradeBreakdown: otherCourseSettings?.progressPage?.showGradeBreakdown ?? true, + showRelatedLinks: otherCourseSettings?.progressPage?.showRelatedLinks ?? true, + showCertificateStatus: otherCourseSettings?.progressPage?.showCertificateStatus ?? true, }} validationSchema={{ enableProgressGraph: Yup.boolean(), showGrades: Yup.boolean(), - showGradeSummary: Yup.boolean(), + showGradeBreakdown: Yup.boolean(), showRelatedLinks: Yup.boolean(), + showCertificateStatus: Yup.boolean(), }} onSettingsSave={handleSettingsSave} > @@ -75,13 +78,13 @@ const ProgressSettings = ({ onClose }) => { checked={values.showGrades} /> { onBlur={handleBlur} checked={values.showRelatedLinks} /> + ) } diff --git a/src/pages-and-resources/progress/messages.js b/src/pages-and-resources/progress/messages.js index 8ee155920b..25438df083 100644 --- a/src/pages-and-resources/progress/messages.js +++ b/src/pages-and-resources/progress/messages.js @@ -36,13 +36,13 @@ const messages = defineMessages({ id: 'course-authoring.pages-resources.progress.show-grades.help', defaultMessage: 'If enabled, students can see their grades on the progress page.', }, - showGradeSummaryLabel: { - id: 'course-authoring.pages-resources.progress.show-grade-summary.label', - defaultMessage: 'Show grades Summary', + showGradeBreakdownLabel: { + id: 'course-authoring.pages-resources.progress.show-grade-breakdown.label', + defaultMessage: 'Show Grade Breakdown', }, - showGradeSummaryHelp: { - id: 'course-authoring.pages-resources.progress.show-grade-summary.help', - defaultMessage: 'If enabled, students can see a summary of their grades on the progress page.', + showGradeBreakdownHelp: { + id: 'course-authoring.pages-resources.progress.show-grade-breakdown.help', + defaultMessage: 'If enabled, students can see a summary and detailed breakdown of their grades on the progress page.', }, showRelatedLinksLabel: { id: 'course-authoring.pages-resources.progress.show-related-links.label', @@ -52,6 +52,14 @@ const messages = defineMessages({ id: 'course-authoring.pages-resources.progress.show-related-links.help', defaultMessage: 'If enabled, students can see related links in the sidebar on the progress page.', }, + showCertificateStatusLabel: { + id: 'course-authoring.pages-resources.progress.show-certificate-status.label', + defaultMessage: 'Show Certificate Status', + }, + showCertificateStatusHelp: { + id: 'course-authoring.pages-resources.progress.show-certificate-status.help', + defaultMessage: 'If enabled, students can see the status of their certificates on the progress page.', + }, }); export default messages; From 6a4d49502b15ea7e94951461d744f19bb9e2dcee Mon Sep 17 00:00:00 2001 From: "kshitij.sobti" Date: Mon, 28 Oct 2024 19:53:28 +0530 Subject: [PATCH 3/3] fixup! fixup! feat: Add support for toggling more parts of the progress page on or off. --- src/pages-and-resources/progress/Settings.jsx | 28 +++++++++++++------ src/pages-and-resources/progress/messages.js | 20 +++++++++---- 2 files changed, 34 insertions(+), 14 deletions(-) diff --git a/src/pages-and-resources/progress/Settings.jsx b/src/pages-and-resources/progress/Settings.jsx index f02af8a17d..7364539bdc 100644 --- a/src/pages-and-resources/progress/Settings.jsx +++ b/src/pages-and-resources/progress/Settings.jsx @@ -22,7 +22,8 @@ const ProgressSettings = ({ onClose }) => { ...otherCourseSettings, progressPage: { showGrades: values.showGrades, - showGradeBreakdown: values.showGradeBreakdown, + showGradeSummary: values.showGradeSummary, + showGradeDetails: values.showGradeDetails, showRelatedLinks: values.showRelatedLinks, showCertificateStatus: values.showCertificateStatus, }, @@ -41,14 +42,16 @@ const ProgressSettings = ({ onClose }) => { initialValues={{ enableProgressGraph: !disableProgressGraph, showGrades: otherCourseSettings?.progressPage?.showGrades ?? true, - showGradeBreakdown: otherCourseSettings?.progressPage?.showGradeBreakdown ?? true, + showGradeSummary: otherCourseSettings?.progressPage?.showGradeSummary ?? true, + showGradeDetails: otherCourseSettings?.progressPage?.showGradeDetails ?? true, showRelatedLinks: otherCourseSettings?.progressPage?.showRelatedLinks ?? true, showCertificateStatus: otherCourseSettings?.progressPage?.showCertificateStatus ?? true, }} validationSchema={{ enableProgressGraph: Yup.boolean(), showGrades: Yup.boolean(), - showGradeBreakdown: Yup.boolean(), + showGradeSummary: Yup.boolean(), + showGradeDetails: Yup.boolean(), showRelatedLinks: Yup.boolean(), showCertificateStatus: Yup.boolean(), }} @@ -78,13 +81,22 @@ const ProgressSettings = ({ onClose }) => { checked={values.showGrades} /> +