Assignment_rubrics: Added and refactored specs for assignments_rubrics_spec.rb

dsoundarrajan, panda, 3

Change-Id: I5c148fc0f65a0cad2e4d8b6bd2ce3fc45a3e694b
Reviewed-on: https://gerrit.instructure.com/60508
Tested-by: Jenkins
Reviewed-by: Derek Hansen <dhansen@instructure.com>
Product-Review: Derek Hansen <dhansen@instructure.com>
QA-Review: Derek Hansen <dhansen@instructure.com>
This commit is contained in:
Deepeeca Soundarrajan 2015-08-11 11:15:07 -06:00 committed by Derek Hansen
parent 5bc6569581
commit a32e486735
3 changed files with 150 additions and 76 deletions

View File

@ -75,7 +75,7 @@ def outcome_with_rubric(opts={})
@outcome_group.save!
rubric_params = {
:title => 'My Rubric',
:title => opts[:title] || 'My Rubric',
:hide_score_total => false,
:criteria => {
"0" => {

View File

@ -1,4 +1,5 @@
require File.expand_path(File.dirname(__FILE__) + '/common')
require File.expand_path(File.dirname(__FILE__) + '/helpers/rubrics_common')
describe "assignment rubrics" do
include_context "in-process server selenium tests"
@ -11,22 +12,56 @@ describe "assignment rubrics" do
def create_assignment_with_points(points)
assignment_name = 'first test assignment'
due_date = Time.now.utc + 2.days
@group = @course.assignment_groups.create!(:name => "default")
@group = @course.assignment_groups.create!(name: "default")
@assignment = @course.assignments.create(
:name => assignment_name,
:due_at => due_date,
:points_possible => points,
:assignment_group => @group
name: assignment_name,
due_at: due_date,
points_possible: points,
assignment_group: @group
)
@assignment
end
def mark_rubric_for_grading(rubric, expect_confirmation)
f("#rubric_#{rubric.id} .edit_rubric_link").click
driver.switch_to.alert.accept if expect_confirmation
fj(".grading_rubric_checkbox:visible").click
fj(".save_button:visible").click
# If change points possible dialog box is present
if f('.ui-dialog')
f(' .ui-button:nth-of-type(1)').click
end
wait_for_ajaximations
end
it "should add a new rubric", priority: "2", test_id: 56587 do
get "/courses/#{@course.id}/outcomes"
expect_new_page_load{f(' .manage_rubrics').click}
expect do
f('.add_rubric_link').click
f('.add_criterion_link').click
set_value(f('.criterion_description input[name = "description"]'), 'criterion 1')
f(' .ok_button').click
wait_for_ajaximations
f('#criterion_2 .add_rating_link_after').click
f('#criterion_2 tbody tr td:nth-of-type(2) .edit_rating_link').click
set_value(f('.rating_description'), 'rating 1')
f(' .ok_button').click
submit_form('#edit_rubric_form')
wait_for_ajaximations
end.to change(Rubric, :count).by(1)
expect(f('.rubric_table tbody tr:nth-of-type(3) .criterion_description_value')).
to include_text('criterion 1')
expect(f('.rubric_table tbody tr:nth-of-type(3) .ratings td:nth-of-type(2) .rating_description_value')).
to include_text('rating 1')
end
it "should add a new rubric to assignment and verify points", priority: "1", test_id: 114341 do
initial_points = 2.5
rubric_name = 'new rubric'
create_assignment_with_points(initial_points)
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
f('.add_rubric_link').click
set_value(f('.rubric_title input[name="title"]'), rubric_name)
criterion_points = fj('.criterion_points:visible')
@ -42,18 +77,51 @@ describe "assignment rubrics" do
expect(f('#rubrics .rubric .rubric_title .displaying .title')).to include_text(rubric_name)
end
it "should verify existing rubrics", priority: "2", test_id: 114342 do
outcome_with_rubric(title: 'Course Rubric')
@rubric.associate_with(@course, @course, :purpose => 'grading')
assignment_with_rubric(10, 'Assignment Rubric ')
get "/courses/#{@course.id}/rubrics"
expect(fln('Course Rubric')).to be_present
expect(fln('Assignment Rubric')).to be_present
end
it "should use an existing rubric to use for grading", priority: "2", test_id: 114344 do
assignment_with_rubric(10)
course_rubric = outcome_with_rubric
course_rubric.associate_with(@course, @course, purpose: 'grading')
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
f(' .rubric_title .icon-edit').click
driver.switch_to.alert.accept
wait_for_ajaximations
fln('Find a Rubric').click
wait_for_ajaximations
fln('My Rubric').click
wait_for_ajaximations
f('#rubric_dialog_'+course_rubric.id.to_s+' .select_rubric_link').click
wait_for_ajaximations
expect(f('#rubric_'+course_rubric.id.to_s+' .rubric_title .title')).to include_text(course_rubric.title)
# Find the associated rubric for the assignment we just edited
association = RubricAssociation.where(title: "first test assignment")
assignment2 = @course.assignments.create!(name: "assign 2", points_possible: 10)
association2 = course_rubric.associate_with(assignment2, @course, purpose: 'grading')
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
mark_rubric_for_grading(course_rubric, true)
get "/courses/#{@course.id}/assignments/#{assignment2.id}"
mark_rubric_for_grading(course_rubric, true)
expect(association[0].reload.use_for_grading).to be_truthy
expect(association[0].rubric.id).to eq course_rubric.id
expect(association2.reload.use_for_grading).to be_truthy
expect(association2.rubric.id).to eq course_rubric.id
end
it "should carry decimal values through rubric to grading", priority: "2", test_id: 220315 do
student_in_course
@assignment = create_assignment_with_points(2.5)
rubric_model(:title => 'new rubric', :data =>
[{
:description => "Some criterion",
:points => 2.5,
:id => 'crit1',
:ratings =>
[{:description => "Good", :points => 2.5, :id => 'rat1', :criterion_id => 'crit1'}]
}], :description => 'new rubric description')
@association = @rubric.associate_with(@assignment, @course, :purpose => 'grading', :use_for_grading => false)
assignment_with_rubric(2.5)
get "/courses/#{@course.id}/gradebook/speed_grader?assignment_id=#{@assignment.id}"
wait_for_ajax_requests
@ -75,7 +143,7 @@ describe "assignment rubrics" do
create_assignment_with_points(2)
outcome_with_rubric
@rubric.associate_with(@course, @course, :purpose => 'grading')
@rubric.associate_with(@course, @course, purpose: 'grading')
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
@ -120,37 +188,37 @@ describe "assignment rubrics" do
end
it "should not allow XSS attacks through rubric descriptions", priority: "2", test_id: 220327 do
student = user_with_pseudonym :active_user => true,
:username => "student@example.com",
:password => "password"
@course.enroll_user(student, "StudentEnrollment", :enrollment_state => 'active')
student = user_with_pseudonym active_user: true,
username: "student@example.com",
password: "password"
@course.enroll_user(student, "StudentEnrollment", enrollment_state: 'active')
@assignment = @course.assignments.create(:name => 'assignment with rubric')
@rubric = Rubric.new(:title => 'My Rubric', :context => @course)
@assignment = @course.assignments.create(name: 'assignment with rubric')
@rubric = Rubric.new(title: 'My Rubric', context: @course)
@rubric.data = [
{
:points => 3,
:description => "XSS Attack!",
:long_description => "<b>This text should not be bold</b>",
:id => 1,
:ratings => [
points: 3,
description: "XSS Attack!",
long_description: "<b>This text should not be bold</b>",
id: 1,
ratings: [
{
:points => 3,
:description => "Rockin'",
:criterion_id => 1,
:id => 2
points: 3,
description: "Rockin'",
criterion_id: 1,
id: 2
},
{
:points => 0,
:description => "Lame",
:criterion_id => 1,
:id => 3
points: 0,
description: "Lame",
criterion_id: 1,
id: 3
}
]
}
]
@rubric.save!
@rubric.associate_with(@assignment, @course, :purpose => 'grading')
@rubric.associate_with(@assignment, @course, purpose: 'grading')
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
@ -170,11 +238,11 @@ describe "assignment rubrics" do
end
it "should follow learning outcome ignore_for_scoring", priority: "2", test_id: 220328 do
student_in_course(:active_all => true)
student_in_course(active_all: true)
outcome_with_rubric
@assignment = @course.assignments.create(:name => 'assignment with rubric')
@association = @rubric.associate_with(@assignment, @course, :purpose => 'grading', :use_for_grading => true)
@submission = @assignment.submit_homework(@student, {:url => "http://www.instructure.com/"})
@assignment = @course.assignments.create(name: 'assignment with rubric')
@association = @rubric.associate_with(@assignment, @course, purpose: 'grading', use_for_grading: true)
@submission = @assignment.submit_homework(@student, {url: "http://www.instructure.com/"})
@rubric.data[0][:ignore_for_scoring] = '1'
@rubric.points_possible = 5
@rubric.save!
@ -191,20 +259,12 @@ describe "assignment rubrics" do
expect(f('.grading_value')).to have_attribute(:value, '5')
end
def mark_rubric_for_grading(rubric, expect_confirmation)
f("#rubric_#{rubric.id} .edit_rubric_link").click
driver.switch_to.alert.accept if expect_confirmation
fj(".grading_rubric_checkbox:visible").click
fj(".save_button:visible").click
wait_for_ajaximations
end
it "should properly manage rubric focus on submission preview page", priority: "2", test_id: 220329 do
student_in_course(:active_all => true)
outcome_with_rubric
@assignment = @course.assignments.create(:name => 'assignment with rubric')
@association = @rubric.associate_with(@assignment, @course, :purpose => 'grading', :use_for_grading => true)
@submission = @assignment.submit_homework(@student, {:url => "http://www.instructure.com/"})
@association = @rubric.associate_with(@assignment, @course, purpose: 'grading', use_for_grading: true)
@submission = @assignment.submit_homework(@student, {url: "http://www.instructure.com/"})
get "/courses/#{@course.id}/assignments/#{@assignment.id}/submissions/#{@student.id}"
wait_for_ajaximations
f(".assess_submission_link").click
@ -224,11 +284,11 @@ describe "assignment rubrics" do
it "should allow multiple rubric associations for grading", priority: "1", test_id: 220330 do
outcome_with_rubric
@assignment1 = @course.assignments.create!(:name => "assign 1", :points_possible => @rubric.points_possible)
@assignment2 = @course.assignments.create!(:name => "assign 2", :points_possible => @rubric.points_possible)
@assignment1 = @course.assignments.create!(name: "assign 1", points_possible: @rubric.points_possible)
@assignment2 = @course.assignments.create!(name: "assign 2", points_possible: @rubric.points_possible)
@association1 = @rubric.associate_with(@assignment1, @course, :purpose => 'grading')
@association2 = @rubric.associate_with(@assignment2, @course, :purpose => 'grading')
@association1 = @rubric.associate_with(@assignment1, @course, purpose: 'grading')
@association2 = @rubric.associate_with(@assignment2, @course, purpose: 'grading')
get "/courses/#{@course.id}/assignments/#{@assignment1.id}"
mark_rubric_for_grading(@rubric, true)
@ -245,13 +305,13 @@ describe "assignment rubrics" do
it "shows status of 'use_for_grading' properly", priority: "1", test_id: 220331 do
outcome_with_rubric
@assignment1 = @course.assignments.create!(
:name => "assign 1",
:points_possible => @rubric.points_possible
name: "assign 1",
points_possible: @rubric.points_possible
)
@association1 = @rubric.associate_with(
@assignment1,
@course,
:purpose => 'grading'
purpose: 'grading'
)
get "/courses/#{@course.id}/assignments/#{@assignment1.id}"
@ -268,10 +328,10 @@ describe "assignment rubrics" do
end
it "should properly show rubric criterion details for learning outcomes", priority: "2", test_id: 220332 do
@assignment = @course.assignments.create(:name => 'assignment with rubric')
@assignment = @course.assignments.create(name: 'assignment with rubric')
outcome_with_rubric
@rubric.associate_with(@assignment, @course, :purpose => 'grading')
@rubric.associate_with(@assignment, @course, purpose: 'grading')
get "/courses/#{@course.id}/assignments/#{@assignment.id}"
@ -283,20 +343,21 @@ describe "assignment rubrics" do
it "should show criterion comments", priority: "2", test_id: 220333 do
# given
comment = 'a comment'
teacher_in_course(:course => @course)
assignment = @course.assignments.create(:name => 'assignment with rubric')
teacher_in_course(course: @course)
assignment = @course.assignments.create(name: 'assignment with rubric')
outcome_with_rubric
association = @rubric.associate_with(assignment, @course, :purpose => 'grading')
assessment = association.assess(:user => @student,
:assessor => @teacher,
:artifact => assignment.find_or_create_submission(@student),
:assessment => {
:assessment_type => 'grading',
:"criterion_#{@rubric.criteria_object.first.id}" => {
:points => 3,
:comments => comment,
}
})
association = @rubric.associate_with(assignment, @course, purpose: 'grading')
association.assess(user: @student,
assessor: @teacher,
artifact: assignment.find_or_create_submission(@student),
assessment: {
assessment_type: 'grading',
:"criterion_#{@rubric.criteria_object.first.id}" => {
points: 3,
comments: comment,
}
}
)
# when
get "/courses/#{@course.id}/assignments/#{assignment.id}/submissions/#{@student.id}"
f('.assess_submission_link').click
@ -307,9 +368,9 @@ describe "assignment rubrics" do
end
it "shouldn't show 'update description' button in long description dialog", priority: "2", test_id: 220334 do
@assignment = @course.assignments.create(:name => 'assignment with rubric')
@assignment = @course.assignments.create(name: 'assignment with rubric')
rubric_for_course
@rubric.associate_with(@assignment, @course, :purpose => 'grading')
@rubric.associate_with(@assignment, @course, purpose: 'grading')
get "/courses/#{@course.id}/assignments/#{@assignment.id}"

View File

@ -11,6 +11,19 @@ def create_rubric_with_criterion_points(points)
wait_for_ajaximations
end
def assignment_with_rubric(points, title = 'new rubric')
@assignment = create_assignment_with_points(points)
rubric_model(title: title, data:
[{
description: "Some criterion",
points: points,
id: 'crit1',
ratings:
[{description: "Good", points: points, id: 'rat1', criterion_id: 'crit1'}]
}], description: 'new rubric description')
@association = @rubric.associate_with(@assignment, @course, purpose: 'grading', use_for_grading: false)
end
def edit_rubric_after_updating
fj(".rubric .edit_rubric_link:visible").click
driver.find_element(:tag_name, "body").click