diff --git a/compair/static/modules/assignment/assignment-module.js b/compair/static/modules/assignment/assignment-module.js index 98e7689b0..9503a6dda 100644 --- a/compair/static/modules/assignment/assignment-module.js +++ b/compair/static/modules/assignment/assignment-module.js @@ -743,6 +743,7 @@ module.controller("AssignmentViewController", $scope.canManageAssignment = resolvedData.canManageAssignment; $scope.allStudents = resolvedData.students.objects; $scope.instructors = resolvedData.instructorLabels.instructors; + $scope.users = []; $scope.AnswerCommentType = AnswerCommentType; $scope.PairingAlgorithm = PairingAlgorithm; @@ -1137,12 +1138,17 @@ module.controller("AssignmentViewController", ); }; - $scope.resetStudents = function(students) { - $scope.students = _.sortBy(students, 'name'); - $scope.students.unshift({ - id: "top-picks", - name: "Instructor's top picks" - }); + $scope.resetUsers = function(instructors, students, addTopPicks) { + addTopPicks = addTopPicks !== undefined ? addTopPicks : true; + instructors = _.sortBy(instructors, 'name'); + students = _.sortBy(students, 'name'); + $scope.users = [].concat(instructors, students); + if (addTopPicks) { + $scope.users.unshift({ + id: "top-picks", + name: "Instructor's top picks" + }); + } }; $scope.updateAnswerList = function() { @@ -1168,7 +1174,7 @@ module.controller("AssignmentViewController", }); }; $scope.updateAnswerList(); - $scope.resetStudents($scope.allStudents); + $scope.resetUsers($scope.allInstructionals, $scope.allStudents); CourseResource.getInstructionals({'id': $scope.courseId}).$promise.then( function(ret) { @@ -1179,6 +1185,8 @@ module.controller("AssignmentViewController", .sortBy(function(o) { return o.name; }) .sortBy(function(o) { return o.role; }) .value(); + + $scope.resetUsers($scope.allInstructionals, $scope.allStudents); } ); @@ -1189,11 +1197,11 @@ module.controller("AssignmentViewController", $scope.answerFilters.author = null; } if ($scope.answerFilters.group == null) { - $scope.resetStudents($scope.allStudents); + $scope.resetUsers($scope.allInstructionals, $scope.allStudents); } else { GroupResource.get({'courseId': $scope.courseId, 'groupName': $scope.answerFilters.group}, function (ret) { - $scope.resetStudents(ret.students); + $scope.resetUsers([], ret.students, false); } ); } diff --git a/compair/static/modules/assignment/assignment-module_spec.js b/compair/static/modules/assignment/assignment-module_spec.js index 13747d77e..8e8cf298f 100644 --- a/compair/static/modules/assignment/assignment-module_spec.js +++ b/compair/static/modules/assignment/assignment-module_spec.js @@ -216,6 +216,15 @@ describe('assignment-module', function () { ] }; + var mockInstructors = { + "objects": [{ + "group_name": null, + "id": "15bcABC123-abcABC123_Z", + "name": "One, Instructor", + "role": "Instructor" + }] + }; + var mockInstructorLabels = { "instructors": { "1": "Instructor" @@ -793,20 +802,15 @@ describe('assignment-module', function () { }); $httpBackend.expectGET('/api/courses/1abcABC123-abcABC123_Z/groups').respond(mockGroups); $httpBackend.expectGET('/api/courses/1abcABC123-abcABC123_Z/assignments/1abcABC123-abcABC123_Z/answers?page=1&perPage=20').respond(mockAnswers); - $httpBackend.expectGET('/api/courses/1abcABC123-abcABC123_Z/users/instructionals').respond({ - "objects": [{ - "group_name": null, - "id": "1", - "name": "One, Instructor", - "role": "Instructor" - }] - }); + $httpBackend.expectGET('/api/courses/1abcABC123-abcABC123_Z/users/instructionals').respond(mockInstructors); $httpBackend.flush(); }); it('should be correctly initialized', function () { + var expectedInstructors = angular.copy(mockInstructors.objects) var expectedStudents = _.sortBy(angular.copy(mockStudents.objects), 'name'); - expectedStudents.unshift({ + var expectedUsers = [].concat(expectedInstructors, expectedStudents) + expectedUsers.unshift({ id: "top-picks", name: "Instructor's top picks" }); @@ -815,7 +819,7 @@ describe('assignment-module', function () { expect($rootScope.courseId).toEqual(mockCourse.id); expect($rootScope.allStudents).toEqual(mockStudents.objects); - expect($rootScope.students).toEqual(expectedStudents); + expect($rootScope.users).toEqual(expectedUsers); expect($rootScope.totalNumAnswers).toEqual(mockAnswers.total); @@ -1207,7 +1211,7 @@ describe('assignment-module', function () { $rootScope.date.astart.date.setDate($rootScope.date.astart.date.getDate()+1); $rootScope.date.aend.date = new Date(); $rootScope.date.aend.date.setDate($rootScope.date.aend.date.getDate()+8); - + $rootScope.date.aend.date = $rootScope.date.astart.date; $rootScope.date.aend.time = $rootScope.date.astart.time; var currentPath = $location.path(); @@ -1245,7 +1249,7 @@ describe('assignment-module', function () { $rootScope.assignment = angular.copy(mockAssignment); $rootScope.assignment.id = undefined; $rootScope.assignment.availableCheck = true; - + // no default dates set. populate with values before proceeding $rootScope.date.astart.date = new Date(); $rootScope.date.astart.date.setDate($rootScope.date.astart.date.getDate()+1); @@ -1267,7 +1271,7 @@ describe('assignment-module', function () { it('should enable save button even if save failed', function() { $rootScope.assignment = angular.copy(mockAssignment); $rootScope.assignment.id = undefined; - + // no default dates set. populate with values before proceeding $rootScope.date.astart.date = new Date(); $rootScope.date.astart.date.setDate($rootScope.date.astart.date.getDate()+1); diff --git a/compair/static/modules/assignment/assignment-view-partial.html b/compair/static/modules/assignment/assignment-view-partial.html index 37fc38a6c..f8f4b1af1 100644 --- a/compair/static/modules/assignment/assignment-view-partial.html +++ b/compair/static/modules/assignment/assignment-view-partial.html @@ -97,7 +97,7 @@

All answers
diff --git a/compair/static/modules/comparison/comparison-module.js b/compair/static/modules/comparison/comparison-module.js index 5692d96f8..931669aa8 100644 --- a/compair/static/modules/comparison/comparison-module.js +++ b/compair/static/modules/comparison/comparison-module.js @@ -380,8 +380,8 @@ module.controller( CourseResource.getStudents({'id': $scope.courseId}).$promise.then( function (ret) { $scope.allStudents = ret.objects; - $scope.users = ret.objects; userIds = $scope.getUserIds(ret.objects); + $scope.resetUsers($scope.allInstructionals, $scope.allStudents); } ); @@ -389,6 +389,7 @@ module.controller( function(ret) { $scope.allInstructionals = ret.objects; instructionalIds = $scope.getUserIds(ret.objects); + $scope.resetUsers($scope.allInstructionals, $scope.allStudents); } ); @@ -396,6 +397,12 @@ module.controller( return user_id in instructionalIds; } + $scope.resetUsers = function(instructors, students) { + instructors = _.sortBy(instructors, 'name'); + students = _.sortBy(students, 'name'); + $scope.users = [].concat(instructors, students); + }; + $scope.loadAnswerByAuthor = function(author_id) { if (_.find($scope.answers, {user_id: author_id})) return; AnswerResource.get({'courseId': $scope.courseId, 'assignmentId': $scope.assignmentId, 'author': author_id}, function(response) { @@ -410,11 +417,11 @@ module.controller( $scope.comparisonFilters.author = null; $scope.comparisonFilters.page = 1; if ($scope.comparisonFilters.group == null) { - $scope.users = $scope.allStudents; + $scope.resetUsers($scope.allInstructionals, $scope.allStudents); } else { GroupResource.get({'courseId': $scope.courseId, 'groupName': $scope.comparisonFilters.group}).$promise.then( function (ret) { - $scope.users = ret.students; + $scope.resetUsers([], ret.students); } ); } @@ -437,6 +444,7 @@ module.controller( }); }; $scope.updateList(); + $scope.resetUsers($scope.allInstructionals, $scope.allStudents); }] ); diff --git a/compair/static/modules/comparison/comparison-view-partial.html b/compair/static/modules/comparison/comparison-view-partial.html index 65b9cf354..0e7f61e00 100644 --- a/compair/static/modules/comparison/comparison-view-partial.html +++ b/compair/static/modules/comparison/comparison-view-partial.html @@ -17,7 +17,7 @@

All comparisons