don't resubmit discussion assignments marked as graded
fixes #7790 fixes #6273 we weren't properly checking the workflow state when deciding whether or not to create a new submission for discussion assignment posts. also, we were ensuring that a submission exists for the entry every time the topic was updated, which is more often than necessary. test-plan: - create a discussion assignment - as a user, post an entry - as a teacher, grade the assignment - do something that would update the topic - make sure a new submission isn't created and that the status is speedgrader is still graded. Change-Id: Ic2d0fc5d809695cf856b2902bd8b478fe3bf6934 Reviewed-on: https://gerrit.instructure.com/9543 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Zach Wily <zach@instructure.com>
This commit is contained in:
parent
0082d1279a
commit
b227cdc537
|
@ -1025,8 +1025,6 @@ class Assignment < ActiveRecord::Base
|
|||
return primary_homework
|
||||
end
|
||||
|
||||
|
||||
|
||||
def submissions_downloaded?
|
||||
self.submissions_downloads && self.submissions_downloads > 0
|
||||
end
|
||||
|
|
|
@ -340,7 +340,7 @@ class DiscussionEntry < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def context_module_action_later
|
||||
self.send_later(:context_module_action)
|
||||
self.send_later_if_production(:context_module_action)
|
||||
end
|
||||
protected :context_module_action_later
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
# ungraded to graded, or from one assignment to another; we ignore the
|
||||
# transition from graded to ungraded) we acknowledge that the users that
|
||||
# have posted have contributed to the topic
|
||||
if self.assignment_id && self.assignment_id != @old_assignment_id
|
||||
if self.assignment_id && self.assignment_id_changed?
|
||||
posters.each{ |user| self.context_module_action(user, :contributed) }
|
||||
end
|
||||
end
|
||||
|
@ -507,7 +507,7 @@ class DiscussionTopic < ActiveRecord::Base
|
|||
|
||||
def ensure_submission(user)
|
||||
submission = Submission.find_by_assignment_id_and_user_id(self.assignment_id, user.id)
|
||||
return if submission && submission.submission_type == 'discussion_topic' && submission.workflow_state == 'submitted'
|
||||
return if submission && submission.submission_type == 'discussion_topic' && submission.workflow_state != 'unsubmitted'
|
||||
self.assignment.submit_homework(user, :submission_type => 'discussion_topic')
|
||||
end
|
||||
|
||||
|
|
|
@ -469,20 +469,23 @@ describe DiscussionTopic do
|
|||
end
|
||||
|
||||
it "should not re-flag graded discussion as needs grading if student make another comment" do
|
||||
pending('bug 6273 - do not re-flag graded discussion as needs grading if student make another comment') do
|
||||
student_enrollment = student_in_course(:name => 'student in course')
|
||||
student = student_enrollment.user
|
||||
assignment = @course.assignments.create(:title => "discussion assignment", :points_possible => 20)
|
||||
topic = @course.discussion_topics.create!(:title => 'discussion topic 1', :message => "this is a new discussion topic", :assignment => assignment)
|
||||
topic.discussion_entries.create!(:message => "student message for grading", :user => student)
|
||||
student_submission = Submission.last
|
||||
student_submission.assignment.grade_student(student, {:grade => 9})
|
||||
student_submission.reload
|
||||
student_submission.workflow_state.should == 'graded'
|
||||
topic.discussion_entries.create!(:message => "student message 2 for grading", :user => student)
|
||||
student_submission.reload
|
||||
student_submission.workflow_state.should == 'graded'
|
||||
end
|
||||
student_in_course(:name => 'student in course')
|
||||
assignment = @course.assignments.create(:title => "discussion assignment", :points_possible => 20)
|
||||
topic = @course.discussion_topics.create!(:title => 'discussion topic 1', :message => "this is a new discussion topic", :assignment => assignment)
|
||||
topic.discussion_entries.create!(:message => "student message for grading", :user => @student)
|
||||
|
||||
submissions = Submission.find_all_by_user_id_and_assignment_id(@student.id, assignment.id)
|
||||
submissions.count.should == 1
|
||||
student_submission = submissions.first
|
||||
assignment.grade_student(@student, {:grade => 9})
|
||||
student_submission.reload
|
||||
student_submission.workflow_state.should == 'graded'
|
||||
|
||||
topic.discussion_entries.create!(:message => "student message 2 for grading", :user => @student)
|
||||
submissions = Submission.find_all_by_user_id_and_assignment_id(@student.id, assignment.id)
|
||||
submissions.count.should == 1
|
||||
student_submission = submissions.first
|
||||
student_submission.workflow_state.should == 'graded'
|
||||
end
|
||||
|
||||
it "should create submissions for existing entries when setting the assignment" do
|
||||
|
@ -583,6 +586,25 @@ describe DiscussionTopic do
|
|||
@student.submissions.size.should == 1
|
||||
@student.submissions.first.id.should == @existing_submission_id
|
||||
end
|
||||
|
||||
it "should not resubmit graded discussion submissions" do
|
||||
@student = student_in_course(:active_all => true).user
|
||||
|
||||
@assignment = assignment_model(:course => @course)
|
||||
@topic.assignment = @assignment
|
||||
@topic.save!
|
||||
@topic.reload
|
||||
|
||||
@topic.reply_from(:user => @student, :text => "entry")
|
||||
@student.reload
|
||||
|
||||
@assignment.grade_student(@student, :grade => 1)
|
||||
@submission = Submission.find(:first, :conditions => {:user_id => @student.id, :assignment_id => @assignment.id})
|
||||
@submission.workflow_state.should == 'graded'
|
||||
|
||||
@topic.ensure_submission(@student)
|
||||
@submission.reload.workflow_state.should == 'graded'
|
||||
end
|
||||
end
|
||||
|
||||
context "read/unread state" do
|
||||
|
|
Loading…
Reference in New Issue