2020-10-27 00:50:13 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-04-28 04:06:18 +08:00
|
|
|
#
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
# Copyright (C) 2023 - present Instructure, Inc.
|
2017-04-28 04:06:18 +08:00
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
2012-10-30 01:00:07 +08:00
|
|
|
class SortsAssignments
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
class InvalidBucketError < StandardError; end
|
2012-10-30 01:00:07 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
VALID_BUCKETS = %i[past overdue undated ungraded unsubmitted upcoming future].freeze
|
2016-07-28 23:17:55 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def initialize(assignments_scope:, user:, session:, course:, requested_user: nil)
|
|
|
|
@assignments_scope = assignments_scope
|
|
|
|
@user = user
|
|
|
|
@session = session
|
|
|
|
@course = course
|
|
|
|
@requested_user = requested_user
|
|
|
|
end
|
2012-10-30 01:00:07 +08:00
|
|
|
|
2023-06-02 06:06:09 +08:00
|
|
|
def assignments(bucket, &)
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
raise InvalidBucketError if VALID_BUCKETS.exclude?(bucket)
|
2012-10-30 01:00:07 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
@now = Time.zone.now
|
2023-06-02 06:06:09 +08:00
|
|
|
filter(bucket, &)
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
end
|
2012-10-30 01:00:07 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
private
|
2012-10-30 01:00:07 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def filter(bucket)
|
|
|
|
assignments_in_bucket = buckets.fetch(bucket).call(assignments_for_students)
|
|
|
|
if block_given?
|
|
|
|
yield assignments_in_bucket
|
|
|
|
else
|
|
|
|
@assignments_scope.where(id: assignments_in_bucket)
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
end
|
2021-11-05 23:06:30 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def buckets
|
|
|
|
{
|
|
|
|
past: filters[:has_date] >> filters[:past_due],
|
|
|
|
overdue: (
|
|
|
|
filters[:has_date] >> filters[:past_due] >>
|
|
|
|
filters[:expects_submission].call(additional_excludes: %w[external_tool online_quiz attendance]) >>
|
|
|
|
filters[:not_submitted_or_graded] >> filters[:can_submit]
|
|
|
|
),
|
|
|
|
undated: filters[:has_no_date],
|
|
|
|
ungraded: filters[:expects_submission].call >> filters[:needs_grading],
|
|
|
|
unsubmitted: filters[:expects_submission].call >> filters[:not_submitted_or_graded],
|
|
|
|
upcoming: filters[:has_date] >> filters[:due_soon],
|
|
|
|
future: filters[:due_in_future]
|
|
|
|
}
|
|
|
|
end
|
2012-10-30 01:00:07 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def filters
|
|
|
|
@filters ||= {
|
|
|
|
has_no_date: ->(scope) { scope.where(submissions: { cached_due_date: nil }) },
|
|
|
|
has_date: ->(scope) { scope.where.not(submissions: { cached_due_date: nil }) },
|
|
|
|
past_due: ->(scope) { scope.where("submissions.cached_due_date < ?", @now) },
|
|
|
|
due_in_future: ->(scope) { scope.where("submissions.cached_due_date IS NULL OR submissions.cached_due_date >= ?", @now) },
|
|
|
|
due_soon: ->(scope) { scope.where("submissions.cached_due_date >= ? AND submissions.cached_due_date <= ?", @now, 1.week.from_now(@now)) },
|
|
|
|
expects_submission: lambda do |additional_excludes: ["external_tool"]|
|
2023-06-02 06:06:09 +08:00
|
|
|
->(scope) { scope.expecting_submission(additional_excludes:) }
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
end,
|
|
|
|
needs_grading: ->(scope) { scope.where(Submission.needs_grading_conditions) },
|
|
|
|
not_submitted_or_graded: ->(scope) { scope.merge(Submission.not_submitted_or_graded) },
|
|
|
|
can_submit: lambda do |scope|
|
|
|
|
students_by_id = students.index_by(&:id)
|
|
|
|
students_by_assignment_id = scope.pluck("submissions.assignment_id", "submissions.user_id").each_with_object({}) do |(assignment_id, user_id), acc|
|
|
|
|
acc[assignment_id] ||= []
|
|
|
|
acc[assignment_id] << students_by_id[user_id]
|
|
|
|
end
|
|
|
|
|
|
|
|
assignments = @course.assignments.except(:order).where(id: students_by_assignment_id.keys).select do |assignment|
|
|
|
|
submittable_by_any_student?(assignment, students_by_assignment_id[assignment.id])
|
|
|
|
end
|
|
|
|
|
|
|
|
@course.assignments.where(id: assignments).except(:order)
|
2021-11-05 23:06:30 +08:00
|
|
|
end
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
}
|
|
|
|
end
|
2012-10-30 01:00:07 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def submittable_by_any_student?(assignment, students)
|
|
|
|
students.any? { |student| student.present? && assignment.grants_right?(student, :submit) }
|
|
|
|
end
|
2012-10-30 01:00:07 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def assignments_for_students
|
|
|
|
@course.assignments.where(id: assignment_ids).except(:order).joins(:submissions).where(submissions: { user: students })
|
|
|
|
end
|
2015-01-20 01:21:17 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def assignment_ids
|
|
|
|
@assignment_ids ||= @assignments_scope.pluck(:id)
|
|
|
|
end
|
2021-09-23 00:25:11 +08:00
|
|
|
|
fixup assignment bucket filtering
The assignments API index and users_index endpoints allow for a 'bucket'
param to be passed that filters assignments based on certain criteria.
This commit fixes inconsitencies with bucket filtering and makes bucket
filtering predictable for teachers, admins, and observers.
Teachers & Admins
- An assignment is included in a 'bucket' if at least one assigned student
meets the bucket criteria, e.g. for the 'past' bucket, an assignment will
be returned if any assigned student has that assignment due in the past
for them.
Observers
- An asignment is included in a 'bucket' if at least one assigned observed
student meets the bucket criteria, .e.g. for the 'past' bucket, an
assignment will be returned if any assigned observed student has that
assignment due in the past for them.
closes EVAL-2894
flag=none
[fsc-timeout=60]
[fsc-max-nodes=20]
Test Plan:
For an admin, teacher, observer, and student, verify the `bucket` param
passed to the api/v1/courses/:id/assignments endpoint behaves in the
following ways:
For the steps below, replace APPLICABLE_STUDENTS with:
- "at least one assigned student" if the current_user is a teacher or admin
- "at least one assigned observed student" if the current_user is an
observer
- "themselves" if the current_user is a student
`past` bucket
- assignment is included if the assignment is due in the past for
APPLICABLE_STUDENTS.
`overdue` bucket
- assignment is included if the assignment is due in the past, expects a
submission, has not been submitted or graded, and is able to be submitted
to by APPLICABLE_STUDENTS.
`undated` bucket
- assignment is included if the assignment is due without a due date for
APPLICABLE_STUDENTS.
`ungraded` bucket
- assignment is included if the assignment expects a submission, the
student has turned in work but has not been graded for
APPLICABLE_STUDENTS.
`unsubmitted` bucket
- assignment is included if the assignment expects a submission and the
student has not turned in work for APPLICABLE_STUDENTS.
`upcoming` bucket
- assignment is included if the assignment has a due date that is due in
the next 10 days for APPLICABLE_STUDENTS.
`future` bucket
- assignment is included if the assignment is due without a due date or
is due in the future for APPLICABLE_STUDENTS.
Change-Id: I3255674cd32373bca36943030c35eaa9d15055b5
Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/312938
Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com>
Reviewed-by: Kai Bjorkman <kbjorkman@instructure.com>
Reviewed-by: Jen Smith <jen.smith@instructure.com>
QA-Review: Kai Bjorkman <kbjorkman@instructure.com>
Product-Review: Cameron Ray <cameron.ray@instructure.com>
2023-03-10 05:34:24 +08:00
|
|
|
def students
|
|
|
|
@students ||= if @requested_user.present? && @user != @requested_user
|
|
|
|
[@requested_user]
|
|
|
|
elsif @course.grants_right?(@user, @session, :read_as_admin)
|
|
|
|
@course.students_visible_to(@user).merge(Enrollment.of_student_type).distinct.to_a
|
|
|
|
elsif @course.observers.where(id: @user).exists?
|
|
|
|
ObserverEnrollment.observed_students(@course, @user).keys
|
|
|
|
else
|
|
|
|
[@user]
|
|
|
|
end
|
2012-10-30 01:00:07 +08:00
|
|
|
end
|
|
|
|
end
|