Commit 0fe31fa9 by Alex Dusenbery Committed by Alex Dusenbery

EDUCATOR-1251 | cert available date validation should take course pacing into account.

parent 03abf94a
......@@ -31,7 +31,8 @@ define(['backbone', 'underscore', 'gettext', 'js/models/validation_helpers', 'js
entrance_exam_enabled: '',
entrance_exam_minimum_score_pct: '50',
learning_info: [],
instructor_info: {}
instructor_info: {},
self_paced: null
},
validate: function(newattrs) {
......@@ -39,8 +40,9 @@ define(['backbone', 'underscore', 'gettext', 'js/models/validation_helpers', 'js
// A bit funny in that the video key validation is asynchronous; so, it won't stop the validation.
var errors = {};
newattrs = DateUtils.convertDateStringsToObjects(
newattrs, ['start_date', 'end_date', 'certificate_available_date', 'enrollment_start', 'enrollment_end']
);
newattrs,
['start_date', 'end_date', 'certificate_available_date', 'enrollment_start', 'enrollment_end']
);
if (newattrs.start_date === null) {
errors.start_date = gettext('The course must have an assigned start date.');
......@@ -58,7 +60,7 @@ define(['backbone', 'underscore', 'gettext', 'js/models/validation_helpers', 'js
if (newattrs.end_date && newattrs.enrollment_end && newattrs.end_date < newattrs.enrollment_end) {
errors.enrollment_end = gettext('The enrollment end date cannot be after the course end date.');
}
if (newattrs.end_date && newattrs.certificate_available_date &&
if (!this.get('self_paced') && newattrs.end_date && newattrs.certificate_available_date &&
newattrs.certificate_available_date < newattrs.end_date) {
errors.certificate_available_date = gettext(
'The certificate available date must be later than the course end date.'
......
......@@ -48,7 +48,8 @@ define([
learning_info: [''],
instructor_info: {
'instructors': [{'name': '', 'title': '', 'organization': '', 'image': '', 'bio': ''}]
}
},
self_paced: false
},
mockSettingsPage = readFixtures('mock/mock-settings-page.underscore'),
......@@ -348,5 +349,15 @@ define([
);
AjaxHelpers.respondWithJson(requests, expectedJson);
});
it('should disallow save with a certificate available date before end date', function() {
$('#course-end-date').val('01/01/2030').trigger('change');
expect(this.view.$('.message-error')).toExist();
});
it('should allow save with a certificate available date before end date for self-paced course', function() {
this.model.set('self_paced', true);
$('#course-end-date').val('01/01/2030').trigger('change');
expect(this.view.$('.message-error')).not.toExist();
this.model.set('self_paced', false);
});
});
});
......@@ -35,6 +35,16 @@
</ol>
<ol class="list-input">
<li class="field-group field-group-certificate-available" id="certificate-available">
<div class="field date" id="field-certificate-available-date">
<label for="certificate-available-date">Certificates Available Date</label>
<input type="text" class="certificate-available-date date start datepicker" id="certificate-available-date" placeholder="MM/DD/YYYY" autocomplete="off" />
<span class="tip tip-stacked">By default, 48 hours after course end date</span>
</div>
</li>
</ol>
<ol class="list-input">
<li class="field-group field-group-enrollment-start" id="enrollment-start">
<div class="field date" id="field-enrollment-start-date">
<label for="course-enrollment-start-date">Enrollment Start Date</label>
......
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