add enrollment filters to gradezilla student column header

closes: CNVS-32363

Test Plan:
1. As teacher/admin navigate to gradezilla
2. Expand student column header menu
  - Observe 'Show' menu item group is present
  - Observe 'inactive' and 'concluded' menu items are present
3. Toggle a menu item
  - Observe that the page reloads
  - Observe that upon reload, the toggled item state is applied
  - Observe that upon reload, the student rows are filtered as
     appropriate for the filter settings
* Changing Gradezilla so that page reloads aren't necessary
  is not performed in this changeset
4. Expand settings cog menu
  - Observe enrollment option items are gone

Change-Id: If308a255ba12ec71c0b6e9c1a5d6c17c8587a229
Reviewed-on: https://gerrit.instructure.com/105219
Tested-by: Jenkins
Reviewed-by: Jeremy Neander <jneander@instructure.com>
Reviewed-by: Neil Gupta <ngupta@instructure.com>
QA-Review: KC Naegle <knaegle@instructure.com>
Product-Review: Christi Wruck
This commit is contained in:
Brian Park 2017-03-15 12:27:51 -07:00 committed by Derek Bender
parent f1c14aa9b3
commit 7661b83afb
10 changed files with 320 additions and 58 deletions

View File

@ -113,6 +113,9 @@ define [
columnId: 'student' # the column controlling the sort
settingKey: 'sortable_name' # the key describing the sort criteria
direction: 'ascending' # the direction of the sort
showEnrollments:
concluded: false
inactive: false
}
## Gradebook Application State
@ -154,10 +157,10 @@ define [
@userFilterRemovedRows = []
# preferences serialization causes these to always come
# from the database as strings
@showConcludedEnrollments = @options.course_is_concluded ||
@options.settings['show_concluded_enrollments'] == "true"
@showInactiveEnrollments =
@options.settings['show_inactive_enrollments'] == "true"
if @options.course_is_concluded || @options.settings.show_concluded_enrollments == true
@toggleEnrollmentFilter('concluded', true)
if @options.settings.show_inactive_enrollments == true
@toggleEnrollmentFilter('inactive', true)
@gradingPeriods = GradingPeriodsApi.deserializePeriods(@options.active_grading_periods)
if @options.grading_period_set
@gradingPeriodSet = GradingPeriodSetsApi.deserializeSet(@options.grading_period_set)
@ -1081,15 +1084,6 @@ define [
@drawGradingPeriodSelectButton() if @gradingPeriodSet?
$settingsMenu = $('.gradebook_dropdown')
showConcludedEnrollmentsEl = $settingsMenu.find("#show_concluded_enrollments")
showConcludedEnrollmentsEl.prop('checked', @showConcludedEnrollments).change (event) =>
@showConcludedEnrollments = showConcludedEnrollmentsEl.is(':checked')
@saveSettings(@showInactiveEnrollments, @showConcludedEnrollments, -> window.location.reload())
showInactiveEnrollmentsEl = $settingsMenu.find("#show_inactive_enrollments")
showInactiveEnrollmentsEl.prop('checked', @showInactiveEnrollments).change (event) =>
@showInactiveEnrollments = showInactiveEnrollmentsEl.is(':checked')
@saveSettings(@showInactiveEnrollments, @showConcludedEnrollments, -> window.location.reload())
includeUngradedAssignmentsEl = $settingsMenu.find("#include_ungraded_assignments")
includeUngradedAssignmentsEl.prop('checked', @include_ungraded_assignments).change (event) =>
@ -1719,11 +1713,11 @@ define [
studentsUrl: ->
switch
when @showConcludedEnrollments && @showInactiveEnrollments
when @getEnrollmentFilters().inactive && @getEnrollmentFilters().concluded
'students_with_concluded_and_inactive_enrollments_url'
when @showConcludedEnrollments
when @getEnrollmentFilters().concluded
'students_with_concluded_enrollments_url'
when @showInactiveEnrollments
when @getEnrollmentFilters().inactive
'students_with_inactive_enrollments_url'
else 'students_url'
@ -1780,6 +1774,8 @@ define [
onSelectSecondaryInfo: @setSelectedSecondaryInfo
sectionsEnabled: @sections_enabled
sortBySetting: @getStudentColumnSortBySetting()
selectedEnrollmentFilters: @getSelectedEnrollmentFilters()
onToggleEnrollmentFilter: @toggleEnrollmentFilter
renderStudentColumnHeader: =>
mountPoint = @getColumnHeaderNode('student')
@ -2028,6 +2024,25 @@ define [
getSortRowsBySetting: =>
@gridDisplaySettings.sortRowsBy
toggleEnrollmentFilter: (enrollmentFilter, skipApply) =>
@getEnrollmentFilters()[enrollmentFilter] = !@getEnrollmentFilters()[enrollmentFilter]
@applyEnrollmentFilter() unless skipApply
applyEnrollmentFilter: () =>
showInactive = @getEnrollmentFilters().inactive
showConcluded = @getEnrollmentFilters().concluded
@saveSettings(showInactive, showConcluded, -> window.location.reload())
getEnrollmentFilters: () =>
@gridDisplaySettings.showEnrollments
getSelectedEnrollmentFilters: () =>
filters = @getEnrollmentFilters()
selectedFilters = []
for filter of filters
selectedFilters.push filter if filters[filter]
selectedFilters
## Gradebook Content Access Methods
setAssignments: (assignmentMap) =>

View File

@ -39,10 +39,17 @@ class GradebookRouter extends Backbone.Router {
initialize () {
this.isLoaded = false
this.views = {}
ENV.GRADEBOOK_OPTIONS.assignmentOrOutcome = getGradebookTab()
ENV.GRADEBOOK_OPTIONS.navigate = this.navigate.bind(this)
this.views.assignment = new Gradebook(ENV.GRADEBOOK_OPTIONS)
if (ENV.GRADEBOOK_OPTIONS.outcome_gradebook_enabled) { this.views.outcome = this.initOutcomes() }
const options = ENV.GRADEBOOK_OPTIONS
options.assignmentOrOutcome = getGradebookTab()
options.navigate = this.navigate.bind(this)
options.settings = options.settings || {}
options.settings.show_concluded_enrollments = options.settings.show_concluded_enrollments === 'true'
options.settings.show_inactive_enrollments = options.settings.show_inactive_enrollments === 'true'
this.views.assignment = new Gradebook(options)
if (options.outcome_gradebook_enabled) {
this.views.outcome = this.initOutcomes()
}
return this
}

View File

@ -25,7 +25,7 @@ import Typography from 'instructure-ui/Typography'
import StudentRowHeaderConstants from 'jsx/gradezilla/default_gradebook/constants/StudentRowHeaderConstants'
import I18n from 'i18n!gradebook'
const { bool, func, oneOf, shape, string } = React.PropTypes;
const { arrayOf, bool, func, oneOf, shape, string } = React.PropTypes;
export default class StudentColumnHeader extends React.Component {
static propTypes = {
@ -43,6 +43,8 @@ export default class StudentColumnHeader extends React.Component {
onSortBySortableNameDescending: func.isRequired,
settingKey: string.isRequired
}).isRequired,
selectedEnrollmentFilters: arrayOf(oneOf(StudentRowHeaderConstants.enrollmentFilterKeys)).isRequired,
onToggleEnrollmentFilter: func.isRequired
};
static defaultProps = {
@ -61,6 +63,9 @@ export default class StudentColumnHeader extends React.Component {
this.onShowFirstLastNames = this.onSelectPrimaryInfo.bind(this, 'first_last');
this.onShowLastFirstNames = this.onSelectPrimaryInfo.bind(this, 'last_first');
this.onHideStudentNames = this.onSelectPrimaryInfo.bind(this, 'anonymous');
this.onToggleInactive = this.onToggleEnrollmentFilter.bind(this, 'inactive');
this.onToggleConcluded = this.onToggleEnrollmentFilter.bind(this, 'concluded');
}
onSelectSecondaryInfo (secondaryInfoKey) {
@ -71,6 +76,10 @@ export default class StudentColumnHeader extends React.Component {
this.props.onSelectPrimaryInfo(primaryInfoKey);
}
onToggleEnrollmentFilter (enrollmentFilterKey) {
this.props.onToggleEnrollmentFilter(enrollmentFilterKey);
}
render () {
const {
sortBySetting: {
@ -188,6 +197,28 @@ export default class StudentColumnHeader extends React.Component {
{StudentRowHeaderConstants.secondaryInfoLabels.none}
</MenuItem>
</MenuItemGroup>
<MenuItemSeparator />
<MenuItemGroup label={I18n.t('Show')} data-menu-item-group-id="enrollment-filter" allowMultiple>
<MenuItem
key="inactive"
data-menu-item-id="inactive"
selected={this.props.selectedEnrollmentFilters.includes('inactive')}
onSelect={this.onToggleInactive}
>
{StudentRowHeaderConstants.enrollmentFilterLabels.inactive}
</MenuItem>
<MenuItem
key="concluded"
data-menu-item-id="concluded"
selected={this.props.selectedEnrollmentFilters.includes('concluded')}
onSelect={this.onToggleConcluded}
>
{StudentRowHeaderConstants.enrollmentFilterLabels.concluded}
</MenuItem>
</MenuItemGroup>
</PopoverMenu>
</div>
);

View File

@ -37,6 +37,13 @@ const secondaryInfoKeys = ['section', 'sis_id', 'login_id', 'none'];
const defaultSecondaryInfo = 'none';
const sectionSecondaryInfo = 'section';
const enrollmentFilterLabels = {
inactive: I18n.t('Inactive enrollments'),
concluded: I18n.t('Concluded enrollments')
};
const enrollmentFilterKeys = ['inactive', 'concluded'];
export default {
primaryInfoKeys,
primaryInfoLabels,
@ -45,5 +52,7 @@ export default {
secondaryInfoKeys,
secondaryInfoLabels,
defaultSecondaryInfo,
sectionSecondaryInfo
sectionSecondaryInfo,
enrollmentFilterKeys,
enrollmentFilterLabels
};

View File

@ -95,8 +95,6 @@
<li><a data-arrange-columns-by="assignment_group" href="#"><label><%= t('Arrange columns by assignment group') %><input type="radio" name="arrange-columns-by" /></label></a></li>
<li><a href="#"><label><%= t('Show Attendance Columns') %> <input type="checkbox" id="show_attendance" /></label></a></li>
<li id="include-ungraded-list-item"><a href="#"><label><%= t("Treat Ungraded as 0") %><input type="checkbox" id="include_ungraded_assignments" /></label></a></li>
<li class="<% if @course_is_concluded %>ui-state-disabled<% end %>"><a href="#"><label><%= t("Show Concluded Enrollments") %><input type="checkbox" id="show_concluded_enrollments" /></label></a></li>
<li><a href="#"><label><%= t("Show Inactive Enrollments") %><input type="checkbox" id="show_inactive_enrollments" /></label></a></li>
</ul>
</div>
</div>

View File

@ -26,6 +26,7 @@ import GradeCalculatorSpecHelper from 'spec/jsx/gradebook/GradeCalculatorSpecHel
import SubmissionDetailsDialog from 'compiled/SubmissionDetailsDialog';
import CourseGradeCalculator from 'jsx/gradebook/CourseGradeCalculator';
import DataLoader from 'jsx/gradezilla/DataLoader';
import StudentRowHeaderConstants from 'jsx/gradezilla/default_gradebook/constants/StudentRowHeaderConstants';
import Gradebook from 'compiled/gradezilla/Gradebook';
const $fixtures = document.getElementById('fixtures');
@ -662,8 +663,7 @@ test('only returns submissions due for the student in the selected grading perio
QUnit.module('Gradebook#studentsUrl', {
setupThis (options = {}) {
return {
showConcludedEnrollments: false,
showInactiveEnrollments: false,
getEnrollmentFilters: this.stub().returns({ concluded: false, inactive: false }),
...options
}
},
@ -679,14 +679,14 @@ test('enrollmentUrl returns "students_url"', function () {
test('when concluded only, enrollmentUrl returns "students_with_concluded_enrollments_url"', function () {
const self = this.setupThis({
showConcludedEnrollments: true
getEnrollmentFilters: this.stub().returns({ concluded: true, inactive: false })
});
equal(this.studentsUrl.call(self), 'students_with_concluded_enrollments_url');
});
test('when inactive only, enrollmentUrl returns "students_with_inactive_enrollments_url"', function () {
const self = this.setupThis({
showInactiveEnrollments: true
getEnrollmentFilters: this.stub().returns({ concluded: false, inactive: true })
});
equal(this.studentsUrl.call(self), 'students_with_inactive_enrollments_url');
});
@ -694,8 +694,7 @@ test('when inactive only, enrollmentUrl returns "students_with_inactive_enrollme
test('when show concluded and hide inactive are true, enrollmentUrl returns ' +
'"students_with_concluded_and_inactive_enrollments_url"', function () {
const self = this.setupThis({
showConcludedEnrollments: true,
showInactiveEnrollments: true
getEnrollmentFilters: this.stub().returns({ concluded: true, inactive: true })
});
equal(this.studentsUrl.call(self), 'students_with_concluded_and_inactive_enrollments_url');
});
@ -2504,3 +2503,84 @@ test('when no submission is found, it is not late', function () {
equal(firstRow.id, '4', 'when late is true, order first');
equal(secondRow.id, '3', 'when no submission is found, order second');
})
QUnit.module('Gradebook#getSelectedEnrollmentFilters', {
setup () {
fakeENV.setup({
GRADEBOOK_OPTIONS: { context_id: 10 },
});
},
teardown () {
fakeENV.teardown();
}
});
test('returns empty array when all settings are off', function () {
const gradebook = createGradebook({
settings: {
show_concluded_enrollments: false,
show_inactive_enrollments: false
}
});
equal(gradebook.getSelectedEnrollmentFilters().length, 0);
});
test('returns array including "concluded" when setting is on', function () {
const gradebook = createGradebook({
settings: {
show_concluded_enrollments: true,
show_inactive_enrollments: false
}
});
ok(gradebook.getSelectedEnrollmentFilters().includes('concluded'));
notOk(gradebook.getSelectedEnrollmentFilters().includes('inactive'));
});
test('returns array including "inactive" when setting is on', function () {
const gradebook = createGradebook({
settings: {
show_concluded_enrollments: false,
show_inactive_enrollments: true
}
});
ok(gradebook.getSelectedEnrollmentFilters().includes('inactive'));
notOk(gradebook.getSelectedEnrollmentFilters().includes('concluded'));
});
test('returns array including multiple values when settings are on', function () {
const gradebook = createGradebook({
settings: {
show_concluded_enrollments: true,
show_inactive_enrollments: true
}
});
ok(gradebook.getSelectedEnrollmentFilters().includes('inactive'));
ok(gradebook.getSelectedEnrollmentFilters().includes('concluded'));
});
QUnit.module('Gradebook#toggleEnrollmentFilter', {
setup () {
fakeENV.setup({
GRADEBOOK_OPTIONS: { context_id: 10 },
});
},
teardown () {
fakeENV.teardown();
}
});
test('changes the value of @getSelectedEnrollmentFilters', function () {
const gradebook = createGradebook();
for (let i = 0; i < 2; i++) {
StudentRowHeaderConstants.enrollmentFilterKeys.forEach((key) => {
const previousValue = gradebook.getSelectedEnrollmentFilters().includes(key);
gradebook.toggleEnrollmentFilter(key, true);
const newValue = gradebook.getSelectedEnrollmentFilters().includes(key);
notEqual(previousValue, newValue);
});
}
});

View File

@ -30,11 +30,13 @@ function mountAndOpenOptions (props) {
QUnit.module('StudentColumnHeader - base behavior', {
setup () {
const props = {
onToggleEnrollmentFilter () {},
selectedEnrollmentFilters: [],
selectedSecondaryInfo: StudentRowHeaderConstants.defaultSecondaryInfo,
sectionsEnabled: true,
onSelectSecondaryInfo: this.stub(),
selectedPrimaryInfo: StudentRowHeaderConstants.defaultPrimaryInfo,
onSelectPrimaryInfo: this.stub(),
onSelectPrimaryInfo () {},
onSelectSecondaryInfo () {},
sortBySetting: {
direction: 'ascending',
disabled: false,
@ -80,11 +82,13 @@ test('renders a title for the More icon', function () {
QUnit.module('StudentColumnHeader - secondaryInfoMenuGroup', {
setup () {
this.props = {
onToggleEnrollmentFilter () {},
selectedEnrollmentFilters: [],
sectionsEnabled: true,
selectedSecondaryInfo: StudentRowHeaderConstants.defaultSecondaryInfo,
onSelectSecondaryInfo: this.stub(),
selectedPrimaryInfo: StudentRowHeaderConstants.defaultPrimaryInfo,
onSelectPrimaryInfo: this.stub(),
onSelectPrimaryInfo () {},
sortBySetting: {
direction: 'ascending',
disabled: false,
@ -139,6 +143,8 @@ test('omits section when sectionsEnabled prop is false', function () {
QUnit.module('StudentColumnHeader - Sort by Settings', {
setup () {
this.props = {
onToggleEnrollmentFilter () {},
selectedEnrollmentFilters: [],
sectionsEnabled: true,
selectedSecondaryInfo: StudentRowHeaderConstants.defaultSecondaryInfo,
onSelectSecondaryInfo: this.stub(),
@ -292,9 +298,11 @@ test('uses default label when loginHandleName prop is falsy', function () {
QUnit.module('StudentColumnHeader - primaryInfoMenuGroup', {
setup () {
this.props = {
onToggleEnrollmentFilter () {},
selectedEnrollmentFilters: [],
sectionsEnabled: true,
selectedSecondaryInfo: StudentRowHeaderConstants.defaultSecondaryInfo,
onSelectSecondaryInfo: this.stub(),
onSelectSecondaryInfo () {},
selectedPrimaryInfo: StudentRowHeaderConstants.defaultPrimaryInfo,
onSelectPrimaryInfo: this.stub(),
sortBySetting: {
@ -332,7 +340,7 @@ test('renders a MenuItem for each primary info option', function () {
});
});
test('invokes prop onSelectSecondaryInfo when MenuItem is clicked', function () {
test('invokes prop onSelectPrimaryInfo when MenuItem is clicked', function () {
this.renderOutput = mount(<StudentColumnHeader {...this.props} />);
StudentRowHeaderConstants.primaryInfoKeys.forEach((key) => {
@ -344,3 +352,62 @@ test('invokes prop onSelectSecondaryInfo when MenuItem is clicked', function ()
equal(this.props.onSelectPrimaryInfo.lastCall.args[0], key);
});
});
QUnit.module('StudentColumnHeader - enrollmentFilterGroup', {
setup () {
this.props = {
onToggleEnrollmentFilter: this.stub(),
selectedEnrollmentFilters: [],
sectionsEnabled: true,
selectedSecondaryInfo: StudentRowHeaderConstants.defaultSecondaryInfo,
onSelectSecondaryInfo () {},
selectedPrimaryInfo: StudentRowHeaderConstants.defaultPrimaryInfo,
onSelectPrimaryInfo: this.stub(),
sortBySetting: {
direction: 'ascending',
disabled: false,
isSortColumn: true,
onSortBySortableNameAscending () {},
onSortBySortableNameDescending () {},
settingKey: 'sortable_name'
}
};
},
teardown () {
this.renderOutput.unmount();
}
});
test('renders a MenuItemGroup for enrollment filter options', function () {
this.renderOutput = mount(<StudentColumnHeader {...this.props} />);
this.renderOutput.find('.Gradebook__ColumnHeaderAction').simulate('click');
const menuItemGroup = document.querySelector('[data-menu-item-group-id="enrollment-filter"]');
ok(menuItemGroup);
});
test('renders a MenuItem for each enrollment filter option', function () {
this.renderOutput = mount(<StudentColumnHeader {...this.props} />);
this.renderOutput.find('.Gradebook__ColumnHeaderAction').simulate('click');
StudentRowHeaderConstants.enrollmentFilterKeys.forEach((key) => {
const menuItem = document.querySelector(`[data-menu-item-id="${key}"]`);
ok(menuItem);
});
});
test('invokes prop onToggleEnrollmentFilter when MenuItem is clicked', function () {
this.renderOutput = mount(<StudentColumnHeader {...this.props} />);
const onToggle = this.props.onToggleEnrollmentFilter;
StudentRowHeaderConstants.enrollmentFilterKeys.forEach((key) => {
this.renderOutput.find('.Gradebook__ColumnHeaderAction').simulate('click');
const menuItem = document.querySelector(`[data-menu-item-id="${key}"]`);
menuItem.click();
equal(onToggle.lastCall.args[0], key, `invocation arg matches clicked menu item ${key}`);
});
});

View File

@ -1,14 +1,17 @@
require_relative '../../helpers/gradezilla_common'
require_relative '../setup/gradebook_setup'
require_relative '../page_objects/gradezilla_page'
describe "Gradezilla - concluded courses and enrollments" do
include_context "in-process server selenium tests"
include GradezillaCommon
include GradebookSetup
let(:gradezilla_page) { Gradezilla::MultipleGradingPeriods.new }
before(:once) { gradebook_data_setup }
before(:each) { user_session(@teacher) }
before(:each) { @teacher.update preferences: {} }
let(:conclude_student_1) { @student_1.enrollments.where(course_id: @course).first.conclude }
let(:deactivate_student_1) { @student_1.enrollments.where(course_id: @course).first.deactivate }
@ -21,10 +24,10 @@ describe "Gradezilla - concluded courses and enrollments" do
end
it "persists settings for displaying inactive enrollments", priority: "2", test_id: 1372593 do
get course_gradebook_path(@course)
f('#gradebook_settings').click
gradezilla_page.visit(@course)
gradezilla_page.open_student_column_menu
expect do
f('label[for="show_inactive_enrollments"]').click
gradezilla_page.select_menu_item 'inactive'
wait_for_ajax_requests
end
.to change { gradebook_settings_for_course.call(@teacher, @course)}
@ -36,13 +39,13 @@ describe "Gradezilla - concluded courses and enrollments" do
end
it "persists settings for displaying concluded enrollments", priority: "2", test_id: 1372592 do
get course_gradebook_path(@course)
f('#gradebook_settings').click
gradezilla_page.visit(@course)
gradezilla_page.open_student_column_menu
expect do
f('label[for="show_concluded_enrollments"]').click
wait_for_ajax_requests
gradezilla_page.select_menu_item 'concluded'
wait_for_ajax_requests
end
.to change { gradebook_settings_for_course.call(@teacher, @course) }
.to change { gradebook_settings_for_course.call(@teacher, @course)}
.from(nil)
.to({
"show_inactive_enrollments" => "false",
@ -58,21 +61,25 @@ describe "Gradezilla - concluded courses and enrollments" do
expect(ff('.student-name')).to have_size @course.students.count
end
it "shows/hides concluded enrollments when checked/unchecked in settings cog", priority: "1", test_id: 164223 do
it "shows concluded enrollments when checked in column header", priority: "1", test_id: 164223 do
conclude_student_1
gradezilla_page.visit(@course)
# show concluded
expect_new_page_load do
f('#gradebook_settings').click
f('label[for="show_concluded_enrollments"]').click
gradezilla_page.open_student_column_menu
gradezilla_page.select_menu_item 'concluded'
end
expect(ff('.student-name')).to have_size @course.all_students.count
end
it "hides concluded enrollments when unchecked in column header", priority: "1", test_id: 3101103 do
conclude_student_1
display_concluded_enrollments
gradezilla_page.visit(@course)
# hide concluded
expect_new_page_load do
f('#gradebook_settings').click
f('label[for="show_concluded_enrollments"]').click
gradezilla_page.open_student_column_menu
gradezilla_page.select_menu_item 'concluded'
end
expect(ff('.student-name')).to have_size @course.students.count
end
@ -85,22 +92,25 @@ describe "Gradezilla - concluded courses and enrollments" do
expect(ff('.student-name')).to have_size @course.students.count
end
it "shows/hides inactive enrollments when checked/unchecked in settings cog", priority: "1", test_id: 1102066 do
it "shows inactive enrollments when checked in column header", priority: "1", test_id: 1102066 do
deactivate_student_1
gradezilla_page.visit(@course)
# show deactivated
expect_new_page_load do
f('#gradebook_settings').click
f('label[for="show_inactive_enrollments"]').click
gradezilla_page.open_student_column_menu
gradezilla_page.select_menu_item 'inactive'
end
expect(ff('.student-name')).to have_size @course.all_students.count
end
it "hides inactive enrollments when unchecked in column header", priority: "1", test_id: 3101104 do
deactivate_student_1
display_inactive_enrollments
gradezilla_page.visit(@course)
# hide deactivated
expect_new_page_load do
f('#gradebook_settings').click
f('label[for="show_inactive_enrollments"]').click
gradezilla_page.open_student_column_menu
gradezilla_page.select_menu_item 'inactive'
end
expect(ff('.student-name')).to have_size @course.students.count
end
@ -110,7 +120,7 @@ describe "Gradezilla - concluded courses and enrollments" do
it "does not allow editing grades", priority: "1", test_id: 210027 do
@course.complete!
gradezilla_page.visit(@course)
cell = f('#gradebook_grid .container_1 .slick-row:nth-child(1) .l1')
cell = gradezilla_page.grading_cell
expect(cell).to include_text '10'
cell.click
expect(cell).not_to contain_css('.grade') # no input box for entry

View File

@ -7,6 +7,12 @@ module Gradezilla
ASSIGNMENT_HEADER_MENU_SELECTOR = '.gradebook-header-drop'.freeze
ASSIGNMENT_HEADER_MENU_ITEM_SELECTOR = 'ul.gradebook-header-menu li.ui-menu-item'.freeze
# Student Headings
STUDENT_COLUMN_MENU_SELECTOR = '.container_0 .Gradebook__ColumnHeaderAction'.freeze
# Menu Items
MENU_ITEM_SELECTOR = '[data-menu-item-id="%s"]'.freeze
def ungradable_selector
".cannot_edit"
end
@ -29,6 +35,14 @@ module Gradezilla
ff('#gradebook_grid .student-name').map(&:text)
end
def student_column_menu
f(STUDENT_COLUMN_MENU_SELECTOR)
end
def menu_item(name)
f(MENU_ITEM_SELECTOR % name)
end
def visit(course)
Account.default.enable_feature!(:gradezilla)
get "/courses/#{course.id}/gradebook/change_gradebook_version?version=gradezilla"
@ -79,6 +93,14 @@ module Gradezilla
end
end
def open_student_column_menu
student_column_menu.click
end
def select_menu_item(name)
menu_item(name).click
end
private
def gp_dropdown() f(".grading-period-select-button") end

View File

@ -51,4 +51,27 @@ module GradebookSetup
end_date: 2.weeks.from_now
}
end
def update_teacher_course_preferences(preferences)
@teacher.update preferences: {
gradebook_settings: {
@course.id => preferences
}
}
end
def update_display_preferences(concluded, inactive)
update_teacher_course_preferences({
'show_concluded_enrollments' => concluded.to_s,
'show_inactive_enrollments' => inactive.to_s
})
end
def display_concluded_enrollments
update_display_preferences(true, false)
end
def display_inactive_enrollments
update_display_preferences(false, true)
end
end