Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: enabled the usage of resumeCourseRunUrl #875

Merged
merged 1 commit into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const CompletedCourseCard = (props) => {
startDate,
endDate,
mode,
resumeCourseRunUrl,
} = props;
const config = getConfig();

Expand All @@ -34,6 +35,7 @@ const CompletedCourseCard = (props) => {
courseRunId={courseRunId}
mode={mode}
startDate={startDate}
resumeCourseRunUrl={resumeCourseRunUrl}
/>
);
};
Expand Down Expand Up @@ -86,13 +88,15 @@ CompletedCourseCard.propTypes = {
endDate: PropTypes.string,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

CompletedCourseCard.defaultProps = {
linkToCertificate: null,
endDate: null,
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

export default CompletedCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
courseRunId,
startDate,
mode,
resumeCourseRunUrl,
}) => {
const { enterpriseConfig } = useContext(AppContext);

Expand All @@ -43,10 +44,13 @@
const variant = isExecutiveEducation2UCourse ? 'inverse-primary' : 'outline-primary';

const renderContent = () => {
if (!isCourseStarted() && startDate) {
// resumeCourseRunUrl indicates that learner has made progress, available only if the learner has started learning.
// The "Start Course" is visible either when the course has not started or when the course has started but the
// learner has not yet begun the learning.
if ((!isCourseStarted() && startDate) || (isCourseStarted && !resumeCourseRunUrl)) {
return 'Start course';
}
return 'Resume';

Check warning on line 53 in src/components/dashboard/main-content/course-enrollments/course-cards/ContinueLearningButton.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/dashboard/main-content/course-enrollments/course-cards/ContinueLearningButton.jsx#L53

Added line #L53 was not covered by tests
};

return (
Expand All @@ -67,6 +71,7 @@
className: null,
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

ContinueLearningButton.propTypes = {
Expand All @@ -76,6 +81,7 @@
courseRunId: PropTypes.string.isRequired,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

export default ContinueLearningButton;
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
courseRunStatus,
startDate,
mode,
resumeCourseRunUrl,
...rest
}) => {
const {
Expand Down Expand Up @@ -49,13 +50,14 @@
courseRunId={courseRunId}
mode={mode}
startDate={startDate}
resumeCourseRunUrl={resumeCourseRunUrl}
/>
{shouldShowUpgradeButton && <UpgradeCourseButton className="ml-1" title={title} />}
</>
);

const filteredNotifications = notifications.filter((notification) => {
const now = dayjs();

Check warning on line 60 in src/components/dashboard/main-content/course-enrollments/course-cards/InProgressCourseCard.jsx

View check run for this annotation

Codecov / codecov/patch

src/components/dashboard/main-content/course-enrollments/course-cards/InProgressCourseCard.jsx#L60

Added line #L60 was not covered by tests
if (dayjs(notification.date).isBetween(now, dayjs(now).add('1', 'w'))) {
return notification;
}
Expand Down Expand Up @@ -185,11 +187,13 @@
courseRunStatus: PropTypes.string.isRequired,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

InProgressCourseCard.defaultProps = {
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

export default InProgressCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const SavedForLaterCourseCard = (props) => {
isRevoked,
startDate,
mode,
resumeCourseRunUrl,
} = props;
const {
updateCourseEnrollmentStatus,
Expand Down Expand Up @@ -104,6 +105,7 @@ const SavedForLaterCourseCard = (props) => {
courseRunId={courseRunId}
mode={mode}
startDate={startDate}
resumeCourseRunUrl={resumeCourseRunUrl}
/>
);
};
Expand Down Expand Up @@ -140,13 +142,15 @@ SavedForLaterCourseCard.propTypes = {
endDate: PropTypes.string,
startDate: PropTypes.string,
mode: PropTypes.string,
resumeCourseRunUrl: PropTypes.string,
};

SavedForLaterCourseCard.defaultProps = {
linkToCertificate: null,
endDate: null,
startDate: null,
mode: null,
resumeCourseRunUrl: null,
};

export default SavedForLaterCourseCard;
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ describe('transformCourseEnrollment', () => {
isRevoked: originalCourseEnrollment.isRevoked,
notifications: originalCourseEnrollment.dueDates,
canUnenroll: false,
resumeCourseRunUrl: 'http://www.resumecourserun.com',
};
expect(transformCourseEnrollment(originalCourseEnrollment)).toEqual(transformedCourseEnrollment);
});
Expand Down Expand Up @@ -52,6 +53,7 @@ describe('transformCourseEnrollment', () => {
isRevoked: originalCourseEnrollment.isRevoked,
notifications: originalCourseEnrollment.dueDates,
canUnenroll,
resumeCourseRunUrl: 'http://www.resumecourserun.com',
};
expect(transformCourseEnrollment(originalCourseEnrollment)).toEqual(transformedCourseEnrollment);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
// Delete renamed/unused fields
delete courseEnrollment.displayName;
delete courseEnrollment.micromastersTitle;
delete courseEnrollment.resumeCourseRunUrl;
delete courseEnrollment.courseRunUrl;
delete courseEnrollment.certificateDownloadUrl;
delete courseEnrollment.emailsEnabled;
Expand Down Expand Up @@ -130,10 +129,10 @@
export const getTransformedAllocatedAssignments = (assignments, slug) => {
if (!assignments) { return assignments; }
const updatedAssignments = assignments?.map((item) => {
const isCancelledAssignment = item.state === 'cancelled';
const isExpiredAssignment = isAssignmentExpired(item);

Check warning on line 133 in src/components/dashboard/main-content/course-enrollments/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/dashboard/main-content/course-enrollments/data/utils.js#L132-L133

Added lines #L132 - L133 were not covered by tests

return {

Check warning on line 135 in src/components/dashboard/main-content/course-enrollments/data/utils.js

View check run for this annotation

Codecov / codecov/patch

src/components/dashboard/main-content/course-enrollments/data/utils.js#L135

Added line #L135 was not covered by tests
linkToCourse: `/${slug}/course/${item.contentKey}`,
courseKey: item.contentKey,
title: item.contentTitle,
Expand Down
Loading