2017-07-18 23:24:21 +08:00
|
|
|
#
|
|
|
|
# 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
|
2020-02-06 00:51:25 +08:00
|
|
|
def initialize(course, course_settings)
|
2017-07-18 23:24:21 +08:00
|
|
|
raise "Context must be a course" unless course.is_a?(Course)
|
|
|
|
raise "Context must have an id" unless course.id
|
|
|
|
|
|
|
|
@course = course
|
2020-02-06 00:51:25 +08:00
|
|
|
@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'
|
2020-02-06 00:51:25 +08:00
|
|
|
}
|
2017-07-18 23:24:21 +08:00
|
|
|
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
|
|
|
|
|
2017-07-18 23:24:21 +08:00
|
|
|
def the_query
|
2020-10-06 06:42:27 +08:00
|
|
|
GuardRail.activate(:secondary) do
|
2020-04-04 03:42:36 +08:00
|
|
|
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
|
2017-07-18 23:24:21 +08:00
|
|
|
end
|
|
|
|
end
|