canvas-lms/lib/gradebook_grading_period_as...

59 lines
2.1 KiB
Ruby
Raw Normal View History

#
# Copyright (C) 2017 - 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/>.
class GradebookGradingPeriodAssignments
def initialize(course, course_settings)
raise "Context must be a course" unless course.is_a?(Course)
raise "Context must have an id" unless course.id
@course = course
@settings_for_course = course_settings || {
fix new gradebook assignment visibility bug closes GRADE-986 Test Plan 1: Concluded Students 1. Create a Grading Period for 2018 (Jan 1 - Dec 31). 2. Create a Grading Period for 2019 (Jan 1 - Dec 31). This should be the ‘last’ grading period, meaning there are no other grading periods after this one. 3. Create an assignment and assign it to everyone without a due date. 4. Go to New Gradebook, make sure you are NOT showing concluded students, and verify the assignment shows up when you select the 2019 Grading Period. 5. Conclude one of the students that the assignment is assigned to. 6. Edit the assignment and change its due date to be in 2018 and save it. 7. Go to New Gradebook, make sure you are NOT showing concluded students, and verify the assignment does not show up when you select the 2019 Grading Period. 8. With the 2019 Grading Period still selected, in the Student Header Menu select to show concluded enrollments. Verify the assignment appears. Then deselect the option to show concluded enrollments and verfify the assignment disappears. Test Plan 2: Inactive Students 1. Create a Grading Period for 2018 (Jan 1 - Dec 31). 2. Create a Grading Period for 2019 (Jan 1 - Dec 31). This should be the ‘last’ grading period, meaning there are no other grading periods after this one. 3. Create an assignment and assign it to a single student in 2018. 4. Deactivate the student that the assignment is assigned to. 5. Go to New Gradebook, make sure you are NOT showing inactive students, and verify the assignment does not show up when you select the 2018 Grading Period. 6. With the 2018 Grading Period still selected, in the Student Header Menu select to show inactive enrollments. Verify the assignment appears. Then deselect the option to show inactive enrollments and verfify the assignment disappears. Change-Id: If463dcd5037125ea4345fcbef964460b23fa8820 Reviewed-on: https://gerrit.instructure.com/144119 Reviewed-by: Keith T. Garner <kgarner@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com> QA-Review: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins
2018-03-20 07:43:54 +08:00
'show_concluded_enrollments' => 'false',
'show_inactive_enrollments' => 'false'
}
end
def to_h
return {} unless @course.grading_periods?
the_query.transform_values {|list| list.map(&:to_s)}
end
private
fix new gradebook assignment visibility bug closes GRADE-986 Test Plan 1: Concluded Students 1. Create a Grading Period for 2018 (Jan 1 - Dec 31). 2. Create a Grading Period for 2019 (Jan 1 - Dec 31). This should be the ‘last’ grading period, meaning there are no other grading periods after this one. 3. Create an assignment and assign it to everyone without a due date. 4. Go to New Gradebook, make sure you are NOT showing concluded students, and verify the assignment shows up when you select the 2019 Grading Period. 5. Conclude one of the students that the assignment is assigned to. 6. Edit the assignment and change its due date to be in 2018 and save it. 7. Go to New Gradebook, make sure you are NOT showing concluded students, and verify the assignment does not show up when you select the 2019 Grading Period. 8. With the 2019 Grading Period still selected, in the Student Header Menu select to show concluded enrollments. Verify the assignment appears. Then deselect the option to show concluded enrollments and verfify the assignment disappears. Test Plan 2: Inactive Students 1. Create a Grading Period for 2018 (Jan 1 - Dec 31). 2. Create a Grading Period for 2019 (Jan 1 - Dec 31). This should be the ‘last’ grading period, meaning there are no other grading periods after this one. 3. Create an assignment and assign it to a single student in 2018. 4. Deactivate the student that the assignment is assigned to. 5. Go to New Gradebook, make sure you are NOT showing inactive students, and verify the assignment does not show up when you select the 2018 Grading Period. 6. With the 2018 Grading Period still selected, in the Student Header Menu select to show inactive enrollments. Verify the assignment appears. Then deselect the option to show inactive enrollments and verfify the assignment disappears. Change-Id: If463dcd5037125ea4345fcbef964460b23fa8820 Reviewed-on: https://gerrit.instructure.com/144119 Reviewed-by: Keith T. Garner <kgarner@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com> QA-Review: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins
2018-03-20 07:43:54 +08:00
def excluded_workflow_states
excluded_workflow_states = ['deleted']
excluded_workflow_states << 'completed' if @settings_for_course['show_concluded_enrollments'] != 'true'
excluded_workflow_states << 'inactive' if @settings_for_course['show_inactive_enrollments'] != 'true'
excluded_workflow_states
end
def the_query
Shackles.activate(:slave) do
Submission.
active.
joins(:assignment).
joins("INNER JOIN #{Enrollment.quoted_table_name} enrollments ON enrollments.user_id = submissions.user_id").
merge(Assignment.for_course(@course).active).
where(enrollments: { course_id: @course, type: ['StudentEnrollment', 'StudentViewEnrollment'] }).
where.not(grading_period_id: nil).where.not(enrollments: { workflow_state: excluded_workflow_states }).
group(:grading_period_id).
pluck(:grading_period_id, Arel.sql("array_agg(DISTINCT assignment_id)")).
to_h
end
end
end