spec: mute/unmute before/after moderated grades posted

fixes: GRADE-1234
refs: GRADE-1051

Change-Id: I5d33c727539351fddc0337b1d36138042ac5c243
Reviewed-on: https://gerrit.instructure.com/153220
Reviewed-by: Nicholas Pitrak <npitrak@instructure.com>
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Product-Review: Anju Reddy <areddy@instructure.com>
QA-Review: Anju Reddy <areddy@instructure.com>
This commit is contained in:
Anju Reddy 2018-06-08 10:48:08 -06:00
parent 940c5029e0
commit a13ca46383
11 changed files with 388 additions and 112 deletions

View File

@ -20,74 +20,114 @@ require_relative '../pages/gradebook_page'
describe 'Original Gradebook' do
include_context "in-process server selenium tests"
include GradebookCommon
before(:each) do
Account.default.enable_feature!(:anonymous_grading)
# create a course with a teacher
@anonymous_course = create_course(course_name: 'anonymous_course', active_all: true)
@teacher1 = User.create!(name: 'Teacher1')
@teacher1.register!
@anonymous_course.enroll_teacher(@teacher1, enrollment_state: 'active')
course_with_teacher(course_name: 'Course1', active_all: true)
# create an anonymous assignment
@anonymous_assignment = @anonymous_course.assignments.create!(
title: 'Anonymous Assignment1',
grader_count: 1,
grading_type: 'points',
points_possible: 15,
submission_types: 'online_upload',
anonymous_grading: true
)
@anonymous_assignment.unmute!
# enroll two students
@student1 = User.create!(name: 'Student1')
@student1.register!
@course.enroll_student(@student1, enrollment_state: 'active')
# add two students
@student_1 = User.create!(name: 'Student M. First')
@student_1.register!
@student_1.pseudonyms.create!(unique_id: "nobody1@example.com",
password: 'password',
password_confirmation: 'password')
student_enrollment1 = @anonymous_course.enroll_student(@student_1)
student_enrollment1.update!(workflow_state: 'active')
@student_2 = User.create!(name: 'Student M. Second')
@student_2.register!
@student_2.pseudonyms.create!(unique_id: "nobody2@example.com",
password: 'password',
password_confirmation: 'password')
student_enrollment2 = @anonymous_course.enroll_student(@student_2)
student_enrollment2.update!(workflow_state: 'active')
@student2 = User.create!(name: 'Student2')
@student2.register!
@course.enroll_student(@student2, enrollment_state: 'active')
end
context 'submission detail' do
context 'with an anonymous assignment' do
before(:each) do
user_session(@teacher1)
Gradebook::MultipleGradingPeriods.visit_gradebook(@anonymous_course)
Gradebook::MultipleGradingPeriods.open_comment_dialog(0,1)
# create an anonymous assignment
@anonymous_assignment = @course.assignments.create!(
title: 'Anonymous Assignment1',
grader_count: 1,
grading_type: 'points',
points_possible: 15,
submission_types: 'online_upload',
anonymous_grading: true
)
# submit homework and give a grade
@student1_submission = @anonymous_assignment.submit_homework(@student1, body: 'student 1 submission moderated assignment')
@student1_submission = @anonymous_assignment.grade_student(@student1, grade: 13, grader: @teacher)
end
it 'cannot navigate to speedgrader for specific student', priority: '1', test_id: 3493483 do
# try to navigate to @student_2
Gradebook::MultipleGradingPeriods.submission_detail_speedgrader_link.click
driver.switch_to.window(driver.window_handles.last)
context 'in submission detail' do
before(:each) do
@anonymous_assignment.unmute!
user_session(@teacher)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
Gradebook::MultipleGradingPeriods.open_comment_dialog(0,1)
end
it 'cannot navigate to speedgrader for specific student', priority: '1', test_id: 3493483 do
# try to navigate to @student_2
Gradebook::MultipleGradingPeriods.submission_detail_speedgrader_link.click
driver.switch_to.window(driver.window_handles.last)
wait_for_ajaximations
expect(driver.current_url).not_to include "student_id"
end
end
context 'grade cells', priority: '1', test_id: 3496299 do
before(:each) do
user_session(@teacher)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
end
it 'are disabled and hide grades when assignment is muted', priority: '1', test_id: 3496299 do
grade_cell_grayed = Gradebook::MultipleGradingPeriods.grading_cell_content(0,0)
class_attribute_fetched = grade_cell_grayed.attribute("class")
expect(class_attribute_fetched).to include "grayed-out cannot_edit"
end
end
end
context 'with a moderated assignment' do
before(:each) do
# enroll a second teacher
@teacher2 = User.create!(name: 'Teacher2')
@teacher2.register!
@course.enroll_teacher(@teacher2, enrollment_state: 'active')
# create moderated assignment
@moderated_assignment = @course.assignments.create!(
title: 'Moderated Assignment1',
grader_count: 2,
final_grader_id: @teacher.id,
grading_type: 'points',
points_possible: 15,
submission_types: 'online_text_entry',
moderated_grading: true
)
# enroll a student
@student1 = User.create!(name: 'Student1')
@student1.register!
@course.enroll_student(@student1, enrollment_state: 'active')
# switch session to non-final-grader
user_session(@teacher2)
end
it 'assignment cannot be unmuted in Gradebook before grades are posted', priority: '1', test_id: 3496195 do
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
Gradebook::MultipleGradingPeriods.assignment_header_menu_select(@moderated_assignment.id)
wait_for_ajaximations
expect(driver.current_url).not_to include "student_id"
end
end
context 'has grade cells', priority: '1', test_id: 3496299 do
before(:each) do
user_session(@teacher1)
Gradebook::MultipleGradingPeriods.visit_gradebook(@anonymous_course)
Gradebook::MultipleGradingPeriods.enter_grade("11", 0, 0)
Gradebook::MultipleGradingPeriods.toggle_assignment_mute_option(@anonymous_assignment.id)
expect(Gradebook::MultipleGradingPeriods.assignment_header_menu_item_find('Unmute Assignment').attribute('aria-disabled')).to eq 'true'
end
it 'greyed out with grades invisible when assignment is muted' do
grade_cell_grayed = Gradebook::MultipleGradingPeriods.grading_cell_content(0,0)
class_attribute_fetched = grade_cell_grayed.attribute("class")
expect(class_attribute_fetched).to include "grayed-out cannot_edit"
it 'assignment can be unmuted in Gradebook after grades are posted', priority: '1', test_id: 3496195 do
@moderated_assignment.update!(grades_published_at: Time.zone.now)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
Gradebook::MultipleGradingPeriods.assignment_header_menu_select(@moderated_assignment.id)
wait_for_ajaximations
expect(Gradebook::MultipleGradingPeriods.assignment_header_menu_item_find('Unmute Assignment').attribute('aria-disabled')).to be nil
end
end
end

View File

@ -41,7 +41,7 @@ describe "gradebook with grading periods" do
it 'assignment in ended grading period should be gradable', test_id: 2947119, priority: "1" do
@course.assignments.create!(due_at: 13.days.ago(now), title: "assign in ended")
Gradebook::MultipleGradingPeriods.visit_gradebook(@course, @teacher)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
Gradebook::MultipleGradingPeriods.select_grading_period(0)
Gradebook::MultipleGradingPeriods.enter_grade("10", 0, 0)
@ -63,7 +63,7 @@ describe "gradebook with grading periods" do
it 'assignment in closed grading period should be gradable', test_id: 2947126, priority: "1" do
assignment = @course.assignments.create!(due_at: 18.days.ago(now), title: "assign in closed")
Gradebook::MultipleGradingPeriods.visit_gradebook(@course, @admin)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
Gradebook::MultipleGradingPeriods.select_grading_period(@gp_closed.id)
Gradebook::MultipleGradingPeriods.enter_grade("10", 0, 0)
@ -76,7 +76,7 @@ describe "gradebook with grading periods" do
user_session(@teacher)
@course.assignments.create!(due_at: 18.days.ago, title: "assign in closed")
Gradebook::MultipleGradingPeriods.visit_gradebook(@course, @teacher)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
Gradebook::MultipleGradingPeriods.select_grading_period(0)
expect(Gradebook::MultipleGradingPeriods.grading_cell_attributes(0, 0)).to contain_css(".cannot_edit")

View File

