-
-
- <%- org %> -
- <%- content.number %> -
- <%- gettext("Starts") %> -
diff --git a/lms/djangoapps/learner_dashboard/views.py b/lms/djangoapps/learner_dashboard/views.py index 22b9e1f91f..b7464df342 100644 --- a/lms/djangoapps/learner_dashboard/views.py +++ b/lms/djangoapps/learner_dashboard/views.py @@ -1,5 +1,4 @@ """Learner dashboard views""" -import waffle from django.contrib.auth.decorators import login_required from django.core.urlresolvers import reverse from django.http import Http404 @@ -67,6 +66,7 @@ def program_details(request, program_uuid): 'commerce_api_url': reverse('commerce_api:v0:baskets:create'), } + # TODO: Tighten this up! context = { 'urls': urls, 'show_program_listing': programs_config.enabled, @@ -76,20 +76,15 @@ def program_details(request, program_uuid): 'user_preferences': get_user_preferences(request.user) } - if waffle.switch_is_active('new_program_progress'): - course_data = meter.progress(programs=[program_data], count_only=False)[0] - certificate_data = get_certificates(request.user, program_data) + course_data = meter.progress(programs=[program_data], count_only=False)[0] + certificate_data = get_certificates(request.user, program_data) - program_data.pop('courses') + program_data.pop('courses') - context.update({ - 'program_data': program_data, - 'course_data': course_data, - 'certificate_data': certificate_data, - }) + context.update({ + 'program_data': program_data, + 'course_data': course_data, + 'certificate_data': certificate_data, + }) - return render_to_response('learner_dashboard/program_details_2017.html', context) - else: - context.update({'program_data': program_data}) - - return render_to_response('learner_dashboard/program_details.html', context) + return render_to_response('learner_dashboard/program_details.html', context) 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 45d8fcb835..547d225d7d 100644 --- a/lms/static/js/learner_dashboard/models/course_card_model.js +++ b/lms/static/js/learner_dashboard/models/course_card_model.js @@ -42,22 +42,12 @@ getUnselectedCourseRun: function(courseRuns) { var unselectedRun = {}, - courseRun, - courseImageUrl; + courseRun; if (courseRuns && courseRuns.length > 0) { courseRun = courseRuns[0]; - if (courseRun.image && courseRun.image.src) { - courseImageUrl = courseRun.image.src; - } else { - // The course_image_url property is attached by setActiveCourseRun. - // If that hasn't been called, it won't be present yet. - courseImageUrl = courseRun.course_image_url; - } - $.extend(unselectedRun, { - course_image_url: courseImageUrl, marketing_url: courseRun.marketing_url, is_enrollment_open: courseRun.is_enrollment_open }); @@ -149,8 +139,8 @@ formatDateString: function(run) { var pacingType = run.pacing_type, dateString = '', - start = run.start_date || this.get('start_date'), - end = run.end_date || this.get('end_date'), + start = this.get('start_date') || run.start_date, + end = this.get('end_date') || run.end_date, now = new Date(), startDate = new Date(start), endDate = new Date(end); @@ -181,8 +171,7 @@ }, setActiveCourseRun: function(courseRun, userPreferences) { - var startDateString, - courseImageUrl; + var startDateString; if (courseRun) { if (this.valueIsDefined(courseRun.advertised_start)) { @@ -191,16 +180,8 @@ startDateString = this.formatDate(courseRun.start, userPreferences); } - if (courseRun.image && courseRun.image.src) { - courseImageUrl = courseRun.image.src; - } else { - courseImageUrl = courseRun.course_image_url; - } - - this.set({ certificate_url: courseRun.certificate_url, - course_image_url: courseImageUrl || '', course_run_key: courseRun.key, course_url: courseRun.course_url || '', title: this.context.title, diff --git a/lms/static/js/learner_dashboard/program_details_factory_2017.js b/lms/static/js/learner_dashboard/program_details_factory_2017.js deleted file mode 100644 index 1478081179..0000000000 --- a/lms/static/js/learner_dashboard/program_details_factory_2017.js +++ /dev/null @@ -1,13 +0,0 @@ -(function(define) { - 'use strict'; - - define([ - 'js/learner_dashboard/views/program_details_view_2017' - ], - function(ProgramDetailsView) { - return function(options) { - var ProgramDetails = new ProgramDetailsView(options); - return ProgramDetails; - }; - }); -}).call(this, define || RequireJS.define); diff --git a/lms/static/js/learner_dashboard/views/certificate_status_view.js b/lms/static/js/learner_dashboard/views/certificate_status_view.js index a0680af0be..ccdfcec226 100644 --- a/lms/static/js/learner_dashboard/views/certificate_status_view.js +++ b/lms/static/js/learner_dashboard/views/certificate_status_view.js @@ -1,13 +1,13 @@ (function(define) { 'use strict'; define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/certificate_status.underscore', - 'text!../../../templates/learner_dashboard/certificate_icon.underscore' - ], + 'jquery', + 'underscore', + 'gettext', + 'edx-ui-toolkit/js/utils/html-utils', + 'text!../../../templates/learner_dashboard/certificate_status.underscore', + 'text!../../../templates/learner_dashboard/certificate_icon.underscore' + ], function( Backbone, $, diff --git a/lms/static/js/learner_dashboard/views/certificate_status_view_2017.js b/lms/static/js/learner_dashboard/views/certificate_status_view_2017.js deleted file mode 100644 index 4b9784b08a..0000000000 --- a/lms/static/js/learner_dashboard/views/certificate_status_view_2017.js +++ /dev/null @@ -1,38 +0,0 @@ -(function(define) { - 'use strict'; - define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/certificate_status_2017.underscore', - 'text!../../../templates/learner_dashboard/certificate_icon.underscore' - ], - function( - Backbone, - $, - _, - gettext, - HtmlUtils, - certificateStatusTpl, - certificateIconTpl - ) { - return Backbone.View.extend({ - statusTpl: HtmlUtils.template(certificateStatusTpl), - iconTpl: HtmlUtils.template(certificateIconTpl), - - initialize: function(options) { - this.$el = options.$el; - this.render(); - }, - - render: function() { - var data = this.model.toJSON(); - - data = $.extend(data, {certificateSvg: this.iconTpl()}); - HtmlUtils.setHtml(this.$el, this.statusTpl(data)); - } - }); - } - ); -}).call(this, define || RequireJS.define); diff --git a/lms/static/js/learner_dashboard/views/course_card_view.js b/lms/static/js/learner_dashboard/views/course_card_view.js index 5acd0c9de0..db7cf04bc2 100644 --- a/lms/static/js/learner_dashboard/views/course_card_view.js +++ b/lms/static/js/learner_dashboard/views/course_card_view.js @@ -2,16 +2,17 @@ 'use strict'; define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'js/learner_dashboard/models/course_enroll_model', - 'js/learner_dashboard/views/upgrade_message_view', - 'js/learner_dashboard/views/certificate_status_view', - 'js/learner_dashboard/views/course_enroll_view', - 'text!../../../templates/learner_dashboard/course_card.underscore' - ], + 'jquery', + 'underscore', + 'gettext', + 'edx-ui-toolkit/js/utils/html-utils', + 'js/learner_dashboard/models/course_enroll_model', + 'js/learner_dashboard/views/upgrade_message_view', + 'js/learner_dashboard/views/certificate_status_view', + 'js/learner_dashboard/views/expired_notification_view', + 'js/learner_dashboard/views/course_enroll_view', + 'text!../../../templates/learner_dashboard/course_card.underscore' + ], function( Backbone, $, @@ -21,33 +22,39 @@ EnrollModel, UpgradeMessageView, CertificateStatusView, + ExpiredNotificationView, CourseEnrollView, pageTpl ) { return Backbone.View.extend({ - className: 'course-card card', + className: 'program-course-card', tpl: HtmlUtils.template(pageTpl), initialize: function(options) { this.enrollModel = new EnrollModel(); - if (options.context && options.context.urls) { + if (options.context) { this.urlModel = new Backbone.Model(options.context.urls); this.enrollModel.urlRoot = this.urlModel.get('commerce_api_url'); } + this.context = options.context || {}; this.render(); this.listenTo(this.model, 'change', this.render); }, render: function() { - var filledTemplate = this.tpl(this.model.toJSON()); - HtmlUtils.setHtml(this.$el, filledTemplate); + var data = $.extend(this.model.toJSON(), { + enrolled: this.context.enrolled || '' + }); + HtmlUtils.setHtml(this.$el, this.tpl(data)); this.postRender(); }, postRender: function() { var $upgradeMessage = this.$('.upgrade-message'), - $certStatus = this.$('.certificate-status'); + $certStatus = this.$('.certificate-status'), + $expiredNotification = this.$('.expired-notification'), + expired = this.model.get('expired'); this.enrollView = new CourseEnrollView({ $parentEl: this.$('.course-actions'), @@ -56,14 +63,14 @@ enrollModel: this.enrollModel }); - if (this.model.get('upgrade_url')) { + if (this.model.get('upgrade_url') && !(expired === true)) { this.upgradeMessage = new UpgradeMessageView({ $el: $upgradeMessage, model: this.model }); $certStatus.remove(); - } else if (this.model.get('certificate_url')) { + } else if (this.model.get('certificate_url') && !(expired === true)) { this.certificateStatus = new CertificateStatusView({ $el: $certStatus, model: this.model @@ -75,6 +82,13 @@ $upgradeMessage.remove(); $certStatus.remove(); } + + if (expired) { + this.expiredNotification = new ExpiredNotificationView({ + $el: $expiredNotification, + model: this.model + }); + } } }); } diff --git a/lms/static/js/learner_dashboard/views/course_card_view_2017.js b/lms/static/js/learner_dashboard/views/course_card_view_2017.js deleted file mode 100644 index 1b4d376ba5..0000000000 --- a/lms/static/js/learner_dashboard/views/course_card_view_2017.js +++ /dev/null @@ -1,96 +0,0 @@ -(function(define) { - 'use strict'; - - define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'js/learner_dashboard/models/course_enroll_model', - 'js/learner_dashboard/views/upgrade_message_view_2017', - 'js/learner_dashboard/views/certificate_status_view_2017', - 'js/learner_dashboard/views/expired_notification_view', - 'js/learner_dashboard/views/course_enroll_view_2017', - 'text!../../../templates/learner_dashboard/course_card_2017.underscore' - ], - function( - Backbone, - $, - _, - gettext, - HtmlUtils, - EnrollModel, - UpgradeMessageView, - CertificateStatusView, - ExpiredNotificationView, - CourseEnrollView, - pageTpl - ) { - return Backbone.View.extend({ - className: 'program-course-card', - - tpl: HtmlUtils.template(pageTpl), - - initialize: function(options) { - this.enrollModel = new EnrollModel(); - if (options.context) { - this.urlModel = new Backbone.Model(options.context.urls); - this.enrollModel.urlRoot = this.urlModel.get('commerce_api_url'); - } - this.context = options.context || {}; - this.render(); - this.listenTo(this.model, 'change', this.render); - }, - - render: function() { - var data = $.extend(this.model.toJSON(), { - enrolled: this.context.enrolled || '' - }); - HtmlUtils.setHtml(this.$el, this.tpl(data)); - this.postRender(); - }, - - postRender: function() { - var $upgradeMessage = this.$('.upgrade-message'), - $certStatus = this.$('.certificate-status'), - $expiredNotification = this.$('.expired-notification'), - expired = this.model.get('expired'); - - this.enrollView = new CourseEnrollView({ - $parentEl: this.$('.course-actions'), - model: this.model, - urlModel: this.urlModel, - enrollModel: this.enrollModel - }); - - if (this.model.get('upgrade_url') && !(expired === true)) { - this.upgradeMessage = new UpgradeMessageView({ - $el: $upgradeMessage, - model: this.model - }); - - $certStatus.remove(); - } else if (this.model.get('certificate_url') && !(expired === true)) { - this.certificateStatus = new CertificateStatusView({ - $el: $certStatus, - model: this.model - }); - - $upgradeMessage.remove(); - } else { - // Styles are applied to these elements which will be visible if they're empty. - $upgradeMessage.remove(); - $certStatus.remove(); - } - - if (expired) { - this.expiredNotification = new ExpiredNotificationView({ - $el: $expiredNotification, - model: this.model - }); - } - } - }); - } - ); -}).call(this, define || RequireJS.define); diff --git a/lms/static/js/learner_dashboard/views/course_enroll_view.js b/lms/static/js/learner_dashboard/views/course_enroll_view.js index c66211fb37..606b85e75f 100644 --- a/lms/static/js/learner_dashboard/views/course_enroll_view.js +++ b/lms/static/js/learner_dashboard/views/course_enroll_view.js @@ -2,12 +2,12 @@ 'use strict'; define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/course_enroll.underscore' - ], + 'jquery', + 'underscore', + 'gettext', + 'edx-ui-toolkit/js/utils/html-utils', + 'text!../../../templates/learner_dashboard/course_enroll.underscore' + ], function( Backbone, $, @@ -17,11 +17,12 @@ pageTpl ) { return Backbone.View.extend({ + className: 'course-enroll-view', + tpl: HtmlUtils.template(pageTpl), events: { - 'click .enroll-button': 'handleEnroll', - 'change .run-select': 'handleCourseRunSelect' + 'click .enroll-button': 'handleEnroll' }, initialize: function(options) { @@ -29,9 +30,6 @@ this.enrollModel = options.enrollModel; this.urlModel = options.urlModel; this.render(); - if (this.urlModel) { - this.trackSelectionUrl = this.urlModel.get('track_selection_url'); - } }, render: function() { @@ -41,16 +39,23 @@ HtmlUtils.setHtml(this.$el, filledTemplate); HtmlUtils.setHtml(this.$parentEl, HtmlUtils.HTML(this.$el)); } + this.postRender(); + }, + + postRender: function() { + if (this.urlModel) { + this.trackSelectionUrl = this.urlModel.get('track_selection_url'); + } }, handleEnroll: function() { - // Enrollment click event handled here - if (!this.model.get('course_run_key')) { - this.$('.select-error').css('visibility', 'visible'); - } else if (!this.model.get('is_enrolled')) { + // Enrollment click event handled here + var courseRunKey = $('.run-select').val() || this.model.get('course_run_key'); + this.model.updateCourseRun(courseRunKey); + if (!this.model.get('is_enrolled')) { // Create the enrollment. this.enrollModel.save({ - course_id: this.model.get('course_run_key') + course_id: courseRunKey }, { success: _.bind(this.enrollSuccess, this), error: _.bind(this.enrollError, this) @@ -58,19 +63,9 @@ } }, - handleCourseRunSelect: function(event) { - var courseRunKey = $(event.target).val(); - - if (courseRunKey) { - this.model.updateCourseRun(courseRunKey); - } else { - // Set back the unselected states - this.model.setUnselected(); - } - }, - enrollSuccess: function() { var courseRunKey = this.model.get('course_run_key'); + window.analytics.track('edx.bi.user.program-details.enrollment'); if (this.trackSelectionUrl) { // Go to track selection page this.redirect(this.trackSelectionUrl + courseRunKey); diff --git a/lms/static/js/learner_dashboard/views/course_enroll_view_2017.js b/lms/static/js/learner_dashboard/views/course_enroll_view_2017.js deleted file mode 100644 index c5a2a8db5e..0000000000 --- a/lms/static/js/learner_dashboard/views/course_enroll_view_2017.js +++ /dev/null @@ -1,104 +0,0 @@ -(function(define) { - 'use strict'; - - define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/course_enroll_2017.underscore' - ], - function( - Backbone, - $, - _, - gettext, - HtmlUtils, - pageTpl - ) { - return Backbone.View.extend({ - className: 'course-enroll-view', - - tpl: HtmlUtils.template(pageTpl), - - events: { - 'click .enroll-button': 'handleEnroll' - }, - - initialize: function(options) { - this.$parentEl = options.$parentEl; - this.enrollModel = options.enrollModel; - this.urlModel = options.urlModel; - this.render(); - }, - - render: function() { - var filledTemplate; - if (this.$parentEl && this.enrollModel) { - filledTemplate = this.tpl(this.model.toJSON()); - HtmlUtils.setHtml(this.$el, filledTemplate); - HtmlUtils.setHtml(this.$parentEl, HtmlUtils.HTML(this.$el)); - } - this.postRender(); - }, - - postRender: function() { - if (this.urlModel) { - this.trackSelectionUrl = this.urlModel.get('track_selection_url'); - } - }, - - handleEnroll: function() { - // Enrollment click event handled here - var courseRunKey = $('.run-select').val() || this.model.get('course_run_key'); - this.model.updateCourseRun(courseRunKey); - if (!this.model.get('is_enrolled')) { - // Create the enrollment. - this.enrollModel.save({ - course_id: courseRunKey - }, { - success: _.bind(this.enrollSuccess, this), - error: _.bind(this.enrollError, this) - }); - } - }, - - enrollSuccess: function() { - var courseRunKey = this.model.get('course_run_key'); - window.analytics.track('edx.bi.user.program-details.enrollment'); - if (this.trackSelectionUrl) { - // Go to track selection page - this.redirect(this.trackSelectionUrl + courseRunKey); - } else { - this.model.set({ - is_enrolled: true - }); - } - }, - - enrollError: function(model, response) { - if (response.status === 403 && response.responseJSON.user_message_url) { - /** - * Check if we've been blocked from the course - * because of country access rules. - * If so, redirect to a page explaining to the user - * why they were blocked. - */ - this.redirect(response.responseJSON.user_message_url); - } else if (this.trackSelectionUrl) { - /** - * Otherwise, go to the track selection page as usual. - * This can occur, for example, when a course does not - * have a free enrollment mode, so we can't auto-enroll. - */ - this.redirect(this.trackSelectionUrl + this.model.get('course_run_key')); - } - }, - - redirect: function(url) { - window.location.href = url; - } - }); - } - ); -}).call(this, define || RequireJS.define); diff --git a/lms/static/js/learner_dashboard/views/program_details_view.js b/lms/static/js/learner_dashboard/views/program_details_view.js index afb267669a..442a98a6b8 100644 --- a/lms/static/js/learner_dashboard/views/program_details_view.js +++ b/lms/static/js/learner_dashboard/views/program_details_view.js @@ -1,17 +1,17 @@ (function(define) { 'use strict'; - define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'js/learner_dashboard/collections/course_card_collection', - 'js/learner_dashboard/views/program_header_view', - 'js/learner_dashboard/views/collection_list_view', - 'js/learner_dashboard/views/course_card_view', - 'text!../../../templates/learner_dashboard/program_details_view.underscore' - ], + 'jquery', + 'underscore', + 'gettext', + 'edx-ui-toolkit/js/utils/html-utils', + 'js/learner_dashboard/collections/course_card_collection', + 'js/learner_dashboard/views/program_header_view', + 'js/learner_dashboard/views/collection_list_view', + 'js/learner_dashboard/views/course_card_view', + 'js/learner_dashboard/views/program_details_sidebar_view', + 'text!../../../templates/learner_dashboard/program_details_view.underscore' + ], function( Backbone, $, @@ -22,6 +22,7 @@ HeaderView, CollectionListView, CourseCardView, + SidebarView, pageTpl ) { return Backbone.View.extend({ @@ -32,15 +33,37 @@ initialize: function(options) { this.options = options; this.programModel = new Backbone.Model(this.options.programData); - this.courseCardCollection = new CourseCardCollection( - this.programModel.get('courses'), + this.courseData = new Backbone.Model(this.options.courseData); + this.certificateCollection = new Backbone.Collection(this.options.certificateData); + this.completedCourseCollection = new CourseCardCollection( + this.courseData.get('completed') || [], this.options.userPreferences - ); + ); + this.inProgressCourseCollection = new CourseCardCollection( + this.courseData.get('in_progress') || [], + this.options.userPreferences + ); + this.remainingCourseCollection = new CourseCardCollection( + this.courseData.get('not_started') || [], + this.options.userPreferences + ); + this.render(); }, render: function() { - HtmlUtils.setHtml(this.$el, this.tpl()); + var completedCount = this.completedCourseCollection.length, + inProgressCount = this.inProgressCourseCollection.length, + remainingCount = this.remainingCourseCollection.length, + totalCount = completedCount + inProgressCount + remainingCount, + data = { + totalCount: totalCount, + inProgressCount: inProgressCount, + remainingCount: remainingCount, + completedCount: completedCount + }; + data = $.extend(data, this.programModel.toJSON()); + HtmlUtils.setHtml(this.$el, this.tpl(data)); this.postRender(); }, @@ -48,16 +71,41 @@ this.headerView = new HeaderView({ model: new Backbone.Model(this.options) }); - new CollectionListView({ - el: '.js-course-list', - childView: CourseCardView, - collection: this.courseCardCollection, - context: this.options, - titleContext: { - el: 'h2', - title: 'Course List' - } - }).render(); + + if (this.remainingCourseCollection.length > 0) { + new CollectionListView({ + el: '.js-course-list-remaining', + childView: CourseCardView, + collection: this.remainingCourseCollection, + context: this.options + }).render(); + } + + if (this.completedCourseCollection.length > 0) { + new CollectionListView({ + el: '.js-course-list-completed', + childView: CourseCardView, + collection: this.completedCourseCollection, + context: this.options + }).render(); + } + + if (this.inProgressCourseCollection.length > 0) { + // This is last because the context is modified below + new CollectionListView({ + el: '.js-course-list-in-progress', + childView: CourseCardView, + collection: this.inProgressCourseCollection, + context: $.extend(this.options, {enrolled: gettext('Enrolled')}) + }).render(); + } + + this.sidebarView = new SidebarView({ + el: '.js-program-sidebar', + model: this.programModel, + courseModel: this.courseData, + certificateCollection: this.certificateCollection + }); } }); } diff --git a/lms/static/js/learner_dashboard/views/program_details_view_2017.js b/lms/static/js/learner_dashboard/views/program_details_view_2017.js deleted file mode 100644 index e4e0a8c1a5..0000000000 --- a/lms/static/js/learner_dashboard/views/program_details_view_2017.js +++ /dev/null @@ -1,113 +0,0 @@ -(function(define) { - 'use strict'; - define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'js/learner_dashboard/collections/course_card_collection', - 'js/learner_dashboard/views/program_header_view_2017', - 'js/learner_dashboard/views/collection_list_view', - 'js/learner_dashboard/views/course_card_view_2017', - 'js/learner_dashboard/views/program_details_sidebar_view', - 'text!../../../templates/learner_dashboard/program_details_view_2017.underscore' - ], - function( - Backbone, - $, - _, - gettext, - HtmlUtils, - CourseCardCollection, - HeaderView, - CollectionListView, - CourseCardView, - SidebarView, - pageTpl - ) { - return Backbone.View.extend({ - el: '.js-program-details-wrapper', - - tpl: HtmlUtils.template(pageTpl), - - initialize: function(options) { - this.options = options; - this.programModel = new Backbone.Model(this.options.programData); - this.courseData = new Backbone.Model(this.options.courseData); - this.certificateCollection = new Backbone.Collection(this.options.certificateData); - this.completedCourseCollection = new CourseCardCollection( - this.courseData.get('completed') || [], - this.options.userPreferences - ); - this.inProgressCourseCollection = new CourseCardCollection( - this.courseData.get('in_progress') || [], - this.options.userPreferences - ); - this.remainingCourseCollection = new CourseCardCollection( - this.courseData.get('not_started') || [], - this.options.userPreferences - ); - - this.render(); - }, - - render: function() { - var completedCount = this.completedCourseCollection.length, - inProgressCount = this.inProgressCourseCollection.length, - remainingCount = this.remainingCourseCollection.length, - totalCount = completedCount + inProgressCount + remainingCount, - data = { - totalCount: totalCount, - inProgressCount: inProgressCount, - remainingCount: remainingCount, - completedCount: completedCount - }; - data = $.extend(data, this.programModel.toJSON()); - HtmlUtils.setHtml(this.$el, this.tpl(data)); - this.postRender(); - }, - - postRender: function() { - this.headerView = new HeaderView({ - model: new Backbone.Model(this.options) - }); - - if (this.remainingCourseCollection.length > 0) { - new CollectionListView({ - el: '.js-course-list-remaining', - childView: CourseCardView, - collection: this.remainingCourseCollection, - context: this.options - }).render(); - } - - if (this.completedCourseCollection.length > 0) { - new CollectionListView({ - el: '.js-course-list-completed', - childView: CourseCardView, - collection: this.completedCourseCollection, - context: this.options - }).render(); - } - - if (this.inProgressCourseCollection.length > 0) { - // This is last because the context is modified below - new CollectionListView({ - el: '.js-course-list-in-progress', - childView: CourseCardView, - collection: this.inProgressCourseCollection, - context: $.extend(this.options, {enrolled: gettext('Enrolled')}) - }).render(); - } - - this.sidebarView = new SidebarView({ - el: '.js-program-sidebar', - model: this.programModel, - courseModel: this.courseData, - certificateCollection: this.certificateCollection - }); - } - }); - } - ); -}).call(this, define || RequireJS.define); diff --git a/lms/static/js/learner_dashboard/views/program_header_view.js b/lms/static/js/learner_dashboard/views/program_header_view.js index b0f0933533..2138140cc5 100644 --- a/lms/static/js/learner_dashboard/views/program_header_view.js +++ b/lms/static/js/learner_dashboard/views/program_header_view.js @@ -2,17 +2,20 @@ 'use strict'; define(['backbone', - 'jquery', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/program_header_view.underscore', - 'picturefill' - ], - function(Backbone, $, HtmlUtils, pageTpl, picturefill) { + 'jquery', + 'edx-ui-toolkit/js/utils/html-utils', + 'text!../../../templates/learner_dashboard/program_header_view.underscore', + 'text!../../../images/programs/micromasters-program-details.svg', + 'text!../../../images/programs/xseries-program-details.svg', + 'text!../../../images/programs/professional-certificate-program-details.svg' + ], + function(Backbone, $, HtmlUtils, pageTpl, MicroMastersLogo, + XSeriesLogo, ProfessionalCertificateLogo) { return Backbone.View.extend({ breakpoints: { min: { - 'medium': '768px', - 'large': '1180px' + medium: '768px', + large: '1180px' } }, @@ -24,32 +27,29 @@ this.render(); }, + getLogo: function() { + var logo = false, + type = this.model.get('programData').type; + + if (type === 'MicroMasters') { + logo = MicroMastersLogo; + } else if (type === 'XSeries') { + logo = XSeriesLogo; + } else if (type === 'Professional Certificate') { + logo = ProfessionalCertificateLogo; + } + return logo; + }, + render: function() { var data = $.extend(this.model.toJSON(), { - breakpoints: this.breakpoints + breakpoints: this.breakpoints, + logo: this.getLogo() }); if (this.model.get('programData')) { HtmlUtils.setHtml(this.$el, this.tpl(data)); - this.postRender(); } - }, - - postRender: function() { - // To resolve a bug in IE with picturefill reevaluate images - if (navigator.userAgent.indexOf('MSIE') !== -1 || - navigator.appVersion.indexOf('Trident/') > 0) { - /* Microsoft Internet Explorer detected in. */ - window.setTimeout(function() { - this.reEvaluatePicture(); - }.bind(this), 100); - } - }, - - reEvaluatePicture: function() { - picturefill({ - reevaluate: true - }); } }); } diff --git a/lms/static/js/learner_dashboard/views/program_header_view_2017.js b/lms/static/js/learner_dashboard/views/program_header_view_2017.js deleted file mode 100644 index 78606ad54f..0000000000 --- a/lms/static/js/learner_dashboard/views/program_header_view_2017.js +++ /dev/null @@ -1,57 +0,0 @@ -(function(define) { - 'use strict'; - - define(['backbone', - 'jquery', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/program_header_view_2017.underscore', - 'text!../../../images/programs/micromasters-program-details.svg', - 'text!../../../images/programs/xseries-program-details.svg', - 'text!../../../images/programs/professional-certificate-program-details.svg' - ], - function(Backbone, $, HtmlUtils, pageTpl, MicroMastersLogo, - XSeriesLogo, ProfessionalCertificateLogo) { - return Backbone.View.extend({ - breakpoints: { - min: { - medium: '768px', - large: '1180px' - } - }, - - el: '.js-program-header', - - tpl: HtmlUtils.template(pageTpl), - - initialize: function() { - this.render(); - }, - - getLogo: function() { - var logo = false, - type = this.model.get('programData').type; - - if (type === 'MicroMasters') { - logo = MicroMastersLogo; - } else if (type === 'XSeries') { - logo = XSeriesLogo; - } else if (type === 'Professional Certificate') { - logo = ProfessionalCertificateLogo; - } - return logo; - }, - - render: function() { - var data = $.extend(this.model.toJSON(), { - breakpoints: this.breakpoints, - logo: this.getLogo() - }); - - if (this.model.get('programData')) { - HtmlUtils.setHtml(this.$el, this.tpl(data)); - } - } - }); - } - ); -}).call(this, define || RequireJS.define); diff --git a/lms/static/js/learner_dashboard/views/upgrade_message_view.js b/lms/static/js/learner_dashboard/views/upgrade_message_view.js index 5f6012374d..c57f91d122 100644 --- a/lms/static/js/learner_dashboard/views/upgrade_message_view.js +++ b/lms/static/js/learner_dashboard/views/upgrade_message_view.js @@ -1,25 +1,22 @@ (function(define) { 'use strict'; define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/upgrade_message.underscore', - 'text!../../../templates/learner_dashboard/certificate_icon.underscore' - ], + 'jquery', + 'underscore', + 'gettext', + 'edx-ui-toolkit/js/utils/html-utils', + 'text!../../../templates/learner_dashboard/upgrade_message.underscore' + ], function( Backbone, $, _, gettext, HtmlUtils, - upgradeMessageTpl, - certificateIconTpl + upgradeMessageTpl ) { return Backbone.View.extend({ messageTpl: HtmlUtils.template(upgradeMessageTpl), - iconTpl: HtmlUtils.template(certificateIconTpl), initialize: function(options) { this.$el = options.$el; @@ -29,7 +26,6 @@ render: function() { var data = this.model.toJSON(); - data = $.extend(data, {certificateSvg: this.iconTpl()}); HtmlUtils.setHtml(this.$el, this.messageTpl(data)); } }); diff --git a/lms/static/js/learner_dashboard/views/upgrade_message_view_2017.js b/lms/static/js/learner_dashboard/views/upgrade_message_view_2017.js deleted file mode 100644 index 53f94793ee..0000000000 --- a/lms/static/js/learner_dashboard/views/upgrade_message_view_2017.js +++ /dev/null @@ -1,34 +0,0 @@ -(function(define) { - 'use strict'; - define(['backbone', - 'jquery', - 'underscore', - 'gettext', - 'edx-ui-toolkit/js/utils/html-utils', - 'text!../../../templates/learner_dashboard/upgrade_message_2017.underscore' - ], - function( - Backbone, - $, - _, - gettext, - HtmlUtils, - upgradeMessageTpl - ) { - return Backbone.View.extend({ - messageTpl: HtmlUtils.template(upgradeMessageTpl), - - initialize: function(options) { - this.$el = options.$el; - this.render(); - }, - - render: function() { - var data = this.model.toJSON(); - - HtmlUtils.setHtml(this.$el, this.messageTpl(data)); - } - }); - } - ); -}).call(this, define || RequireJS.define); 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 019ac5b7ff..4c0acf023c 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 @@ -17,7 +17,7 @@ define([ var programData = $.extend({}, data); programData.course_runs[0].is_enrolled = isEnrolled; - setFixtures('
'); + setFixtures(''); courseCardModel = new CourseCardModel(programData); view = new CourseCardView({ model: courseCardModel @@ -26,12 +26,10 @@ define([ validateCourseInfoDisplay = function() { // DRY validation for course card in enrolled state - expect(view.$('.header-img').attr('src')).toEqual(course.course_runs[0].image.src); expect(view.$('.course-details .course-title-link').text().trim()).toEqual(course.title); expect(view.$('.course-details .course-title-link').attr('href')).toEqual( course.course_runs[0].marketing_url ); - expect(view.$('.course-details .course-text .course-key').html()).toEqual(course.key); expect(view.$('.course-details .course-text .run-period').html()).toEqual( startDate + ' - ' + endDate ); @@ -99,7 +97,9 @@ define([ it('should show the course advertised start date', function() { var advertisedStart = 'A long time ago...'; course.course_runs[0].advertised_start = advertisedStart; + setupView(course, false); + expect(view.$('.course-details .course-text .run-period').html()).toEqual( advertisedStart + ' - ' + endDate ); @@ -108,13 +108,12 @@ define([ it('should only show certificate status section if a certificate has been earned', function() { var certUrl = 'sample-certificate'; - expect(view.$('.certificate-status').length).toEqual(0); + expect(view.$('.course-certificate .certificate-status').length).toEqual(0); view.remove(); course.course_runs[0].certificate_url = certUrl; setupView(course, false); - expect(view.$('.certificate-status').length).toEqual(1); - expect(view.$('.certificate-status .cta-secondary').attr('href')).toEqual(certUrl); + expect(view.$('.course-certificate .certificate-status').length).toEqual(1); }); it('should only show upgrade message section if an upgrade is required', function() { @@ -135,7 +134,7 @@ define([ course.course_runs[0].certificate_url = ''; setupView(course, false); expect(view.$('.upgrade-message').length).toEqual(0); - expect(view.$('.certificate-status').length).toEqual(0); + expect(view.$('.course-certificate .certificate-status').length).toEqual(0); view.remove(); // Verify that the upgrade message takes priority. @@ -143,7 +142,7 @@ define([ course.course_runs[0].certificate_url = '/path/to/certificate'; setupView(course, false); expect(view.$('.upgrade-message').length).toEqual(1); - expect(view.$('.certificate-status').length).toEqual(0); + expect(view.$('.course-certificate .certificate-status').length).toEqual(0); }); it('should show a message if an there is an upcoming course run', function() { @@ -151,9 +150,7 @@ define([ setupView(course, false); - expect(view.$('.header-img').attr('src')).toEqual(course.course_runs[0].image.src); expect(view.$('.course-details .course-title').text().trim()).toEqual(course.title); - expect(view.$('.course-details .course-text .course-key').html()).toEqual(course.key); expect(view.$('.course-details .course-text .run-period').length).toBe(0); expect(view.$('.no-action-message').text().trim()).toBe('Coming Soon'); expect(view.$('.enrollment-open-date').text().trim()).toEqual( @@ -167,27 +164,21 @@ define([ setupView(course, false); - expect(view.$('.header-img').attr('src')).toEqual(course.course_runs[0].image.src); expect(view.$('.course-details .course-title').text().trim()).toEqual(course.title); - expect(view.$('.course-details .course-text .course-key').html()).toEqual(course.key); expect(view.$('.course-details .course-text .run-period').length).toBe(0); expect(view.$('.no-action-message').text().trim()).toBe('Not Currently Available'); expect(view.$('.enrollment-opens').length).toEqual(0); }); it('should link to the marketing site when a URL is available', function() { - $.each(['.course-image-link', '.course-title-link'], function(index, selector) { - expect(view.$(selector).attr('href')).toEqual(course.course_runs[0].marketing_url); - }); + 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); - $.each(['.course-image-link', '.course-title-link'], function(index, selector) { - expect(view.$(selector).attr('href')).toEqual(course.course_runs[0].course_url); - }); + 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() { @@ -195,9 +186,7 @@ define([ course.course_runs[0].course_url = null; setupView(course, false); - $.each(['.course-image-link', '.course-title-link'], function(index, selector) { - expect(view.$(selector).length).toEqual(0); - }); + expect(view.$('.course-title-link').length).toEqual(0); }); }); } diff --git a/lms/static/js/spec/learner_dashboard/course_enroll_view_spec.js b/lms/static/js/spec/learner_dashboard/course_enroll_view_spec.js index c445d38e54..a8cc100879 100644 --- a/lms/static/js/spec/learner_dashboard/course_enroll_view_spec.js +++ b/lms/static/js/spec/learner_dashboard/course_enroll_view_spec.js @@ -33,6 +33,9 @@ define([ }; beforeEach(function() { + // Stub analytics tracking + window.analytics = jasmine.createSpyObj('analytics', ['track']); + // NOTE: This data is redefined prior to each test case so that tests // can't break each other by modifying data copied by reference. singleCourseRunList = [{ @@ -132,8 +135,6 @@ define([ it('should render the course enroll view when not enrolled', function() { setupView(singleCourseRunList); - - expect(view.$('.enrollment-info').html().trim()).toEqual('Not Enrolled'); expect(view.$('.enroll-button').text().trim()).toEqual('Enroll Now'); expect(view.$('.run-select').length).toBe(0); }); @@ -142,24 +143,10 @@ define([ singleCourseRunList[0].is_enrolled = true; setupView(singleCourseRunList); - - expect(view.$('.enrollment-info').html().trim()).toEqual('enrolled'); - expect(view.$('.view-course-link').attr('href')).toEqual(course.course_runs[0].course_url); - expect(view.$('.view-course-link').text().trim()).toEqual('View Course'); + expect(view.$('.view-course-button').text().trim()).toEqual('View Course'); expect(view.$('.run-select').length).toBe(0); }); - it('should allow the learner to view an archived course', function() { - // Regression test for ECOM-4974. - singleCourseRunList[0].is_enrolled = true; - singleCourseRunList[0].is_enrollment_open = false; - singleCourseRunList[0].is_course_ended = true; - - setupView(singleCourseRunList); - - expect(view.$('.view-course-link').text().trim()).toEqual('View Archived Course'); - }); - it('should not render anything if course runs are empty', function() { setupView([]); @@ -172,24 +159,8 @@ define([ setupView(multiCourseRunList); expect(view.$('.run-select').length).toBe(1); - expect(view.$('.run-select').val()).toEqual(''); - expect(view.$('.run-select option').length).toBe(3); - }); - - it('should switch course run context if an option is selected from the dropdown', function() { - setupView(multiCourseRunList); - - spyOn(courseCardModel, 'updateCourseRun').and.callThrough(); - - expect(view.$('.run-select').val()).toEqual(''); - - view.$('.run-select').val(multiCourseRunList[1].key); - view.$('.run-select').trigger('change'); - - expect(view.$('.run-select').val()).toEqual(multiCourseRunList[1].key); - expect(courseCardModel.updateCourseRun) - .toHaveBeenCalledWith(multiCourseRunList[1].key); - expect(courseCardModel.get('course_key')).toEqual(course.key); + expect(view.$('.run-select').val()).toEqual(multiCourseRunList[0].key); + expect(view.$('.run-select option').length).toBe(2); }); it('should enroll learner when enroll button is clicked with one course run available', function() { @@ -304,6 +275,15 @@ define([ response.responseJSON.user_message_url ); }); + + it('sends analytics event when enrollment succeeds', function() { + setupView(singleCourseRunList, urls); + spyOn(view, 'redirect'); + view.enrollSuccess(); + expect(window.analytics.track).toHaveBeenCalledWith( + 'edx.bi.user.program-details.enrollment' + ); + }); }); } ); diff --git a/lms/static/js/spec/learner_dashboard/course_enroll_view_spec_2017.js b/lms/static/js/spec/learner_dashboard/course_enroll_view_spec_2017.js deleted file mode 100644 index a6e8cc0bd2..0000000000 --- a/lms/static/js/spec/learner_dashboard/course_enroll_view_spec_2017.js +++ /dev/null @@ -1,289 +0,0 @@ -define([ - 'backbone', - 'jquery', - 'js/learner_dashboard/models/course_card_model', - 'js/learner_dashboard/models/course_enroll_model', - 'js/learner_dashboard/views/course_enroll_view_2017' -], function(Backbone, $, CourseCardModel, CourseEnrollModel, CourseEnrollView) { - 'use strict'; - - describe('Course Enroll View', function() { - var view = null, - courseCardModel, - courseEnrollModel, - urlModel, - setupView, - singleCourseRunList, - multiCourseRunList, - course = { - key: 'WageningenX+FFESx', - uuid: '9f8562eb-f99b-45c7-b437-799fd0c15b6a', - title: 'Systems thinking and environmental sustainability', - owners: [ - { - uuid: '0c6e5fa2-96e8-40b2-9ebe-c8b0df2a3b22', - key: 'WageningenX', - name: 'Wageningen University & Research' - } - ] - }, - urls = { - commerce_api_url: '/commerce', - track_selection_url: '/select_track/course/' - }; - - beforeEach(function() { - // Stub analytics tracking - window.analytics = jasmine.createSpyObj('analytics', ['track']); - - // NOTE: This data is redefined prior to each test case so that tests - // can't break each other by modifying data copied by reference. - singleCourseRunList = [{ - key: 'course-v1:WageningenX+FFESx+1T2017', - uuid: '2f2edf03-79e6-4e39-aef0-65436a6ee344', - title: 'Food Security and Sustainability: Systems thinking and environmental sustainability', - image: { - src: 'https://example.com/2f2edf03-79e6-4e39-aef0-65436a6ee344.jpg' - }, - marketing_url: 'https://www.edx.org/course/food-security-sustainability-systems-wageningenx-ffesx', - start: '2017-02-28T05:00:00Z', - end: '2017-05-30T23:00:00Z', - enrollment_start: '2017-01-18T00:00:00Z', - enrollment_end: null, - type: 'verified', - certificate_url: '', - course_url: 'https://courses.example.com/courses/course-v1:edX+DemoX+Demo_Course', - enrollment_open_date: 'Jan 18, 2016', - is_course_ended: false, - is_enrolled: false, - is_enrollment_open: true, - upgrade_url: '' - }]; - - multiCourseRunList = [{ - key: 'course-v1:WageningenX+FFESx+2T2016', - uuid: '9bbb7844-4848-44ab-8e20-0be6604886e9', - title: 'Food Security and Sustainability: Systems thinking and environmental sustainability', - image: { - src: 'https://example.com/9bbb7844-4848-44ab-8e20-0be6604886e9.jpg' - }, - short_description: 'Learn how to apply systems thinking to improve food production systems.', - marketing_url: 'https://www.edx.org/course/food-security-sustainability-systems-wageningenx-stesx', - start: '2016-09-08T04:00:00Z', - end: '2016-11-11T00:00:00Z', - enrollment_start: null, - enrollment_end: null, - pacing_type: 'instructor_paced', - type: 'verified', - certificate_url: '', - course_url: 'https://courses.example.com/courses/course-v1:WageningenX+FFESx+2T2016', - enrollment_open_date: 'Jan 18, 2016', - is_course_ended: false, - is_enrolled: false, - is_enrollment_open: true - }, { - key: 'course-v1:WageningenX+FFESx+1T2017', - uuid: '2f2edf03-79e6-4e39-aef0-65436a6ee344', - title: 'Food Security and Sustainability: Systems thinking and environmental sustainability', - image: { - src: 'https://example.com/2f2edf03-79e6-4e39-aef0-65436a6ee344.jpg' - }, - marketing_url: 'https://www.edx.org/course/food-security-sustainability-systems-wageningenx-ffesx', - start: '2017-02-28T05:00:00Z', - end: '2017-05-30T23:00:00Z', - enrollment_start: '2017-01-18T00:00:00Z', - enrollment_end: null, - type: 'verified', - certificate_url: '', - course_url: 'https://courses.example.com/courses/course-v1:WageningenX+FFESx+1T2017', - enrollment_open_date: 'Jan 18, 2016', - is_course_ended: false, - is_enrolled: false, - is_enrollment_open: true - }]; - }); - - setupView = function(courseRuns, urlMap) { - course.course_runs = courseRuns; - setFixtures(''); - courseCardModel = new CourseCardModel(course); - courseEnrollModel = new CourseEnrollModel({}, { - courseId: courseCardModel.get('course_run_key') - }); - if (urlMap) { - urlModel = new Backbone.Model(urlMap); - } - view = new CourseEnrollView({ - $parentEl: $('.course-actions'), - model: courseCardModel, - enrollModel: courseEnrollModel, - urlModel: urlModel - }); - }; - - afterEach(function() { - view.remove(); - urlModel = null; - courseCardModel = null; - courseEnrollModel = null; - }); - - it('should exist', function() { - setupView(singleCourseRunList); - expect(view).toBeDefined(); - }); - - it('should render the course enroll view when not enrolled', function() { - setupView(singleCourseRunList); - expect(view.$('.enroll-button').text().trim()).toEqual('Enroll Now'); - expect(view.$('.run-select').length).toBe(0); - }); - - it('should render the course enroll view when enrolled', function() { - singleCourseRunList[0].is_enrolled = true; - - setupView(singleCourseRunList); - expect(view.$('.view-course-button').text().trim()).toEqual('View Course'); - expect(view.$('.run-select').length).toBe(0); - }); - - it('should not render anything if course runs are empty', function() { - setupView([]); - - expect(view.$('.enrollment-info').length).toBe(0); - expect(view.$('.run-select').length).toBe(0); - expect(view.$('.enroll-button').length).toBe(0); - }); - - it('should render run selection dropdown if multiple course runs are available', function() { - setupView(multiCourseRunList); - - expect(view.$('.run-select').length).toBe(1); - expect(view.$('.run-select').val()).toEqual(multiCourseRunList[0].key); - expect(view.$('.run-select option').length).toBe(2); - }); - - it('should enroll learner when enroll button is clicked with one course run available', function() { - setupView(singleCourseRunList); - - expect(view.$('.enroll-button').length).toBe(1); - - spyOn(courseEnrollModel, 'save'); - - view.$('.enroll-button').click(); - - expect(courseEnrollModel.save).toHaveBeenCalled(); - }); - - it('should enroll learner when enroll button is clicked with multiple course runs available', function() { - setupView(multiCourseRunList); - - spyOn(courseEnrollModel, 'save'); - - view.$('.run-select').val(multiCourseRunList[1].key); - view.$('.run-select').trigger('change'); - view.$('.enroll-button').click(); - - expect(courseEnrollModel.save).toHaveBeenCalled(); - }); - - it('should redirect to track selection when audit enrollment succeeds', function() { - singleCourseRunList[0].is_enrolled = false; - singleCourseRunList[0].mode_slug = 'audit'; - - setupView(singleCourseRunList, urls); - - expect(view.$('.enroll-button').length).toBe(1); - expect(view.trackSelectionUrl).toBeDefined(); - - spyOn(view, 'redirect'); - - view.enrollSuccess(); - - expect(view.redirect).toHaveBeenCalledWith( - view.trackSelectionUrl + courseCardModel.get('course_run_key')); - }); - - it('should redirect to track selection when enrollment in an unspecified mode is attempted', function() { - singleCourseRunList[0].is_enrolled = false; - singleCourseRunList[0].mode_slug = null; - - setupView(singleCourseRunList, urls); - - expect(view.$('.enroll-button').length).toBe(1); - expect(view.trackSelectionUrl).toBeDefined(); - - spyOn(view, 'redirect'); - - view.enrollSuccess(); - - expect(view.redirect).toHaveBeenCalledWith( - view.trackSelectionUrl + courseCardModel.get('course_run_key') - ); - }); - - it('should not redirect when urls are not provided', function() { - singleCourseRunList[0].is_enrolled = false; - singleCourseRunList[0].mode_slug = 'verified'; - - setupView(singleCourseRunList); - - expect(view.$('.enroll-button').length).toBe(1); - expect(view.verificationUrl).not.toBeDefined(); - expect(view.dashboardUrl).not.toBeDefined(); - expect(view.trackSelectionUrl).not.toBeDefined(); - - spyOn(view, 'redirect'); - - view.enrollSuccess(); - - expect(view.redirect).not.toHaveBeenCalled(); - }); - - it('should redirect to track selection on error', function() { - setupView(singleCourseRunList, urls); - - expect(view.$('.enroll-button').length).toBe(1); - expect(view.trackSelectionUrl).toBeDefined(); - - spyOn(view, 'redirect'); - - view.enrollError(courseEnrollModel, {status: 500}); - expect(view.redirect).toHaveBeenCalledWith( - view.trackSelectionUrl + courseCardModel.get('course_run_key') - ); - }); - - it('should redirect to login on 403 error', function() { - var response = { - status: 403, - responseJSON: { - user_message_url: 'redirect/to/this' - } - }; - - setupView(singleCourseRunList, urls); - - expect(view.$('.enroll-button').length).toBe(1); - expect(view.trackSelectionUrl).toBeDefined(); - - spyOn(view, 'redirect'); - - view.enrollError(courseEnrollModel, response); - - expect(view.redirect).toHaveBeenCalledWith( - response.responseJSON.user_message_url - ); - }); - - it('sends analytics event when enrollment succeeds', function() { - setupView(singleCourseRunList, urls); - spyOn(view, 'redirect'); - view.enrollSuccess(); - expect(window.analytics.track).toHaveBeenCalledWith( - 'edx.bi.user.program-details.enrollment' - ); - }); - }); -} -); diff --git a/lms/static/js/spec/learner_dashboard/program_details_header_spec.js b/lms/static/js/spec/learner_dashboard/program_details_header_spec.js index 5d692dd749..7829e0be1e 100644 --- a/lms/static/js/spec/learner_dashboard/program_details_header_spec.js +++ b/lms/static/js/spec/learner_dashboard/program_details_header_spec.js @@ -8,9 +8,6 @@ define([ describe('Program Details Header View', function() { var view = null, context = { - urls: { - program_listing_url: '/dashboard/programs' - }, programData: { uuid: 'a87e5eac-3c93-45a1-a8e1-4c79ca8401c8', title: 'Food Security and Sustainability', @@ -68,16 +65,12 @@ define([ }); it('should render the header based on the passed in model', function() { - var programListUrl = view.$('.breadcrumb-list .crumb:nth-of-type(2) .crumb-link').attr('href'); - - expect(view.$('.title').html()).toEqual(context.programData.title); - expect(view.$('.subtitle').html()).toEqual(context.programData.subtitle); + expect(view.$('.program-title').html()).toEqual(context.programData.title); expect(view.$('.org-logo').length).toEqual(context.programData.authoring_organizations.length); expect(view.$('.org-logo').attr('src')) .toEqual(context.programData.authoring_organizations[0].certificate_logo_image_url); expect(view.$('.org-logo').attr('alt')) .toEqual(context.programData.authoring_organizations[0].name + '\'s logo'); - expect(programListUrl).toEqual(context.urls.program_listing_url); }); }); } diff --git a/lms/static/js/spec/learner_dashboard/program_details_view_spec.js b/lms/static/js/spec/learner_dashboard/program_details_view_spec.js index 82e5b36154..f48aa92a91 100644 --- a/lms/static/js/spec/learner_dashboard/program_details_view_spec.js +++ b/lms/static/js/spec/learner_dashboard/program_details_view_spec.js @@ -1,7 +1,7 @@ define([ 'backbone', 'jquery', - 'js/learner_dashboard/views/program_details_view_2017' + 'js/learner_dashboard/views/program_details_view' ], function(Backbone, $, ProgramDetailsView) { 'use strict'; diff --git a/lms/static/lms/js/build.js b/lms/static/lms/js/build.js index 536d867c4d..a24009f863 100644 --- a/lms/static/lms/js/build.js +++ b/lms/static/lms/js/build.js @@ -30,7 +30,6 @@ 'js/groups/views/cohorts_dashboard_factory', 'js/header_factory', 'js/learner_dashboard/program_details_factory', - 'js/learner_dashboard/program_details_factory_2017', 'js/learner_dashboard/program_list_factory', 'js/search/course/course_search_factory', 'js/search/dashboard/dashboard_search_factory', diff --git a/lms/static/lms/js/spec/main.js b/lms/static/lms/js/spec/main.js index 4ad059063a..11ff778593 100644 --- a/lms/static/lms/js/spec/main.js +++ b/lms/static/lms/js/spec/main.js @@ -746,7 +746,6 @@ 'js/spec/learner_dashboard/program_details_sidebar_view_spec.js', 'js/spec/learner_dashboard/course_card_view_spec.js', 'js/spec/learner_dashboard/course_enroll_view_spec.js', - 'js/spec/learner_dashboard/course_enroll_view_spec_2017.js', 'js/spec/markdown_editor_spec.js', 'js/spec/dateutil_factory_spec.js', 'js/spec/navigation_spec.js', diff --git a/lms/templates/discovery/course_card_2017.underscore b/lms/templates/discovery/course_card_2017.underscore deleted file mode 100644 index 02324005c1..0000000000 --- a/lms/templates/discovery/course_card_2017.underscore +++ /dev/null @@ -1,24 +0,0 @@ -+ <%- gettext('Certificate Status:') %> + + <%- gettext('Certificate Purchased') %> +
diff --git a/lms/templates/learner_dashboard/certificate_status_2017.underscore b/lms/templates/learner_dashboard/certificate_status_2017.underscore deleted file mode 100644 index 5921f07ff5..0000000000 --- a/lms/templates/learner_dashboard/certificate_status_2017.underscore +++ /dev/null @@ -1,5 +0,0 @@ -- <%- gettext('Certificate Status:') %> - - <%- gettext('Certificate Purchased') %> -
diff --git a/lms/templates/learner_dashboard/course_card.underscore b/lms/templates/learner_dashboard/course_card.underscore index e93ff8eec1..8138d989c5 100644 --- a/lms/templates/learner_dashboard/course_card.underscore +++ b/lms/templates/learner_dashboard/course_card.underscore @@ -1,21 +1,7 @@