Commit 391ee40e by Matthew Piatetsky Committed by GitHub

Merge pull request #14937 from edx/fix_progress_issues

Fix progress issues
parents 22ab0c8d ff0da0f7
...@@ -122,19 +122,25 @@ ...@@ -122,19 +122,25 @@
}, },
getCertificatePriceString: function(run) { getCertificatePriceString: function(run) {
var verifiedSeat, currency; var upgradeableSeat, upgradeableSeats, currency;
if ('seats' in run && run.seats.length) { if ('seats' in run && run.seats.length) {
// eslint-disable-next-line consistent-return // eslint-disable-next-line consistent-return
verifiedSeat = _.filter(run.seats, function(seat) { upgradeableSeats = _.filter(run.seats, function(seat) {
if (['verified', 'professional', 'credit'].indexOf(seat.type) >= 0) { var upgradeableSeatTypes = ['verified', 'professional', 'no-id-professional', 'credit'];
if (upgradeableSeatTypes.indexOf(seat.type) >= 0) {
return seat; return seat;
} }
})[0]; });
currency = verifiedSeat.currency; if (upgradeableSeats.length > 0) {
upgradeableSeat = upgradeableSeats[0];
if (upgradeableSeat) {
currency = upgradeableSeat.currency;
if (currency === 'USD') { if (currency === 'USD') {
return '$' + verifiedSeat.price; return '$' + upgradeableSeat.price;
} else { } else {
return verifiedSeat.price + ' ' + currency; return upgradeableSeat.price + ' ' + currency;
}
}
} }
} }
return null; return null;
......
...@@ -53,7 +53,8 @@ ...@@ -53,7 +53,8 @@
postRender: function() { postRender: function() {
var $upgradeMessage = this.$('.upgrade-message'), var $upgradeMessage = this.$('.upgrade-message'),
$certStatus = this.$('.certificate-status'), $certStatus = this.$('.certificate-status'),
$expiredNotification = this.$('.expired-notification'); $expiredNotification = this.$('.expired-notification'),
expired = this.model.get('expired');
this.enrollView = new CourseEnrollView({ this.enrollView = new CourseEnrollView({
$parentEl: this.$('.course-actions'), $parentEl: this.$('.course-actions'),
...@@ -62,14 +63,14 @@ ...@@ -62,14 +63,14 @@
enrollModel: this.enrollModel enrollModel: this.enrollModel
}); });
if (this.model.get('upgrade_url')) { if (this.model.get('upgrade_url') && !(expired === true)) {
this.upgradeMessage = new UpgradeMessageView({ this.upgradeMessage = new UpgradeMessageView({
$el: $upgradeMessage, $el: $upgradeMessage,
model: this.model model: this.model
}); });
$certStatus.remove(); $certStatus.remove();
} else if (this.model.get('certificate_url')) { } else if (this.model.get('certificate_url') && !(expired === true)) {
this.certificateStatus = new CertificateStatusView({ this.certificateStatus = new CertificateStatusView({
$el: $certStatus, $el: $certStatus,
model: this.model model: this.model
...@@ -82,7 +83,7 @@ ...@@ -82,7 +83,7 @@
$certStatus.remove(); $certStatus.remove();
} }
if (this.model.get('expired')) { if (expired) {
this.expiredNotification = new ExpiredNotificationView({ this.expiredNotification = new ExpiredNotificationView({
$el: $expiredNotification, $el: $expiredNotification,
model: this.model model: this.model
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
handleEnroll: function() { handleEnroll: function() {
// Enrollment click event handled here // Enrollment click event handled here
var courseRunKey = $('.run-select').val(); var courseRunKey = $('.run-select').val() || this.model.get('course_run_key');
this.model.updateCourseRun(courseRunKey); this.model.updateCourseRun(courseRunKey);
if (!this.model.get('is_enrolled')) { if (!this.model.get('is_enrolled')) {
// Create the enrollment. // Create the enrollment.
......
define([
'backbone',
'jquery',
'js/learner_dashboard/views/program_details_view_2017'
], function(Backbone, $, ProgramDetailsView) {
'use strict';
describe('Program Details Header View', function() {
var view = null,
options = {
programData: {
subtitle: '',
overview: '',
weeks_to_complete: null,
corporate_endorsements: [],
video: null,
type: 'Test',
max_hours_effort_per_week: null,
transcript_languages: [
'en-us'
],
expected_learning_items: [],
uuid: '0ffff5d6-0177-4690-9a48-aa2fecf94610',
title: 'Test Course Title',
languages: [
'en-us'
],
subjects: [],
individual_endorsements: [],
staff: [
{
family_name: 'Tester',
uuid: '11ee1afb-5750-4185-8434-c9ae8297f0f1',
bio: 'Dr. Tester, PhD, RD, is an Associate Professor at the School of Nutrition.',
profile_image: {},
profile_image_url: 'some image',
given_name: 'Bob',
urls: {
blog: null,
twitter: null,
facebook: null
},
position: {
organization_name: 'Test University',
title: 'Associate Professor of Nutrition'
},
works: [],
slug: 'dr-tester'
}
],
marketing_slug: 'testing',
marketing_url: 'someurl',
status: 'active',
credit_redemption_overview: '',
card_image_url: 'some image',
faq: [],
price_ranges: [
{
max: 378,
total: 109,
min: 10,
currency: 'USD'
}
],
banner_image: {
large: {
url: 'someurl',
width: 1440,
height: 480
},
small: {
url: 'someurl',
width: 435,
height: 145
},
medium: {
url: 'someurl',
width: 726,
height: 242
},
'x-small': {
url: 'someurl',
width: 348,
height: 116
}
},
authoring_organizations: [
{
description: '<p>Learning University is home to leading creators, entrepreneurs.</p>',
tags: [
'contributor'
],
name: 'Learning University',
homepage_url: null,
key: 'LearnX',
certificate_logo_image_url: null,
marketing_url: 'someurl',
logo_image_url: 'https://stage.edx.org/sites/default/files/school/image/logo/learnx.png',
uuid: 'de3e9ff0-477d-4496-8cfa-a98f902e5830'
},
{
description: '<p>The Test University was chartered in 1868.</p>',
tags: [
'charter',
'contributor'
],
name: 'Test University',
homepage_url: null,
key: 'TestX',
certificate_logo_image_url: null,
marketing_url: 'someurl',
logo_image_url: 'https://stage.edx.org/sites/default/files/school/image/logo/ritx.png',
uuid: '54bc81cb-b736-4505-aa51-dd2b18c61d84'
}
],
job_outlook_items: [],
credit_backing_organizations: [],
weeks_to_complete_min: 8,
weeks_to_complete_max: 8,
min_hours_effort_per_week: null
},
courseData: {
completed: [
{
owners: [
{
uuid: '766a3716-f962-425b-b56e-e214c019b229',
key: 'Testx',
name: 'Test University'
}
],
uuid: '4be8dceb-3454-4fbf-8993-17d563ab41d4',
title: 'Who let the dogs out',
image: null,
key: 'Testx+DOGx002',
course_runs: [
{
upgrade_url: null,
image: {
src: 'someurl',
width: null,
description: null,
height: null
},
max_effort: null,
is_enrollment_open: true,
course: 'Testx+DOGx002',
content_language: null,
eligible_for_financial_aid: true,
seats: [
{
sku: '4250900',
credit_hours: null,
price: '89.00',
currency: 'USD',
upgrade_deadline: null,
credit_provider: '',
type: 'verified'
}
],
course_url: '/courses/course-v1:Testx+DOGx002+1T2016/',
availability: 'Archived',
transcript_languages: [],
staff: [],
announcement: null,
end: '2016-10-01T23:59:00Z',
uuid: 'f0ac45f5-f0d6-44bc-aeb9-a14e36e963a5',
title: 'Who let the dogs out',
certificate_url: '/certificates/1730700d89434b718d0d91f8b5d339bf',
enrollment_start: null,
start: '2017-03-21T22:18:15Z',
min_effort: null,
short_description: null,
hidden: false,
level_type: null,
type: 'verified',
enrollment_open_date: 'Jan 01, 1900',
marketing_url: null,
is_course_ended: false,
instructors: [],
full_description: null,
key: 'course-v1:Testx+DOGx002+1T2016',
enrollment_end: null,
reporting_type: 'mooc',
advertised_start: null,
mobile_available: false,
modified: '2017-03-24T14:22:15.609907Z',
is_enrolled: true,
pacing_type: null,
video: null
}
]
}
],
in_progress: [
{
owners: [
{
uuid: 'c484a523-d396-4aff-90f4-bb7e82e16bf6',
key: 'LearnX',
name: 'Learning University'
}
],
uuid: '872ec14c-3b7d-44b8-9cf2-9fa62182e1dd',
title: 'Star Trek: The Next Generation',
image: null,
key: 'LearnX+NGIx',
course_runs: [
{
upgrade_url: 'someurl',
image: {
src: '',
width: null,
description: null,
height: null
},
max_effort: null,
is_enrollment_open: true,
course: 'LearnX+NGx',
content_language: null,
eligible_for_financial_aid: true,
seats: [
{
sku: '44EEB26',
credit_hours: null,
price: '0.00',
currency: 'USD',
upgrade_deadline: null,
credit_provider: null,
type: 'audit'
},
{
sku: '64AAFBA',
credit_hours: null,
price: '10.00',
currency: 'USD',
upgrade_deadline: '2017-04-29T00:00:00Z',
credit_provider: null,
type: 'verified'
}
],
course_url: 'someurl',
availability: 'Current',
transcript_languages: [],
staff: [],
announcement: null,
end: '2017-03-31T12:00:00Z',
uuid: 'ce841f5b-f5a9-428f-b187-e6372b532266',
title: 'Star Trek: The Next Generation',
certificate_url: null,
enrollment_start: '2014-03-31T20:00:00Z',
start: '2017-03-20T20:50:14Z',
min_effort: null,
short_description: null,
hidden: false,
level_type: null,
type: 'verified',
enrollment_open_date: 'Jan 01, 1900',
marketing_url: 'someurl',
is_course_ended: false,
instructors: [],
full_description: null,
key: 'course-v1:LearnX+NGIx+3T2016',
enrollment_end: null,
reporting_type: 'mooc',
advertised_start: null,
mobile_available: false,
modified: '2017-03-24T14:16:47.547643Z',
is_enrolled: true,
pacing_type: null,
video: null
}
]
}
],
uuid: '0ffff5d6-0177-4690-9a48-aa2fecf94610',
not_started: [
{
owners: [
{
uuid: '766a3716-f962-425b-b56e-e214c019b229',
key: 'Testx',
name: 'Test University'
}
],
uuid: '88da08e4-e9ef-406e-95d7-7a178f9f9695',
title: 'Introduction to Health and Wellness',
image: null,
key: 'Testx+EXW100x',
course_runs: [
{
upgrade_url: null,
image: {
src: 'someurl',
width: null,
description: null,
height: null
},
max_effort: null,
is_enrollment_open: true,
course: 'Testx+EXW100x',
content_language: 'en-us',
eligible_for_financial_aid: true,
seats: [
{
sku: '',
credit_hours: null,
price: '0.00',
currency: 'USD',
upgrade_deadline: null,
credit_provider: '',
type: 'audit'
},
{
sku: '',
credit_hours: null,
price: '10.00',
currency: 'USD',
upgrade_deadline: null,
credit_provider: '',
type: 'verified'
}
],
course_url: 'someurl',
availability: 'Archived',
transcript_languages: [
'en-us'
],
staff: [
{
family_name: 'Tester',
uuid: '11ee1afb-5750-4185-8434-c9ae8297f0f1',
bio: 'Dr. Tester, PhD, RD, is a Professor at the School of Nutrition.',
profile_image: {},
profile_image_url: 'someimage.jpg',
given_name: 'Bob',
urls: {
blog: null,
twitter: null,
facebook: null
},
position: {
organization_name: 'Test University',
title: 'Associate Professor of Nutrition'
},
works: [],
slug: 'dr-tester'
}
],
announcement: null,
end: '2017-03-25T22:18:33Z',
uuid: 'a36efd39-6637-11e6-a8e3-22000bdde520',
title: 'Introduction to Jedi',
certificate_url: null,
enrollment_start: null,
start: '2016-01-11T05:00:00Z',
min_effort: null,
short_description: null,
hidden: false,
level_type: null,
type: 'verified',
enrollment_open_date: 'Jan 01, 1900',
marketing_url: 'someurl',
is_course_ended: false,
instructors: [],
full_description: null,
key: 'course-v1:Testx+EXW100x+1T2016',
enrollment_end: null,
reporting_type: 'mooc',
advertised_start: null,
mobile_available: true,
modified: '2017-03-24T14:18:08.693748Z',
is_enrolled: false,
pacing_type: 'instructor_paced',
video: null
},
{
upgrade_url: null,
image: {
src: 'someurl',
width: null,
description: null,
height: null
},
max_effort: null,
is_enrollment_open: true,
course: 'Testx+EXW100x',
content_language: null,
eligible_for_financial_aid: true,
seats: [
{
sku: '77AA8F2',
credit_hours: null,
price: '0.00',
currency: 'USD',
upgrade_deadline: null,
credit_provider: null,
type: 'audit'
},
{
sku: '7EC7BB0',
credit_hours: null,
price: '100.00',
currency: 'USD',
upgrade_deadline: null,
credit_provider: null,
type: 'verified'
},
{
sku: 'BD436CC',
credit_hours: 10,
price: '378.00',
currency: 'USD',
upgrade_deadline: null,
credit_provider: 'asu',
type: 'credit'
}
],
course_url: 'someurl',
availability: 'Archived',
transcript_languages: [],
staff: [],
announcement: null,
end: '2016-07-29T00:00:00Z',
uuid: '03b34748-19b1-4732-9ea2-e68da95024e6',
title: 'Introduction to Jedi',
certificate_url: null,
enrollment_start: null,
start: '2017-03-22T18:10:39Z',
min_effort: null,
short_description: null,
hidden: false,
level_type: null,
type: 'credit',
enrollment_open_date: 'Jan 01, 1900',
marketing_url: null,
is_course_ended: false,
instructors: [],
full_description: null,
key: 'course-v1:Testx+EXW100x+2164C',
enrollment_end: '2016-06-18T19:00:00Z',
reporting_type: 'mooc',
advertised_start: null,
mobile_available: false,
modified: '2017-03-23T16:47:37.108260Z',
is_enrolled: false,
pacing_type: null,
video: null
}
]
}
]
},
urls: {
program_listing_url: '/dashboard/programs/',
commerce_api_url: '/api/commerce/v0/baskets/',
track_selection_url: '/course_modes/choose/'
},
userPreferences: {
'pref-lang': 'en'
}
},
data = options.programData;
beforeEach(function() {
setFixtures('<div class="js-program-details-wrapper"></div>');
view = new ProgramDetailsView(options);
view.render();
});
afterEach(function() {
view.remove();
});
it('should exist', function() {
expect(view).toBeDefined();
});
it('should render the header', function() {
expect(view.$('.js-program-header h2').html()).toEqual(data.title);
expect(view.$('.js-program-header .org-logo')[0].src).toEqual(
data.authoring_organizations[0].logo_image_url
);
expect(view.$('.js-program-header .org-logo')[1].src).toEqual(
data.authoring_organizations[1].logo_image_url
);
});
it('should render the program heading', function() {
expect(view.$('.program-heading-title').text()).toEqual('Your Program Journey');
expect(view.$('.program-heading-message').text().trim()
.replace(/\s+/g, ' ')).toEqual(
'Track and plan your progress through the 3 courses in this program. ' +
'To complete the program, you must earn a verified certificate for each course.'
);
});
it('should render the course list headings', function() {
expect(view.$('.course-list-heading .status').text()).toEqual(
'COURSES IN PROGRESSREMAINING COURSESCOMPLETED COURSES'
);
expect(view.$('.course-list-heading .count').text()).toEqual('111');
});
it('should render the basic course card information', function() {
expect($(view.$('.course-title')[0]).text().trim()).toEqual('Star Trek: The Next Generation');
expect($(view.$('.enrolled')[0]).text().trim()).toEqual('Enrolled:');
expect($(view.$('.run-period')[0]).text().trim()).toEqual('Mar 20, 2017 - Mar 31, 2017');
});
it('should render certificate information', function() {
expect($(view.$('.upgrade-message .card-msg')).text().trim()).toEqual('Certificate Status:');
expect($(view.$('.upgrade-message .price')).text().trim()).toEqual('$10.00');
expect($(view.$('.upgrade-button')[0]).text().trim()).toEqual('Buy Certificate');
});
it('should render enrollment information', function() {
expect(view.$('.run-select')[0].options.length).toEqual(2);
expect($(view.$('.select-choice')[0]).attr('for')).toEqual($(view.$('.run-select')[0]).attr('id'));
expect($(view.$('.enroll-button button')[0]).text().trim()).toEqual('Enroll Now');
});
});
}
);
...@@ -115,6 +115,10 @@ ...@@ -115,6 +115,10 @@
margin-top: 10px; margin-top: 10px;
height: auto; height: auto;
svg {
width: inherit;
}
/* IE11 CSS styles */ /* IE11 CSS styles */
@media(min-width: $bp-screen-md) and (-ms-high-contrast: none), (-ms-high-contrast: active) { @media(min-width: $bp-screen-md) and (-ms-high-contrast: none), (-ms-high-contrast: active) {
height: 50px; height: 50px;
...@@ -147,6 +151,7 @@ ...@@ -147,6 +151,7 @@
.meta-info { .meta-info {
margin: 0; margin: 0;
display: block;
@media(min-width: $bp-screen-md) { @media(min-width: $bp-screen-md) {
width: 70%; width: 70%;
} }
...@@ -426,7 +431,7 @@ ...@@ -426,7 +431,7 @@
height: 37px; height: 37px;
width: 128px; width: 128px;
border-radius: 0; border-radius: 0;
padding: 0; padding: 7px 0 0 0;
text-align: center; text-align: center;
font-size: 0.9375em; font-size: 0.9375em;
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<span class="price"> <%- price %></span> <span class="price"> <%- price %></span>
</div> </div>
<div class="action col-12 md-col-4"> <div class="action col-12 md-col-4">
<button href="<%- upgrade_url %>" type="button" class="btn-brand btn cta-primary upgrade-button"> <a href="<%- upgrade_url %>" class="btn-brand btn cta-primary upgrade-button">
<%- gettext('Buy Certificate') %> <%- gettext('Buy Certificate') %>
</button> <a>
</div> </div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment