1+ require File . expand_path ( File . dirname ( __FILE__ ) + '/helpers/gradebook2_common' )
2+ require File . expand_path ( File . dirname ( __FILE__ ) + '/helpers/groups_common' )
3+
4+ describe 'Excuse an Assignment' do
5+ include_examples "in-process server selenium tests"
6+
7+ context 'SpeedGrader' do
8+ before do
9+ course_with_teacher_logged_in
10+ course_with_student ( course : @course , active_all : true , name : 'Student' )
11+ end
12+
13+ it 'can excuse complete/incomplete assignments' , priority : "1" , test_id : 209315 do
14+ @assignment = @course . assignments . build
15+ @assignment . grading_type = 'pass_fail'
16+ @assignment . publish
17+
18+ get "/courses/#{ @course . id } /gradebook/speed_grader?assignment_id=#{ @assignment . id } "
19+ Selenium ::WebDriver ::Support ::Select . new ( f ( '#grading-box-extended' ) )
20+ . select_by ( :text , 'Excused' )
21+
22+ get "/courses/#{ @course . id } /grades"
23+ dropped = f ( '#gradebook_grid .container_1 .slick-row :first-child' )
24+ expect ( dropped . text ) . to eq 'EX'
25+ expect ( dropped ) . to have_class 'dropped'
26+ end
27+
28+ it 'excuses an assignment properly' , priority : "1" , test_id : 201949 do
29+ a1 = @course . assignments . create! title : 'Excuse Me' , points_possible : 20
30+ a2 = @course . assignments . create! title : 'Don\'t Excuse Me' , points_possible : 10
31+ a1 . grade_student ( @student , { grade : 20 } )
32+ a2 . grade_student ( @student , { grade : 5 } )
33+
34+ get "/courses/#{ @course . id } /gradebook/speed_grader?assignment_id=#{ a2 . id } "
35+ replace_content f ( '#grading-box-extended' ) , "EX\n "
36+
37+ get "/courses/#{ @course . id } /grades"
38+ row = ff ( '#gradebook_grid .container_1 .slick-row .slick-cell' )
39+
40+ expect ( row [ 0 ] . text ) . to eq '20'
41+ # this should show 'EX' and have dropped class
42+ expect ( row [ 1 ] . text ) . to eq ( 'EX' )
43+ expect ( row [ 1 ] ) . to have_class 'dropped'
44+
45+ # only one cell should have 'dropped' class
46+ dropped = ff ( '#gradebook_grid .container_1 .slick-row .dropped' )
47+ expect ( dropped . length ) . to eq 1
48+
49+ # 'EX' should only affect that one cell
50+ expect ( row [ 2 ] . text ) . to eq '100%'
51+ end
52+
53+ it 'indicates excused assignment as graded' , priority : "1" , test_id : 209316 do
54+ assignment = @course . assignments . build
55+ assignment . publish
56+
57+ assignment . grade_student ( @student , { excuse : true } )
58+
59+ get "/courses/#{ @course . id } /gradebook/speed_grader?assignment_id=#{ assignment . id } "
60+ expect ( f ( '#combo_box_container .ui-selectmenu-item-icon i' ) ) . to have_class 'icon-check'
61+ expect ( f ( '#combo_box_container .ui-selectmenu-item-header' ) . text ) . to eq 'Student'
62+ end
63+ end
64+
65+ shared_examples 'Basic Behavior' do |view |
66+ context 'Group Assignments' , :group do
67+ it 'preserves assignment excused status' , priority : "1" , test_id : view == 'srgb' ? 216318 : 207117 do
68+ course_with_teacher_logged_in
69+ group_test_setup 4 , 1 , 1
70+
71+ @students . each { |student | @testgroup [ 0 ] . add_user student }
72+ @testgroup [ 0 ] . save!
73+
74+ assignment = @course . assignments . create! (
75+ title : 'Group Assignment' ,
76+ group_category_id : @testgroup [ 0 ] . id ,
77+ grade_group_students_individually : false ,
78+ points_possible : 20
79+ )
80+
81+ assignment . grade_student @students [ 1 ] , { excuse : true }
82+ assignment . grade_student @students [ 0 ] , { grade : 15 }
83+
84+ score_values = [ ]
85+
86+ if view == 'srgb'
87+ get "/courses/#{ @course . id } /gradebook/change_gradebook_version?version=srgb"
88+ Selenium ::WebDriver ::Support ::Select . new ( f ( '#assignment_select' ) )
89+ . select_by ( :text , assignment . title )
90+ next_student = f ( '.student_navigation button.next_object' )
91+ 4 . times do
92+ next_student . click
93+ score_values << f ( '#student_and_assignment_grade' ) . attribute ( 'value' )
94+ end
95+ else
96+ get "/courses/#{ @course . id } /gradebook/"
97+ score_values = ff ( '.canvas_1 .slick-row .slick-cell:first-child' ) . map ( & :text )
98+ end
99+
100+ expect ( score_values ) . to eq [ '15' , 'EX' , '15' , '15' ]
101+ end
102+
103+ it 'excuses assignments on individual basis' , priority : "1" , test_id : view == 'srgb' ? 209405 : 209384 do
104+ course_with_teacher_logged_in
105+ group_test_setup 2 , 1 , 1
106+
107+ @students . each { |student | @testgroup [ 0 ] . add_user student }
108+ @testgroup [ 0 ] . save!
109+
110+ a1 = @course . assignments . create! (
111+ title : 'Group Assignment' ,
112+ group_category_id : @testgroup [ 0 ] . id ,
113+ grade_group_students_individually : false ,
114+ points_possible : 10
115+ )
116+ a2 = @course . assignments . create! title : 'Assignment' , points_possible : 20
117+
118+ @students . each do |student |
119+ a1 . grade_student student , grade : 5
120+ a2 . grade_student student , grade : 20
121+ end
122+
123+ a1 . grade_student @students [ 1 ] , excuse : true
124+
125+ totals = [ ]
126+ if view == 'srgb'
127+ get "/courses/#{ @course . id } /gradebook/change_gradebook_version?version=srgb"
128+ next_student = f ( '.student_navigation button.next_object' )
129+ 2 . times do
130+ next_student . click
131+ totals << f ( 'span.total-grade' ) . text [ /\d +(\. \d +)?%/ ]
132+ end
133+ else
134+ get "/courses/#{ @course . id } /gradebook/"
135+ totals = ff ( '.canvas_1 .slick-row .slick-cell:last-child' ) . map ( & :text )
136+ end
137+
138+ expect ( totals ) . to eq ( [ '83.33%' , '100%' ] ) . or eq [ '83.3%' , '100%' ]
139+ end
140+ end
141+
142+ it 'formats excused grade like dropped assignment' , priority : "1" , test_id : view == 'srgb' ? 216380 : 197051 do
143+ assignment = @course . assignments . create! title : 'Excuse Me' , points_possible : 20
144+
145+ if view == 'srgb'
146+ skip "Skipped because this spec fails if not run in foreground\n " \
147+ "This is believed to be the issue: https://code.google.com/p/selenium/issues/detail?id=7346"
148+ get "/courses/#{ @course . id } /gradebook/change_gradebook_version?version=srgb"
149+ Selenium ::WebDriver ::Support ::Select . new ( f ( '#assignment_select' ) )
150+ . select_by ( :text , assignment . title )
151+ Selenium ::WebDriver ::Support ::Select . new ( f ( '#student_select' ) )
152+ . select_by ( :text , @students [ 0 ] . name )
153+ replace_content f ( '#student_and_assignment_grade' ) , "EX\t "
154+ wait_for_ajaximations
155+ else
156+ assignment . grade_student ( @students [ 0 ] , { excuse : true } )
157+ end
158+
159+ user_session ( @students [ 0 ] )
160+ get "/courses/#{ @course . id } /grades"
161+
162+ grade_row = f ( "#submission_#{ assignment . id } " )
163+ grade_cell = f ( ".assignment_score .grade" , grade_row )
164+ grade = grade_cell . text . scan ( /\d +|EX/ ) . first
165+
166+ expect ( grade_row ) . to have_class '.excused'
167+ expect ( grade ) . to eq 'EX'
168+ expect ( grade_row . attribute 'title' ) . to eq 'This assignment is excused ' \
169+ 'and will not be considered in the total calculation'
170+ end
171+
172+ [ 'percent' , 'letter_grade' , 'gpa_scale' , 'points' ] . each do |type |
173+ it "is not included in grade calculations (#{ type } )" , priority : "1" , test_id : view == 'srgb' ? 216379 : 196596 do
174+ a1 = @course . assignments . create! title : 'Excuse Me' , grading_type : type , points_possible : 20
175+ a2 = @course . assignments . create! title : 'Don\'t Excuse Me' , grading_type : type , points_possible : 20
176+
177+ if type == 'points'
178+ a1 . grade_student ( @students [ 0 ] , { grade : 20 } )
179+ a2 . grade_student ( @students [ 0 ] , { grade : 13.2 } )
180+ else
181+ a1 . grade_student ( @students [ 0 ] , { grade : '100%' } )
182+ a2 . grade_student ( @students [ 0 ] , { grade : '66%' } )
183+ end
184+
185+ total = ''
186+ if view == 'srgb'
187+ skip "Skipped because this spec fails if not run in foreground\n " \
188+ "This is believed to be the issue: https://code.google.com/p/selenium/issues/detail?id=7346"
189+ get "/courses/#{ @course . id } /gradebook/change_gradebook_version?version=srgb"
190+ Selenium ::WebDriver ::Support ::Select . new ( f ( '#student_select' ) )
191+ . select_by ( :text , @students [ 0 ] . name )
192+
193+ total = f ( 'span.total-grade' ) . text [ /\d +(\. \d +)?%/ ]
194+ expect ( total ) . to eq '83%'
195+
196+ Selenium ::WebDriver ::Support ::Select . new ( f ( '#assignment_select' ) )
197+ . select_by ( :text , a2 . title )
198+ replace_content f ( '#student_and_assignment_grade' ) , "EX"
199+ wait_for_ajaximations
200+ total = f ( 'span.total-grade' ) . text [ /\d +(\. \d +)?%/ ]
201+ else
202+ get "/courses/#{ @course . id } /gradebook/"
203+
204+ total = f ( '.canvas_1 .slick-row .slick-cell:last-child' ) . text
205+ expect ( total ) . to eq '83%'
206+
207+ excused = f ( '.canvas_1 .slick-row .slick-cell:nth-child(2)' )
208+ excused . click
209+ replace_content f ( '.grade' , excused ) , "EX\n "
210+
211+ total = f ( '.canvas_1 .slick-row .slick-cell:last-child' ) . text
212+ end
213+
214+
215+ expect ( total ) . to eq '100%'
216+
217+ end
218+ end
219+ end
220+
221+ context 'Gradebook Grid' do
222+ before do |example |
223+ unless example . metadata [ :group ]
224+ init_course_with_students
225+ end
226+ end
227+
228+ it_behaves_like 'Basic Behavior'
229+
230+ it 'default grade cannot be set to excused' , priority : "1" , test_id : 209380 do
231+ assignment = @course . assignments . create! title : 'Test Me!' , points_possible : 20
232+ get "/courses/#{ @course . id } /grades"
233+ f ( '.assignment_header_drop' ) . click
234+ f ( '.gradebook-header-menu [data-action="setDefaultGrade"]' ) . click
235+
236+ [ 'EX' , 'eX' , 'Ex' , 'ex' ] . each_with_index do |ex , i |
237+ replace_content f ( "#student_grading_#{ assignment . id } " ) , "#{ ex } \n "
238+ wait_for_ajaximations
239+ expect ( ff ( '.ic-flash-error' ) . length ) . to be i + 1
240+ expect ( f ( '.ic-flash-error' ) . text ) . to include 'Default grade cannot be set to EX'
241+ end
242+
243+ end
244+
245+ it 'excused grade shows up in grading modal' , priority : "1" , test_id : 209324 do
246+ assignment = @course . assignments . create! title : 'Excuse Me' , points_possible : 20
247+ assignment . grade_student @students [ 0 ] , excuse : true
248+
249+ get "/courses/#{ @course . id } /gradebook/"
250+ driver . action . move_to ( f ( '.canvas_1 .slick-cell' ) ) . perform
251+ f ( 'a.gradebook-cell-comment' ) . click
252+ wait_for_ajaximations
253+
254+ expect ( f ( "#student_grading_#{ assignment . id } " ) . attribute 'value' ) . to eq 'EX'
255+ end
256+
257+ it 'assignments can be excused from grading modal' , priority : "1" , test_id : 217594 do
258+ assignment = @course . assignments . create! title : 'Excuse Me' , points_possible : 20
259+
260+ get "/courses/#{ @course . id } /gradebook/"
261+
262+ [ 'EX' , 'ex' , 'Ex' , 'eX' ] . each_with_index do |ex , i |
263+ driver . action . move_to ( f ( '.canvas_1 .slick-cell' ) ) . perform
264+ f ( 'a.gradebook-cell-comment' ) . click
265+ wait_for_ajaximations
266+
267+ arr = ff ( "#student_grading_#{ assignment . id } " )
268+ replace_content arr [ i ] , "#{ ex } \n "
269+ wait_for_ajaximations
270+
271+ f ( '.canvas_1 .slick-row .slick-cell:first-child .grade-and-outof-wrapper input' ) . send_keys "\n "
272+ wait_for_ajaximations
273+ expect ( f ( '.canvas_1 .slick-row .slick-cell:first-child' ) . text ) . to eq 'EX'
274+ end
275+ end
276+
277+ [ 'EX' , 'ex' , 'Ex' , 'eX' ] . each do |ex |
278+ it "#{ ex } can be used to excuse assignments" , priority : "1" , test_id : 225630 do
279+ @course . assignments . create! title : 'Excuse Me' , points_possible : 20
280+
281+ get "/courses/#{ @course . id } /gradebook/"
282+
283+ excused = f ( '.canvas_1 .slick-row .slick-cell:first-child' )
284+ excused . click
285+ replace_content f ( '.grade' , excused ) , "#{ ex } \n "
286+
287+ excused = f ( '.canvas_1 .slick-row .slick-cell:first-child' )
288+ expect ( excused . text ) . to eq 'EX'
289+ expect ( excused ) . to have_class 'dropped'
290+ end
291+ end
292+ end
293+
294+
295+ context 'Individual View' do
296+ before do |example |
297+ unless example . metadata [ :group ]
298+ init_course_with_students
299+ end
300+ end
301+
302+ it_behaves_like 'Basic Behavior' , 'srgb'
303+ end
304+ end
0 commit comments