canvas-lms/lib/gradebook_user_ids.rb

236 lines
8.2 KiB
Ruby
Raw Normal View History

# frozen_string_literal: true
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +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 GradebookUserIds
def initialize(course, user)
settings = (user.get_preference(:gradebook_settings, course.global_id) || {}).with_indifferent_access
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
@course = course
@user = user
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
@include_inactive = settings[:show_inactive_enrollments] == "true"
@include_concluded = settings[:show_concluded_enrollments] == "true"
@column = settings[:sort_rows_by_column_id] || "student"
@sort_by = settings[:sort_rows_by_setting_key] || "name"
@selected_grading_period_id = settings.dig(:filter_columns_by, :grading_period_id)
@selected_section_id = settings.dig(:filter_rows_by, :section_id)
2019-02-12 05:53:58 +08:00
@selected_student_group_id = settings.dig(:filter_rows_by, :student_group_id)
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
@direction = settings[:sort_rows_by_direction] || "ascending"
end
def user_ids
if @column == "student"
Add more gradebook sort options flag=new_gradebook_sort_options closes TALLY-210 Test plan: - Have a course using new gradebook - Have several students with pseudonyms (i.e., logins; see below) - Have at least one pseudonym-less student - Have a mechanism to filter students (section or student group) - Enable the feature: - Open the Settings page for your root account and allow the "Additional Sort Options for New Gradebook" feature - Open the Settings page for your course and enable the above setting for the course - Open new Gradebook - In the student column header menu, the "Sort by" item should now show several sort fields and (separately) a sort order - Check that the sort fields work as expected: - (Note that you will need to use the "Secondary info" menu item to show the relevant info field under users' names; selecting a sort option will not automatically change the secondary info to match) - "Name" should sort by the user's (sortable) name - "SIS ID" should sort by the SIS user ID on the user's account - "Integration ID" should sort by the account's integration ID - "Login ID" should sort by the user's login name - "A-Z" and "Z-A" should switch between ascending and descending sort order for the selected sort field - In all cases, students with no value for the selected field (e.g., a student with no login ID) should appear at the bottom of the list, regardless of the selected sort order - Check that filtering by section or group still works as expected - Selecting a specific filter, as well as removing the filter, should respect the sort field and order - Turn OFF the feature flag for the course - Go back to New Gradebook - Check that the sort menu has returned to its previous state, with only "A-Z" and "Z-A" options that sort by name - (If you were sorting by a different criterion when you had the flag enabled, said criterion will initially still be in effect, but adjusting the sort order will bounce it back to sorting by name) APPENDIX: adding pseudonyms To create a pseudonym for a student in a Rails console: > user = <a student> > user.pseudonyms.create!( account: user.account, sis_user_id: "some_sis_id_or_other", integration_id: "some_integration_id_or_other", unique_id: "a_login_id" ) Or you could do it the boring way by just adding a login from their user details page, but I'm not sure how to update the SIS ID and integration ID from there. Change-Id: I290bced84432a4776a9c20efbaeb26aeb7e18638 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/200805 Reviewed-by: Gary Mei <gmei@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins QA-Review: Robin Kuss <rkuss@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
2019-07-09 04:38:12 +08:00
sort_by_student_field
elsif @column =~ /assignment_\d+$/
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
assignment_id = @column[/\d+$/]
send("sort_by_assignment_#{@sort_by}", assignment_id)
elsif @column =~ /^assignment_group_\d+$/
assignment_id = @column[/\d+$/]
sort_by_assignment_group(assignment_id)
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
elsif @column == "total_grade"
sort_by_total_grade
else
sort_by_student_name
end
end
private
Add more gradebook sort options flag=new_gradebook_sort_options closes TALLY-210 Test plan: - Have a course using new gradebook - Have several students with pseudonyms (i.e., logins; see below) - Have at least one pseudonym-less student - Have a mechanism to filter students (section or student group) - Enable the feature: - Open the Settings page for your root account and allow the "Additional Sort Options for New Gradebook" feature - Open the Settings page for your course and enable the above setting for the course - Open new Gradebook - In the student column header menu, the "Sort by" item should now show several sort fields and (separately) a sort order - Check that the sort fields work as expected: - (Note that you will need to use the "Secondary info" menu item to show the relevant info field under users' names; selecting a sort option will not automatically change the secondary info to match) - "Name" should sort by the user's (sortable) name - "SIS ID" should sort by the SIS user ID on the user's account - "Integration ID" should sort by the account's integration ID - "Login ID" should sort by the user's login name - "A-Z" and "Z-A" should switch between ascending and descending sort order for the selected sort field - In all cases, students with no value for the selected field (e.g., a student with no login ID) should appear at the bottom of the list, regardless of the selected sort order - Check that filtering by section or group still works as expected - Selecting a specific filter, as well as removing the filter, should respect the sort field and order - Turn OFF the feature flag for the course - Go back to New Gradebook - Check that the sort menu has returned to its previous state, with only "A-Z" and "Z-A" options that sort by name - (If you were sorting by a different criterion when you had the flag enabled, said criterion will initially still be in effect, but adjusting the sort order will bounce it back to sorting by name) APPENDIX: adding pseudonyms To create a pseudonym for a student in a Rails console: > user = <a student> > user.pseudonyms.create!( account: user.account, sis_user_id: "some_sis_id_or_other", integration_id: "some_integration_id_or_other", unique_id: "a_login_id" ) Or you could do it the boring way by just adding a login from their user details page, but I'm not sure how to update the SIS ID and integration ID from there. Change-Id: I290bced84432a4776a9c20efbaeb26aeb7e18638 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/200805 Reviewed-by: Gary Mei <gmei@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins QA-Review: Robin Kuss <rkuss@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
2019-07-09 04:38:12 +08:00
def sort_by_student_field
if ["name", "sortable_name"].include?(@sort_by) || !pseudonym_sort_field
Add more gradebook sort options flag=new_gradebook_sort_options closes TALLY-210 Test plan: - Have a course using new gradebook - Have several students with pseudonyms (i.e., logins; see below) - Have at least one pseudonym-less student - Have a mechanism to filter students (section or student group) - Enable the feature: - Open the Settings page for your root account and allow the "Additional Sort Options for New Gradebook" feature - Open the Settings page for your course and enable the above setting for the course - Open new Gradebook - In the student column header menu, the "Sort by" item should now show several sort fields and (separately) a sort order - Check that the sort fields work as expected: - (Note that you will need to use the "Secondary info" menu item to show the relevant info field under users' names; selecting a sort option will not automatically change the secondary info to match) - "Name" should sort by the user's (sortable) name - "SIS ID" should sort by the SIS user ID on the user's account - "Integration ID" should sort by the account's integration ID - "Login ID" should sort by the user's login name - "A-Z" and "Z-A" should switch between ascending and descending sort order for the selected sort field - In all cases, students with no value for the selected field (e.g., a student with no login ID) should appear at the bottom of the list, regardless of the selected sort order - Check that filtering by section or group still works as expected - Selecting a specific filter, as well as removing the filter, should respect the sort field and order - Turn OFF the feature flag for the course - Go back to New Gradebook - Check that the sort menu has returned to its previous state, with only "A-Z" and "Z-A" options that sort by name - (If you were sorting by a different criterion when you had the flag enabled, said criterion will initially still be in effect, but adjusting the sort order will bounce it back to sorting by name) APPENDIX: adding pseudonyms To create a pseudonym for a student in a Rails console: > user = <a student> > user.pseudonyms.create!( account: user.account, sis_user_id: "some_sis_id_or_other", integration_id: "some_integration_id_or_other", unique_id: "a_login_id" ) Or you could do it the boring way by just adding a login from their user details page, but I'm not sure how to update the SIS ID and integration ID from there. Change-Id: I290bced84432a4776a9c20efbaeb26aeb7e18638 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/200805 Reviewed-by: Gary Mei <gmei@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins QA-Review: Robin Kuss <rkuss@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
2019-07-09 04:38:12 +08:00
sort_by_student_name
else
sort_by_pseudonym_field
end
end
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
def sort_by_student_name
add secondary sorting by sortable_name for user_ids closes CNVS-37707 test plan: * Create a course with at least four students, two of whom have the same name (we'll call them the twins) * Create two assignments, each with a maximum score of 10 * Go to Gradezilla * Sort the gradebook by Student Name from A-Z * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in ascending alphabetical order * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by Student Name from Z-A * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in descending alphabetical order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Ensure all students have submissions for the first assignment * Assign grades to the students in assignment #1 and ensure both twins get the same grade * Sort the gradebook by the grade in assignment #1 (Low to High) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by the grade in assignment #1 (High to Low) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in descending order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Update assignment #1 to ensure three students have due dates in the past, thus making their submissions late * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with late submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #1 to ensure only one student has a due date in the past, thus making only one student have a late submission. * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with timely submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #2 to have a due date in the past * Ensure only one student (not one of the twins) has submitted their work for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student who submitted their work * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Ensure both the twins now submit their work for assignment #2. This should leave just one student who is missing a submission for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first user_id is for the student who still has not submitted their work * Verify the last 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id Change-Id: Id91e02fc7dc475177d1f8c09cc75015916375576 Reviewed-on: https://gerrit.instructure.com/117227 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-28 06:37:54 +08:00
students.
order(Arel.sql("enrollments.type = 'StudentViewEnrollment'")).
new gradebook: fake student ids always sort last closes CNVS-37752 Test Plan: 1. Create a course that has some active students, inactive students, concluded students, and a fake student. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. The fake student's ID should always be last. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. The fake student's ID should be last. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. The fake student's ID should be last. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. The fake student's ID should be last. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. The fake student's ID should be last. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences, with the fake student's ID sorted last: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. 13. Conclude the course. Hit the user_ids endpoint as the teacher and verify you do not get a 401 response. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I6c4b16b72e051d46cc7b7521949d5c82b92960b9 Reviewed-on: https://gerrit.instructure.com/116698 Reviewed-by: Keith T. Garner <kgarner@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> Tested-by: Jenkins QA-Review: KC Naegle <knaegle@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-23 08:17:41 +08:00
order_by_sortable_name(direction: @direction.to_sym).
pluck(:id).
uniq
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
end
Add more gradebook sort options flag=new_gradebook_sort_options closes TALLY-210 Test plan: - Have a course using new gradebook - Have several students with pseudonyms (i.e., logins; see below) - Have at least one pseudonym-less student - Have a mechanism to filter students (section or student group) - Enable the feature: - Open the Settings page for your root account and allow the "Additional Sort Options for New Gradebook" feature - Open the Settings page for your course and enable the above setting for the course - Open new Gradebook - In the student column header menu, the "Sort by" item should now show several sort fields and (separately) a sort order - Check that the sort fields work as expected: - (Note that you will need to use the "Secondary info" menu item to show the relevant info field under users' names; selecting a sort option will not automatically change the secondary info to match) - "Name" should sort by the user's (sortable) name - "SIS ID" should sort by the SIS user ID on the user's account - "Integration ID" should sort by the account's integration ID - "Login ID" should sort by the user's login name - "A-Z" and "Z-A" should switch between ascending and descending sort order for the selected sort field - In all cases, students with no value for the selected field (e.g., a student with no login ID) should appear at the bottom of the list, regardless of the selected sort order - Check that filtering by section or group still works as expected - Selecting a specific filter, as well as removing the filter, should respect the sort field and order - Turn OFF the feature flag for the course - Go back to New Gradebook - Check that the sort menu has returned to its previous state, with only "A-Z" and "Z-A" options that sort by name - (If you were sorting by a different criterion when you had the flag enabled, said criterion will initially still be in effect, but adjusting the sort order will bounce it back to sorting by name) APPENDIX: adding pseudonyms To create a pseudonym for a student in a Rails console: > user = <a student> > user.pseudonyms.create!( account: user.account, sis_user_id: "some_sis_id_or_other", integration_id: "some_integration_id_or_other", unique_id: "a_login_id" ) Or you could do it the boring way by just adding a login from their user details page, but I'm not sure how to update the SIS ID and integration ID from there. Change-Id: I290bced84432a4776a9c20efbaeb26aeb7e18638 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/200805 Reviewed-by: Gary Mei <gmei@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins QA-Review: Robin Kuss <rkuss@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
2019-07-09 04:38:12 +08:00
def sort_by_pseudonym_field
sort_column = Pseudonym.best_unicode_collation_key("pseudonyms.#{pseudonym_sort_field}")
Add more gradebook sort options flag=new_gradebook_sort_options closes TALLY-210 Test plan: - Have a course using new gradebook - Have several students with pseudonyms (i.e., logins; see below) - Have at least one pseudonym-less student - Have a mechanism to filter students (section or student group) - Enable the feature: - Open the Settings page for your root account and allow the "Additional Sort Options for New Gradebook" feature - Open the Settings page for your course and enable the above setting for the course - Open new Gradebook - In the student column header menu, the "Sort by" item should now show several sort fields and (separately) a sort order - Check that the sort fields work as expected: - (Note that you will need to use the "Secondary info" menu item to show the relevant info field under users' names; selecting a sort option will not automatically change the secondary info to match) - "Name" should sort by the user's (sortable) name - "SIS ID" should sort by the SIS user ID on the user's account - "Integration ID" should sort by the account's integration ID - "Login ID" should sort by the user's login name - "A-Z" and "Z-A" should switch between ascending and descending sort order for the selected sort field - In all cases, students with no value for the selected field (e.g., a student with no login ID) should appear at the bottom of the list, regardless of the selected sort order - Check that filtering by section or group still works as expected - Selecting a specific filter, as well as removing the filter, should respect the sort field and order - Turn OFF the feature flag for the course - Go back to New Gradebook - Check that the sort menu has returned to its previous state, with only "A-Z" and "Z-A" options that sort by name - (If you were sorting by a different criterion when you had the flag enabled, said criterion will initially still be in effect, but adjusting the sort order will bounce it back to sorting by name) APPENDIX: adding pseudonyms To create a pseudonym for a student in a Rails console: > user = <a student> > user.pseudonyms.create!( account: user.account, sis_user_id: "some_sis_id_or_other", integration_id: "some_integration_id_or_other", unique_id: "a_login_id" ) Or you could do it the boring way by just adding a login from their user details page, but I'm not sure how to update the SIS ID and integration ID from there. Change-Id: I290bced84432a4776a9c20efbaeb26aeb7e18638 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/200805 Reviewed-by: Gary Mei <gmei@instructure.com> Reviewed-by: Jeremy Neander <jneander@instructure.com> Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Tested-by: Jenkins QA-Review: Robin Kuss <rkuss@instructure.com> Product-Review: Jonathan Fenton <jfenton@instructure.com>
2019-07-09 04:38:12 +08:00
students.joins("LEFT JOIN #{Pseudonym.quoted_table_name} ON pseudonyms.user_id=users.id AND
pseudonyms.workflow_state <> 'deleted'").
order(Arel.sql("#{sort_column} #{sort_direction} NULLS LAST")).
order(Arel.sql("pseudonyms.id IS NULL")).
order(Arel.sql("users.id #{sort_direction}")).
pluck(:id).
uniq
end
def pseudonym_sort_field
# The sort keys integration_id and sis_user_id map to columns in Pseudonym,
# while login_id needs to be changed to unique_id
{
"login_id" => "unique_id",
"sis_user_id" => "sis_user_id",
"integration_id" => "integration_id"
}.with_indifferent_access[@sort_by]
end
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
def sort_by_assignment_grade(assignment_id)
add secondary sorting by sortable_name for user_ids closes CNVS-37707 test plan: * Create a course with at least four students, two of whom have the same name (we'll call them the twins) * Create two assignments, each with a maximum score of 10 * Go to Gradezilla * Sort the gradebook by Student Name from A-Z * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in ascending alphabetical order * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by Student Name from Z-A * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in descending alphabetical order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Ensure all students have submissions for the first assignment * Assign grades to the students in assignment #1 and ensure both twins get the same grade * Sort the gradebook by the grade in assignment #1 (Low to High) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by the grade in assignment #1 (High to Low) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in descending order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Update assignment #1 to ensure three students have due dates in the past, thus making their submissions late * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with late submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #1 to ensure only one student has a due date in the past, thus making only one student have a late submission. * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with timely submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #2 to have a due date in the past * Ensure only one student (not one of the twins) has submitted their work for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student who submitted their work * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Ensure both the twins now submit their work for assignment #2. This should leave just one student who is missing a submission for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first user_id is for the student who still has not submitted their work * Verify the last 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id Change-Id: Id91e02fc7dc475177d1f8c09cc75015916375576 Reviewed-on: https://gerrit.instructure.com/117227 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-28 06:37:54 +08:00
students.
joins("LEFT JOIN #{Submission.quoted_table_name} ON submissions.user_id=users.id AND
submissions.workflow_state<>'deleted' AND
submissions.assignment_id=#{Submission.connection.quote(assignment_id)}").
order(Arel.sql("enrollments.type = 'StudentViewEnrollment'")).
order(Arel.sql("submissions.score #{sort_direction} NULLS LAST")).
order(Arel.sql("submissions.id IS NULL")).
add secondary sorting by sortable_name for user_ids closes CNVS-37707 test plan: * Create a course with at least four students, two of whom have the same name (we'll call them the twins) * Create two assignments, each with a maximum score of 10 * Go to Gradezilla * Sort the gradebook by Student Name from A-Z * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in ascending alphabetical order * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by Student Name from Z-A * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in descending alphabetical order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Ensure all students have submissions for the first assignment * Assign grades to the students in assignment #1 and ensure both twins get the same grade * Sort the gradebook by the grade in assignment #1 (Low to High) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by the grade in assignment #1 (High to Low) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in descending order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Update assignment #1 to ensure three students have due dates in the past, thus making their submissions late * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with late submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #1 to ensure only one student has a due date in the past, thus making only one student have a late submission. * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with timely submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #2 to have a due date in the past * Ensure only one student (not one of the twins) has submitted their work for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student who submitted their work * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Ensure both the twins now submit their work for assignment #2. This should leave just one student who is missing a submission for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first user_id is for the student who still has not submitted their work * Verify the last 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id Change-Id: Id91e02fc7dc475177d1f8c09cc75015916375576 Reviewed-on: https://gerrit.instructure.com/117227 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-28 06:37:54 +08:00
order_by_sortable_name(direction: @direction.to_sym).
pluck(:id).
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
uniq
end
def sort_by_assignment_missing(assignment_id)
add secondary sorting by sortable_name for user_ids closes CNVS-37707 test plan: * Create a course with at least four students, two of whom have the same name (we'll call them the twins) * Create two assignments, each with a maximum score of 10 * Go to Gradezilla * Sort the gradebook by Student Name from A-Z * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in ascending alphabetical order * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by Student Name from Z-A * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in descending alphabetical order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Ensure all students have submissions for the first assignment * Assign grades to the students in assignment #1 and ensure both twins get the same grade * Sort the gradebook by the grade in assignment #1 (Low to High) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by the grade in assignment #1 (High to Low) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in descending order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Update assignment #1 to ensure three students have due dates in the past, thus making their submissions late * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with late submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #1 to ensure only one student has a due date in the past, thus making only one student have a late submission. * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with timely submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #2 to have a due date in the past * Ensure only one student (not one of the twins) has submitted their work for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student who submitted their work * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Ensure both the twins now submit their work for assignment #2. This should leave just one student who is missing a submission for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first user_id is for the student who still has not submitted their work * Verify the last 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id Change-Id: Id91e02fc7dc475177d1f8c09cc75015916375576 Reviewed-on: https://gerrit.instructure.com/117227 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-28 06:37:54 +08:00
sort_user_ids(Submission.missing.where(assignment_id: assignment_id))
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
end
def sort_by_assignment_late(assignment_id)
add secondary sorting by sortable_name for user_ids closes CNVS-37707 test plan: * Create a course with at least four students, two of whom have the same name (we'll call them the twins) * Create two assignments, each with a maximum score of 10 * Go to Gradezilla * Sort the gradebook by Student Name from A-Z * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in ascending alphabetical order * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by Student Name from Z-A * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in descending alphabetical order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Ensure all students have submissions for the first assignment * Assign grades to the students in assignment #1 and ensure both twins get the same grade * Sort the gradebook by the grade in assignment #1 (Low to High) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by the grade in assignment #1 (High to Low) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in descending order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Update assignment #1 to ensure three students have due dates in the past, thus making their submissions late * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with late submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #1 to ensure only one student has a due date in the past, thus making only one student have a late submission. * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with timely submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #2 to have a due date in the past * Ensure only one student (not one of the twins) has submitted their work for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student who submitted their work * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Ensure both the twins now submit their work for assignment #2. This should leave just one student who is missing a submission for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first user_id is for the student who still has not submitted their work * Verify the last 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id Change-Id: Id91e02fc7dc475177d1f8c09cc75015916375576 Reviewed-on: https://gerrit.instructure.com/117227 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-28 06:37:54 +08:00
sort_user_ids(Submission.late.where(assignment_id: assignment_id))
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
end
def sort_by_total_grade
grading_period_id ? sort_by_scores(:grading_period, grading_period_id) : sort_by_scores(:total_grade)
end
def sort_by_assignment_group(assignment_group_id)
sort_by_scores(:assignment_group, assignment_group_id)
add secondary sorting by sortable_name for user_ids closes CNVS-37707 test plan: * Create a course with at least four students, two of whom have the same name (we'll call them the twins) * Create two assignments, each with a maximum score of 10 * Go to Gradezilla * Sort the gradebook by Student Name from A-Z * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in ascending alphabetical order * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by Student Name from Z-A * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user names are in descending alphabetical order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Ensure all students have submissions for the first assignment * Assign grades to the students in assignment #1 and ensure both twins get the same grade * Sort the gradebook by the grade in assignment #1 (Low to High) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Sort the gradebook by the grade in assignment #1 (High to Low) * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify that user_ids are returned in an order where the corresponding user grades are in descending order * Verify that the twins' user_ids appear next to each other and are in decreasing order by user_id * Update assignment #1 to ensure three students have due dates in the past, thus making their submissions late * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with late submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #1 to ensure only one student has a due date in the past, thus making only one student have a late submission. * Sort the gradebook by "Late" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with timely submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student whose submission was on time * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Update assignment #2 to have a due date in the past * Ensure only one student (not one of the twins) has submitted their work for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify the last (fourth) user_id is for the student who submitted their work * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id * Ensure both the twins now submit their work for assignment #2. This should leave just one student who is missing a submission for assignment #2 * Sort the gradebook by "Missing" * As a teacher hit the user_ids API endpoint (GET /courses/:course_id/gradebook/user_ids) * Verify the first user_id is for the student who still has not submitted their work * Verify the last 3 user_ids are for users with missing submissions for that assignment and are in ascending order of name * Verify that the twins' user_ids appear next to each other and are in increasing order by user_id Change-Id: Id91e02fc7dc475177d1f8c09cc75015916375576 Reviewed-on: https://gerrit.instructure.com/117227 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Keith T. Garner <kgarner@instructure.com> Tested-by: Jenkins QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-28 06:37:54 +08:00
end
def all_user_ids
@all_user_ids ||= students.order_by_sortable_name(direction: @direction.to_sym).pluck(:id).uniq
end
def all_user_ids_index
@all_user_ids_index ||= index_user_ids(all_user_ids)
end
def fake_user_ids
student_enrollments_scope.where(type: "StudentViewEnrollment").pluck(:user_id).uniq
end
def sorted_fake_user_ids
@sorted_fake_user_ids ||= sort_using_index(fake_user_ids, all_user_ids_index)
end
def sorted_real_user_ids
@sorted_real_user_ids ||= sort_using_index(all_user_ids - sorted_fake_user_ids, all_user_ids_index)
end
def real_user_ids_from_submissions(submissions)
submissions.where(user_id: sorted_real_user_ids).pluck(:user_id)
end
def sorted_real_user_ids_from_submissions(submissions)
sort_using_index(real_user_ids_from_submissions(submissions), all_user_ids_index)
end
def sort_user_ids(submissions)
sorted_real_user_ids_from_submissions(submissions).concat(sorted_real_user_ids, sorted_fake_user_ids).uniq
end
def index_user_ids(user_ids)
user_ids_index = {}
# Traverse the array once and cache all indexes so we don't incur traversal costs at the end
user_ids.each_with_index { |item, idx| user_ids_index[item] = idx }
user_ids_index
end
def sort_using_index(user_ids, user_ids_index)
user_ids.sort_by { |item| user_ids_index[item] }
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
end
def student_enrollments_scope
workflow_states = [:active, :invited]
workflow_states << :inactive if @include_inactive
workflow_states << :completed if @include_concluded || @course.completed?
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
student_enrollments = @course.enrollments.where(
workflow_state: workflow_states,
type: [:StudentEnrollment, :StudentViewEnrollment]
)
section_ids = section_id ? [section_id] : nil
@course.apply_enrollment_visibility(student_enrollments, @user, section_ids, include: workflow_states)
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
end
def students
# Because of AR internals (https://github.com/rails/rails/issues/32598),
# we avoid using Arel left_joins here so that sort_by_scores will have
# Enrollment defined.
students = User.
joins("LEFT JOIN #{Enrollment.quoted_table_name} ON enrollments.user_id=users.id").
merge(student_enrollments_scope)
2019-02-12 05:53:58 +08:00
if student_group_id.present?
students.joins(group_memberships: :group).
where(group_memberships: {group: student_group_id, workflow_state: :accepted})
else
students
end
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
end
def sort_by_scores(type = :total_grade, id = nil)
score_scope = if type == :assignment_group
"scores.assignment_group_id=#{Score.connection.quote(id)}"
elsif type == :grading_period
"scores.grading_period_id=#{Score.connection.quote(id)}"
else
"scores.course_score IS TRUE"
end
# Without doing the score conditions in the join, we lose data. For
# example, we might lose concluded enrollments who don't have a Score.
students.joins("LEFT JOIN #{Score.quoted_table_name} ON scores.enrollment_id=enrollments.id AND
scores.workflow_state='active' AND #{score_scope}").
order(Arel.sql("enrollments.type = 'StudentViewEnrollment'")).
order(Arel.sql("scores.unposted_current_score #{sort_direction} NULLS LAST")).
order_by_sortable_name(direction: @direction.to_sym).
pluck(:id).uniq
end
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
def sort_direction
@direction == "ascending" ? :asc : :desc
end
def grading_period_id
return nil unless @course.grading_periods?
return nil if @selected_grading_period_id == "0"
if @selected_grading_period_id.nil? || @selected_grading_period_id == "null"
GradingPeriod.current_period_for(@course)&.id
else
@selected_grading_period_id
end
end
def section_id
2019-02-12 05:53:58 +08:00
return nil if @selected_section_id.nil? || @selected_section_id == "null" || @selected_section_id == "0"
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
@selected_section_id
end
2019-02-12 05:53:58 +08:00
def student_group_id
return nil if @selected_student_group_id.nil? || ["0", "null"].include?(@selected_student_group_id)
Exclude deleted groups from filter Do not show deleted groups/group categories in the student group filter. If a filter is selected and then subsequently deleted, behave as though no filter is applied until such time as a valid group is selected. fixes GRADE-2275 Test plan: - Have a course with New Gradebook and some group sets/groups - Enable the "Launch SpeedGrader filtered by student group" setting - Open New Gradebook and filter by a group - Go to the course's People page and delete the specific group you're filtering by - Return to New Gradebook - The group filter should be cleared and all students should be shown - The submission details tray should disable the SpeedGrader link because no group is selected (except for group assignments) - WITHOUT selecting a new group: - Open the view page for an assignment: - The SpeedGrader link/group select on the right-hand side should not have a group pre-selected, and the list of eligible groups should not include the deleted group - Open SpeedGrader directly for an assignment: - /courses/<course_id>/gradebook/speed_grader?assignment_id=<id> - All students should be shown (we should not attempt to filter by the selected-but-deleted group) - Select a new group for real and make sure things work as before: - Check that Gradebook filters properly by the now-selected group - Check that the submission details tray now allows you to access SpeedGrader - Check that the view page for an assignment recognizes the selected group - Check that SpeedGrader filters by the selected group Change-Id: Ib528e6594afc80e50d4e0127b62a161226c674bb Reviewed-on: https://gerrit.instructure.com/205287 Tested-by: Jenkins Reviewed-by: Jeremy Neander <jneander@instructure.com> Reviewed-by: Keith Garner <kgarner@instructure.com> QA-Review: Gary Mei <gmei@instructure.com> Product-Review: Keith Garner <kgarner@instructure.com>
2019-08-16 00:54:33 +08:00
Group.active.exists?(id: @selected_student_group_id) ? @selected_student_group_id : nil
2019-02-12 05:53:58 +08:00
end
add user_ids endpoint to gradebooks_controller Add endpoint to gradebooks controller which returns user ids sorted according to the user's gradebook sort preferences. closes CNVS-37608 Test Plan: 1. Create a course that has some active students, inactive students, and concluded students. Enable New Gradebook and go to the gradebook. 2. Click on the student header and select 'Inactive enrollments' and 'Concluded enrollments'. Then select 'Sort by -> A-Z'. 2. As a student in the course, hit the new endpoint to get user IDs (GET /courses/:course_id/gradebook/user_ids). Verify you get a 401 unauthorized response. 3. As a teacher in the course, hit the user_ids endpoint and verify you get a list of user IDs back. The user IDs should be ordered such that their corresponding users' names are in alpha ascending order. The list of user IDs should also include inactive and concluded students' IDs. 4. Go to the gradebook and click on the student header. Select 'Sort by -> Z-A'. 5. Hit the user_ids endpoint and verify the returned user IDs are now ordered such that their corresponding users' names are in alpha descending order. The list of user IDs should also include inactive and concluded students' IDs. 6. Go to the gradebook and click on the student column header. Deselect the 'Inactive enrollments' and 'Concluded enrollments' options. 7. Hit the user_ids endpoint and verify the returned user IDs no longer include IDs for inactive or concluded students. The IDs should still be ordered such that their corresponding users' names are in alpha descending order. 8. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> Low to High' 9. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in ascending order. 10. Go to the gradebook and click on the total grade header. Select 'Sort by Grade -> High to Low' 11. Hit the user_ids endpoint and verify the returned user IDs are ordered such that their corresponding users' current total grades are in descending order. 12. In the same manner as the steps above, make sure changing the following settings in the gradebook causes the user_ids endpoint to return an array of IDs ordered according to the gradebook sort preferences: a) Assignment column header -> Sort by Grade -> Low to High b) Assignment column header -> Sort by Grade -> High to Low c) Assignment column header -> Sort by -> Missing (the user_ids endpoint should return all users with a missing submission for that assignment first) d) Assignment column header -> Sort by -> Late (the user_ids endpoint shoudl return all users with a late submission for that assignment first) e) Select a grading period and sort by total grade. The user_ids endpoint should return user IDs that are ordered such that their corresponding users' grades are in ascending or descending order for the selected grading period. * Note: Sorting by assignment group totals is not currently supported. Change-Id: I4a36aa5b82d87f49d2396bbc16e1cc56e89eba0f Reviewed-on: https://gerrit.instructure.com/116491 Reviewed-by: Shahbaz Javeed <sjaveed@instructure.com> Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Anju Reddy <areddy@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2017-06-17 06:37:46 +08:00
end