Skip to content

Bug: instructor editing student answer overwrites student authorship #1107

@catinhere

Description

@catinhere

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

  1. Log in as an instructor
  2. Open a student's answer and click Edit
  3. Make any change and save
  4. 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;
        }
    }
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No fields configured for Bug.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions