canvas-lms/db/migrate/20190319200622_populate_fin...

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
991 B
Ruby
Raw Normal View History

# frozen_string_literal: true
Convert FGO user prefs to course settings closes GRADE-2035 Test plan: Note that this test plan relies on the presence of the FGO gradebook setting for individual instructors, which has been superseded in our code by the course setting. See the APPENDIX at the bottom for instructions on configuring the setting for users/courses. Course/account setup: Set up some accounts and courses with the following structure, setting the Final Grade Override feature flag to the value. - Your root account (feature flag ALLOW) - Course (feature flag ON) [C1] - An instructor with the GB setting enabled - Course (feature flag ON) [C2] - An instructor with the GB setting disabled - Course (feature flag ON) [C3] - An instructor, but do not set the GB setting - A subaccount (feature flag ON) - Course [C4] - An instructor with the GB setting enabled Note that the instructors mentioned above can all be the same instructor. Actually testing: - Run the migration - Observe the following results: - Courses: - C1: course setting should be true - C2: course setting should be false - C3: course setting should not be set (i.e., nil) - C4: course setting should be true - Users: - The instructors you set up should have had the FGO setting removed from their gradebook settings for affected courses APPENDIX: setting up the setting (as it were) To check a user's Gradebook setting for a particular course: > user = <some instructor> > user.preferences.dig( :gradebook_settings, <course>.id, "show_final_grade_overrides" ) To set a user's Gradebook setting for a particular course: > user = <some instructor> > user.preferences.deep_merge!({ gradebook_settings: {<course>.id => { "show_final_grade_overrides" => <"true" or "false"> }} }) To check the course setting: > course = <some course> > course.allow_final_grade_override (Note this is distinct from allow_final_grade_override?, which will return the setting as a boolean and also check whether the feature is enabled.) To set or clear a course setting: > course = <some course> > course.update!(allow_final_grade_override: <true/false/nil>) Change-Id: I76b5d5e13d075fd4e4835f67db8745f1173981f4 Reviewed-on: https://gerrit.instructure.com/185985 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Gary Mei <gmei@instructure.com> Tested-by: Jenkins QA-Review: James Butters <jbutters@instructure.com> Product-Review: Keith Garner <kgarner@instructure.com>
2019-03-20 03:01:08 +08:00
#
# Copyright (C) 2019 - 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 PopulateFinalGradeOverrideCourseSetting < ActiveRecord::Migration[5.1]
tag :postdeploy
def up
if User.exists? # don't raise for a fresh install
raise "DataFixup::PopulateFinalGradeOverrideCourseSetting needs to be run on a previous release"
end
end
Convert FGO user prefs to course settings closes GRADE-2035 Test plan: Note that this test plan relies on the presence of the FGO gradebook setting for individual instructors, which has been superseded in our code by the course setting. See the APPENDIX at the bottom for instructions on configuring the setting for users/courses. Course/account setup: Set up some accounts and courses with the following structure, setting the Final Grade Override feature flag to the value. - Your root account (feature flag ALLOW) - Course (feature flag ON) [C1] - An instructor with the GB setting enabled - Course (feature flag ON) [C2] - An instructor with the GB setting disabled - Course (feature flag ON) [C3] - An instructor, but do not set the GB setting - A subaccount (feature flag ON) - Course [C4] - An instructor with the GB setting enabled Note that the instructors mentioned above can all be the same instructor. Actually testing: - Run the migration - Observe the following results: - Courses: - C1: course setting should be true - C2: course setting should be false - C3: course setting should not be set (i.e., nil) - C4: course setting should be true - Users: - The instructors you set up should have had the FGO setting removed from their gradebook settings for affected courses APPENDIX: setting up the setting (as it were) To check a user's Gradebook setting for a particular course: > user = <some instructor> > user.preferences.dig( :gradebook_settings, <course>.id, "show_final_grade_overrides" ) To set a user's Gradebook setting for a particular course: > user = <some instructor> > user.preferences.deep_merge!({ gradebook_settings: {<course>.id => { "show_final_grade_overrides" => <"true" or "false"> }} }) To check the course setting: > course = <some course> > course.allow_final_grade_override (Note this is distinct from allow_final_grade_override?, which will return the setting as a boolean and also check whether the feature is enabled.) To set or clear a course setting: > course = <some course> > course.update!(allow_final_grade_override: <true/false/nil>) Change-Id: I76b5d5e13d075fd4e4835f67db8745f1173981f4 Reviewed-on: https://gerrit.instructure.com/185985 Reviewed-by: Cody Cutrer <cody@instructure.com> Reviewed-by: Gary Mei <gmei@instructure.com> Tested-by: Jenkins QA-Review: James Butters <jbutters@instructure.com> Product-Review: Keith Garner <kgarner@instructure.com>
2019-03-20 03:01:08 +08:00
end