fix include_ungraded_assignments behavior of gradebook2
When I made gradebook2 I thought "include ungraded assignments" was to show/hide "not-graded" assignments it is actually there to adjust how final scores are displayed. So that was bug 1 bug 2 was that toggling that setting did not actually update final grade percentages. also, reword the setting in the header to say: "Treat ungraded as 0's" instead of: "Include Ungraded Assignments" because it is less confusing test plan * create an assignment of type 'not-graded' * make sure it does not show up in gradebook2 * in gradebook2 click the "Treat ungraded as 0's" option in the cog menu in the header * make sure that total columns change to reflect treating ungraded assignments as a score of 0 Change-Id: I276d02dfcf13acafd49ce2697a8f4b4bca6bef64 fixes: #6765 Reviewed-on: https://gerrit.instructure.com/8107 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Jake Sorce <jake@instructure.com> Tested-by: Jake Sorce <jake@instructure.com>
This commit is contained in:
parent
b9b8381843
commit
ea973909f5
|
@ -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
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
<li><a data-arrange-columns-by="due_date" href="#"><label><%= t('arrange_columns_by_due_date', 'Arrange columns by due date') %><input type="radio" name="arrange-columns-by" /></label></a></li>
|
||||
<li><a data-arrange-columns-by="assignment_group" href="#"><label><%= t('arrange_columns_by_group', 'Arrange columns by assignment group') %><input type="radio" name="arrange-columns-by" /></label></a></li>
|
||||
<li><a href="#"><label><%= t('show_attendance_columns', 'Show Attendance Columns') %> <input type="checkbox" id="show_attendance" /></label></a></li>
|
||||
<li><a href="#"><label><%= t('include_ungraded', 'Include Ungraded Assignments') %><input type="checkbox" id="include_ungraded_assignments" /></label></a></li>
|
||||
<li><a href="#"><label><%= t('include_ungraded', "Treat Ungraded as 0's") %><input type="checkbox" id="include_ungraded_assignments" /></label></a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="gradebook-grid-wrapper">
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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!"
|
||||
|
||||
|
|
Loading…
Reference in New Issue