Commit 7e7e9788 by Farhanah Sheets Committed by GitHub

Merge pull request #363 from jspayd/toggle-timer

Toggle timer visibility on timed exams
parents 23ab09c4 63d9456e
...@@ -49,6 +49,9 @@ var edx = edx || {}; ...@@ -49,6 +49,9 @@ var edx = edx || {};
/* will call into the rendering */ /* will call into the rendering */
this.model.fetch(); this.model.fetch();
}, },
events: {
'click #toggle_timer': 'toggleTimerVisibility'
},
detectScroll: function(event) { detectScroll: function(event) {
if ($(event.currentTarget).scrollTop() > this.timerBarTopPosition) { if ($(event.currentTarget).scrollTop() > this.timerBarTopPosition) {
$(".proctored_exam_status").addClass('is-fixed'); $(".proctored_exam_status").addClass('is-fixed');
...@@ -171,6 +174,22 @@ var edx = edx || {}; ...@@ -171,6 +174,22 @@ var edx = edx || {};
// refresh the page when the timer expired // refresh the page when the timer expired
self.reloadPage(); self.reloadPage();
} }
},
toggleTimerVisibility: function (event) {
var button = $(event.currentTarget);
var icon = button.find('i');
var timer = this.$el.find('span#time_remaining_id b');
if (timer.hasClass('timer-hidden')) {
timer.removeClass('timer-hidden');
button.attr('aria-pressed', 'false');
icon.removeClass('fa-eye').addClass('fa-eye-slash');
} else {
timer.addClass('timer-hidden');
button.attr('aria-pressed', 'true');
icon.removeClass('fa-eye-slash').addClass('fa-eye');
}
event.stopPropagation();
event.preventDefault();
} }
}); });
this.edx.coursware.proctored_exam.ProctoredExamView = edx.coursware.proctored_exam.ProctoredExamView; this.edx.coursware.proctored_exam.ProctoredExamView = edx.coursware.proctored_exam.ProctoredExamView;
......
...@@ -9,7 +9,11 @@ describe('ProctoredExamView', function () { ...@@ -9,7 +9,11 @@ describe('ProctoredExamView', function () {
'You are taking "' + 'You are taking "' +
'<a href="<%= exam_url_path %>"> <%= exam_display_name %> </a>' + '<a href="<%= exam_url_path %>"> <%= exam_display_name %> </a>' +
'" as a proctored exam. The timer on the right shows the time remaining in the exam' + '" as a proctored exam. The timer on the right shows the time remaining in the exam' +
'<span id="time_remaining_id" class="pull-right"> <b> </b> </span> </div>' + '<span class="exam-timer-clock"> <span id="time_remaining_id">' +
'<b> </b> <button role="button" id="toggle_timer" aria-label="Hide Timer" aria-pressed="false">' +
'<i class="fa fa-eye-slash" aria-hidden="true"></i></button>' +
'</span> </span>' +
'</div>' +
'</script>'+ '</script>'+
'</div>' '</div>'
); );
...@@ -55,6 +59,15 @@ describe('ProctoredExamView', function () { ...@@ -55,6 +59,15 @@ describe('ProctoredExamView', function () {
this.proctored_exam_view.render(); this.proctored_exam_view.render();
expect(this.proctored_exam_view.$el.find('div.exam-timer')).toHaveClass('low-time critical'); expect(this.proctored_exam_view.$el.find('div.exam-timer')).toHaveClass('low-time critical');
}); });
it('toggles timer visibility correctly', function() {
var button = this.proctored_exam_view.$el.find('#toggle_timer');
var timer = this.proctored_exam_view.$el.find('span#time_remaining_id b');
expect(timer).not.toHaveClass('timer-hidden');
button.click();
expect(timer).toHaveClass('timer-hidden');
button.click();
expect(timer).not.toHaveClass('timer-hidden');
});
it("reload the page when the exam time finishes", function(){ it("reload the page when the exam time finishes", function(){
this.proctored_exam_view.secondsLeft = -10; this.proctored_exam_view.secondsLeft = -10;
var reloadPage = spyOn(this.proctored_exam_view, 'reloadPage'); var reloadPage = spyOn(this.proctored_exam_view, 'reloadPage');
......
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