diff --git a/lms/static/js/learner_dashboard/models/course_card_model.js b/lms/static/js/learner_dashboard/models/course_card_model.js index 34c2e26885..330854f36f 100644 --- a/lms/static/js/learner_dashboard/models/course_card_model.js +++ b/lms/static/js/learner_dashboard/models/course_card_model.js @@ -185,6 +185,7 @@ setActiveCourseRun: function(courseRun, userPreferences) { var startDateString, + courseTitleLink = '', isEnrolled = this.isEnrolledInSession() && courseRun.key; if (courseRun) { if (this.valueIsDefined(courseRun.advertised_start)) { @@ -192,6 +193,11 @@ } else { startDateString = this.formatDate(courseRun.start, userPreferences); } + if (isEnrolled && courseRun.course_url) { + courseTitleLink = courseRun.course_url; + } else if (!isEnrolled && courseRun.marketing_url) { + courseTitleLink = courseRun.marketing_url; + } this.set({ certificate_url: courseRun.certificate_url, course_run_key: courseRun.key || '', @@ -210,7 +216,8 @@ start_date: startDateString, upcoming_course_runs: this.getUpcomingCourseRuns(), upgrade_url: courseRun.upgrade_url, - price: this.getCertificatePriceString(courseRun) + price: this.getCertificatePriceString(courseRun), + course_title_link: courseTitleLink }); // This is used to render the date for completed and in progress courses diff --git a/lms/static/js/spec/learner_dashboard/course_card_view_spec.js b/lms/static/js/spec/learner_dashboard/course_card_view_spec.js index 0e44a48f88..ea7030b3b2 100644 --- a/lms/static/js/spec/learner_dashboard/course_card_view_spec.js +++ b/lms/static/js/spec/learner_dashboard/course_card_view_spec.js @@ -80,7 +80,7 @@ define([ ] }; - setupView(course, false); + setupView(course, true); }); afterEach(function() { @@ -91,12 +91,6 @@ define([ expect(view).toBeDefined(); }); - it('should render the course card based on the data enrolled', function() { - view.remove(); - setupView(course, true); - validateCourseInfoDisplay(); - }); - it('should render final grade if course is completed', function() { view.remove(); setupView(course, true); @@ -110,10 +104,13 @@ define([ }); it('should render the course card based on the data not enrolled', function() { + view.remove(); + setupView(course, false); validateCourseInfoDisplay(); }); it('should update render if the course card is_enrolled updated', function() { + setupView(course, false); courseCardModel.set({ is_enrolled: true }); @@ -216,25 +213,30 @@ define([ expect(view.$('.enrollment-opens').length).toEqual(0); }); - it('should link to the marketing site when a URL is available', function() { + it('should link to the marketing site when the user is not enrolled', function() { + setupView(course, false); expect(view.$('.course-title-link').attr('href')).toEqual(course.course_runs[0].marketing_url); }); - it('should link to the course home when no marketing URL is available', function() { - course.course_runs[0].marketing_url = null; - setupView(course, false); - + it('should link to the course home when the user is enrolled', function() { + setupView(course, true); expect(view.$('.course-title-link').attr('href')).toEqual(course.course_runs[0].course_url); }); - it('should not link to the marketing site or the course home if neither URL is available', function() { + it('should not link to the marketing site if the URL is not available', function() { course.course_runs[0].marketing_url = null; - course.course_runs[0].course_url = null; setupView(course, false); expect(view.$('.course-title-link').length).toEqual(0); }); + it('should not link to the course home if the URL is not available', function() { + course.course_runs[0].course_url = null; + setupView(course, true); + + expect(view.$('.course-title-link').length).toEqual(0); + }); + it('should show an unfulfilled user entitlement allows you to select a session', function() { course.user_entitlement = { uuid: '99fc7414c36d4f56b37e8e30acf4c7ba', diff --git a/lms/templates/learner_dashboard/course_card.underscore b/lms/templates/learner_dashboard/course_card.underscore index 7cc2df61b2..f15b7c4881 100644 --- a/lms/templates/learner_dashboard/course_card.underscore +++ b/lms/templates/learner_dashboard/course_card.underscore @@ -3,8 +3,8 @@
- <% if ( (marketing_url || course_url) && !is_unfulfilled_entitlement) { %> - + <% if (course_title_link) { %> + <%- title %> <% } else { %>