@ -19,7 +19,7 @@ require_relative '../pages/gradezilla_cells_page'
require_relative '../pages/gradezilla_page'
require_relative '../pages/gradezilla_grade_detail_tray_page'
describe 'Anonymous Moderated Marking' do
describe 'New Gradebook' do
include_context 'in-process server selenium tests'
before(:each) do
@ -27,9 +27,8 @@ describe 'Anonymous Moderated Marking' do
course_with_teacher(course_name: 'Course1', active_all: true)
end
context 'with Anonymous Marking Flag ON' do
context 'with an anonymous assignment' do
before(:each) do
Account.default.enable_feature!(:anonymous_marking)
@student1 = student_in_course.user
# create a new anonymous assignment
@ -48,11 +47,7 @@ describe 'Anonymous Moderated Marking' do
)
end
it 'new anonymous assignment is muted by default', priority: '1', test_id: 3500571 do
expect(@anonymous_assignment.muted?).to be true
end
it 'score cell disabled in tray in New Gradebook' do # test_id: 3500571
it 'score cell disabled in grade detail tray', priority: '1', test_id: 3500571 do
user_session(@teacher)
Gradezilla.visit(@course)
Gradezilla::Cells.open_tray(@student1, @anonymous_assignment)
@ -65,7 +60,63 @@ describe 'Anonymous Moderated Marking' do
# make the assignment anonymous
@non_anonymous_assignment.update!(anonymous_grading: true)
expect(@anonymous_assignment.muted?).to be true
expect(@non_anonymous_assignment.muted?).to be true
end
end
context 'with a moderated assignment' do
before(:each) do
# enroll a second teacher
@teacher2 = User.create!(name: 'Teacher2')
@teacher2.register!
@course.enroll_teacher(@teacher2, enrollment_state: 'active')
# create moderated assignment
@moderated_assignment = @course.assignments.create!(
title: 'Moderated Assignment1',
grader_count: 2,
final_grader_id: @teacher.id,
grading_type: 'points',
points_possible: 15,
submission_types: 'online_text_entry',
moderated_grading: true
)
# enroll a student
@student1 = User.create!(name: 'Student1')
@student1.register!
@course.enroll_student(@student1, enrollment_state: 'active')
# give a grade as non-final grader
@student1_submission = @moderated_assignment.submit_homework(@student1, body: 'student 1 submission moderated assignment')
@student1_submission = @moderated_assignment.grade_student(@student1, grade: 13, grader: @teacher2, provisional: true).first
# switch session to non-final-grader
user_session(@teacher2)
end
it 'displays "MUTED" in the assignment', priority: '1', test_id: 3496196 do
Gradezilla.visit(@course)
expect(Gradezilla.select_assignment_header_secondary_label(@moderated_assignment.name).text).to include 'MUTED'
end
it 'prevents unmuting the assignment before grades are posted', prirotiy: '1', test_id: 3496196 do
Gradezilla.visit(@course)
Gradezilla.click_assignment_header_menu(@moderated_assignment.id)
wait_for_ajaximations
expect(Gradezilla.assignment_menu_selector('Unmute Assignment').attribute('aria-disabled')).to eq 'true'
end
it 'allows unmuting the assignment after grades are posted', priority: '1', test_id: 3496196 do
@moderated_assignment.update!(grades_published_at: Time.zone.now)
Gradezilla.visit(@course)
Gradezilla.click_assignment_header_menu(@moderated_assignment.id)
wait_for_ajaximations
expect(Gradezilla.assignment_menu_selector('Unmute Assignment').attribute('aria-disabled')).to be nil
end
end
end

View File

@ -26,7 +26,7 @@ describe 'classic gradebook' do
let(:total_grade) do
grading_period_ids = [0, @gp1.id, @gp2.id]
user_session(@teacher)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course,@teacher)
Gradebook::MultipleGradingPeriods.visit_gradebook(@course)
if @grading_period_index
Gradebook::MultipleGradingPeriods.select_grading_period(grading_period_ids[@grading_period_index])

View File

@ -17,9 +17,7 @@
require_relative '../../common'
require_relative '../../assignments/page_objects/assignment_page'
require_relative '../pages/speedgrader_page'
require_relative '../pages/moderate_page'
require_relative '../pages/gradebook_page'
describe 'Moderated Marking' do
include_context 'in-process server selenium tests'

View File

@ -115,10 +115,7 @@ module Gradebook
end
# actions
def visit_gradebook(course, user = nil)
if user.present?
user.preferences[:gradebook_version] = '2'
end
def visit_gradebook(course)
get "/courses/#{course.id}/gradebook"
end

View File

@ -21,8 +21,6 @@ class Gradezilla
class << self
include SeleniumDependencies
private
# Student Headings
STUDENT_COLUMN_MENU_SELECTOR = '.container_0 .Gradebook__ColumnHeaderAction'.freeze
@ -73,6 +71,10 @@ class Gradezilla
select_assignment_header_cell_element(title).find('.assignment-name')
end
def assignment_menu_selector(menu_text)
fj("span[role='menuitem']:contains('#{menu_text}')")
end
# student header column elements
def student_column_menu
f("span .Gradebook__ColumnHeaderAction")
@ -186,8 +188,6 @@ class Gradezilla
fj('li li:contains("Unpublished Assignments")')
end
public
def body
f('body')
end
@ -549,10 +549,6 @@ class Gradezilla
# ASSIGNMENT COLUMN HEADER OPTIONS
# css selectors
def assignment_header_menu_selector(id)
assignment_header_menu_element(id)
end
def assignment_header_cell_element(title)
f(assignment_header_cell_selector(title))
end

