Skip to content
Snippets Groups Projects
Commit f3d43ab5 authored by ibrahimahmed443's avatar ibrahimahmed443
Browse files

SOL-1479 set max time limit to 99:59 hours; add jasmine tests to validate time limit

parent 65ec8538
No related merge requests found
......@@ -727,6 +727,29 @@ define(["jquery", "common/js/spec_helpers/ajax_helpers", "common/js/components/u
expect($('.modal-section .advanced-settings-button')).toHaveClass('active');
});
it('can select valid time', function() {
createCourseOutlinePage(this, mockCourseJSON, false);
outlinePage.$('.outline-subsection .configure-button').click();
selectAdvancedSettings();
var default_time = "00:30";
var valid_times = ["00:30", "23:00", "24:00", "99:00"];
var invalid_times = ["00:00", "100:00", "01:60"];
var time_limit, i;
for (i = 0; i < valid_times.length; i++){
time_limit = valid_times[i];
selectTimedExam(time_limit);
expect($("#id_time_limit").val()).toEqual(time_limit);
}
for (i = 0; i < invalid_times.length; i++){
time_limit = invalid_times[i];
selectTimedExam(time_limit);
expect($("#id_time_limit").val()).not.toEqual(time_limit);
expect($("#id_time_limit").val()).toEqual(default_time);
}
});
it('can be edited', function() {
createCourseOutlinePage(this, mockCourseJSON, false);
outlinePage.$('.outline-subsection .configure-button').click();
......
......@@ -388,7 +388,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
this.$('input.time').timepicker({
'timeFormat' : 'H:i',
'minTime': '00:30',
'maxTime': '05:00',
'maxTime': '24:00',
'forceRoundTime': false
});
......@@ -429,7 +429,7 @@ define(['jquery', 'backbone', 'underscore', 'gettext', 'js/views/baseview',
this.$('#id_exam_review_rules').val(value);
},
isValidTimeLimit: function(time_limit) {
var pattern = new RegExp('^([0-9]|0[0-9]|1[0-9]|2[0-3]):[0-5][0-9]$');
var pattern = new RegExp('^\\d{1,2}:[0-5][0-9]$');
return pattern.test(time_limit) && time_limit !== "00:00";
},
getExamTimeLimit: function () {
......
......@@ -55,7 +55,7 @@
value="" aria-describedby="time-limit-description"
placeholder="HH:MM" class="time_limit release-time time input input-text" autocomplete="off" />
</li>
<p class='field-message' id='time-limit-description'><%- gettext('Learners see warnings when 20% and 5% of the allotted time remains. You can grant learners extra time to complete the exam through the Instructor Dashboard.') %></p>
<p class='field-message' id='time-limit-description'><%- gettext('Select a time allotment for the exam. If it is over 24 hours, type in the amount of time. You can grant individual learners extra time to complete the exam through the Instructor Dashboard.') %></p>
</ul>
</div>
<div class='exam-review-rules-list-fields is-hidden'>
......
......@@ -304,9 +304,8 @@ requires jQuery 1.7+
// make sure the end time is greater than start time, otherwise there will be no list to show
end += _ONE_DAY;
}
for (var i=start; i <= end; i += settings.step*60) {
var timeInt = i%_ONE_DAY;
var timeInt = i;
var row = $('<li />');
row.data('time', timeInt);
row.text(_int2time(timeInt, settings.timeFormat));
......@@ -609,6 +608,8 @@ requires jQuery 1.7+
case 'H':
hour = time.getHours();
if (seconds >= _ONE_DAY)
hour = Math.floor(seconds / (60 * 60));
output += (hour > 9) ? hour : '0'+hour;
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment