Summary
When an instructor edits a student's answer, the answer is saved as authored by the instructor instead of the original student.
Steps to Reproduce
- Log in as an instructor
- Open a student's answer and click Edit
- Make any change and save
- The answer now shows as authored by the instructor, not the original student
Root Cause
Introduced in commit 7f416cb6 ("Fix re-review issues, primarily with self-eval form").
The user_id preset was moved from inside the if ($scope.method == "create") block into the getInstructors async callback in compair/static/modules/answer/answer-module.js, dropping the create-only guard in the process:
// canManageAssignment block — runs for BOTH create and edit
CourseResource.getInstructors({'id': $scope.courseId}, function (ret) {
$scope.instructors = ret.objects;
var found = $filter('filter')($scope.instructors, $scope.loggedInUserId, true);
if (found != "") {
// preset the user_id if instructors creating new answers <-- comment says "creating" but runs on edit too
$scope.answer.user_id = $scope.loggedInUserId;
}
});
Before 7f416cb6, the preset was correctly guarded inside if ($scope.method == "create"), so editing a student's answer preserved the student as author.
Fix
Wrap the user_id assignment in a $scope.method == 'create' check in compair/static/modules/answer/answer-module.js:
CourseResource.getInstructors({'id': $scope.courseId}, function (ret) {
$scope.instructors = ret.objects;
if ($scope.method == 'create') {
var found = $filter('filter')($scope.instructors, $scope.loggedInUserId, true);
if (found != "") {
$scope.answer.user_id = $scope.loggedInUserId;
}
}
});
Summary
When an instructor edits a student's answer, the answer is saved as authored by the instructor instead of the original student.
Steps to Reproduce
Root Cause
Introduced in commit
7f416cb6("Fix re-review issues, primarily with self-eval form").The
user_idpreset was moved from inside theif ($scope.method == "create")block into thegetInstructorsasync callback incompair/static/modules/answer/answer-module.js, dropping the create-only guard in the process:Before
7f416cb6, the preset was correctly guarded insideif ($scope.method == "create"), so editing a student's answer preserved the student as author.Fix
Wrap the
user_idassignment in a$scope.method == 'create'check incompair/static/modules/answer/answer-module.js: