diff --git a/app/coffeescripts/gradebook2/Gradebook.coffee b/app/coffeescripts/gradebook2/Gradebook.coffee
index 1687dd02138..a61ee84ddcc 100644
--- a/app/coffeescripts/gradebook2/Gradebook.coffee
+++ b/app/coffeescripts/gradebook2/Gradebook.coffee
@@ -389,8 +389,8 @@ define 'compiled/Gradebook', [
$settingsMenu.find("##{setting}").prop('checked', @[setting]).change (event) =>
@[setting] = $(event.target).is(':checked')
$.store.userSet "#{setting}_#{@options.context_code}", (''+@[setting])
- @gradeGrid.setColumns @getVisibleGradeGridColumns()
- @gradeGrid.invalidate()
+ @gradeGrid.setColumns @getVisibleGradeGridColumns() if setting is 'show_attendance'
+ @buildRows()
# don't show the "show attendance" link in the dropdown if there's no attendance assignments
unless ($.detect @gradeGrid.getColumns(), -> this.object?.submission_types == "attendance")
@@ -430,7 +430,7 @@ define 'compiled/Gradebook', [
res = []
for column in @allAssignmentColumns
submissionType = ''+ column.object.submission_types
- res.push(column) unless submissionType is "not_graded" and !@include_ungraded_assignments or
+ res.push(column) unless submissionType is "not_graded" or
submissionType is "attendance" and !@show_attendance
res.concat(@aggregateColumns)
@@ -485,8 +485,6 @@ define 'compiled/Gradebook', [
toolTip: true
type: 'assignment'
- if ''+assignment.submission_types is "not_graded"
- columnDef.cssClass = (columnDef.cssClass || '') + ' ungraded'
if fieldName in @assignmentsToHide
columnDef.width = 10
@@ -562,7 +560,7 @@ define 'compiled/Gradebook', [
@gradeGrid = @multiGrid.grids[1]
@gradeGrid.onCellChange.subscribe (event, data) =>
@calculateStudentGrade(data.item)
- @gradeGrid.invalidate
+ @gradeGrid.invalidate()
sortRowsBy = (sortFn) =>
@rows.sort(sortFn)
student.row = i for student, i in @rows
diff --git a/app/views/gradebook2/show.html.erb b/app/views/gradebook2/show.html.erb
index 98e59d9a072..60892cff3a8 100644
--- a/app/views/gradebook2/show.html.erb
+++ b/app/views/gradebook2/show.html.erb
@@ -34,7 +34,7 @@
-
+
diff --git a/spec/selenium/custom_selenium_rspec_matchers.rb b/spec/selenium/custom_selenium_rspec_matchers.rb
index 7b49885d281..dd17206b61f 100644
--- a/spec/selenium/custom_selenium_rspec_matchers.rb
+++ b/spec/selenium/custom_selenium_rspec_matchers.rb
@@ -32,7 +32,7 @@ module CustomSeleniumRspecMatchers
"expected #{@element.inspect} text to include #{@text}, actual text was: #{@element.text}"
end
def negative_failure_message
- "expected #{@element.inspect} text to include #{@text}, actual text was: #{@element.text}"
+ "expected #{@element.inspect} text to NOT include #{@text}, actual text was: #{@element.text}"
end
end
diff --git a/spec/selenium/gradebook2_spec.rb b/spec/selenium/gradebook2_spec.rb
index 6c20b3ed8b1..a3a4db29c51 100644
--- a/spec/selenium/gradebook2_spec.rb
+++ b/spec/selenium/gradebook2_spec.rb
@@ -8,11 +8,13 @@ describe "gradebook2 selenium tests" do
ASSIGNMENT_3_POINTS = "50"
ATTENDANCE_POINTS = "15"
- EXPECTED_ASSIGN_1_TOTAL = "100%"
- EXPECTED_ASSIGN_2_TOTAL = "66.7%"
STUDENT_NAME_1 = "nobody1@example.com"
STUDENT_NAME_2 = "nobody2@example.com"
+ STUDENT_1_TOTAL_IGNORING_UNGRADED = "100%"
+ STUDENT_2_TOTAL_IGNORING_UNGRADED = "66.7%"
+ STUDENT_1_TOTAL_TREATING_UNGRADED_AS_ZEROS = "18.8%"
+ STUDENT_2_TOTAL_TREATING_UNGRADED_AS_ZEROS = "12.5%"
DEFAULT_PASSWORD = "qwerty"
def find_slick_cells(row_index, element)
@@ -36,7 +38,7 @@ describe "gradebook2 selenium tests" do
cell.text
end
- def open_gradebook_settings(element_to_click)
+ def open_gradebook_settings(element_to_click = nil)
driver.find_element(:css, '#gradebook_settings').click
driver.find_element(:css, '#ui-menu-0').should be_displayed
element_to_click.click if element_to_click != nil
@@ -59,6 +61,30 @@ describe "gradebook2 selenium tests" do
driver.find_element(:css, '#ui-menu-1').should be_displayed
end
+ def final_score_for_row(row)
+ grade_grid = driver.find_element(:css, '#gradebook_grid')
+ cells = find_slick_cells(row, grade_grid)
+ cells[4].text
+ end
+
+ # `students` should be a hash of student_id, expected total pairs, like:
+ # {
+ # 1 => '12%',
+ # 3 => '86.7%',
+ # }
+ def check_gradebook_1_totals(students)
+ get "/courses/#{@course.id}/gradebook"
+ # this keep_trying_untill is there because gradebook1 loads it's cells in a bunch of setTimeouts
+ keep_trying_until {
+ students.each do |student_id, expected_score|
+ row_total = driver.find_element(:css, ".final_grade .student_#{student_id}").text
+ # gradebook1 has a space between number and % like: "33.3 %"
+ row_total = row_total.sub ' ', ''
+ row_total.should eql expected_score
+ end
+ }
+ end
+
before(:each) do
course_with_teacher_logged_in
@@ -150,10 +176,17 @@ describe "gradebook2 selenium tests" do
:assignment_group => @group,
})
+ @ungraded_assignment = @course.assignments.create! :title => 'not-graded assignment',
+ :submission_types => 'not_graded'
+
get "/courses/#{@course.id}/gradebook2"
wait_for_ajaximations
end
+ it "should not show 'not-graded' assignments" do
+ driver.find_element(:css, '#gradebook_grid .slick-header').should_not include_text(@ungraded_assignment.title)
+ end
+
it "should validate correct number of students showing up in gradebook" do
driver.find_elements(:css, '.student-name').count.should == @course.students.count
end
@@ -182,55 +215,61 @@ describe "gradebook2 selenium tests" do
end
it "should validate initial grade totals are correct" do
- grade_grid = driver.find_element(:css, '#gradebook_grid')
- first_row_cells = find_slick_cells(0, grade_grid)
- second_row_cells = find_slick_cells(1, grade_grid)
+ final_score_for_row(0).should eql STUDENT_1_TOTAL_IGNORING_UNGRADED
+ final_score_for_row(1).should eql STUDENT_2_TOTAL_IGNORING_UNGRADED
+ end
- #validating first student initial total
- validate_cell_text(first_row_cells[4], EXPECTED_ASSIGN_1_TOTAL)
+ it "should treat ungraded as 0's when asked, and ignore when not" do
+ # make sure it shows like it is not treating ungraded as 0's by default
+ is_checked('#include_ungraded_assignments').should be_false
+ final_score_for_row(0).should eql STUDENT_1_TOTAL_IGNORING_UNGRADED
+ final_score_for_row(1).should eql STUDENT_2_TOTAL_IGNORING_UNGRADED
- #validating second student initial total
- validate_cell_text(second_row_cells[4], EXPECTED_ASSIGN_2_TOTAL)
+ # set the "treat ungraded as 0's" option in the header
+ open_gradebook_settings(driver.find_element(:css, 'label[for="include_ungraded_assignments"]'))
+
+ # now make sure that the grades show as if those ungraded assignments had a '0'
+ is_checked('#include_ungraded_assignments').should be_true
+ final_score_for_row(0).should eql STUDENT_1_TOTAL_TREATING_UNGRADED_AS_ZEROS
+ final_score_for_row(1).should eql STUDENT_2_TOTAL_TREATING_UNGRADED_AS_ZEROS
+
+ # reload the page and make sure it remembered the setting
+ get "/courses/#{@course.id}/gradebook2"
+ wait_for_ajaximations
+ is_checked('#include_ungraded_assignments').should be_true
+ final_score_for_row(0).should eql STUDENT_1_TOTAL_TREATING_UNGRADED_AS_ZEROS
+ final_score_for_row(1).should eql STUDENT_2_TOTAL_TREATING_UNGRADED_AS_ZEROS
+
+ # NOTE: gradebook1 does not handle 'remembering' the `include_ungraded_assignments` setting
+
+ # clear our saved settings
+ driver.execute_script '$.store.clear();'
end
it "should change grades and validate course total is correct" do
expected_edited_total = "33.3%"
- grade_grid = driver.find_element(:css, '#gradebook_grid')
- first_row_cells = find_slick_cells(0, grade_grid)
- second_row_cells = find_slick_cells(1, grade_grid)
#editing grade for first row, first cell
- edit_grade(first_row_cells[0], 0)
+ edit_grade(driver.find_element(:css, '#gradebook_grid [row="0"] .l0'), 0)
#editing grade for second row, first cell
- edit_grade(second_row_cells[0], 0)
+ edit_grade(driver.find_element(:css, '#gradebook_grid [row="1"] .l0'), 0)
- #page refresh
+ #refresh page and make sure the grade sticks
get "/courses/#{@course.id}/gradebook2"
wait_for_ajaximations
+ final_score_for_row(0).should eql expected_edited_total
+ final_score_for_row(1).should eql expected_edited_total
- #total validation after page refresh
- grade_grid = driver.find_element(:css, '#gradebook_grid')
- first_row_cells = find_slick_cells(0, grade_grid)
- second_row_cells = find_slick_cells(1, grade_grid)
- first_row_total = validate_cell_text(first_row_cells[4], expected_edited_total)
- second_row_total = validate_cell_text(second_row_cells[4], expected_edited_total)
-
- #go back to grade book one get those total values and compare to make sure they match
- get "/courses/#{@course.id}/gradebook"
- wait_for_ajaximations
- # this keep_trying_untill is there because gradebook1 loads it's cells in a bunch of setTimeouts
- keep_trying_until(5) {
- # gradebook1 has a space between number and % like: "33.3 %"
- gradebook1_first_row_total = driver.find_element(:css, ".final_grade .student_#{@student_1.id}").text.sub ' ', ''
- first_row_total.should eql gradebook1_first_row_total
- }
- gradebook1_second_row_total = driver.find_element(:css, ".final_grade .student_#{@student_2.id}").text.sub ' ', ''
- second_row_total.should eql gradebook1_second_row_total
+ #go back to gradebook1 and compare to make sure they match
+ check_gradebook_1_totals({
+ @student_1.id => expected_edited_total,
+ @student_2.id => expected_edited_total
+ })
end
it "should validate that gradebook settings is displayed when button is clicked" do
- open_gradebook_settings(nil)
+ open_gradebook_settings
end
it "should validate row sorting works when first column is clicked" do
@@ -244,7 +283,7 @@ describe "gradebook2 selenium tests" do
#filter validation
validate_cell_text(meta_cells[0], STUDENT_NAME_2 + "\n" + @other_section.name)
validate_cell_text(grade_cells[0], ASSIGNMENT_2_POINTS)
- validate_cell_text(grade_cells[4], EXPECTED_ASSIGN_2_TOTAL)
+ validate_cell_text(grade_cells[4], STUDENT_2_TOTAL_IGNORING_UNGRADED)
end
it "should validate setting group weights" do
@@ -293,22 +332,6 @@ describe "gradebook2 selenium tests" do
open_gradebook_settings(driver.find_element(:css, '#ui-menu-0-6'))
end
- it "should validate include ungraded assignments option" do
- pending("new changes broke this link, clicking include ungraded assignments doesn't make grade totals change anymore'")
- expected_total_row_1 = "19%"
- expected_total_row_2 = "13%"
- open_gradebook_settings(driver.find_element(:css, '#ui-menu-0-7'))
- grade_grid = driver.find_element(:css, '#gradebook_grid')
- first_row_cells = find_slick_cells(0, grade_grid)
- second_row_cells = find_slick_cells(1, grade_grid)
-
- #validating first student total after ungraded option click
- validate_cell_text(first_row_cells[4], expected_total_row_1)
-
- #validating second student total after ungraded option click
- validate_cell_text(second_row_cells[4], expected_total_row_2)
- end
-
it "should validate posting a comment to a graded assignment" do
comment_text = "This is a new comment!"