@edx/edx-proctoring
Advanced tools
Comparing version 3.6.7 to 3.7.0
@@ -41,2 +41,22 @@ (function(Backbone, $) { | ||
message: gettext('An error has occurred during your onboarding exam. Please retry onboarding.') | ||
}, | ||
other_course_approved: { | ||
status: gettext('Approved in Another Course'), | ||
message: gettext( | ||
'Your onboarding profile has been approved in another course, ' + | ||
'so you are eligible to take proctored exams in this course. ' + | ||
'However, it is highly recommended that you complete this ' + | ||
'course\'s onboarding exam in order to ensure that your device ' + | ||
'still meets the requirements for proctoring.' | ||
) | ||
}, | ||
expiring_soon: { | ||
status: gettext('Expiring Soon'), | ||
message: gettext( | ||
'Your onboarding profile has been approved in another course, ' + | ||
'so you are eligible to take proctored exams in this course. ' + | ||
'However, your onboarding status is expiring soon. Please ' + | ||
'complete onboarding again to ensure that you will be ' + | ||
'able to continue taking proctored exams.' | ||
) | ||
} | ||
@@ -58,5 +78,5 @@ }; | ||
var color = '#b20610'; | ||
if (this.status === 'verified') { | ||
if (['verified', 'other_course_approved'].includes(this.status)) { | ||
color = '#008100'; | ||
} else if (['submitted', 'second_review_required'].includes(this.status)) { | ||
} else if (['submitted', 'second_review_required', 'expiring_soon'].includes(this.status)) { | ||
color = '#0d4e6c'; | ||
@@ -109,2 +129,9 @@ } | ||
isExpiringSoon: function(expirationDate) { | ||
var today = new Date(); | ||
var expirationDateObject = new Date(expirationDate); | ||
// Return true if the expiration date is within 28 days | ||
return today.getTime() > expirationDateObject.getTime() - 2419200000; | ||
}, | ||
shouldShowExamLink: function(status) { | ||
@@ -120,8 +147,12 @@ // show the exam link if the user should retry onboarding, or if they haven't submitted the exam | ||
if (this.template) { | ||
this.status = data.onboarding_status; | ||
statusText = this.getExamAttemptText(data.onboarding_status); | ||
if (data.expiration_date && this.isExpiringSoon(data.expiration_date)) { | ||
this.status = 'expiring_soon'; | ||
} else { | ||
this.status = data.onboarding_status; | ||
} | ||
statusText = this.getExamAttemptText(this.status); | ||
data = { | ||
onboardingStatus: statusText.status, | ||
onboardingMessage: statusText.message, | ||
showOnboardingReminder: data.onboarding_status !== 'verified', | ||
showOnboardingReminder: !['verified', 'other_course_approved'].includes(data.onboarding_status), | ||
showOnboardingExamLink: this.shouldShowExamLink(data.onboarding_status), | ||
@@ -128,0 +159,0 @@ onboardingLink: data.onboarding_link |
@@ -15,3 +15,4 @@ /* global LearnerOnboardingModel:false */ | ||
onboarding_status: status, | ||
onboarding_link: 'onboarding_link' | ||
onboarding_link: 'onboarding_link', | ||
expiration_date: null | ||
} | ||
@@ -21,2 +22,12 @@ ); | ||
function expectedOtherCourseApprovedJson(expirationDate) { | ||
return ( | ||
{ | ||
onboarding_status: 'other_course_approved', | ||
onboarding_link: 'onboarding_link', | ||
expiration_date: expirationDate | ||
} | ||
); | ||
} | ||
beforeEach(function() { | ||
@@ -342,2 +353,57 @@ html = '<div class="proctoring-info">' + | ||
}); | ||
it('should render proctoring info panel correctly for other course approved', function() { | ||
var expirationDate = new Date(); | ||
// Set the expiration date 50 days in the future | ||
expirationDate.setTime(expirationDate.getTime() + 3456900000); | ||
this.server.respondWith('GET', '/api/edx_proctoring/v1/user_onboarding/status?course_id=test_course_id', | ||
[ | ||
200, | ||
{ | ||
'Content-Type': 'application/json' | ||
}, | ||
JSON.stringify(expectedOtherCourseApprovedJson(expirationDate.toString())) | ||
] | ||
); | ||
this.proctored_exam_info = new edx.courseware.proctored_exam.ProctoredExamInfo({ | ||
el: $('.proctoring-info-panel'), | ||
model: new LearnerOnboardingModel() | ||
}); | ||
this.server.respond(); | ||
this.server.respond(); | ||
expect(this.proctored_exam_info.$el.find('.onboarding-status').html()) | ||
.toContain('Approved in Another Course'); | ||
expect(this.proctored_exam_info.$el.find('.onboarding-status-message').html()) | ||
.toContain('it is highly recommended that you complete this course\'s onboarding exam'); | ||
expect(this.proctored_exam_info.$el.find('.action-onboarding').html()) | ||
.toContain('Complete Onboarding'); | ||
}); | ||
it('should render proctoring info panel when expiring soon', function() { | ||
var expirationDate = new Date(); | ||
// This message will render if the expiration date is within 28 days | ||
// Set the expiration date 10 days in future | ||
expirationDate.setTime(expirationDate.getTime() + 864800000); | ||
this.server.respondWith('GET', '/api/edx_proctoring/v1/user_onboarding/status?course_id=test_course_id', | ||
[ | ||
200, | ||
{ | ||
'Content-Type': 'application/json' | ||
}, | ||
JSON.stringify(expectedOtherCourseApprovedJson(expirationDate.toString())) | ||
] | ||
); | ||
this.proctored_exam_info = new edx.courseware.proctored_exam.ProctoredExamInfo({ | ||
el: $('.proctoring-info-panel'), | ||
model: new LearnerOnboardingModel() | ||
}); | ||
this.server.respond(); | ||
this.server.respond(); | ||
expect(this.proctored_exam_info.$el.find('.onboarding-status').html()) | ||
.toContain('Expiring Soon'); | ||
expect(this.proctored_exam_info.$el.find('.onboarding-status-message').html()) | ||
.toContain('However, your onboarding status is expiring soon.'); | ||
expect(this.proctored_exam_info.$el.find('.action-onboarding').html()) | ||
.toContain('Complete Onboarding'); | ||
}); | ||
}); |
@@ -5,3 +5,3 @@ { | ||
"//": "Note that the version format is slightly different than that of the Python version when using prereleases.", | ||
"version": "3.6.7", | ||
"version": "3.7.0", | ||
"main": "edx_proctoring/static/index.js", | ||
@@ -8,0 +8,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
967939
17845