Skip to content

Commit

Permalink
fix: fixes the navigation issue if the user does not pass the entranc…
Browse files Browse the repository at this point in the history
…e exam

- adds checks while rendering the next button text for status of the
entrance exam.

closes openedx#1415

Signed-off by: Ishan Masdekar <[email protected]>
  • Loading branch information
imasdekar committed Aug 2, 2024
1 parent 3a54276 commit 8765bd2
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ const CertificateStatus = ({ intl }) => {
courseId,
} = useSelector(state => state.courseHome);

const {
entranceExamData,
} = useModel('coursewareMeta', courseId);

const {
isEnrolled,
org,
Expand All @@ -42,13 +46,16 @@ const CertificateStatus = ({ intl }) => {
certificateAvailableDate,
} = certificateData || {};

const entranceExamPassed = entranceExamData ? entranceExamData.entranceExamPassed : null;

const mode = getCourseExitMode(
certificateData,
hasScheduledContent,
isEnrolled,
userHasPassingGrade,
null, // CourseExitPageIsActive
canViewCertificate,
entranceExamPassed,
);

const eventProperties = {
Expand Down
11 changes: 11 additions & 0 deletions src/courseware/course/course-exit/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const COURSE_EXIT_MODES = {
celebration: 1,
nonPassing: 2,
inProgress: 3,
entranceExamFail: 4,
};

// These are taken from the edx-platform `get_cert_data` function found in lms/courseware/views/views.py
Expand All @@ -32,9 +33,14 @@ function getCourseExitMode(
userHasPassingGrade,
courseExitPageIsActive = null,
canImmediatelyViewCertificate = false,
entranceExamPassed = null,
) {
const authenticatedUser = getAuthenticatedUser();

if (entranceExamPassed === false) {
return COURSE_EXIT_MODES.entranceExamFail;
}

if (courseExitPageIsActive === false || !authenticatedUser || !isEnrolled) {
return COURSE_EXIT_MODES.disabled;
}
Expand Down Expand Up @@ -73,6 +79,7 @@ function GetCourseExitNavigation(courseId, intl) {
isEnrolled,
userHasPassingGrade,
courseExitPageIsActive,
entranceExamData: { entranceExamPassed },
} = useModel('coursewareMeta', courseId);
const { canViewCertificate } = useModel('courseHomeMeta', courseId);
const exitMode = getCourseExitMode(
Expand All @@ -82,6 +89,7 @@ function GetCourseExitNavigation(courseId, intl) {
userHasPassingGrade,
courseExitPageIsActive,
canViewCertificate,
entranceExamPassed,
);
const exitActive = exitMode !== COURSE_EXIT_MODES.disabled;

Expand All @@ -93,6 +101,9 @@ function GetCourseExitNavigation(courseId, intl) {
case COURSE_EXIT_MODES.nonPassing:
exitText = intl.formatMessage(messages.nextButtonEnd);
break;
case COURSE_EXIT_MODES.entranceExamFail:
exitText = intl.formatMessage(messages.nextButtonEnd);
break;
default:
exitText = null;
}
Expand Down
11 changes: 11 additions & 0 deletions src/courseware/course/sequence/sequence-navigation/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export function useSequenceNavigationMetadata(currentSequenceId, currentUnitId)
const sequence = useModel('sequences', currentSequenceId);
const courseId = useSelector(state => state.courseware.courseId);
const courseStatus = useSelector(state => state.courseware.courseStatus);
const { entranceExamData: { entranceExamPassed } } = useModel('coursewareMeta', courseId);
const sequenceStatus = useSelector(state => state.courseware.sequenceStatus);

// If we don't know the sequence and unit yet, then assume no.
Expand All @@ -25,6 +26,16 @@ export function useSequenceNavigationMetadata(currentSequenceId, currentUnitId)
};
}

// if entrance exam is not passed then we should treat this as 1st and last unit
if (entranceExamPassed === false) {
return {
isFirstUnit: true,
isLastUnit: true,
navigationDisabledNextSequence: false,
navigationDisabledPrevSequence: false,
};
}

const sequenceIndex = sequenceIds.indexOf(currentSequenceId);
const unitIndex = sequence.unitIds.indexOf(currentUnitId);

Expand Down

0 comments on commit 8765bd2

Please sign in to comment.