View File

@ -56,6 +56,10 @@ class Speedgrader
fxpath('//ul[@role = "menu"]//span[text() = "Keyboard Shortcuts"]')
end
def mute_button
f('button#mute_link')
end
def hide_students_chkbox
f('#hide_student_names')
end

View File

@ -60,6 +60,14 @@ class SRGB
f('#student_information .total-grade')
end
def assignment_muted_checkbox
f('#assignment_muted_check')
end
def assignment_mute_dialog_button
fj("button:contains('Unmute Assignment')")
end
def assign_subtotal_grade
f('.assignment-subtotal-grade .grade')
end
@ -105,6 +113,10 @@ class SRGB
f('#show_notes')
end
def all_content
f('#content')
end
# content selection buttons
def previous_student
f('.student_navigation button.previous_object')

View File

@ -19,56 +19,91 @@ require_relative "../../common"
require_relative "../../helpers/speed_grader_common"
require_relative "../pages/speedgrader_page"
describe "SpeedGrader with Anonymous Marking enabled" do
describe "SpeedGrader" do
include_context "in-process server selenium tests"
include SpeedGraderCommon
before do
Account.default.enable_feature!(:anonymous_marking)
before(:each) do
# a course with 1 teacher
course_with_teacher_logged_in
outcome_with_rubric
@assignment = @course.assignments.create!(
name: 'some topic',
points_possible: 10,
submission_types: 'discussion_topic',
description: 'a little bit of content',
anonymous_grading: true
)
student = user_with_pseudonym(
name: 'Fen',
active_user: true,
username: 'student@example.com',
password: 'qwertyuiop'
)
@course.enroll_user(student, "StudentEnrollment", enrollment_state: :active)
# create and enroll second student
student_2 = user_with_pseudonym(
name: 'Zaz',
active_user: true,
username: 'student2@example.com',
password: 'qwertyuiop'
)
@course.enroll_user(student_2, "StudentEnrollment", enrollment_state: :active)
Speedgrader.visit(@course.id, @assignment.id)
# enroll two students
@student1 = User.create!(name: 'Student1')
@student1.register!
@course.enroll_student(@student1, enrollment_state: 'active')
@student2 = User.create!(name: 'Student2')
@student2.register!
@course.enroll_student(@student2, enrollment_state: 'active')
end
context "shows unique anonymous student IDs" do
it "when teacher visits the page", priority: "1", test_id: 3481048 do
context "with an anonymous assignment" do
before(:each) do
# an anonymous assignment
@assignment = @course.assignments.create!(
name: 'anonymous assignment',
points_possible: 10,
submission_types: 'text',
anonymous_grading: true
)
user_session(@teacher)
Speedgrader.visit(@course.id, @assignment.id)
end
it "student names are anonymous", priority: "1", test_id: 3481048 do
Speedgrader.students_dropdown_button.click
student_names = Speedgrader.students_select_menu_list.map(&:text)
expect(student_names).to eql ['Student 1', 'Student 2']
end
context "give a teacher as selected student two's submission" do
context "given a specific student" do
before do
Speedgrader.click_next_or_prev_student(:next)
Speedgrader.students_dropdown_button.click
@current_student = Speedgrader.selected_student
end
it "when teacher selects a submission and refreshes page", priority: "1", test_id: 3481049 do
it "when their submission is selected and page reloaded", priority: "1", test_id: 3481049 do
expect { refresh_page }.not_to change { Speedgrader.selected_student.text }.from('Student 2')
end
end
end
context 'with a moderated assignment' do
before(:each) do
# enroll a second teacher
@teacher2 = User.create!(name: 'Teacher2')
@teacher2.register!
@course.enroll_teacher(@teacher2, enrollment_state: 'active')
# create moderated assignment
@moderated_assignment = @course.assignments.create!(
title: 'Moderated Assignment1',
grader_count: 2,
final_grader_id: @teacher.id,
grading_type: 'points',
points_possible: 15,
submission_types: 'online_text_entry',
moderated_grading: true
)
# switch session to non-final-grader
user_session(@teacher2)
end
it 'prevents unmuting the assignment before grades are posted', priority: '2', test_id: 3493531 do
Speedgrader.visit(@course.id, @moderated_assignment.id)
expect(Speedgrader.mute_button.attribute('data-muted')).to eq 'true'
expect(Speedgrader.mute_button.attribute('class')).to include 'disabled'
end
it 'allows unmuting the assignment after grades are posted', priority: '2', test_id: 3493531 do
@moderated_assignment.update!(grades_published_at: Time.zone.now)
Speedgrader.visit(@course.id, @moderated_assignment.id)
expect(Speedgrader.mute_button.attribute('class')).not_to include 'disabled'
end
end
end

