2011-02-01 09:57:29 +08:00
|
|
|
#
|
2014-02-28 01:46:02 +08:00
|
|
|
# Copyright (C) 2011 - 2014 Instructure, Inc.
|
2011-02-01 09:57:29 +08:00
|
|
|
#
|
|
|
|
# This file is part of Canvas.
|
|
|
|
#
|
|
|
|
# Canvas is free software: you can redistribute it and/or modify it under
|
|
|
|
# the terms of the GNU Affero General Public License as published by the Free
|
|
|
|
# Software Foundation, version 3 of the License.
|
|
|
|
#
|
|
|
|
# Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
|
|
|
|
# A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
|
|
# details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Affero General Public License along
|
|
|
|
# with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
|
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2015-02-28 06:04:01 +08:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/../sharding_spec_helper.rb')
|
2011-11-08 01:06:01 +08:00
|
|
|
require File.expand_path(File.dirname(__FILE__) + '/../lib/validates_as_url.rb')
|
2011-02-01 09:57:29 +08:00
|
|
|
|
|
|
|
describe Submission do
|
2014-07-31 13:21:57 +08:00
|
|
|
before(:once) do
|
2015-02-28 06:04:01 +08:00
|
|
|
course_with_student(active_all: true)
|
|
|
|
@context = @course
|
2011-02-01 09:57:29 +08:00
|
|
|
@assignment = @context.assignments.new(:title => "some assignment")
|
|
|
|
@assignment.workflow_state = "published"
|
|
|
|
@assignment.save
|
|
|
|
@valid_attributes = {
|
|
|
|
:assignment_id => @assignment.id,
|
|
|
|
:user_id => @user.id,
|
|
|
|
:grade => "1.5",
|
|
|
|
:url => "www.instructure.com"
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should create a new instance given valid attributes" do
|
|
|
|
Submission.create!(@valid_attributes)
|
|
|
|
end
|
2012-12-12 21:50:15 +08:00
|
|
|
|
2014-01-24 05:13:49 +08:00
|
|
|
include_examples "url validation tests"
|
2011-11-08 01:06:01 +08:00
|
|
|
it "should check url validity" do
|
|
|
|
test_url_validation(Submission.create!(@valid_attributes))
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should add http:// to the body for long urls, too" do
|
|
|
|
s = Submission.create!(@valid_attributes)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.url).to eq 'http://www.instructure.com'
|
2011-11-08 01:06:01 +08:00
|
|
|
|
|
|
|
long_url = ("a"*300 + ".com")
|
|
|
|
s.url = long_url
|
|
|
|
s.save!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.url).to eq "http://#{long_url}"
|
2011-11-08 01:06:01 +08:00
|
|
|
# make sure it adds the "http://" to the body for long urls, too
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.body).to eq "http://#{long_url}"
|
2011-11-08 01:06:01 +08:00
|
|
|
end
|
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
it "should offer the context, if one is available" do
|
2011-10-26 07:15:30 +08:00
|
|
|
@course = Course.new
|
|
|
|
@assignment = Assignment.new(:context => @course)
|
|
|
|
@assignment.expects(:context).returns(@course)
|
2012-12-12 21:50:15 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
@submission = Submission.new
|
2014-10-14 10:08:00 +08:00
|
|
|
expect{@submission.context}.not_to raise_error
|
|
|
|
expect(@submission.context).to be_nil
|
2011-02-01 09:57:29 +08:00
|
|
|
@submission.assignment = @assignment
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.context).to eql(@course)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2012-12-12 21:50:15 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
it "should have an interesting state machine" do
|
|
|
|
submission_spec_model
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.state).to eql(:submitted)
|
2011-02-01 09:57:29 +08:00
|
|
|
@submission.grade_it
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.state).to eql(:graded)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2012-12-12 21:50:15 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
it "should be versioned" do
|
|
|
|
submission_spec_model
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_respond_to(:versions)
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
|
2011-10-13 00:19:46 +08:00
|
|
|
it "should not save new versions by default" do
|
|
|
|
submission_spec_model
|
2014-10-14 10:08:00 +08:00
|
|
|
expect {
|
2011-10-13 00:19:46 +08:00
|
|
|
@submission.save!
|
2014-10-14 10:08:00 +08:00
|
|
|
}.not_to change(@submission.versions, :count)
|
2011-10-13 00:19:46 +08:00
|
|
|
end
|
|
|
|
|
2013-04-16 07:06:20 +08:00
|
|
|
describe "version indexing" do
|
|
|
|
it "should create a SubmissionVersion when a new submission is created" do
|
2014-10-14 10:08:00 +08:00
|
|
|
expect {
|
2013-04-16 07:06:20 +08:00
|
|
|
submission_spec_model
|
2014-10-14 10:08:00 +08:00
|
|
|
}.to change(SubmissionVersion, :count)
|
2013-04-16 07:06:20 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should create a SubmissionVersion when a new version is saved" do
|
|
|
|
submission_spec_model
|
2014-10-14 10:08:00 +08:00
|
|
|
expect {
|
2013-04-16 07:06:20 +08:00
|
|
|
@submission.with_versioning(:explicit => true) { @submission.save }
|
2014-10-14 10:08:00 +08:00
|
|
|
}.to change(SubmissionVersion, :count)
|
2013-04-16 07:06:20 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-07-14 05:51:26 +08:00
|
|
|
it "should ensure the media object exists" do
|
|
|
|
assignment_model
|
|
|
|
se = @course.enroll_student(user)
|
|
|
|
MediaObject.expects(:ensure_media_object).with("fake", { :context => se.user, :user => se.user })
|
|
|
|
@submission = @assignment.submit_homework(se.user, :media_comment_id => "fake", :media_comment_type => "audio")
|
|
|
|
end
|
|
|
|
|
2013-12-03 04:42:07 +08:00
|
|
|
it "should log submissions with grade changes" do
|
|
|
|
submission_spec_model
|
|
|
|
|
|
|
|
Auditors::GradeChange.expects(:record).once
|
|
|
|
|
|
|
|
@submission.score = 5
|
|
|
|
@submission.save!
|
|
|
|
|
|
|
|
@submission.grader_id = @user.id
|
|
|
|
@submission.save!
|
|
|
|
end
|
|
|
|
|
2011-10-18 05:50:01 +08:00
|
|
|
context "Discussion Topic" do
|
2012-02-29 05:45:40 +08:00
|
|
|
it "should use correct date for its submitted_at value" do
|
|
|
|
course_with_student_logged_in(:active_all => true)
|
|
|
|
@topic = @course.discussion_topics.create(:title => "some topic")
|
|
|
|
@assignment = @course.assignments.create(:title => "some discussion assignment")
|
|
|
|
@assignment.submission_types = 'discussion_topic'
|
|
|
|
@assignment.save!
|
|
|
|
@entry1 = @topic.discussion_entries.create(:message => "first entry", :user => @user)
|
|
|
|
@topic.assignment_id = @assignment.id
|
|
|
|
@topic.save!
|
2013-03-26 23:19:59 +08:00
|
|
|
@submission = @assignment.submissions.where(:user_id => @entry1.user_id).first
|
2011-10-18 05:50:01 +08:00
|
|
|
new_time = Time.now + 30.minutes
|
2011-10-26 07:15:30 +08:00
|
|
|
Time.stubs(:now).returns(new_time)
|
2012-02-29 05:45:40 +08:00
|
|
|
@entry2 = @topic.discussion_entries.create(:message => "second entry", :user => @user)
|
2011-10-18 05:50:01 +08:00
|
|
|
@submission.reload
|
2014-10-14 10:08:00 +08:00
|
|
|
expect((@submission.submitted_at.to_i - @submission.created_at.to_i).abs).to be < 1.minute
|
2011-10-18 05:50:01 +08:00
|
|
|
end
|
2015-02-06 04:32:38 +08:00
|
|
|
|
|
|
|
it "should not create multiple versions on submission for discussion topics" do
|
|
|
|
course_with_student_logged_in(:active_all => true)
|
|
|
|
@topic = @course.discussion_topics.create(:title => "some topic")
|
|
|
|
@assignment = @course.assignments.create(:title => "some discussion assignment")
|
|
|
|
@assignment.submission_types = 'discussion_topic'
|
|
|
|
@assignment.save!
|
|
|
|
@topic.assignment_id = @assignment.id
|
|
|
|
@topic.save!
|
|
|
|
|
|
|
|
Timecop.freeze(1.second.ago) do
|
|
|
|
@assignment.submit_homework(@student, :submission_type => 'discussion_topic')
|
|
|
|
end
|
|
|
|
@assignment.submit_homework(@student, :submission_type => 'discussion_topic')
|
|
|
|
expect(@student.submissions.first.submission_history.count).to eq 1
|
|
|
|
end
|
2011-10-18 05:50:01 +08:00
|
|
|
end
|
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
context "broadcast policy" do
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
context "Submission Notifications" do
|
2014-07-31 13:21:57 +08:00
|
|
|
before :once do
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
Notification.create(:name => 'Assignment Submitted')
|
|
|
|
Notification.create(:name => 'Assignment Resubmitted')
|
2011-02-01 09:57:29 +08:00
|
|
|
Notification.create(:name => 'Assignment Submitted Late')
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
Notification.create(:name => 'Group Assignment Submitted Late')
|
|
|
|
|
2015-02-28 06:04:01 +08:00
|
|
|
course_with_teacher(course: @course, active_all: true)
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should send the correct message when an assignment is turned in on-time" do
|
|
|
|
@assignment.workflow_state = "published"
|
|
|
|
@assignment.update_attributes(:due_at => Time.now + 1000)
|
|
|
|
|
|
|
|
submission_spec_model(:user => @student)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.messages_sent.keys).to eq ['Assignment Submitted']
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should send the correct message when an assignment is turned in late" do
|
2011-02-01 09:57:29 +08:00
|
|
|
@assignment.workflow_state = "published"
|
|
|
|
@assignment.update_attributes(:due_at => Time.now - 1000)
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
|
|
|
|
submission_spec_model(:user => @student)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.messages_sent.keys).to eq ['Assignment Submitted Late']
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should send the correct message when an assignment is resubmitted on-time" do
|
|
|
|
@assignment.submission_types = ['online_text_entry']
|
|
|
|
@assignment.due_at = Time.now + 1000
|
|
|
|
@assignment.save!
|
|
|
|
|
|
|
|
@assignment.submit_homework(@student, :body => "lol")
|
|
|
|
resubmission = @assignment.submit_homework(@student, :body => "frd")
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(resubmission.messages_sent.keys).to eq ['Assignment Resubmitted']
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should send the correct message when an assignment is resubmitted late" do
|
|
|
|
@assignment.submission_types = ['online_text_entry']
|
|
|
|
@assignment.due_at = Time.now - 1000
|
|
|
|
@assignment.save!
|
|
|
|
|
|
|
|
@assignment.submit_homework(@student, :body => "lol")
|
|
|
|
resubmission = @assignment.submit_homework(@student, :body => "frd")
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(resubmission.messages_sent.keys).to eq ['Assignment Submitted Late']
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should send the correct message when a group assignment is submitted late" do
|
|
|
|
@a = assignment_model(:course => @context, :group_category => "Study Groups", :due_at => Time.now - 1000, :submission_types => ["online_text_entry"])
|
|
|
|
@group1 = @a.context.groups.create!(:name => "Study Group 1", :group_category => @a.group_category)
|
|
|
|
@group1.add_user(@student)
|
|
|
|
submission = @a.submit_homework @student, :submission_type => "online_text_entry", :body => "blah"
|
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission.messages_sent.keys).to eq ['Group Assignment Submitted Late']
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
VDD: notifications; closes #10896
The following changes have been made:
- Assignment Created
- students see the due date that applies to them
- admins see "Multiple Dates"
- Assignment Due Date Changed
- students see the due date that applies to them;
they receive no notification if their date doesn't change
- admins receive a separate notification for each due
date that changes, that they have access to;
the message indicates which section or group applies
(section-limited TAs will not get messages about due dates
in sections they can't see)
- Assignment Submitted Late
- the message text does not change, but the student's overridden
due date is checked
- Group Assignment Submitted Late
- same as previous
There were some bugs fixed along the way:
- no longer send duplicate Assignment Submitted and
Assignment Resubmitted notifications when an assignment
is resubmitted
- Group Assignment Submitted Late actually goes out
(there was a typo in the whenever clause)
Test plan:
- Create a course with two sections and a teacher
- Enroll a student in each section
- Enroll a section-limited TA in each section
- Make sure everybody involved is signed up for "Due Date"
notifications, ASAP
- Using the API, Create an assignment with a default due date
(in the past) and an overridden due date for section 2
(in the future). the assignment and override must be
created in the same request (use the "Create an assignment"
API and supply assignment[assignment_overrides]; it may
be easier to use a JSON request body)
- Verify that everybody got an "Assignment Created"
message (use /users/X/messages)
- the teacher should see "Multiple Dates",
as should the TA in section 2 (because the default date
is still visible to him)
- the student and the TA in section 1 should see
the default due date
- the student in section 2 should see the overridden
due date
- "Due Date Changed" messages will not go out for assignments
that were created less than 3 hours ago (by design, and not
new with this changeset), so for the remaining items, you
either need to wait 3 hours, or falsify created_at for the
assignment you just made...
- Change the default due date for the assignment, leaving it
in the past
- Everybody except the student in section 2 should get a
notification with the new date
- Change the overridden due date for section 2, leaving it
in the future
- everybody except the teacher and TA in section 1 should get
a notification about the new date
- the teacher and section-2 TA's notifications should indicate
that they apply to section 2 (the student's should not)
- submit the assignment as each student
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not
- submit again
- the teacher should get one notification about each submission:
the one about the student in section 1 should say it's late;
the one about the student in section 2 should not, and should
be identified as a resubmission
(there is no late-re-submission notification)
Change-Id: I26e57807ea0c83b69e2b532ec8822f6570ba1701
Reviewed-on: https://gerrit.instructure.com/14662
Tested-by: Jenkins <jenkins@instructure.com>
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
2012-10-27 04:10:08 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
context "Submission Graded" do
|
2014-07-31 13:21:57 +08:00
|
|
|
before :once do
|
2011-02-01 09:57:29 +08:00
|
|
|
Notification.create(:name => 'Submission Graded')
|
2013-05-09 00:45:10 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should create a message when the assignment has been graded and published" do
|
2011-02-01 09:57:29 +08:00
|
|
|
submission_spec_model
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
@submission.reload
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.assignment).to eql(@assignment)
|
|
|
|
expect(@submission.assignment.state).to eql(:published)
|
2011-02-01 09:57:29 +08:00
|
|
|
@submission.grade_it!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.messages_sent).to be_include('Submission Graded')
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2011-09-15 06:41:56 +08:00
|
|
|
|
|
|
|
it "should not create a message when a muted assignment has been graded and published" do
|
|
|
|
submission_spec_model
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
@assignment.mute!
|
|
|
|
@submission.reload
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.assignment).to eql(@assignment)
|
|
|
|
expect(@submission.assignment.state).to eql(:published)
|
2011-09-15 06:41:56 +08:00
|
|
|
@submission.grade_it!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.messages_sent).not_to be_include "Submission Graded"
|
2011-09-15 06:41:56 +08:00
|
|
|
end
|
|
|
|
|
2013-05-09 00:45:10 +08:00
|
|
|
it "should not create a message when this is a quiz submission" do
|
|
|
|
submission_spec_model
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
2014-01-15 06:11:27 +08:00
|
|
|
@quiz = Quizzes::Quiz.create!(:context => @course)
|
2013-05-09 00:45:10 +08:00
|
|
|
@submission.quiz_submission = @quiz.generate_submission(@user)
|
|
|
|
@submission.save!
|
|
|
|
@submission.reload
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.assignment).to eql(@assignment)
|
|
|
|
expect(@submission.assignment.state).to eql(:published)
|
2013-05-09 00:45:10 +08:00
|
|
|
@submission.grade_it!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.messages_sent).not_to include('Submission Graded')
|
2013-05-09 00:45:10 +08:00
|
|
|
end
|
|
|
|
|
2011-09-15 06:41:56 +08:00
|
|
|
it "should create a hidden stream_item_instance when muted, graded, and published" do
|
|
|
|
submission_spec_model
|
|
|
|
@cc = @user.communication_channels.create :path => "somewhere"
|
|
|
|
@assignment.mute!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect {
|
2011-09-15 06:41:56 +08:00
|
|
|
@submission = @assignment.grade_student(@user, :grade => 10)[0]
|
2014-10-14 10:08:00 +08:00
|
|
|
}.to change StreamItemInstance, :count
|
|
|
|
expect(@user.stream_item_instances.last).to be_hidden
|
2011-09-15 06:41:56 +08:00
|
|
|
end
|
2011-12-11 08:09:40 +08:00
|
|
|
|
|
|
|
it "should hide any existing stream_item_instances when muted" do
|
|
|
|
submission_spec_model
|
|
|
|
@cc = @user.communication_channels.create :path => "somewhere"
|
2014-10-14 10:08:00 +08:00
|
|
|
expect {
|
2011-12-11 08:09:40 +08:00
|
|
|
@submission = @assignment.grade_student(@user, :grade => 10)[0]
|
2014-10-14 10:08:00 +08:00
|
|
|
}.to change StreamItemInstance, :count
|
|
|
|
expect(@user.stream_item_instances.last).not_to be_hidden
|
2011-12-11 08:09:40 +08:00
|
|
|
@assignment.mute!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@user.stream_item_instances.last).to be_hidden
|
2011-12-11 08:09:40 +08:00
|
|
|
end
|
2012-08-28 02:28:34 +08:00
|
|
|
|
|
|
|
it "should not create a message for admins and teachers with quiz submissions" do
|
|
|
|
course_with_teacher(:active_all => true)
|
|
|
|
assignment = @course.assignments.create!(
|
|
|
|
:title => 'assignment',
|
|
|
|
:points_possible => 10)
|
|
|
|
quiz = @course.quizzes.build(
|
|
|
|
:assignment_id => assignment.id,
|
|
|
|
:title => 'test quiz',
|
|
|
|
:points_possible => 10)
|
|
|
|
quiz.workflow_state = 'available'
|
|
|
|
quiz.save!
|
|
|
|
|
|
|
|
user = account_admin_user
|
|
|
|
channel = user.communication_channels.create!(:path => 'admin@example.com')
|
|
|
|
submission = quiz.generate_submission(user, false)
|
2014-04-22 04:14:52 +08:00
|
|
|
Quizzes::SubmissionGrader.new(submission).grade_submission
|
2012-08-28 02:28:34 +08:00
|
|
|
|
|
|
|
channel2 = @teacher.communication_channels.create!(:path => 'chang@example.com')
|
|
|
|
submission2 = quiz.generate_submission(@teacher, false)
|
2014-04-22 04:14:52 +08:00
|
|
|
Quizzes::SubmissionGrader.new(submission2).grade_submission
|
2012-08-28 02:28:34 +08:00
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission.submission.messages_sent).not_to be_include('Submission Graded')
|
|
|
|
expect(submission2.submission.messages_sent).not_to be_include('Submission Graded')
|
2012-08-28 02:28:34 +08:00
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2011-09-15 06:41:56 +08:00
|
|
|
|
|
|
|
it "should create a stream_item_instance when graded and published" do
|
|
|
|
Notification.create :name => "Submission Graded"
|
|
|
|
submission_spec_model
|
|
|
|
@cc = @user.communication_channels.create :path => "somewhere"
|
2014-10-14 10:08:00 +08:00
|
|
|
expect {
|
2011-09-15 06:41:56 +08:00
|
|
|
@assignment.grade_student(@user, :grade => 10)
|
2014-10-14 10:08:00 +08:00
|
|
|
}.to change StreamItemInstance, :count
|
2011-09-15 06:41:56 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should create a stream_item_instance when graded, and then made it visible when unmuted" do
|
|
|
|
Notification.create :name => "Submission Graded"
|
|
|
|
submission_spec_model
|
|
|
|
@cc = @user.communication_channels.create :path => "somewhere"
|
|
|
|
@assignment.mute!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect {
|
2011-09-15 06:41:56 +08:00
|
|
|
@assignment.grade_student(@user, :grade => 10)
|
2014-10-14 10:08:00 +08:00
|
|
|
}.to change StreamItemInstance, :count
|
2011-09-15 06:41:56 +08:00
|
|
|
|
|
|
|
@assignment.unmute!
|
2013-03-26 23:19:59 +08:00
|
|
|
stream_item_ids = StreamItem.where(:asset_type => 'Submission', :asset_id => @assignment.submissions.all).pluck(:id)
|
|
|
|
stream_item_instances = StreamItemInstance.where(:stream_item_id => stream_item_ids)
|
2014-10-14 10:08:00 +08:00
|
|
|
stream_item_instances.each { |sii| expect(sii).not_to be_hidden }
|
2011-09-15 06:41:56 +08:00
|
|
|
end
|
|
|
|
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
context "Submission Grade Changed" do
|
|
|
|
it "should create a message when the score is changed and the grades were already published" do
|
|
|
|
Notification.create(:name => 'Submission Grade Changed')
|
2013-10-21 22:29:26 +08:00
|
|
|
@assignment.stubs(:score_to_grade).returns("10.0")
|
2011-10-26 07:15:30 +08:00
|
|
|
@assignment.stubs(:due_at).returns(Time.now - 100)
|
2011-02-01 09:57:29 +08:00
|
|
|
submission_spec_model
|
|
|
|
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
s = @assignment.grade_student(@user, :grade => 10)[0] #@submission
|
|
|
|
s.graded_at = Time.parse("Jan 1 2000")
|
|
|
|
s.save
|
|
|
|
@submission = @assignment.grade_student(@user, :grade => 9)[0]
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to eql(s)
|
|
|
|
expect(@submission.messages_sent).to be_include('Submission Grade Changed')
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
|
|
|
it 'doesnt create a grade changed message when theres a quiz attached' do
|
|
|
|
Notification.create(:name => 'Submission Grade Changed')
|
2013-10-21 22:29:26 +08:00
|
|
|
@assignment.stubs(:score_to_grade).returns("10.0")
|
2013-05-09 00:45:10 +08:00
|
|
|
@assignment.stubs(:due_at).returns(Time.now - 100)
|
|
|
|
submission_spec_model
|
2014-01-15 06:11:27 +08:00
|
|
|
@quiz = Quizzes::Quiz.create!(:context => @course)
|
2013-05-09 00:45:10 +08:00
|
|
|
@submission.quiz_submission = @quiz.generate_submission(@user)
|
|
|
|
@submission.save!
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
s = @assignment.grade_student(@user, :grade => 10)[0] #@submission
|
|
|
|
s.graded_at = Time.parse("Jan 1 2000")
|
|
|
|
s.save
|
|
|
|
@submission = @assignment.grade_student(@user, :grade => 9)[0]
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to eql(s)
|
|
|
|
expect(@submission.messages_sent).not_to include('Submission Grade Changed')
|
2013-05-09 00:45:10 +08:00
|
|
|
end
|
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
it "should create a message when the score is changed and the grades were already published" do
|
|
|
|
Notification.create(:name => 'Submission Grade Changed')
|
|
|
|
Notification.create(:name => 'Submission Graded')
|
2013-10-21 22:29:26 +08:00
|
|
|
@assignment.stubs(:score_to_grade).returns("10.0")
|
2011-10-26 07:15:30 +08:00
|
|
|
@assignment.stubs(:due_at).returns(Time.now - 100)
|
2011-02-01 09:57:29 +08:00
|
|
|
submission_spec_model
|
|
|
|
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
s = @assignment.grade_student(@user, :grade => 10)[0] #@submission
|
|
|
|
@submission = @assignment.grade_student(@user, :grade => 9)[0]
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to eql(s)
|
|
|
|
expect(@submission.messages_sent).not_to be_include('Submission Grade Changed')
|
|
|
|
expect(@submission.messages_sent).to be_include('Submission Graded')
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
2011-09-15 06:41:56 +08:00
|
|
|
|
|
|
|
it "should not create a message when the score is changed and the grades were already published for a muted assignment" do
|
|
|
|
Notification.create(:name => 'Submission Grade Changed')
|
|
|
|
@assignment.mute!
|
2013-10-21 22:29:26 +08:00
|
|
|
@assignment.stubs(:score_to_grade).returns("10.0")
|
2011-10-26 07:15:30 +08:00
|
|
|
@assignment.stubs(:due_at).returns(Time.now - 100)
|
2011-09-15 06:41:56 +08:00
|
|
|
submission_spec_model
|
|
|
|
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
s = @assignment.grade_student(@user, :grade => 10)[0] #@submission
|
|
|
|
s.graded_at = Time.parse("Jan 1 2000")
|
|
|
|
s.save
|
|
|
|
@submission = @assignment.grade_student(@user, :grade => 9)[0]
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to eql(s)
|
|
|
|
expect(@submission.messages_sent).not_to be_include('Submission Grade Changed')
|
2011-09-15 06:41:56 +08:00
|
|
|
|
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2011-02-01 09:57:29 +08:00
|
|
|
it "should NOT create a message when the score is changed and the submission was recently graded" do
|
|
|
|
Notification.create(:name => 'Submission Grade Changed')
|
2013-10-21 22:29:26 +08:00
|
|
|
@assignment.stubs(:score_to_grade).returns("10.0")
|
2011-10-26 07:15:30 +08:00
|
|
|
@assignment.stubs(:due_at).returns(Time.now - 100)
|
2011-02-01 09:57:29 +08:00
|
|
|
submission_spec_model
|
|
|
|
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
s = @assignment.grade_student(@user, :grade => 10)[0] #@submission
|
|
|
|
@submission = @assignment.grade_student(@user, :grade => 9)[0]
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to eql(s)
|
|
|
|
expect(@submission.messages_sent).not_to be_include('Submission Grade Changed')
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2011-10-20 02:40:49 +08:00
|
|
|
context "turnitin" do
|
2012-02-21 00:37:11 +08:00
|
|
|
context "submission" do
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
def init_turnitin_api
|
|
|
|
@turnitin_api = Turnitin::Client.new('test_account', 'sekret')
|
|
|
|
@submission.context.expects(:turnitin_settings).at_least(1).returns([:placeholder])
|
|
|
|
Turnitin::Client.expects(:new).at_least(1).with(:placeholder).returns(@turnitin_api)
|
|
|
|
end
|
|
|
|
|
2014-07-31 13:21:57 +08:00
|
|
|
before(:once) do
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
@assignment.submission_types = "online_upload,online_text_entry"
|
|
|
|
@assignment.turnitin_enabled = true
|
|
|
|
@assignment.turnitin_settings = @assignment.turnitin_settings
|
|
|
|
@assignment.save!
|
|
|
|
@submission = @assignment.submit_homework(@user, { :body => "hello there", :submission_type => 'online_text_entry' })
|
|
|
|
end
|
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
it "should submit to turnitin after a delay" do
|
2012-08-16 23:20:29 +08:00
|
|
|
job = Delayed::Job.list_jobs(:future, 100).find { |j| j.tag == 'Submission#submit_to_turnitin' }
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(job).not_to be_nil
|
|
|
|
expect(job.run_at).to be > Time.now.utc
|
2012-02-21 00:37:11 +08:00
|
|
|
end
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
|
|
|
|
it "should initially set turnitin submission to pending" do
|
|
|
|
init_turnitin_api
|
|
|
|
@turnitin_api.expects(:createOrUpdateAssignment).with(@assignment, @assignment.turnitin_settings).returns({ :assignment_id => "1234" })
|
2014-05-20 02:03:41 +08:00
|
|
|
@turnitin_api.expects(:enrollStudent).with(@context, @user).returns(stub(:success? => true))
|
|
|
|
@turnitin_api.expects(:submitPaper).returns({
|
|
|
|
@submission.asset_string => {
|
|
|
|
:object_id => '12345'
|
|
|
|
}
|
|
|
|
})
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
@submission.submit_to_turnitin
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.reload.turnitin_data[@submission.asset_string][:status]).to eq 'pending'
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should schedule a retry if something fails initially" do
|
|
|
|
init_turnitin_api
|
|
|
|
@turnitin_api.expects(:createOrUpdateAssignment).with(@assignment, @assignment.turnitin_settings).returns({ :assignment_id => "1234" })
|
2014-05-20 02:03:41 +08:00
|
|
|
@turnitin_api.expects(:enrollStudent).with(@context, @user).returns(stub(:success? => false))
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
@submission.submit_to_turnitin
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(Delayed::Job.list_jobs(:future, 100).find_all { |j| j.tag == 'Submission#submit_to_turnitin' }.size).to eq 2
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should set status as failed if something fails after several attempts" do
|
|
|
|
init_turnitin_api
|
2014-05-20 02:03:41 +08:00
|
|
|
@assignment.expects(:create_in_turnitin).returns(false)
|
|
|
|
@turnitin_api.expects(:enrollStudent).with(@context, @user).returns(stub(:success? => false, :error? => true, :error_hash => {}))
|
|
|
|
@turnitin_api.expects(:submitPaper).never
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
@submission.submit_to_turnitin(Submission::TURNITIN_RETRY)
|
2014-05-20 02:03:41 +08:00
|
|
|
expect(@submission.reload.turnitin_data[:status]).to eq 'error'
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
it "should set status back to pending on retry" do
|
|
|
|
init_turnitin_api
|
|
|
|
# first a submission, to get us into failed state
|
2014-05-20 02:03:41 +08:00
|
|
|
@assignment.expects(:create_in_turnitin).returns(false)
|
|
|
|
@turnitin_api.expects(:enrollStudent).with(@context, @user).returns(stub(:success? => false, :error? => true, :error_hash => {}))
|
|
|
|
@turnitin_api.expects(:submitPaper).never
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
@submission.submit_to_turnitin(Submission::TURNITIN_RETRY)
|
2014-05-20 02:03:41 +08:00
|
|
|
expect(@submission.reload.turnitin_data[:status]).to eq 'error'
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
|
|
|
|
# resubmit
|
|
|
|
@submission.resubmit_to_turnitin
|
2014-05-20 02:03:41 +08:00
|
|
|
expect(@submission.reload.turnitin_data[:status]).to be_nil
|
|
|
|
expect(@submission.turnitin_data[@submission.asset_string][:status]).to eq 'pending'
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should set status to scored on success" do
|
|
|
|
init_turnitin_api
|
|
|
|
@submission.turnitin_data ||= {}
|
|
|
|
@submission.turnitin_data[@submission.asset_string] = { :object_id => '1234', :status => 'pending' }
|
|
|
|
@turnitin_api.expects(:generateReport).with(@submission, @submission.asset_string).returns({
|
|
|
|
:similarity_score => 56,
|
|
|
|
:web_overlap => 22,
|
|
|
|
:publication_overlap => 0,
|
|
|
|
:student_overlap => 33
|
|
|
|
})
|
|
|
|
|
2012-06-21 05:23:07 +08:00
|
|
|
@submission.check_turnitin_status
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.reload.turnitin_data[@submission.asset_string][:status]).to eq 'scored'
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should set status as failed if something fails after several attempts" do
|
|
|
|
init_turnitin_api
|
|
|
|
@submission.turnitin_data ||= {}
|
|
|
|
@submission.turnitin_data[@submission.asset_string] = { :object_id => '1234', :status => 'pending' }
|
|
|
|
@turnitin_api.expects(:generateReport).with(@submission, @submission.asset_string).returns({})
|
|
|
|
|
2012-08-16 23:20:29 +08:00
|
|
|
expects_job_with_tag('Submission#check_turnitin_status') do
|
2014-12-11 02:24:34 +08:00
|
|
|
@submission.check_turnitin_status(Submission::TURNITIN_STATUS_RETRY-1)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.reload.turnitin_data[@submission.asset_string][:status]).to eq 'pending'
|
2012-08-16 23:20:29 +08:00
|
|
|
end
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
|
2014-12-11 02:24:34 +08:00
|
|
|
@submission.check_turnitin_status(Submission::TURNITIN_STATUS_RETRY)
|
2014-05-20 02:03:41 +08:00
|
|
|
@submission.reload
|
|
|
|
updated_data = @submission.turnitin_data[@submission.asset_string]
|
|
|
|
expect(updated_data[:status]).to eq 'error'
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
end
|
2012-06-21 05:23:07 +08:00
|
|
|
|
|
|
|
it "should check status for all assets" do
|
|
|
|
init_turnitin_api
|
|
|
|
@submission.turnitin_data ||= {}
|
|
|
|
@submission.turnitin_data[@submission.asset_string] = { :object_id => '1234', :status => 'pending' }
|
|
|
|
@submission.turnitin_data["other_asset"] = { :object_id => 'xxyy', :status => 'pending' }
|
|
|
|
@turnitin_api.expects(:generateReport).with(@submission, @submission.asset_string).returns({
|
|
|
|
:similarity_score => 56, :web_overlap => 22, :publication_overlap => 0, :student_overlap => 33
|
|
|
|
})
|
|
|
|
@turnitin_api.expects(:generateReport).with(@submission, "other_asset").returns({ :similarity_score => 20 })
|
|
|
|
|
|
|
|
@submission.check_turnitin_status
|
|
|
|
@submission.reload
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.turnitin_data[@submission.asset_string][:status]).to eq 'scored'
|
|
|
|
expect(@submission.turnitin_data["other_asset"][:status]).to eq 'scored'
|
2012-06-21 05:23:07 +08:00
|
|
|
end
|
2014-10-22 10:14:08 +08:00
|
|
|
|
|
|
|
it "should not blow up if submission_type has changed when job runs" do
|
|
|
|
@submission.submission_type = 'online_url'
|
|
|
|
@submission.context.expects(:turnitin_settings).never
|
|
|
|
expect { @submission.submit_to_turnitin }.not_to raise_error
|
|
|
|
end
|
2011-10-20 02:40:49 +08:00
|
|
|
end
|
|
|
|
|
2013-06-05 23:34:43 +08:00
|
|
|
describe "group" do
|
2014-07-31 13:21:57 +08:00
|
|
|
before(:once) do
|
2013-06-05 23:34:43 +08:00
|
|
|
@teacher = User.create(:name => "some teacher")
|
|
|
|
@student = User.create(:name => "a student")
|
|
|
|
@student1 = User.create(:name => "student 1")
|
|
|
|
@context.enroll_teacher(@teacher)
|
|
|
|
@context.enroll_student(@student)
|
|
|
|
@context.enroll_student(@student1)
|
|
|
|
|
|
|
|
@a = assignment_model(:course => @context, :group_category => "Study Groups")
|
|
|
|
@a.submission_types = "online_upload,online_text_entry"
|
|
|
|
@a.turnitin_enabled = true
|
|
|
|
@a.save!
|
|
|
|
|
|
|
|
@group1 = @a.context.groups.create!(:name => "Study Group 1", :group_category => @a.group_category)
|
|
|
|
@group1.add_user(@student)
|
|
|
|
@group1.add_user(@student1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should submit to turnitin for the original submitter" do
|
|
|
|
submission = @a.submit_homework @student, :submission_type => "online_text_entry", :body => "blah"
|
2014-09-27 21:46:36 +08:00
|
|
|
Submission.where(assignment_id: @a).each do |s|
|
2013-06-05 23:34:43 +08:00
|
|
|
if s.id == submission.id
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.turnitin_data[:last_processed_attempt]).to be > 0
|
2013-06-05 23:34:43 +08:00
|
|
|
else
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.turnitin_data).to eq({})
|
2013-06-05 23:34:43 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
context "report" do
|
2014-07-31 13:21:57 +08:00
|
|
|
before :once do
|
allow teachers to resubmit to turnitin; closes #7981
add more structure to the turnitin_data hash on a submission to keep track of
what state things are in, so that we can present errors to the user as they
happen and provide a way to resubmit. there are three states: 'pending',
'error', and 'scored'.
submissions start out as 'pending', and can move to 'error' if anything goes
wrong in the submission process (either in creating the assignment, enrolling
the user, or actually submitting the paper). there are built in retrys, and the
error state only gets set if there is still an error after the retry limit. if
this succeeds, we stay pending until the score is successfully retrieved from
turnitin, at which point it is marked 'scored'.
this change is primarily in speed grader, although icons have been updated in
the gradebooks and submission pages as well. in the 'scored' state, (or without
a state) things should work exactly as they have previously - display a score,
which can be clicked to see the full report. in the 'error' state (indicated
with an exclaimation point icon), clicking the icon gives you more details
about the error and the option to resubmit. in the 'pending' state (indicated
by a clock icon), clicking the icon just explains that the submission is
pending.
test-plan:
- locate some submissions that were scored with turnitin before this change was
applied and verify that they still work as expected
- submit something new that will get sent to turnitin. verify that it initially
gets marked as pending, and then after 5-10 minutes has a score.
- submit something that will result in a turnitin error (eg: < 20 words,
password protected pdf). verify that it initially gets marked as pending,
then after ~30 minutes (to account for retries) is marked as an error.
- click the icon, and click the resubmit button. verify that it goes back to
pending.
- verify that the new turnitin icons for these submission in gradebooks 1 and
2 look correct and don't mess up the layout.
Change-Id: Ia5e1b04842de16aaa44d498eefe59ddb716dc014
Reviewed-on: https://gerrit.instructure.com/10125
Reviewed-by: Simon Williams <simon@instructure.com>
Tested-by: Hudson <hudson@instructure.com>
2012-04-19 00:54:19 +08:00
|
|
|
@assignment.submission_types = "online_upload,online_text_entry"
|
|
|
|
@assignment.turnitin_enabled = true
|
|
|
|
@assignment.turnitin_settings = @assignment.turnitin_settings
|
|
|
|
@assignment.save!
|
|
|
|
@submission = @assignment.submit_homework(@user, { :body => "hello there", :submission_type => 'online_text_entry' })
|
2012-02-21 00:37:11 +08:00
|
|
|
@submission.turnitin_data = {
|
|
|
|
"submission_#{@submission.id}" => {
|
|
|
|
:web_overlap => 92,
|
|
|
|
:error => true,
|
|
|
|
:publication_overlap => 0,
|
|
|
|
:state => "failure",
|
|
|
|
:object_id => "123456789",
|
|
|
|
:student_overlap => 90,
|
|
|
|
:similarity_score => 92
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@submission.save!
|
2014-07-31 13:21:57 +08:00
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2014-07-31 13:21:57 +08:00
|
|
|
before :each do
|
2012-02-21 00:37:11 +08:00
|
|
|
api = Turnitin::Client.new('test_account', 'sekret')
|
|
|
|
Turnitin::Client.expects(:new).at_least(1).returns(api)
|
|
|
|
api.expects(:sendRequest).with(:generate_report, 1, has_entries(:oid => "123456789")).at_least(1).returns('http://foo.bar')
|
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
it "should let teachers view the turnitin report" do
|
|
|
|
@teacher = User.create
|
|
|
|
@context.enroll_teacher(@teacher)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_grants_right(@teacher, nil, :view_turnitin_report)
|
|
|
|
expect(@submission.turnitin_report_url("submission_#{@submission.id}", @teacher)).not_to be_nil
|
2012-02-21 00:37:11 +08:00
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
it "should let students view the turnitin report after grading" do
|
|
|
|
@assignment.turnitin_settings[:originality_report_visibility] = 'after_grading'
|
|
|
|
@assignment.save!
|
|
|
|
@submission.reload
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).not_to be_grants_right(@user, nil, :view_turnitin_report)
|
|
|
|
expect(@submission.turnitin_report_url("submission_#{@submission.id}", @user)).to be_nil
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
@submission.score = 1
|
|
|
|
@submission.grade_it!
|
2015-06-19 22:33:47 +08:00
|
|
|
AdheresToPolicy::Cache.clear
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_grants_right(@user, nil, :view_turnitin_report)
|
|
|
|
expect(@submission.turnitin_report_url("submission_#{@submission.id}", @user)).not_to be_nil
|
2012-02-21 00:37:11 +08:00
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
it "should let students view the turnitin report immediately if the visibility setting allows it" do
|
|
|
|
@assignment.turnitin_settings[:originality_report_visibility] = 'after_grading'
|
|
|
|
@assignment.save
|
|
|
|
@submission.reload
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).not_to be_grants_right(@user, nil, :view_turnitin_report)
|
|
|
|
expect(@submission.turnitin_report_url("submission_#{@submission.id}", @user)).to be_nil
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
@assignment.turnitin_settings[:originality_report_visibility] = 'immediate'
|
|
|
|
@assignment.save
|
|
|
|
@submission.reload
|
2015-06-19 22:33:47 +08:00
|
|
|
AdheresToPolicy::Cache.clear
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_grants_right(@user, nil, :view_turnitin_report)
|
|
|
|
expect(@submission.turnitin_report_url("submission_#{@submission.id}", @user)).not_to be_nil
|
2012-02-21 00:37:11 +08:00
|
|
|
end
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
it "should let students view the turnitin report after the due date if the visibility setting allows it" do
|
|
|
|
@assignment.turnitin_settings[:originality_report_visibility] = 'after_due_date'
|
|
|
|
@assignment.due_at = Time.now + 1.day
|
|
|
|
@assignment.save
|
|
|
|
@submission.reload
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).not_to be_grants_right(@user, nil, :view_turnitin_report)
|
|
|
|
expect(@submission.turnitin_report_url("submission_#{@submission.id}", @user)).to be_nil
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2012-02-21 00:37:11 +08:00
|
|
|
@assignment.due_at = Time.now - 1.day
|
|
|
|
@assignment.save
|
|
|
|
@submission.reload
|
2015-06-19 22:33:47 +08:00
|
|
|
AdheresToPolicy::Cache.clear
|
2013-05-09 00:45:10 +08:00
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_grants_right(@user, nil, :view_turnitin_report)
|
|
|
|
expect(@submission.turnitin_report_url("submission_#{@submission.id}", @user)).not_to be_nil
|
2012-02-21 00:37:11 +08:00
|
|
|
end
|
2011-10-20 02:40:49 +08:00
|
|
|
end
|
|
|
|
end
|
2012-01-06 05:28:40 +08:00
|
|
|
|
|
|
|
it "should return the correct quiz_submission_version" do
|
|
|
|
# see redmine #6048
|
|
|
|
|
|
|
|
# set up the data to have a submission with a quiz submission with multiple versions
|
|
|
|
course
|
|
|
|
quiz = @course.quizzes.create!
|
|
|
|
quiz_submission = quiz.generate_submission @user, false
|
|
|
|
quiz_submission.save
|
|
|
|
|
|
|
|
submission = Submission.create!({
|
|
|
|
:assignment_id => @assignment.id,
|
|
|
|
:user_id => @user.id,
|
|
|
|
:quiz_submission_id => quiz_submission.id
|
|
|
|
})
|
|
|
|
|
|
|
|
submission = @assignment.submit_homework @user, :submission_type => 'online_quiz'
|
|
|
|
submission.quiz_submission_id = quiz_submission.id
|
|
|
|
|
|
|
|
# set the microseconds of the submission.submitted_at to be less than the
|
|
|
|
# quiz_submission.finished_at.
|
|
|
|
|
|
|
|
# first set them to be exactly the same (with microseconds)
|
|
|
|
time_to_i = submission.submitted_at.to_i
|
|
|
|
usec = submission.submitted_at.usec
|
|
|
|
timestamp = "#{time_to_i}.#{usec}".to_f
|
|
|
|
|
|
|
|
quiz_submission.finished_at = Time.at(timestamp)
|
|
|
|
quiz_submission.save
|
|
|
|
|
|
|
|
# get the data in a strange state where the quiz_submission.finished_at is
|
|
|
|
# microseconds older than the submission (caused the bug in #6048)
|
|
|
|
quiz_submission.finished_at = Time.at(timestamp + 0.00001)
|
|
|
|
quiz_submission.save
|
|
|
|
|
|
|
|
# verify the data is weird, to_i says they are equal, but the usecs are off
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(quiz_submission.finished_at.to_i).to eq submission.submitted_at.to_i
|
|
|
|
expect(quiz_submission.finished_at.usec).to be > submission.submitted_at.usec
|
2012-01-06 05:28:40 +08:00
|
|
|
|
|
|
|
# create the versions that Submission#quiz_submission_version uses
|
|
|
|
quiz_submission.with_versioning do
|
|
|
|
quiz_submission.save
|
|
|
|
quiz_submission.save
|
|
|
|
end
|
|
|
|
|
|
|
|
# the real test, quiz_submission_version shouldn't care about usecs
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission.reload.quiz_submission_version).to eq 2
|
2012-01-06 05:28:40 +08:00
|
|
|
end
|
2012-07-10 00:12:34 +08:00
|
|
|
|
|
|
|
it "should return only comments readable by the user" do
|
|
|
|
course_with_teacher(:active_all => true)
|
|
|
|
@student1 = student_in_course(:active_user => true).user
|
|
|
|
@student2 = student_in_course(:active_user => true).user
|
|
|
|
|
|
|
|
@assignment = @course.assignments.new(:title => "some assignment")
|
|
|
|
@assignment.submission_types = "online_text_entry"
|
|
|
|
@assignment.workflow_state = "published"
|
|
|
|
@assignment.save
|
|
|
|
|
|
|
|
@submission = @assignment.submit_homework(@student1, :body => 'some message')
|
|
|
|
sc1 = SubmissionComment.create!(:submission => @submission, :author => @teacher, :comment => "a")
|
|
|
|
sc2 = SubmissionComment.create!(:submission => @submission, :author => @teacher, :comment => "b", :hidden => true)
|
|
|
|
sc3 = SubmissionComment.create!(:submission => @submission, :author => @student1, :comment => "c")
|
|
|
|
sc4 = SubmissionComment.create!(:submission => @submission, :author => @student2, :comment => "d")
|
|
|
|
@submission.reload
|
|
|
|
|
|
|
|
@submission.limit_comments(@teacher)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.submission_comments.count).to eql 4
|
|
|
|
expect(@submission.visible_submission_comments.count).to eql 3
|
2012-07-10 00:12:34 +08:00
|
|
|
|
|
|
|
@submission.limit_comments(@student1)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.submission_comments.count).to eql 3
|
|
|
|
expect(@submission.visible_submission_comments.count).to eql 3
|
2012-07-10 00:12:34 +08:00
|
|
|
|
|
|
|
@submission.limit_comments(@student2)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.submission_comments.count).to eql 1
|
|
|
|
expect(@submission.visible_submission_comments.count).to eql 1
|
2012-07-10 00:12:34 +08:00
|
|
|
end
|
submission unread counts
refs #10541
add a new unread count to the left nav bar, indicating how many grade changes
have occured since you last viewed the course. a grade change can either be
a change in score or a comment left on a submission. when the grades page is
visited, there will be a small new dot next to each submission with new grade
activity, and the count will clear after visiting the grades page.
todo: specs
test plan:
- as a teacher, set up some assignments, including some that are muted, and
some that are peer review
- as a student, submit these assignments
- the counts should not change
- as another student, complete the peer review
- as the original student the count should be up by one, and there should be
a blue dot next to the peer review assignment
- as the teacher, grade the other assignments, including the muted one
- as a student the count and dots should represent what was graded and visible
(everthing but the muted assignment)
- after leaving/refreshing the page, the count and dots should be gone
- as a student, reply to comments on the submissions
- the counts should not change
Change-Id: Ifd5988e37831c4c63314f2aad27ddd2875389dd0
Reviewed-on: https://gerrit.instructure.com/14051
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-25 02:41:18 +08:00
|
|
|
|
|
|
|
describe "read/unread state" do
|
|
|
|
it "should be read if a submission exists with no grade" do
|
|
|
|
@submission = @assignment.submit_homework(@user)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.read?(@user)).to be_truthy
|
submission unread counts
refs #10541
add a new unread count to the left nav bar, indicating how many grade changes
have occured since you last viewed the course. a grade change can either be
a change in score or a comment left on a submission. when the grades page is
visited, there will be a small new dot next to each submission with new grade
activity, and the count will clear after visiting the grades page.
todo: specs
test plan:
- as a teacher, set up some assignments, including some that are muted, and
some that are peer review
- as a student, submit these assignments
- the counts should not change
- as another student, complete the peer review
- as the original student the count should be up by one, and there should be
a blue dot next to the peer review assignment
- as the teacher, grade the other assignments, including the muted one
- as a student the count and dots should represent what was graded and visible
(everthing but the muted assignment)
- after leaving/refreshing the page, the count and dots should be gone
- as a student, reply to comments on the submissions
- the counts should not change
Change-Id: Ifd5988e37831c4c63314f2aad27ddd2875389dd0
Reviewed-on: https://gerrit.instructure.com/14051
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-25 02:41:18 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be unread after assignment is graded" do
|
|
|
|
@submission = @assignment.grade_student(@user, { :grade => 3 }).first
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.unread?(@user)).to be_truthy
|
submission unread counts
refs #10541
add a new unread count to the left nav bar, indicating how many grade changes
have occured since you last viewed the course. a grade change can either be
a change in score or a comment left on a submission. when the grades page is
visited, there will be a small new dot next to each submission with new grade
activity, and the count will clear after visiting the grades page.
todo: specs
test plan:
- as a teacher, set up some assignments, including some that are muted, and
some that are peer review
- as a student, submit these assignments
- the counts should not change
- as another student, complete the peer review
- as the original student the count should be up by one, and there should be
a blue dot next to the peer review assignment
- as the teacher, grade the other assignments, including the muted one
- as a student the count and dots should represent what was graded and visible
(everthing but the muted assignment)
- after leaving/refreshing the page, the count and dots should be gone
- as a student, reply to comments on the submissions
- the counts should not change
Change-Id: Ifd5988e37831c4c63314f2aad27ddd2875389dd0
Reviewed-on: https://gerrit.instructure.com/14051
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-25 02:41:18 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be unread after submission is graded" do
|
|
|
|
@assignment.submit_homework(@user)
|
|
|
|
@submission = @assignment.grade_student(@user, { :grade => 3 }).first
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.unread?(@user)).to be_truthy
|
submission unread counts
refs #10541
add a new unread count to the left nav bar, indicating how many grade changes
have occured since you last viewed the course. a grade change can either be
a change in score or a comment left on a submission. when the grades page is
visited, there will be a small new dot next to each submission with new grade
activity, and the count will clear after visiting the grades page.
todo: specs
test plan:
- as a teacher, set up some assignments, including some that are muted, and
some that are peer review
- as a student, submit these assignments
- the counts should not change
- as another student, complete the peer review
- as the original student the count should be up by one, and there should be
a blue dot next to the peer review assignment
- as the teacher, grade the other assignments, including the muted one
- as a student the count and dots should represent what was graded and visible
(everthing but the muted assignment)
- after leaving/refreshing the page, the count and dots should be gone
- as a student, reply to comments on the submissions
- the counts should not change
Change-Id: Ifd5988e37831c4c63314f2aad27ddd2875389dd0
Reviewed-on: https://gerrit.instructure.com/14051
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-25 02:41:18 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be unread after submission is commented on by teacher" do
|
|
|
|
@student = @user
|
|
|
|
course_with_teacher(:course => @context, :active_all => true)
|
|
|
|
@submission = @assignment.grade_student(@student, { :grader => @teacher, :comment => "good!" }).first
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.unread?(@user)).to be_truthy
|
submission unread counts
refs #10541
add a new unread count to the left nav bar, indicating how many grade changes
have occured since you last viewed the course. a grade change can either be
a change in score or a comment left on a submission. when the grades page is
visited, there will be a small new dot next to each submission with new grade
activity, and the count will clear after visiting the grades page.
todo: specs
test plan:
- as a teacher, set up some assignments, including some that are muted, and
some that are peer review
- as a student, submit these assignments
- the counts should not change
- as another student, complete the peer review
- as the original student the count should be up by one, and there should be
a blue dot next to the peer review assignment
- as the teacher, grade the other assignments, including the muted one
- as a student the count and dots should represent what was graded and visible
(everthing but the muted assignment)
- after leaving/refreshing the page, the count and dots should be gone
- as a student, reply to comments on the submissions
- the counts should not change
Change-Id: Ifd5988e37831c4c63314f2aad27ddd2875389dd0
Reviewed-on: https://gerrit.instructure.com/14051
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-25 02:41:18 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be read if other submission fields change" do
|
|
|
|
@submission = @assignment.submit_homework(@user)
|
|
|
|
@submission.workflow_state = 'graded'
|
|
|
|
@submission.graded_at = Time.now
|
|
|
|
@submission.save!
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.read?(@user)).to be_truthy
|
submission unread counts
refs #10541
add a new unread count to the left nav bar, indicating how many grade changes
have occured since you last viewed the course. a grade change can either be
a change in score or a comment left on a submission. when the grades page is
visited, there will be a small new dot next to each submission with new grade
activity, and the count will clear after visiting the grades page.
todo: specs
test plan:
- as a teacher, set up some assignments, including some that are muted, and
some that are peer review
- as a student, submit these assignments
- the counts should not change
- as another student, complete the peer review
- as the original student the count should be up by one, and there should be
a blue dot next to the peer review assignment
- as the teacher, grade the other assignments, including the muted one
- as a student the count and dots should represent what was graded and visible
(everthing but the muted assignment)
- after leaving/refreshing the page, the count and dots should be gone
- as a student, reply to comments on the submissions
- the counts should not change
Change-Id: Ifd5988e37831c4c63314f2aad27ddd2875389dd0
Reviewed-on: https://gerrit.instructure.com/14051
Reviewed-by: Jeremy Stanley <jeremy@instructure.com>
Tested-by: Jenkins <jenkins@instructure.com>
2012-09-25 02:41:18 +08:00
|
|
|
end
|
|
|
|
end
|
2012-10-30 01:00:07 +08:00
|
|
|
|
|
|
|
describe "mute" do
|
|
|
|
let(:submission) { Submission.new }
|
|
|
|
|
|
|
|
before :each do
|
|
|
|
submission.published_score = 100
|
|
|
|
submission.published_grade = 'A'
|
|
|
|
submission.graded_at = Time.now
|
|
|
|
submission.grade = 'B'
|
|
|
|
submission.score = 90
|
|
|
|
submission.mute
|
|
|
|
end
|
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
specify { expect(submission.published_score).to be_nil }
|
|
|
|
specify { expect(submission.published_grade).to be_nil }
|
|
|
|
specify { expect(submission.graded_at).to be_nil }
|
|
|
|
specify { expect(submission.grade).to be_nil }
|
|
|
|
specify { expect(submission.score).to be_nil }
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
describe "muted_assignment?" do
|
|
|
|
it "returns true if assignment is muted" do
|
|
|
|
assignment = stub(:muted? => true)
|
|
|
|
@submission = Submission.new
|
|
|
|
@submission.expects(:assignment).returns(assignment)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.muted_assignment?).to eq true
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
|
|
|
|
2012-12-14 09:37:22 +08:00
|
|
|
it "returns false if assignment is not muted" do
|
2012-10-30 01:00:07 +08:00
|
|
|
assignment = stub(:muted? => false)
|
|
|
|
@submission = Submission.new
|
|
|
|
@submission.expects(:assignment).returns(assignment)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.muted_assignment?).to eq false
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "without_graded_submission?" do
|
|
|
|
let(:submission) { Submission.new }
|
|
|
|
|
|
|
|
it "returns false if submission does not has_submission?" do
|
|
|
|
submission.stubs(:has_submission?).returns false
|
|
|
|
submission.stubs(:graded?).returns true
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission.without_graded_submission?).to eq false
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns false if submission does is not graded" do
|
|
|
|
submission.stubs(:has_submission?).returns true
|
|
|
|
submission.stubs(:graded?).returns false
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission.without_graded_submission?).to eq false
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns true if submission is not graded and has no submission" do
|
|
|
|
submission.stubs(:has_submission?).returns false
|
|
|
|
submission.stubs(:graded?).returns false
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission.without_graded_submission?).to eq true
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-04-17 07:24:31 +08:00
|
|
|
describe "graded?" do
|
|
|
|
it "is false before graded" do
|
|
|
|
s, _ = @assignment.find_or_create_submission(@user)
|
|
|
|
expect(s.graded?).to eql false
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is true for graded assignments" do
|
|
|
|
s, _ = @assignment.grade_student(@user, grade: 1)
|
|
|
|
expect(s.graded?).to eql true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "is also true for excused assignments" do
|
|
|
|
s, _ = @assignment.find_or_create_submission(@user)
|
|
|
|
s.excused = true
|
|
|
|
expect(s.graded?).to eql true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-11-05 02:56:25 +08:00
|
|
|
describe "autograded" do
|
|
|
|
let(:submission) { Submission.new }
|
|
|
|
|
|
|
|
it "returns false when its not autograded" do
|
|
|
|
assignment = stub(:muted? => false)
|
|
|
|
@submission = Submission.new
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.autograded?).to eq false
|
2013-11-05 02:56:25 +08:00
|
|
|
|
|
|
|
@submission.grader_id = Shard.global_id_for(@user.id)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.autograded?).to eq false
|
2013-11-05 02:56:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns true when its autograded" do
|
|
|
|
assignment = stub(:muted? => false)
|
|
|
|
@submission = Submission.new
|
|
|
|
@submission.grader_id = -1
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.autograded?).to eq true
|
2013-11-05 02:56:25 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-01 04:07:26 +08:00
|
|
|
describe "past_due" do
|
2014-07-31 13:21:57 +08:00
|
|
|
before :once do
|
2012-12-14 09:37:22 +08:00
|
|
|
u1 = @user
|
|
|
|
submission_spec_model
|
|
|
|
@submission1 = @submission
|
|
|
|
|
|
|
|
add_section('overridden section')
|
|
|
|
u2 = student_in_section(@course_section, :active_all => true)
|
|
|
|
submission_spec_model(:user => u2)
|
|
|
|
@submission2 = @submission
|
|
|
|
|
|
|
|
@assignment.update_attribute(:due_at, Time.zone.now - 1.day)
|
|
|
|
@submission1.reload
|
|
|
|
@submission2.reload
|
|
|
|
end
|
|
|
|
|
2013-06-01 04:07:26 +08:00
|
|
|
it "should update when an assignment's due date is changed" do
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission1).to be_past_due
|
2012-12-14 09:37:22 +08:00
|
|
|
@assignment.reload.update_attribute(:due_at, Time.zone.now + 1.day)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission1.reload).not_to be_past_due
|
2012-12-14 09:37:22 +08:00
|
|
|
end
|
|
|
|
|
2013-06-01 04:07:26 +08:00
|
|
|
it "should update when an applicable override is changed" do
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission1).to be_past_due
|
|
|
|
expect(@submission2).to be_past_due
|
2012-12-14 09:37:22 +08:00
|
|
|
|
|
|
|
assignment_override_model :assignment => @assignment,
|
|
|
|
:due_at => Time.zone.now + 1.day,
|
|
|
|
:set => @course_section
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission1.reload).to be_past_due
|
|
|
|
expect(@submission2.reload).not_to be_past_due
|
2012-12-14 09:37:22 +08:00
|
|
|
end
|
|
|
|
|
2013-06-01 04:07:26 +08:00
|
|
|
it "should give a quiz submission 30 extra seconds before making it past due" do
|
2012-12-27 02:07:15 +08:00
|
|
|
quiz_with_graded_submission([{:question_data => {:name => 'question 1', :points_possible => 1, 'question_type' => 'essay_question'}}]) do
|
|
|
|
{
|
|
|
|
"text_after_answers" => "",
|
|
|
|
"question_#{@questions[0].id}" => "<p>Lorem ipsum answer.</p>",
|
|
|
|
"context_id" => "#{@course.id}",
|
|
|
|
"context_type" => "Course",
|
|
|
|
"user_id" => "#{@user.id}",
|
|
|
|
"quiz_id" => "#{@quiz.id}",
|
|
|
|
"course_id" => "#{@course.id}",
|
|
|
|
"question_text" => "Lorem ipsum question",
|
|
|
|
}
|
|
|
|
end
|
|
|
|
@assignment.due_at = "20130101T23:59Z"
|
|
|
|
@assignment.save!
|
|
|
|
|
|
|
|
submission = @quiz_submission.submission.reload
|
|
|
|
submission.write_attribute(:submitted_at, @assignment.due_at + 3.days)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission).to be_past_due
|
2012-12-27 02:07:15 +08:00
|
|
|
|
|
|
|
submission.write_attribute(:submitted_at, @assignment.due_at + 30.seconds)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission).not_to be_past_due
|
2013-06-01 04:07:26 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "late" do
|
2014-07-31 13:21:57 +08:00
|
|
|
before :once do
|
2013-06-01 04:07:26 +08:00
|
|
|
submission_spec_model
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be false if not past due" do
|
|
|
|
@submission.submitted_at = 2.days.ago
|
|
|
|
@submission.cached_due_date = 1.day.ago
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).not_to be_late
|
2013-06-01 04:07:26 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be false if not submitted, even if past due" do
|
|
|
|
@submission.submission_type = nil # forces submitted_at to be nil
|
|
|
|
@submission.cached_due_date = 1.day.ago
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).not_to be_late
|
2013-06-01 04:07:26 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be true if submitted and past due" do
|
|
|
|
@submission.submitted_at = 1.day.ago
|
|
|
|
@submission.cached_due_date = 2.days.ago
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_late
|
2013-06-01 04:07:26 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "missing" do
|
2014-07-31 13:21:57 +08:00
|
|
|
before :once do
|
2013-06-01 04:07:26 +08:00
|
|
|
submission_spec_model
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should be false if not past due" do
|
|
|
|
@submission.submitted_at = 2.days.ago
|
|
|
|
@submission.cached_due_date = 1.day.ago
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).not_to be_missing
|
2013-06-01 04:07:26 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be false if submitted, even if past due" do
|
|
|
|
@submission.submitted_at = 1.day.ago
|
|
|
|
@submission.cached_due_date = 2.days.ago
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).not_to be_missing
|
2013-06-01 04:07:26 +08:00
|
|
|
end
|
|
|
|
|
2014-01-24 00:35:05 +08:00
|
|
|
it "should be true if not submitted, past due, and expects a submission" do
|
|
|
|
@submission.assignment.submission_types = "online_quiz"
|
2013-06-01 04:07:26 +08:00
|
|
|
@submission.submission_type = nil # forces submitted_at to be nil
|
|
|
|
@submission.cached_due_date = 1.day.ago
|
2014-01-24 00:35:05 +08:00
|
|
|
|
|
|
|
# Regardless of score
|
|
|
|
@submission.score = 0.00000001
|
|
|
|
@submission.graded_at = Time.zone.now + 1.day
|
|
|
|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_missing
|
2014-01-24 00:35:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be true if not submitted, score of zero, and does not expect a submission" do
|
|
|
|
@submission.assignment.submission_types = "on_paper"
|
|
|
|
@submission.submission_type = nil # forces submitted_at to be nil
|
|
|
|
@submission.cached_due_date = 1.day.ago
|
|
|
|
@submission.score = 0
|
|
|
|
@submission.graded_at = Time.zone.now + 1.day
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_missing
|
2014-01-24 00:35:05 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should be false if not submitted, score greater than zero, and does not expect a submission" do
|
|
|
|
@submission.assignment.submission_types = "on_paper"
|
|
|
|
@submission.submission_type = nil # forces submitted_at to be nil
|
|
|
|
@submission.cached_due_date = 1.day.ago
|
|
|
|
@submission.score = 0.00000001
|
|
|
|
@submission.graded_at = Time.zone.now + 1.day
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission).to be_missing
|
2013-06-01 04:07:26 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "cached_due_date" do
|
|
|
|
it "should get initialized during submission creation" do
|
2015-02-28 06:04:01 +08:00
|
|
|
# create an invited user, so that the submission is not automatically
|
|
|
|
# created by the DueDateCacher
|
|
|
|
student_in_course
|
2013-06-01 04:07:26 +08:00
|
|
|
@assignment.update_attribute(:due_at, Time.zone.now - 1.day)
|
|
|
|
|
|
|
|
override = @assignment.assignment_overrides.build
|
|
|
|
override.title = "Some Title"
|
|
|
|
override.set = @course.default_section
|
|
|
|
override.override_due_at(Time.zone.now + 1.day)
|
|
|
|
override.save!
|
2014-01-16 04:20:30 +08:00
|
|
|
# mysql just truncated the timestamp
|
|
|
|
override.reload
|
2013-06-01 04:07:26 +08:00
|
|
|
|
|
|
|
submission = @assignment.submissions.create(:user => @user)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(submission.cached_due_date).to eq override.due_at
|
2012-12-27 02:07:15 +08:00
|
|
|
end
|
|
|
|
end
|
2013-06-27 07:38:13 +08:00
|
|
|
|
2013-12-21 05:14:46 +08:00
|
|
|
describe "update_attachment_associations" do
|
2014-02-11 03:04:30 +08:00
|
|
|
before do
|
2013-12-21 05:14:46 +08:00
|
|
|
course_with_student active_all: true
|
|
|
|
@assignment = @course.assignments.create!
|
|
|
|
end
|
|
|
|
|
|
|
|
it "doesn't include random attachment ids" do
|
|
|
|
f = Attachment.create! uploaded_data: StringIO.new('blah'),
|
|
|
|
context: @course,
|
|
|
|
filename: 'blah.txt'
|
|
|
|
sub = @assignment.submit_homework(@user, attachments: [f])
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(sub.attachments).to eq []
|
2013-12-21 05:14:46 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-08-08 01:02:48 +08:00
|
|
|
describe "versioned_attachments" do
|
|
|
|
it "should include user attachments" do
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
att = attachment_model(filename: "submission.doc", :context => @student)
|
|
|
|
sub = @assignment.submit_homework(@student, attachments: [att])
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(sub.versioned_attachments).to eq [att]
|
2013-08-08 01:02:48 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "should not include attachments with a context of Submission" do
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
att = attachment_model(filename: "submission.doc", :context => @student)
|
|
|
|
sub = @assignment.submit_homework(@student, attachments: [att])
|
|
|
|
sub.attachments.update_all(:context_type => "Submission", :context_id => sub.id)
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(sub.reload.versioned_attachments).to be_empty
|
2013-08-08 01:02:48 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-06-27 07:38:13 +08:00
|
|
|
describe "#bulk_load_versioned_attachments" do
|
2014-07-16 07:19:24 +08:00
|
|
|
def ensure_attachments_arent_queried
|
|
|
|
Attachment.expects(:where).never
|
|
|
|
end
|
|
|
|
|
2013-06-27 07:38:13 +08:00
|
|
|
it "loads attachments for many submissions at once" do
|
|
|
|
attachments = []
|
|
|
|
|
|
|
|
submissions = 3.times.map { |i|
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
attachments << [
|
|
|
|
attachment_model(filename: "submission#{i}-a.doc", :context => @student),
|
|
|
|
attachment_model(filename: "submission#{i}-b.doc", :context => @student)
|
|
|
|
]
|
|
|
|
|
|
|
|
@assignment.submit_homework @student, attachments: attachments[i]
|
|
|
|
}
|
|
|
|
|
|
|
|
Submission.bulk_load_versioned_attachments(submissions)
|
2014-07-16 07:19:24 +08:00
|
|
|
ensure_attachments_arent_queried
|
2013-06-27 07:38:13 +08:00
|
|
|
submissions.each_with_index { |s, i|
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.versioned_attachments).to eq attachments[i]
|
2013-06-27 07:38:13 +08:00
|
|
|
}
|
|
|
|
end
|
2014-07-16 07:19:24 +08:00
|
|
|
|
2014-09-10 06:08:45 +08:00
|
|
|
def submission_for_some_user
|
2014-07-16 07:19:24 +08:00
|
|
|
student_in_course active_all: true
|
2014-09-10 06:08:45 +08:00
|
|
|
@assignment.submit_homework(@student,
|
|
|
|
submission_type: "online_url",
|
|
|
|
url: "http://example.com")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "includes url submission attachments" do
|
|
|
|
s = submission_for_some_user
|
2014-07-16 07:19:24 +08:00
|
|
|
s.attachment = attachment_model(filename: "screenshot.jpg",
|
|
|
|
context: @student)
|
|
|
|
|
|
|
|
Submission.bulk_load_versioned_attachments([s])
|
|
|
|
ensure_attachments_arent_queried
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.versioned_attachments).to eq [s.attachment]
|
2014-07-16 07:19:24 +08:00
|
|
|
end
|
2014-09-10 06:08:45 +08:00
|
|
|
|
|
|
|
it "handles bad data" do
|
|
|
|
s = submission_for_some_user
|
|
|
|
s.update_attribute(:attachment_ids, '99999999')
|
|
|
|
Submission.bulk_load_versioned_attachments([s])
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(s.versioned_attachments).to eq []
|
2014-09-10 06:08:45 +08:00
|
|
|
end
|
2013-06-27 07:38:13 +08:00
|
|
|
end
|
2014-01-16 08:53:05 +08:00
|
|
|
|
|
|
|
describe "#assign_assessor" do
|
|
|
|
def peer_review_assignment
|
|
|
|
assignment = @course.assignments.build(title: 'Peer review',
|
|
|
|
due_at: Time.now - 1.day,
|
|
|
|
points_possible: 5,
|
|
|
|
submission_types: 'online_text_entry')
|
|
|
|
assignment.peer_reviews_assigned = true
|
|
|
|
assignment.peer_reviews = true
|
|
|
|
assignment.automatic_peer_reviews = true
|
|
|
|
assignment.save!
|
|
|
|
|
|
|
|
assignment
|
|
|
|
end
|
|
|
|
|
|
|
|
before(:each) do
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
@student2 = user
|
|
|
|
@course.enroll_student(@student2).accept!
|
|
|
|
@assignment = peer_review_assignment
|
|
|
|
@assignment.submit_homework(@student, body: 'Lorem ipsum dolor')
|
|
|
|
@assignment.submit_homework(@student2, body: 'Sit amet consectetuer')
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should send a reminder notification" do
|
|
|
|
AssessmentRequest.any_instance.expects(:send_reminder!).once
|
|
|
|
submission1, submission2 = @assignment.submissions
|
|
|
|
submission1.assign_assessor(submission2)
|
|
|
|
end
|
|
|
|
end
|
2014-09-11 23:43:15 +08:00
|
|
|
|
|
|
|
describe "#get_web_snapshot" do
|
|
|
|
it "should not blow up if web snapshotting fails" do
|
|
|
|
sub = Submission.new(@valid_attributes)
|
|
|
|
CutyCapt.expects(:enabled?).returns(true)
|
|
|
|
CutyCapt.expects(:snapshot_attachment_for_url).with(sub.url).returns(nil)
|
|
|
|
sub.get_web_snapshot
|
|
|
|
end
|
|
|
|
end
|
2014-10-08 09:27:04 +08:00
|
|
|
|
|
|
|
describe '#submit_attachments_to_canvadocs' do
|
|
|
|
it 'creates crocodoc documents' do
|
|
|
|
Canvas::Crocodoc.stubs(:enabled?).returns true
|
|
|
|
s = @assignment.submit_homework(@user,
|
|
|
|
submission_type: "online_text_entry",
|
|
|
|
body: "hi")
|
|
|
|
|
|
|
|
# creates crocodoc documents
|
|
|
|
a1 = crocodocable_attachment_model context: @user
|
|
|
|
s.attachments = [a1]
|
|
|
|
s.save
|
|
|
|
cd = a1.crocodoc_document
|
|
|
|
expect(cd).not_to be_nil
|
|
|
|
|
|
|
|
# shouldn't mess with existing crocodoc documents
|
|
|
|
a2 = crocodocable_attachment_model context: @user
|
|
|
|
s.attachments = [a1, a2]
|
|
|
|
s.save
|
|
|
|
expect(a1.crocodoc_document(true)).to eq cd
|
|
|
|
expect(a2.crocodoc_document).to eq a2.crocodoc_document
|
|
|
|
end
|
|
|
|
end
|
2015-01-28 02:13:08 +08:00
|
|
|
|
|
|
|
describe "cross-shard attachments" do
|
|
|
|
specs_require_sharding
|
|
|
|
it "should work" do
|
|
|
|
@shard1.activate do
|
|
|
|
@student = user(:active_user => true)
|
|
|
|
@attachment = Attachment.create! uploaded_data: StringIO.new('blah'), context: @student, filename: 'blah.txt'
|
|
|
|
end
|
|
|
|
course(:active_all => true)
|
|
|
|
@course.enroll_user(@student, "StudentEnrollment").accept!
|
|
|
|
@assignment = @course.assignments.create!
|
|
|
|
|
|
|
|
sub = @assignment.submit_homework(@user, attachments: [@attachment])
|
|
|
|
expect(sub.attachments).to eq [@attachment]
|
|
|
|
end
|
|
|
|
end
|
2015-03-17 15:26:47 +08:00
|
|
|
|
|
|
|
describe '.process_bulk_update' do
|
|
|
|
before(:once) do
|
|
|
|
course_with_teacher active_all: true
|
|
|
|
@u1, @u2 = n_students_in_course(2)
|
|
|
|
@a1, @a2 = 2.times.map {
|
|
|
|
@course.assignments.create! points_possible: 10
|
|
|
|
}
|
|
|
|
@progress = Progress.create!(context: @course, tag: "submissions_update")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates submissions on an assignment' do
|
|
|
|
Submission.process_bulk_update(@progress, @course, nil, @teacher, {
|
|
|
|
@a1.id.to_s => {
|
|
|
|
@u1.id => {posted_grade: 5},
|
|
|
|
@u2.id => {posted_grade: 10}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
expect(@a1.submission_for_student(@u1).grade).to eql "5"
|
|
|
|
expect(@a1.submission_for_student(@u2).grade).to eql "10"
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'updates submissions on multiple assignments' do
|
|
|
|
Submission.process_bulk_update(@progress, @course, nil, @teacher, {
|
|
|
|
@a1.id => {
|
|
|
|
@u1.id => {posted_grade: 5},
|
|
|
|
@u2.id => {posted_grade: 10}
|
|
|
|
},
|
|
|
|
@a2.id.to_s => {
|
|
|
|
@u1.id => {posted_grade: 10},
|
|
|
|
@u2.id => {posted_grade: 5}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
expect(@a1.submission_for_student(@u1).grade).to eql "5"
|
|
|
|
expect(@a1.submission_for_student(@u2).grade).to eql "10"
|
|
|
|
expect(@a2.submission_for_student(@u1).grade).to eql "10"
|
|
|
|
expect(@a2.submission_for_student(@u2).grade).to eql "5"
|
|
|
|
end
|
|
|
|
end
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
def submission_spec_model(opts={})
|
|
|
|
@submission = Submission.new(@valid_attributes.merge(opts))
|
2014-10-14 10:08:00 +08:00
|
|
|
expect(@submission.assignment).to eql(@assignment)
|
|
|
|
expect(@assignment.context).to eql(@context)
|
|
|
|
expect(@submission.assignment.context).to eql(@context)
|
2012-12-14 09:37:22 +08:00
|
|
|
@submission.save!
|
2011-02-01 09:57:29 +08:00
|
|
|
end
|