feat: Show course enrollment with cert on dash

Previously the programs dashboard picked the first course run enrollment
for a course to display on the dash if the user had multiple. Now it has
a preference for the enrolled course run that earned a certificate if
there is one.
This commit is contained in:
Matt Tuchfarber
2021-05-07 15:17:32 -04:00
parent 06422fe8b2
commit e6e3bade93

View File

@@ -17,7 +17,14 @@ class CourseCardModel extends Backbone.Model {
}
getCourseRun(course) {
const enrolledCourseRun = course.course_runs.find(run => run.is_enrolled);
// A learner might have have enrolled in a course multiple times,
// so we want to get the enrollment with a certificate if it exists
// otherwise any enrolled run.
let enrolledCourseRun = course.course_runs.find(run => run.is_enrolled && run.certificate_url);
if (!enrolledCourseRun) {
enrolledCourseRun = course.course_runs.find(run => run.is_enrolled);
}
const openEnrollmentCourseRuns = this.getEnrollableCourseRuns();
let desiredCourseRun;