Skip to content

Commit

Permalink
Clear late policy status on new submission
Browse files Browse the repository at this point in the history
fixes CNVS-38203

Test plan:
* Create an assignment in a course with a student
* As the student, submit something for the assignment
* As a teacher, manually mark the submission as missing
* As the student, submit something again

The "missing" status should be cleared.

Change-Id: I8649a634043477f89a6d93269d10e2e59da1495e
Reviewed-on: https://gerrit.instructure.com/118977
Reviewed-by: Gary Mei <[email protected]>
Reviewed-by: Shahbaz Javeed <[email protected]>
Tested-by: Jenkins
Product-Review: Keith T. Garner <[email protected]>
QA-Review: Keith T. Garner <[email protected]>
  • Loading branch information
neilgupta committed Jul 14, 2017
1 parent e0668bb commit 98db0b4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
2 changes: 2 additions & 0 deletions app/models/assignment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1631,6 +1631,8 @@ def submit_homework(original_student, opts={})
# clear out attributes from prior submissions
if opts[:submission_type].present?
SUBMIT_HOMEWORK_ATTRS.each { |attr| homework[attr] = nil }
homework.late_policy_status = nil
homework.seconds_late_override = nil
end

student = homework.user
Expand Down
12 changes: 12 additions & 0 deletions spec/models/assignment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1282,10 +1282,16 @@
end

it "clears out stale submission information" do
@a.submissions.find_by(user: @user).update(
late_policy_status: 'late',
seconds_late_override: 120
)
s = @a.submit_homework(@user, submission_type: "online_url",
url: "http://example.com")
expect(s.submission_type).to eq "online_url"
expect(s.url).to eq "http://example.com"
expect(s.late_policy_status).to be nil
expect(s.seconds_late_override).to be nil

s2 = @a.submit_homework(@user, submission_type: "online_text_entry",
body: "blah blah blah blah blah blah blah")
Expand All @@ -1294,11 +1300,17 @@
expect(s2.url).to be_nil
expect(s2.workflow_state).to eq "submitted"

@a.submissions.find_by(user: @user).update(
late_policy_status: 'late',
seconds_late_override: 120
)
# comments shouldn't clear out submission data
s3 = @a.submit_homework(@user, comment: "BLAH BLAH")
expect(s3.body).to eq "blah blah blah blah blah blah blah"
expect(s3.submission_comments.first.comment).to eq "BLAH BLAH"
expect(s3.submission_type).to eq "online_text_entry"
expect(s3.late_policy_status).to eq "late"
expect(s3.seconds_late_override).to eq 120
end
end

Expand Down

0 comments on commit 98db0b4

Please sign in to comment.