canvas-lms/lib/gradebook_settings_helpers.rb

50 lines
1.6 KiB
Ruby
Raw Normal View History

#
# Copyright (C) 2016 - 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/>.
#
module GradebookSettingsHelpers
private
def gradebook_includes(user:, course:)
@gradebook_includes ||= begin
tweak speed grader comment visiblity closes: GRADE-1266 Test Plan: enroll two students and two TAs and the teacher is the final grader (it shouldn't matter if the final grader is a TA or a teacher, in fact feel free to rotate them for more possibilities). If you're short on time the following could be done on one assignment and for each test case toggle the settings on and off, but then it would be difficult to quickly pull of the correct configuration, if problems arise. The titles of each feature are how they are found in the Assignment form. This can cause some confusion due to some rules being enabling or disabling a phrase with a 'not' present so be careful! /------------+---------------------------+-----------+-----------------------+---------------------+-----------------------\ | assignment | anonymous (graders cannot | moderated | graders can view | graders cannot view | final grader can view | | | view student names) | grading | each other's comments | each other's names | other grader names | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | I (basic) | | | | | | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | II | | on | on | | on | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | III | | on | on | | | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | IV | | on | | | | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | V | on | on | on | on | on | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | VI | on | on | on | on | | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | VII | on | on | on | | | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | VIII | on | on | | | | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ | IX | on | | | | | +------------+---------------------------+-----------+-----------------------+---------------------+-----------------------+ Note: if a cell is empty, it means `off`, For assignments with Moderated Grading enabled the `Number of graders` will always be `2` (the final grader makes three enrollments we'll use for Speed Grader) for each assignment do the following: have the first student (Student A) submit their homework - As the first TA (TA1), create a published comment and draft comment on Student A's submission - As the second TA (TA2), create a published comment and draft comment on Student A's submission - As the final grader (the teacher), create a published comment and draft comment on Student A's submission For the follow instructions, negatives are presented in uppercase (`CANNOT`) for enhanced clarity. Ensure for each grader (unless final grader is specified) in each assignment referenced via the parens: (I) 1. can view student names 2. can view each other's comments (II) 1. can view student names 2. can view each other's comments 3. final graders can view other graders' names (III) 1. can view student names 2. can view each other's comments 3. final grader CANNOT view other graders' names (IV) 1. can view student names 2. CANNOT view each other's comments 3. final grader can view each others' comments (V) 1. CANNOT view student names 2. can view each other's comments 3. CANNOT view each other's names 4. final grader view other graders' names (VI) 1. CANNOT view student names 2. can view each other's comments 3. CANNOT each other's names 4. final grader CANNOT view other graders' names (VII) 1. CANNOT view student names 2. can view each other's comments 3. can view each other's names 4. final grader CANNOT view other graders' names (VIII) 1. CANNOT view student names 2. CANNOT each other's comments 3. final grader can view each others' comments (IX) 1. CANNOT view student names Change-Id: I3e9a8787f04cf03a38ea651aa85b3eaa98f41f9c Reviewed-on: https://gerrit.instructure.com/154391 Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> QA-Review: Indira Pai <ipai@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-20 03:51:52 +08:00
course_id = course.id
gb_settings = user.preferences.fetch(:gradebook_settings, {}).fetch(course_id, {})
includes = []
includes << :inactive if gb_settings.fetch('show_inactive_enrollments', "false") == "true"
hide concluded students in speedgrader This changes SpeedGrader to be consistent with Gradebook in showing or hiding concluded students in a soft concluded course. Concluded students will show or be hidden depending on if "Show Concluded enrollments" is checked or not. closes GRADE-1204 and GRADE-585 Test Plan Setup - Have a course with at least 2 students. - Create an assignment. - Conclude 1 student. - Go to the course settings and change the course dates to start and end before the current day. - Under the course dates, check the box for "Users can only participate in the course between these dates" Testing SpeedGrader - Navigate to the Gradebook. - Uncheck the option to show concluded students, if it's checked. - Open SpeedGrader for the assignment. - Verify that the concluded student does not show. - Navigate to the Gradebook. - Check the option to show concluded students. - Open SpeedGrader for the assignment. - Verify that the concluded student does show. Testing Exports - Navigate to the Gradebook. - Uncheck the option to show concluded students, if it's checked. - Export the Gradebook. - Verify that the concluded student does not appear in the export. - Navigate to the Gradebook. - Check the option to show concluded students. - Export the Gradebook. - Verify that the concluded student does appear in the export. Change-Id: Id237086263e47405c03e0ae4af20195fa4d8ca35 Reviewed-on: https://gerrit.instructure.com/155111 Tested-by: Jenkins Reviewed-by: Keith T. Garner <kgarner@instructure.com> Reviewed-by: Adrian Packel <apackel@instructure.com> QA-Review: James Butters <jbutters@instructure.com> Product-Review: Keith T. Garner <kgarner@instructure.com>
2018-06-26 03:49:29 +08:00
if gb_settings.fetch('show_concluded_enrollments', "false") == "true" || course.completed?
includes << :completed
end
includes
end
end
def gradebook_enrollment_scope(user:, course:)
scope = course.all_accepted_student_enrollments
unless gradebook_includes(user: user, course: course).include?(:inactive)
scope = scope.where("enrollments.workflow_state <> 'inactive'")
end
unless gradebook_includes(user: user, course: course).include?(:completed)
scope = scope.where("enrollments.workflow_state <> 'completed'")
end
scope
end
end