diff --git a/.python-version b/.python-version new file mode 100644 index 00000000000..2c0733315e4 --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.11 diff --git a/edx_proctoring/static/proctoring/js/views/proctored_exam_attempt_view.js b/edx_proctoring/static/proctoring/js/views/proctored_exam_attempt_view.js index 18c909bae76..d5e11681e33 100644 --- a/edx_proctoring/static/proctoring/js/views/proctored_exam_attempt_view.js +++ b/edx_proctoring/static/proctoring/js/views/proctored_exam_attempt_view.js @@ -45,6 +45,9 @@ edx = edx || {}; initialize: function() { this.setElement($('.student-proctored-exam-container')); this.course_id = this.$el.data('course-id'); + + if (!this.course_id) return; // No course defined. + this.template = null; this.model = new edx.instructor_dashboard.proctoring.ProctoredExamAttemptModel(); @@ -133,6 +136,16 @@ edx = edx || {}; self.hydrate(); }); }, + + hydrateDone: function(self) { + var $searchIcon, $spinner; + self.render(); + $spinner = $(document.getElementById('attempt-loading-indicator')); + $spinner.addClass('hidden'); + $searchIcon = $(document.getElementById('attempt-search-indicator')); + $searchIcon.removeClass('hidden'); + }, + hydrate: function() { /* This function will load the bound collection */ @@ -140,15 +153,15 @@ edx = edx || {}; /* we might - at some point - add a visual element to the */ /* loading, like a spinner */ var self = this; + + if (!self.course_id) { + // If there's no course_id, there's no point in fetching, so we remove the loading state. + self.hydrateDone(self); + return; + } + self.collection.fetch({ - success: function() { - var $searchIcon, $spinner; - self.render(); - $spinner = $(document.getElementById('attempt-loading-indicator')); - $spinner.addClass('hidden'); - $searchIcon = $(document.getElementById('attempt-search-indicator')); - $searchIcon.removeClass('hidden'); - } + success: self.hydrateDone(self) }); }, collectionChanged: function() { diff --git a/edx_proctoring/static/proctoring/spec/proctored_exam_attempt_spec.js b/edx_proctoring/static/proctoring/spec/proctored_exam_attempt_spec.js index c7f6e350899..b8080062841 100644 --- a/edx_proctoring/static/proctoring/spec/proctored_exam_attempt_spec.js +++ b/edx_proctoring/static/proctoring/spec/proctored_exam_attempt_spec.js @@ -396,6 +396,14 @@ describe('ProctoredExamAttemptView', function() { afterEach(function() { this.server.restore(); }); + + it('should not fetch if student-proctored-exam-container is missing', function() { + setFixtures('