View File

@ -0,0 +1,143 @@
#
# Copyright (C) 2018 - present Instructure, Inc.
#
# 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_relative '../../helpers/gradebook_common'
require_relative '../pages/srgb_page'
describe "Individual View Gradebook" do
include_context 'in-process server selenium tests'
include GradebookCommon
before(:each) do
# create a course with a teacher
course_with_teacher(course_name: 'Course1', active_all: true)
# enroll two students
@student1 = User.create!(name: 'Student1')
@student1.register!
@course.enroll_student(@student1, enrollment_state: 'active')
@student2 = User.create!(name: 'Student2')
@student2.register!
@course.enroll_student(@student2, enrollment_state: 'active')
end
context 'with a moderated assignment' do
before(:each) do
# enroll a second teacher
@teacher2 = User.create!(name: 'Teacher2')
@teacher2.register!
@course.enroll_teacher(@teacher2, enrollment_state: 'active')
# create moderated assignment
@moderated_assignment = @course.assignments.create!(
title: 'Moderated Assignment1',
grader_count: 2,
final_grader_id: @teacher.id,
grading_type: 'points',
points_possible: 15,
submission_types: 'online_text_entry',
moderated_grading: true
)
# enroll a student
@student1 = User.create!(name: 'Student1')
@student1.register!
@course.enroll_student(@student1, enrollment_state: 'active')
# give a grade as non-final grader
@student1_submission = @moderated_assignment.submit_homework(@student1, :body => 'student 1 submission moderated assignment')
@student1_submission = @moderated_assignment.grade_student(@student1, grade: 13, grader: @teacher2, provisional: true).first
# switch session to non-final-grader
user_session(@teacher2)
end
it 'prevents unmuting the assignment before grades are posted', priority: '2', test_id: 3504343 do
skip 'will be unskipped in https://instructure.atlassian.net/browse/GRADE-1051'
SRGB.visit(@course.id)
SRGB.select_assignment(@moderated_assignment)
wait_for_ajaximations
expect(SRGB.assignment_muted_checkbox.attribute('checked')).to eq 'true'
expect(SRGB.assignment_muted_checkbox.attribute('aria-disabled')).to eq 'true'
end
it 'allows unmuting the assignment after grades are posted', priority: '2', test_id: 3504343 do
@moderated_assignment.update!(grades_published_at: Time.zone.now)
SRGB.visit(@course.id)
SRGB.select_assignment(@moderated_assignment)
wait_for_ajaximations
expect(SRGB.assignment_muted_checkbox.attribute('aria-disabled')).to be nil
end
it 'prevents grading for the assignment before grades are posted', priority: '2', test_id: 3505171 do
skip 'will be unskipped in https://instructure.atlassian.net/browse/GRADE-969'
SRGB.visit(@course.id)
SRGB.select_student(@student1)
SRGB.select_assignment(@moderated_assignment)
expect(SRGB.main_grade_input.attribute).to include 'disabled'
end
it 'allows grading for the assignment after grades are posted', priority: '2', test_id: 3505171 do
@moderated_assignment.update!(grades_published_at: Time.zone.now)
SRGB.visit(@course.id)
SRGB.select_student(@student1)
SRGB.select_assignment(@moderated_assignment)
SRGB.enter_grade('15')
expect(SRGB.current_grade).to eq '15'
end
end
context 'with an anonymous assignment' do
before(:each) do
# create a new anonymous assignment
@anonymous_assignment = @course.assignments.create!(
title: 'Anonymous Assignment',
submission_types: 'online_text_entry',
anonymous_grading: true,
points_possible: 10
)
# create an unmuted anonymous assignment
@unmuted_anonymous_assignment = @course.assignments.create!(
title: 'Unmuted Anon Assignment',
submission_types: 'online_text_entry',
anonymous_grading: true,
points_possible: 10
)
@unmuted_anonymous_assignment.unmute!
user_session(@teacher)
end
it 'excludes the muted assignment from the assignment list', priority: '1', test_id: 3505168 do
SRGB.visit(@course.id)
SRGB.select_student(@student1)
SRGB.assignment_dropdown.click
# muted anonymous assignment is not displayed
expect(SRGB.assignment_dropdown).not_to include_text 'Anonymous Assignment'
# unmuted anonymous assignment is displayed
expect(SRGB.assignment_dropdown).to include_text 'Unmuted Anon Assignment'
end
end
end