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!
|
|
|
|
|
2016-05-24 03:16:31 +08:00
|
|
|
@submission.grader_id = @user.id
|
|
|
|
@submission.save!
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should log excused submissions" do
|
|
|
|
submission_spec_model
|
|
|
|
|
|
|
|
Auditors::GradeChange.expects(:record).once
|
|
|
|
|
|
|
|
@submission.excused = true
|
|
|
|
@submission.save!
|
|
|
|
|
2013-12-03 04:42:07 +08:00
|
|
|
@submission.grader_id = @user.id
|
|
|
|
@submission.save!
|
|
|
|
end
|
2015-09-23 00:51:07 +08:00
|
|
|
|
2016-06-03 05:10:18 +08:00
|
|
|
it "should log submissions affected by assignment update" do
|
|
|
|
submission_spec_model
|
|
|
|
|
|
|
|
Auditors::GradeChange.expects(:record).twice
|
|
|
|
|
|
|
|
# only graded submissions are updated by assignment
|
|
|
|
@submission.score = 111
|
|
|
|
@submission.save!
|
|
|
|
|
|
|
|
@assignment.points_possible = 999
|
|
|
|
@assignment.save!
|
|
|
|
end
|
|
|
|
|
2015-09-23 00:51:07 +08:00
|
|
|
context "#graded_anonymously" do
|
|
|
|
it "saves when grade changed and set explicitly" do
|
|
|
|
submission_spec_model
|
|
|
|
expect(@submission.graded_anonymously).to be_falsey
|
|
|
|
@submission.score = 42
|
|
|
|
@submission.graded_anonymously = true
|
|
|
|
@submission.save!
|
|
|
|
expect(@submission.graded_anonymously).to be_truthy
|
|
|
|
@submission.reload
|
|
|
|
expect(@submission.graded_anonymously).to be_truthy
|
|
|
|
end
|
|
|
|
|
|
|
|
it "retains its value when grade does not change" do
|
|
|
|
submission_spec_model(graded_anonymously: true, score: 3, grade: "3")
|
|
|
|
@submission = Submission.find(@submission.id) # need new model object
|
|
|
|
expect(@submission.graded_anonymously).to be_truthy
|
|
|
|
@submission.body = 'test body'
|
|
|
|
@submission.save!
|
|
|
|
@submission.reload
|
|
|
|
expect(@submission.graded_anonymously).to be_truthy
|
|
|
|
end
|
|
|
|
|
|
|
|
it "resets when grade changed and not set explicitly" do
|
|
|
|
submission_spec_model(graded_anonymously: true, score: 3, grade: "3")
|
|
|
|
@submission = Submission.find(@submission.id) # need new model object
|
|
|
|
expect(@submission.graded_anonymously).to be_truthy
|
|
|
|
@submission.score = 42
|
|
|
|
@submission.save!
|
|
|
|
@submission.reload
|
|
|
|
expect(@submission.graded_anonymously).to be_falsey
|
|
|
|
end
|
|
|
|
end
|
2013-12-03 04:42:07 +08:00
|
|
|
|
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
|
2016-03-22 03:18:01 +08:00
|
|
|
Notification.create(:name => 'Submission Graded', :category => 'TestImmediately')
|
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
|
|
|
|
2016-05-10 03:31:59 +08:00
|
|
|
it "should not create a message for a soft-concluded student" do
|
|
|
|
submission_spec_model
|
|
|
|
@course.start_at = 2.weeks.ago
|
|
|
|
@course.conclude_at = 1.weeks.ago
|
|
|
|
@course.restrict_enrollments_to_course_dates = true
|
|
|
|
@course.save!
|
|
|
|
|
|
|
|
@cc = @user.communication_channels.create(:path => "somewhere")
|
|
|
|
@submission.reload
|
|
|
|
expect(@submission.assignment).to eql(@assignment)
|
|
|
|
expect(@submission.assignment.state).to eql(:published)
|
|
|
|
@submission.grade_it!
|
|
|
|
expect(@submission.messages_sent).to_not be_include('Submission Graded')
|
|
|
|
end
|
|
|
|
|
2016-03-22 03:18:01 +08:00
|
|
|
it "notifies observers" do
|
|
|
|
submission_spec_model
|
|
|
|
course_with_observer(course: @course, associated_user_id: @user.id, active_all: true, active_cc: true)
|
|
|
|
@submission.grade_it!
|
|
|
|
expect(@observer.email_channel.messages.length).to eq 1
|
|
|
|
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
|
2016-01-29 07:07:56 +08:00
|
|
|
|
|
|
|
context "Turnitin LTI" do
|
|
|
|
let(:lti_tii_data) do
|
|
|
|
{
|
|
|
|
"attachment_42" => {
|
|
|
|
:status => "error",
|
|
|
|
:outcome_response => {
|
|
|
|
"outcomes_tool_placement_url" => "https://api.turnitin.com/api/lti/1p0/invalid?lang=en_us",
|
|
|
|
"paperid" => "607954245",
|
|
|
|
"lis_result_sourcedid" => "10-5-42-8-invalid"
|
|
|
|
},
|
|
|
|
:public_error_message => "Turnitin has not returned a score after 11 attempts to retrieve one."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
let(:submission) { Submission.new }
|
|
|
|
|
|
|
|
describe "#turnitinable_by_lti?" do
|
|
|
|
it 'returns true if there is an associated lti tool and data stored' do
|
|
|
|
submission.turnitin_data = lti_tii_data
|
|
|
|
expect(submission.turnitinable_by_lti?).to be true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "#resubmit_lti_tii" do
|
|
|
|
let(:tool) do
|
|
|
|
@course.context_external_tools.create(
|
|
|
|
name: "a",
|
|
|
|
consumer_key: '12345',
|
|
|
|
shared_secret: 'secret',
|
|
|
|
url: 'http://example.com/launch')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'resubmits errored tii attachments' do
|
|
|
|
a = @course.assignments.create!(title: "test",
|
|
|
|
submission_types: 'external_tool',
|
|
|
|
external_tool_tag_attributes: {url: tool.url})
|
|
|
|
submission.assignment = a
|
|
|
|
submission.turnitin_data = lti_tii_data
|
|
|
|
submission.user = @user
|
|
|
|
outcome_response_processor_mock = mock('outcome_response_processor')
|
|
|
|
outcome_response_processor_mock.expects(:resubmit).with(submission, "attachment_42")
|
|
|
|
Turnitin::OutcomeResponseProcessor.stubs(:new).returns(outcome_response_processor_mock)
|
|
|
|
submission.retrieve_lti_tii_score
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
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
|
2016-05-13 11:51:31 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context '#external_tool_url' do
|
|
|
|
let(:submission) { Submission.new }
|
|
|
|
let(:lti_submission) { @assignment.submit_homework @user, submission_type: 'basic_lti_launch', url: 'http://www.example.com' }
|
|
|
|
context 'submission_type of "basic_lti_launch"' do
|
|
|
|
it 'returns a url containing the submitted url' do
|
2016-06-24 04:26:58 +08:00
|
|
|
expect(lti_submission.external_tool_url).to eq(lti_submission.url)
|
2016-05-13 11:51:31 +08:00
|
|
|
end
|
|
|
|
end
|
2016-06-24 04:26:58 +08:00
|
|
|
|
2016-05-13 11:51:31 +08:00
|
|
|
context 'submission_type of anything other than "basic_lti_launch"' do
|
|
|
|
it 'returns nothing' do
|
|
|
|
expect(submission.external_tool_url).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")
|
autosave comments on navigating to different user in speedgrader
closes CNVS-28529
While in SpeedGrader, if you have something entered in the comments
field and, without submitting those comments, you navigate to a
different user or otherwise navigate away from SpeedGrader, your
comments will now automatically be saved as "draft" comments for
that user's submission.
Draft comments
* don't show up anywhere other than while grading
* are invisible to users whether or not the assignment is muted
* are only "submittable" by the author of the draft comment
test plan:
1. Create a course, with at least two students
2. Add a quiz with at least one essay type question
3. As each student, take the quiz
4. As the teacher, grade the quiz and start up SpeedGrader
5. Enter comments for the first student's submission but do *not*
submit them
6. Navigate to the next student
7. You should see a message telling you your comment was
auto-saved
8. Go back to the previous student
9. You should see your comment styled differently with a red
asterisk before it, indicating a draft comment (also using
aria-label for a11y goodness)
10.Enter another comment and this time submit it
11.You should see your comment styled normally without a red
asterisk before it, indicating a normal (non-draft) comment
12.Try steps 5 through 11 with different ways of leaving that
student in step #6 e.g. using the drop down, or quitting
SpeedGrader altogether and you should see the same results for
draft comments
13.Go back to a submission with a draft comment.
14.Click on the button labelled "Publish" next to your draft
comment.
15.Watch your comment change in appearance from a draft comment
to a regular comment
16.Delete any comment and watch it disappear from the comment
list.
17.Go to the next student
18.Go back to the previous student for whose submission you
deleted the comment
19.Notice the deleted comment remains missing from the comment
list.
20.Verify that, if logged in as a student, you never see draft
comments
Change-Id: If32294a7bed6f847709b54d4c8e4fc21fb2a6eca
Reviewed-on: https://gerrit.instructure.com/77133
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Neil Gupta <ngupta@instructure.com>
Tested-by: Jenkins
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Christi Wruck
2016-04-14 05:02:28 +08:00
|
|
|
SubmissionComment.create!(:submission => @submission, :author => @teacher, :comment => "e", :draft => true)
|
2012-07-10 00:12:34 +08:00
|
|
|
@submission.reload
|
|
|
|
|
|
|
|
@submission.limit_comments(@teacher)
|
autosave comments on navigating to different user in speedgrader
closes CNVS-28529
While in SpeedGrader, if you have something entered in the comments
field and, without submitting those comments, you navigate to a
different user or otherwise navigate away from SpeedGrader, your
comments will now automatically be saved as "draft" comments for
that user's submission.
Draft comments
* don't show up anywhere other than while grading
* are invisible to users whether or not the assignment is muted
* are only "submittable" by the author of the draft comment
test plan:
1. Create a course, with at least two students
2. Add a quiz with at least one essay type question
3. As each student, take the quiz
4. As the teacher, grade the quiz and start up SpeedGrader
5. Enter comments for the first student's submission but do *not*
submit them
6. Navigate to the next student
7. You should see a message telling you your comment was
auto-saved
8. Go back to the previous student
9. You should see your comment styled differently with a red
asterisk before it, indicating a draft comment (also using
aria-label for a11y goodness)
10.Enter another comment and this time submit it
11.You should see your comment styled normally without a red
asterisk before it, indicating a normal (non-draft) comment
12.Try steps 5 through 11 with different ways of leaving that
student in step #6 e.g. using the drop down, or quitting
SpeedGrader altogether and you should see the same results for
draft comments
13.Go back to a submission with a draft comment.
14.Click on the button labelled "Publish" next to your draft
comment.
15.Watch your comment change in appearance from a draft comment
to a regular comment
16.Delete any comment and watch it disappear from the comment
list.
17.Go to the next student
18.Go back to the previous student for whose submission you
deleted the comment
19.Notice the deleted comment remains missing from the comment
list.
20.Verify that, if logged in as a student, you never see draft
comments
Change-Id: If32294a7bed6f847709b54d4c8e4fc21fb2a6eca
Reviewed-on: https://gerrit.instructure.com/77133
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Neil Gupta <ngupta@instructure.com>
Tested-by: Jenkins
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Christi Wruck
2016-04-14 05:02:28 +08:00
|
|
|
expect(@submission.submission_comments.count).to eql 5
|
2014-10-14 10:08:00 +08:00
|
|
|
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)
|
2016-06-04 09:05:50 +08:00
|
|
|
@submission = @assignment.update_submission(@student, { :commenter => @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
|
2015-08-04 13:26:42 +08:00
|
|
|
submission, _ = @assignment.find_or_create_submission(@user)
|
|
|
|
expect(submission).to_not be_graded
|
2015-04-17 07:24:31 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is true for graded assignments" do
|
2015-08-04 13:26:42 +08:00
|
|
|
submission, _ = @assignment.grade_student(@user, grade: 1)
|
|
|
|
expect(submission).to be_graded
|
2015-04-17 07:24:31 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "is also true for excused assignments" do
|
2015-08-04 13:26:42 +08:00
|
|
|
submission, _ = @assignment.find_or_create_submission(@user)
|
|
|
|
submission.excused = true
|
|
|
|
expect(submission).to be_graded
|
2015-04-17 07:24:31 +08:00
|
|
|
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
|
2015-08-04 13:26:42 +08:00
|
|
|
submission = Submission.new
|
|
|
|
expect(submission).to_not be_autograded
|
2013-11-05 02:56:25 +08:00
|
|
|
|
2015-08-04 13:26:42 +08:00
|
|
|
submission.grader_id = Shard.global_id_for(@user.id)
|
|
|
|
expect(submission).to_not be_autograded
|
2013-11-05 02:56:25 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
it "returns true when its autograded" do
|
2015-08-04 13:26:42 +08:00
|
|
|
submission = Submission.new
|
|
|
|
submission.grader_id = -1
|
|
|
|
expect(submission).to be_autograded
|
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
|
|
|
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
|
|
|
|
|
2016-06-09 04:34:36 +08:00
|
|
|
describe "includes_attachment?" do
|
|
|
|
it "includes current attachments" do
|
|
|
|
spoiler = attachment_model(context: @student)
|
|
|
|
attachment_model context: @student
|
|
|
|
sub = @assignment.submit_homework @student, attachments: [@attachment]
|
|
|
|
expect(sub.attachments).to eq([@attachment])
|
|
|
|
expect(sub.includes_attachment?(spoiler)).to eq false
|
|
|
|
expect(sub.includes_attachment?(@attachment)).to eq true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "includes attachments to previous versions" do
|
|
|
|
old_attachment_1 = attachment_model(context: @student)
|
|
|
|
old_attachment_2 = attachment_model(context: @student)
|
|
|
|
sub = @assignment.submit_homework @student, attachments: [old_attachment_1, old_attachment_2]
|
|
|
|
attachment_model context: @student
|
|
|
|
sub = @assignment.submit_homework @student, attachments: [@attachment]
|
|
|
|
expect(sub.attachments).to eq([@attachment])
|
|
|
|
expect(sub.includes_attachment?(old_attachment_1)).to eq true
|
|
|
|
expect(sub.includes_attachment?(old_attachment_2)).to eq true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-05-20 22:34:14 +08:00
|
|
|
context "bulk loading" do
|
2014-07-16 07:19:24 +08:00
|
|
|
def ensure_attachments_arent_queried
|
|
|
|
Attachment.expects(:where).never
|
|
|
|
end
|
|
|
|
|
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
|
|
|
|
|
2016-05-20 22:34:14 +08:00
|
|
|
describe "#bulk_load_versioned_attachments" do
|
|
|
|
it "loads attachments for many submissions at once" do
|
|
|
|
attachments = []
|
|
|
|
|
|
|
|
submissions = 3.times.map do |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]
|
|
|
|
end
|
|
|
|
|
|
|
|
Submission.bulk_load_versioned_attachments(submissions)
|
|
|
|
ensure_attachments_arent_queried
|
|
|
|
submissions.each_with_index do |s, i|
|
|
|
|
expect(s.versioned_attachments).to eq attachments[i]
|
|
|
|
end
|
|
|
|
end
|
2014-07-16 07:19:24 +08:00
|
|
|
|
2016-05-20 22:34:14 +08:00
|
|
|
it "includes url submission attachments" do
|
|
|
|
s = submission_for_some_user
|
|
|
|
s.attachment = attachment_model(filename: "screenshot.jpg",
|
|
|
|
context: @student)
|
|
|
|
|
|
|
|
Submission.bulk_load_versioned_attachments([s])
|
|
|
|
ensure_attachments_arent_queried
|
|
|
|
expect(s.versioned_attachments).to eq [s.attachment]
|
|
|
|
end
|
|
|
|
|
|
|
|
it "handles bad data" do
|
|
|
|
s = submission_for_some_user
|
|
|
|
s.update_attribute(:attachment_ids, '99999999')
|
|
|
|
Submission.bulk_load_versioned_attachments([s])
|
|
|
|
expect(s.versioned_attachments).to eq []
|
|
|
|
end
|
2016-06-05 23:43:41 +08:00
|
|
|
|
|
|
|
it "handles submission histories with different attachments" do
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
attachments = [attachment_model(filename: "submission-a.doc", :context => @student)]
|
|
|
|
Timecop.freeze(10.second.ago) do
|
|
|
|
@assignment.submit_homework(@student, submission_type: 'online_upload',
|
|
|
|
attachments: [attachments[0]])
|
|
|
|
end
|
|
|
|
|
|
|
|
attachments << attachment_model(filename: "submission-b.doc", :context => @student)
|
|
|
|
Timecop.freeze(5.second.ago) do
|
|
|
|
@assignment.submit_homework @student, attachments: [attachments[1]]
|
|
|
|
end
|
|
|
|
|
|
|
|
attachments << attachment_model(filename: "submission-c.doc", :context => @student)
|
|
|
|
Timecop.freeze(1.second.ago) do
|
|
|
|
@assignment.submit_homework @student, attachments: [attachments[2]]
|
|
|
|
end
|
|
|
|
|
|
|
|
submission = @assignment.submission_for_student(@student)
|
|
|
|
Submission.bulk_load_versioned_attachments(submission.submission_history)
|
|
|
|
|
|
|
|
submission.submission_history.each_with_index do |s, index|
|
|
|
|
expect(s.attachment_ids.to_i).to eq attachments[index].id
|
|
|
|
end
|
|
|
|
end
|
2014-07-16 07:19:24 +08:00
|
|
|
end
|
2014-09-10 06:08:45 +08:00
|
|
|
|
2016-05-20 22:34:14 +08:00
|
|
|
describe "#bulk_load_attachments_for_submissions" do
|
|
|
|
it "loads attachments for many submissions at once and returns a hash" do
|
|
|
|
expected_attachments_for_submissions = {}
|
|
|
|
|
|
|
|
submissions = 3.times.map do |i|
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
attachment = [attachment_model(filename: "submission#{i}.doc", :context => @student)]
|
|
|
|
sub = @assignment.submit_homework @student, attachments: attachment
|
|
|
|
expected_attachments_for_submissions[sub] = attachment
|
|
|
|
sub
|
|
|
|
end
|
|
|
|
|
|
|
|
result = Submission.bulk_load_attachments_for_submissions(submissions)
|
|
|
|
ensure_attachments_arent_queried
|
|
|
|
expect(result).to eq(expected_attachments_for_submissions)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "handles bad data" do
|
|
|
|
s = submission_for_some_user
|
|
|
|
s.update_attribute(:attachment_ids, '99999999')
|
|
|
|
expected_attachments_for_submissions = { s => [] }
|
|
|
|
result = Submission.bulk_load_attachments_for_submissions(s)
|
|
|
|
expect(result).to eq(expected_attachments_for_submissions)
|
|
|
|
end
|
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
|
2015-12-23 05:26:50 +08:00
|
|
|
|
2016-04-09 01:54:22 +08:00
|
|
|
context "canvadocs_submissions records" do
|
|
|
|
before(:once) do
|
|
|
|
@student1, @student2 = n_students_in_course(2)
|
|
|
|
@attachment = crocodocable_attachment_model(context: @student1)
|
|
|
|
@assignment = @course.assignments.create! name: "A1",
|
|
|
|
submission_types: "online_upload"
|
|
|
|
end
|
|
|
|
|
|
|
|
before do
|
|
|
|
Canvadocs.stubs(:enabled?).returns true
|
|
|
|
Canvadocs.stubs(:annotations_supported?).returns true
|
|
|
|
Canvadocs.stubs(:config).returns {}
|
|
|
|
end
|
|
|
|
|
|
|
|
it "ties submissions to canvadocs" do
|
|
|
|
s = @assignment.submit_homework(@student1,
|
|
|
|
submission_type: "online_upload",
|
|
|
|
attachments: [@attachment])
|
|
|
|
expect(s.canvadocs).to eq [@attachment.canvadoc]
|
|
|
|
end
|
|
|
|
|
|
|
|
it "create records for each group submission" do
|
|
|
|
gc = @course.group_categories.create! name: "Project Groups"
|
|
|
|
group = gc.groups.create! name: "A Team", context: @course
|
|
|
|
group.add_user(@student1)
|
|
|
|
group.add_user(@student2)
|
|
|
|
|
|
|
|
@assignment.update_attribute :group_category, gc
|
|
|
|
@assignment.submit_homework(@student1,
|
|
|
|
submission_type: "online_upload",
|
|
|
|
attachments: [@attachment])
|
|
|
|
|
|
|
|
[@student1, @student2].each do |student|
|
|
|
|
submission = @assignment.submission_for_student(student)
|
|
|
|
expect(submission.canvadocs).to eq [@attachment.canvadoc]
|
|
|
|
end
|
|
|
|
end
|
2016-07-07 02:44:45 +08:00
|
|
|
|
|
|
|
context 'preferred plugin course id' do
|
|
|
|
let(:submit_homework) do
|
|
|
|
->() do
|
|
|
|
@assignment.submit_homework(@student1,
|
|
|
|
submission_type: "online_upload",
|
|
|
|
attachments: [@attachment])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'sets preferred plugin course id to the course ID' do
|
|
|
|
s = submit_homework.call
|
|
|
|
expect(s.canvadocs.first.preferred_plugin_course_id).to eq(@course.id.to_s)
|
|
|
|
end
|
|
|
|
end
|
2016-04-09 01:54:22 +08:00
|
|
|
end
|
|
|
|
|
2015-12-23 05:26:50 +08:00
|
|
|
it "doesn't create jobs for non-previewable documents" do
|
|
|
|
job_scope = Delayed::Job.where(strand: "canvadocs")
|
|
|
|
orig_job_count = job_scope.count
|
|
|
|
|
|
|
|
attachment = attachment_model(context: @user)
|
|
|
|
s = @assignment.submit_homework(@user,
|
|
|
|
submission_type: "online_upload",
|
|
|
|
attachments: [attachment])
|
|
|
|
expect(job_scope.count).to eq orig_job_count
|
|
|
|
end
|
2015-12-31 03:38:28 +08:00
|
|
|
|
|
|
|
it "doesn't use canvadocs for moderated grading assignments" do
|
|
|
|
@assignment.update_attribute :moderated_grading, true
|
|
|
|
Canvas::Crocodoc.stubs(:enabled?).returns true
|
|
|
|
Canvadocs.stubs(:enabled?).returns true
|
|
|
|
Canvadocs.stubs(:annotations_supported?).returns true
|
|
|
|
|
|
|
|
attachment = crocodocable_attachment_model(context: @user)
|
|
|
|
s = @assignment.submit_homework(@user,
|
|
|
|
submission_type: "online_upload",
|
|
|
|
attachments: [attachment])
|
|
|
|
run_jobs
|
|
|
|
expect(@attachment.canvadoc).to be_nil
|
|
|
|
expect(@attachment.crocodoc_document).not_to be_nil
|
|
|
|
end
|
2014-10-08 09:27:04 +08:00
|
|
|
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
|
2015-11-25 02:37:53 +08:00
|
|
|
|
|
|
|
it "should maintain grade when only updating comments" do
|
|
|
|
@a1.grade_student(@u1, :grade => 3)
|
|
|
|
Submission.process_bulk_update(@progress, @course, nil, @teacher,
|
|
|
|
{
|
|
|
|
@a1.id => {
|
|
|
|
@u1.id => {text_comment: "comment"}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
expect(@a1.submission_for_student(@u1).grade).to eql "3"
|
|
|
|
end
|
|
|
|
|
|
|
|
it "should nil grade when receiving empty posted_grade" do
|
|
|
|
@a1.grade_student(@u1, :grade => 3)
|
|
|
|
Submission.process_bulk_update(@progress, @course, nil, @teacher,
|
|
|
|
{
|
|
|
|
@a1.id => {
|
|
|
|
@u1.id => {posted_grade: nil}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
|
|
|
expect(@a1.submission_for_student(@u1).grade).to be_nil
|
|
|
|
end
|
2015-03-17 15:26:47 +08:00
|
|
|
end
|
crocodoc filtering for moderated grading
Test plan:
* Ensure Crocodoc annotation filtering works in a moderated
assignment:
- Prior to publishing grades,
- Students see only their own annotations, _not_ any
annotations made by provisional graders or moderators
(using the View Feedback link on the submission page)
- TAs as provisional graders see their own annotations
and the student's annotations, _not_ those made by
teachers or other TAs
- Moderators see the correct provisional grader's annotations
in the 1st Mark / 2nd Mark Speedgrader tabs
* if the moderator copies an existing mark from another
grader to the final mark, she should see her own
annotations as well as the original grader's
annotations
- After publishing grades, all users (students, TAs, and
teachers) should see the same set of annotations:
- If a provisional grade was selected for publication,
that grader's annotations and the student's annotations
should be visible
- If a provisional grade was copied to the final mark,
the original grader's, moderator's, and student's
annotations should be visible
- If a student was not in the moderation set,
no filtering should take place (all annotations should be
visible to everyone)
- Other users (provisional graders whose grades were
not selected for publication) should not be able to
create new annotations (because we have no way to
hide _past_ annotations but allow _future_ ones--
our only solution is to lock them out)
* Regression test Crocodoc annotations in a non-moderated
setting:
- teachers can annotate student submissions
- students can see teacher annotations
- teachers can see student annotations
fixes CNVS-23952
Change-Id: Ib842fac356263cff2fc27e6ff4e9abe3e712d6c1
Reviewed-on: https://gerrit.instructure.com/64970
Tested-by: Jenkins
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-10-11 22:07:37 +08:00
|
|
|
|
2016-06-24 06:37:56 +08:00
|
|
|
describe 'find_or_create_provisional_grade!' do
|
|
|
|
before(:once) do
|
|
|
|
submission_spec_model
|
|
|
|
@assignment.moderated_grading = true
|
|
|
|
@assignment.save!
|
|
|
|
|
|
|
|
@teacher2 = User.create(name: "some teacher 2")
|
|
|
|
@context.enroll_teacher(@teacher2)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "properly creates a provisional grade with all default values but scorer" do
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher)
|
|
|
|
|
|
|
|
expect(@submission.provisional_grades.length).to eql 1
|
|
|
|
|
|
|
|
pg = @submission.provisional_grades.first
|
|
|
|
|
|
|
|
expect(pg.scorer_id).to eql @teacher.id
|
|
|
|
expect(pg.final).to eql false
|
|
|
|
expect(pg.graded_anonymously).to be_nil
|
|
|
|
expect(pg.grade).to be_nil
|
|
|
|
expect(pg.score).to be_nil
|
|
|
|
expect(pg.source_provisional_grade).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it "properly amends information to an existing provisional grade" do
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher)
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher,
|
|
|
|
score: 15.0,
|
|
|
|
grade: "20",
|
|
|
|
graded_anonymously: true
|
|
|
|
)
|
|
|
|
|
|
|
|
expect(@submission.provisional_grades.length).to eql 1
|
|
|
|
|
|
|
|
pg = @submission.provisional_grades.first
|
|
|
|
|
|
|
|
expect(pg.scorer_id).to eql @teacher.id
|
|
|
|
expect(pg.final).to eql false
|
|
|
|
expect(pg.graded_anonymously).to eql true
|
|
|
|
expect(pg.grade).to eql "20"
|
|
|
|
expect(pg.score).to eql 15.0
|
|
|
|
expect(pg.source_provisional_grade).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not update grade or score if not given" do
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher, grade: "20", score: 12.0)
|
|
|
|
|
|
|
|
expect(@submission.provisional_grades.first.grade).to eql "20"
|
|
|
|
expect(@submission.provisional_grades.first.score).to eql 12.0
|
|
|
|
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher)
|
|
|
|
|
|
|
|
expect(@submission.provisional_grades.first.grade).to eql "20"
|
|
|
|
expect(@submission.provisional_grades.first.score).to eql 12.0
|
|
|
|
end
|
|
|
|
|
|
|
|
it "does not update graded_anonymously if not given" do
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher, graded_anonymously: true)
|
|
|
|
|
|
|
|
expect(@submission.provisional_grades.first.graded_anonymously).to eql true
|
|
|
|
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher)
|
|
|
|
|
|
|
|
expect(@submission.provisional_grades.first.graded_anonymously).to eql true
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an exception if final is true and user is not allowed to moderate grades" do
|
|
|
|
expect{ @submission.find_or_create_provisional_grade!(@student, final: true) }
|
|
|
|
.to raise_error(Assignment::GradeError, "User not authorized to give final provisional grades")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an exception if grade is not final and student does not need a provisional grade" do
|
|
|
|
@submission.find_or_create_provisional_grade!(@teacher)
|
|
|
|
|
|
|
|
expect{ @submission.find_or_create_provisional_grade!(@teacher2, final: false) }
|
|
|
|
.to raise_error(Assignment::GradeError, "Student already has the maximum number of provisional grades")
|
|
|
|
end
|
|
|
|
|
|
|
|
it "raises an exception if the grade is final and no non-final provisional grades exist" do
|
|
|
|
expect{ @submission.find_or_create_provisional_grade!(@teacher, final: true) }
|
|
|
|
.to raise_error(Assignment::GradeError,
|
|
|
|
"Cannot give a final mark for a student with no other provisional grades")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
crocodoc filtering for moderated grading
Test plan:
* Ensure Crocodoc annotation filtering works in a moderated
assignment:
- Prior to publishing grades,
- Students see only their own annotations, _not_ any
annotations made by provisional graders or moderators
(using the View Feedback link on the submission page)
- TAs as provisional graders see their own annotations
and the student's annotations, _not_ those made by
teachers or other TAs
- Moderators see the correct provisional grader's annotations
in the 1st Mark / 2nd Mark Speedgrader tabs
* if the moderator copies an existing mark from another
grader to the final mark, she should see her own
annotations as well as the original grader's
annotations
- After publishing grades, all users (students, TAs, and
teachers) should see the same set of annotations:
- If a provisional grade was selected for publication,
that grader's annotations and the student's annotations
should be visible
- If a provisional grade was copied to the final mark,
the original grader's, moderator's, and student's
annotations should be visible
- If a student was not in the moderation set,
no filtering should take place (all annotations should be
visible to everyone)
- Other users (provisional graders whose grades were
not selected for publication) should not be able to
create new annotations (because we have no way to
hide _past_ annotations but allow _future_ ones--
our only solution is to lock them out)
* Regression test Crocodoc annotations in a non-moderated
setting:
- teachers can annotate student submissions
- students can see teacher annotations
- teachers can see student annotations
fixes CNVS-23952
Change-Id: Ib842fac356263cff2fc27e6ff4e9abe3e712d6c1
Reviewed-on: https://gerrit.instructure.com/64970
Tested-by: Jenkins
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-10-11 22:07:37 +08:00
|
|
|
describe 'crocodoc_whitelist' do
|
|
|
|
before(:once) do
|
|
|
|
submission_spec_model
|
|
|
|
end
|
|
|
|
|
|
|
|
context "not moderated" do
|
|
|
|
it "returns nil" do
|
|
|
|
expect(@submission.crocodoc_whitelist).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "moderated" do
|
|
|
|
before(:once) do
|
|
|
|
@assignment.moderated_grading = true
|
|
|
|
@assignment.save!
|
|
|
|
@submission.reload
|
2016-06-24 06:37:56 +08:00
|
|
|
@pg = @submission.find_or_create_provisional_grade!(@teacher, score: 1)
|
crocodoc filtering for moderated grading
Test plan:
* Ensure Crocodoc annotation filtering works in a moderated
assignment:
- Prior to publishing grades,
- Students see only their own annotations, _not_ any
annotations made by provisional graders or moderators
(using the View Feedback link on the submission page)
- TAs as provisional graders see their own annotations
and the student's annotations, _not_ those made by
teachers or other TAs
- Moderators see the correct provisional grader's annotations
in the 1st Mark / 2nd Mark Speedgrader tabs
* if the moderator copies an existing mark from another
grader to the final mark, she should see her own
annotations as well as the original grader's
annotations
- After publishing grades, all users (students, TAs, and
teachers) should see the same set of annotations:
- If a provisional grade was selected for publication,
that grader's annotations and the student's annotations
should be visible
- If a provisional grade was copied to the final mark,
the original grader's, moderator's, and student's
annotations should be visible
- If a student was not in the moderation set,
no filtering should take place (all annotations should be
visible to everyone)
- Other users (provisional graders whose grades were
not selected for publication) should not be able to
create new annotations (because we have no way to
hide _past_ annotations but allow _future_ ones--
our only solution is to lock them out)
* Regression test Crocodoc annotations in a non-moderated
setting:
- teachers can annotate student submissions
- students can see teacher annotations
- teachers can see student annotations
fixes CNVS-23952
Change-Id: Ib842fac356263cff2fc27e6ff4e9abe3e712d6c1
Reviewed-on: https://gerrit.instructure.com/64970
Tested-by: Jenkins
Reviewed-by: James Williams <jamesw@instructure.com>
QA-Review: Clare Strong <clare@instructure.com>
Product-Review: Jeremy Stanley <jeremy@instructure.com>
2015-10-11 22:07:37 +08:00
|
|
|
end
|
|
|
|
|
|
|
|
context "grades not published" do
|
|
|
|
context "student not in moderation set" do
|
|
|
|
it "returns the student alone" do
|
|
|
|
expect(@submission.crocodoc_whitelist).to eq([@student.reload.crocodoc_id!])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "student in moderation set" do
|
|
|
|
it "returns the student alone" do
|
|
|
|
@assignment.moderated_grading_selections.create!(student: @student)
|
|
|
|
expect(@submission.crocodoc_whitelist).to eq([@student.reload.crocodoc_id!])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "grades published" do
|
|
|
|
before(:once) do
|
|
|
|
@assignment.grades_published_at = 1.hour.ago
|
|
|
|
@assignment.save!
|
|
|
|
@submission.reload
|
|
|
|
end
|
|
|
|
|
|
|
|
context "student not in moderation set" do
|
|
|
|
it "returns nil" do
|
|
|
|
expect(@submission.crocodoc_whitelist).to be_nil
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "student in moderation set" do
|
|
|
|
before(:once) do
|
|
|
|
@sel = @assignment.moderated_grading_selections.create!(student: @student)
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns nil if no provisional grade was published" do
|
|
|
|
expect(@submission.crocodoc_whitelist).to be_nil
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the student's and selected provisional grader's ids" do
|
|
|
|
@sel.provisional_grade = @pg
|
|
|
|
@sel.save!
|
|
|
|
expect(@submission.crocodoc_whitelist).to match_array([@student.reload.crocodoc_id!,
|
|
|
|
@teacher.reload.crocodoc_id!])
|
|
|
|
end
|
|
|
|
|
|
|
|
it "returns the student's, provisional grader's, and moderator's ids for a copied mark" do
|
|
|
|
moderator = @course.enroll_teacher(user_model, :enrollment_state => 'active').user
|
|
|
|
final = @pg.copy_to_final_mark!(moderator)
|
|
|
|
@sel.provisional_grade = final
|
|
|
|
@sel.save!
|
|
|
|
expect(@submission.crocodoc_whitelist).to match_array([@student.reload.crocodoc_id!,
|
|
|
|
@teacher.reload.crocodoc_id!,
|
|
|
|
moderator.reload.crocodoc_id!])
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
cleanup SubmissionsController#show
fixes CNVS-25767
- Simplifies SubmissionsController#show & adds test coverage.
- Adds Submissions::DownloadsController#show to handle submission
download functionality.
- Adds Submissions::PreviewsController#show to handle submission preview
functionality.
test plan:
- As a teacher, add assignments for each online submission type: Text
Entry, Website URL & File Uploads.
- As a student, provide a submission for each of these assignments.
Provide two submissions for at least one of the assignments.
- As the student, view each of these submissions via the submission
details page. URL path looks like:
/courses/1/assignments/1/submissions/2,
and can be accessed from assignment page.
- Observe that the body of the submission shows up in the Submission
Detail page.
- Observe that for file uploads, the files can be downloaded.
- As the teacher, access the speed grader for each submission.
- Observe that the submission body appears in the speed grader.
- Observe that, for file uploads, the files are displayed inline (this
doesn't work for every media type and it will tell you as much if it's
not supported).
- Observe that if there are multiple files provided, the list of files
appears in the left hand column, and the teacher can tolggle between
them.
- Observe that if the submission has multiple versions, in the left hand
column there is a dropdown labeled 'Submission to view:', and toggling
the selected datetime will change the submission that is displayed.
- As the teacher viewing a submission in the speed grader, leave a
comment in the right hand column, and attach a file.
- As the student, view the submission details page.
- Observe that there is a link to the fiel in the right hand column, and
that the file can be downloaded.
Change-Id: Ib3fff3909f47873b37c373e53ab26cb8176b94e1
Reviewed-on: https://gerrit.instructure.com/68559
Tested-by: Jenkins
Reviewed-by: Mike Nomitch <mnomitch@instructure.com>
QA-Review: Michael Hargiss <mhargiss@instructure.com>
Product-Review: Jason Sparks <jsparks@instructure.com>
2015-12-04 00:15:27 +08:00
|
|
|
|
|
|
|
describe '#rubric_association_with_assessing_user_id' do
|
|
|
|
before :once do
|
|
|
|
submission_model assignment: @assignment, user: @student
|
|
|
|
rubric_association_model association_object: @assignment, purpose: 'grading'
|
|
|
|
end
|
|
|
|
subject { @submission.rubric_association_with_assessing_user_id }
|
|
|
|
|
|
|
|
it 'sets assessing_user_id to submission.user_id' do
|
|
|
|
expect(subject.assessing_user_id).to eq @submission.user_id
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
describe '#visible_rubric_assessments_for' do
|
|
|
|
before :once do
|
|
|
|
submission_model assignment: @assignment, user: @student
|
|
|
|
@viewing_user = @teacher
|
|
|
|
end
|
|
|
|
subject { @submission.visible_rubric_assessments_for(@viewing_user) }
|
|
|
|
|
|
|
|
it 'returns empty if assignment is muted?' do
|
|
|
|
@assignment.update_attribute(:muted, true)
|
|
|
|
expect(@assignment.muted?).to be_truthy, 'precondition'
|
|
|
|
expect(subject).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns empty if viewing user cannot :read_grade' do
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
@viewing_user = @student
|
|
|
|
expect(@submission.grants_right?(@viewing_user, :read_grade)).to be_falsey, 'precondition'
|
|
|
|
expect(subject).to be_empty
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'with rubric_assessments' do
|
|
|
|
before :once do
|
|
|
|
@assessed_user = @student
|
|
|
|
rubric_association_model association_object: @assignment, purpose: 'grading'
|
|
|
|
student_in_course(active_all: true)
|
|
|
|
[ @teacher, @student ].each do |user|
|
|
|
|
@rubric_association.rubric_assessments.create!({
|
|
|
|
artifact: @submission,
|
|
|
|
assessment_type: 'grading',
|
|
|
|
assessor: user,
|
|
|
|
rubric: @rubric,
|
|
|
|
user: @assessed_user
|
|
|
|
})
|
|
|
|
end
|
|
|
|
@teacher_assessment = @submission.rubric_assessments.where(assessor_id: @teacher).first
|
|
|
|
@student_assessment = @submission.rubric_assessments.where(assessor_id: @student).first
|
|
|
|
end
|
|
|
|
subject { @submission.visible_rubric_assessments_for(@viewing_user) }
|
|
|
|
|
|
|
|
it 'returns rubric_assessments for teacher' do
|
|
|
|
expect(subject).to include(@teacher_assessment)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'returns only student rubric assessment' do
|
|
|
|
@viewing_user = @student
|
|
|
|
expect(subject).not_to include(@teacher_assessment)
|
|
|
|
expect(subject).to include(@student_assessment)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
autosave comments on navigating to different user in speedgrader
closes CNVS-28529
While in SpeedGrader, if you have something entered in the comments
field and, without submitting those comments, you navigate to a
different user or otherwise navigate away from SpeedGrader, your
comments will now automatically be saved as "draft" comments for
that user's submission.
Draft comments
* don't show up anywhere other than while grading
* are invisible to users whether or not the assignment is muted
* are only "submittable" by the author of the draft comment
test plan:
1. Create a course, with at least two students
2. Add a quiz with at least one essay type question
3. As each student, take the quiz
4. As the teacher, grade the quiz and start up SpeedGrader
5. Enter comments for the first student's submission but do *not*
submit them
6. Navigate to the next student
7. You should see a message telling you your comment was
auto-saved
8. Go back to the previous student
9. You should see your comment styled differently with a red
asterisk before it, indicating a draft comment (also using
aria-label for a11y goodness)
10.Enter another comment and this time submit it
11.You should see your comment styled normally without a red
asterisk before it, indicating a normal (non-draft) comment
12.Try steps 5 through 11 with different ways of leaving that
student in step #6 e.g. using the drop down, or quitting
SpeedGrader altogether and you should see the same results for
draft comments
13.Go back to a submission with a draft comment.
14.Click on the button labelled "Publish" next to your draft
comment.
15.Watch your comment change in appearance from a draft comment
to a regular comment
16.Delete any comment and watch it disappear from the comment
list.
17.Go to the next student
18.Go back to the previous student for whose submission you
deleted the comment
19.Notice the deleted comment remains missing from the comment
list.
20.Verify that, if logged in as a student, you never see draft
comments
Change-Id: If32294a7bed6f847709b54d4c8e4fc21fb2a6eca
Reviewed-on: https://gerrit.instructure.com/77133
Reviewed-by: Spencer Olson <solson@instructure.com>
Reviewed-by: Neil Gupta <ngupta@instructure.com>
Tested-by: Jenkins
QA-Review: Amber Taniuchi <amber@instructure.com>
Product-Review: Christi Wruck
2016-04-14 05:02:28 +08:00
|
|
|
|
|
|
|
describe '#add_comment' do
|
|
|
|
before(:once) do
|
|
|
|
@submission = Submission.create!(@valid_attributes)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a draft comment when passed true in the draft_comment option' do
|
|
|
|
comment = @submission.add_comment(author: @teacher, comment: '42', draft_comment: true)
|
|
|
|
|
|
|
|
expect(comment).to be_draft
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a final comment when not passed in a draft_comment option' do
|
|
|
|
comment = @submission.add_comment(author: @teacher, comment: '42')
|
|
|
|
|
|
|
|
expect(comment).not_to be_draft
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'creates a final comment when passed false in the draft_comment option' do
|
|
|
|
comment = @submission.add_comment(author: @teacher, comment: '42', draft_comment: false)
|
|
|
|
|
|
|
|
expect(comment).not_to be_draft
|
|
|
|
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
|