release final grade override
closes: GRADE-1965 test plan: - This feature cannot be reversed - New Gradebook cannot be disabled if final grade override is either allowed or on Change-Id: I398b6e0a370d2ab507cad088a7947d35be989037 Reviewed-on: https://gerrit.instructure.com/179263 Reviewed-by: Keith Garner <kgarner@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>
This commit is contained in:
parent
8c32cc4fec
commit
e49dd8db64
|
@ -3264,7 +3264,9 @@ class Course < ActiveRecord::Base
|
|||
# to identify the user can't move backwards, such as feature flags
|
||||
def gradebook_backwards_incompatible_features_enabled?
|
||||
# The old gradebook can't deal with late policies at all
|
||||
return true if late_policy&.missing_submission_deduction_enabled? || late_policy&.late_submission_deduction_enabled?
|
||||
return true if late_policy&.missing_submission_deduction_enabled? ||
|
||||
late_policy&.late_submission_deduction_enabled? ||
|
||||
feature_enabled?(:final_grades_override)
|
||||
|
||||
# If you've used the grade tray status changes at all, you can't
|
||||
# go back. Even if set to none, it'll break "Message Students
|
||||
|
|
|
@ -249,7 +249,6 @@ END
|
|||
state: 'allowed',
|
||||
root_opt_in: true,
|
||||
beta: true,
|
||||
|
||||
custom_transition_proc: ->(user, context, _from_state, transitions) do
|
||||
if context.is_a?(Course)
|
||||
if !context.grants_right?(user, :change_course_state)
|
||||
|
@ -260,13 +259,14 @@ END
|
|||
transitions['off']['locked'] = should_lock if transitions&.dig('off')
|
||||
end
|
||||
elsif context.is_a?(Account)
|
||||
new_gradebook_feature_flag = FeatureFlag.where(feature: :new_gradebook, state: :on)
|
||||
backwards_incompatible_feature_flags =
|
||||
FeatureFlag.where(feature: [:new_gradebook, :final_grades_override], state: :on)
|
||||
all_active_sub_account_ids = Account.sub_account_ids_recursive(context.id)
|
||||
relevant_accounts = Account.joins(:feature_flags).where(id: [context.id].concat(all_active_sub_account_ids))
|
||||
relevant_courses = Course.joins(:feature_flags).where(account_id: all_active_sub_account_ids)
|
||||
|
||||
accounts_with_feature = relevant_accounts.merge(new_gradebook_feature_flag)
|
||||
courses_with_feature = relevant_courses.merge(new_gradebook_feature_flag)
|
||||
accounts_with_feature = relevant_accounts.merge(backwards_incompatible_feature_flags)
|
||||
courses_with_feature = relevant_courses.merge(backwards_incompatible_feature_flags)
|
||||
|
||||
if accounts_with_feature.exists? || courses_with_feature.exists?
|
||||
transitions['off'] ||= {}
|
||||
|
@ -277,6 +277,33 @@ END
|
|||
end
|
||||
end
|
||||
},
|
||||
'final_grades_override' => {
|
||||
display_name: -> { I18n.t('Final Grade Override') },
|
||||
description: -> {
|
||||
I18n.t <<~DESCRIPTION
|
||||
Enable ability to alter the final grade for the entire course without changing scores for assignments.
|
||||
DESCRIPTION
|
||||
},
|
||||
applies_to: 'Course',
|
||||
root_opt_in: true,
|
||||
state: 'allowed',
|
||||
beta: true,
|
||||
custom_transition_proc: ->(_user, context, from_state, transitions) do
|
||||
# can't go back
|
||||
if context.is_a?(Course) && from_state == 'on'
|
||||
transitions['off'] ||= {}
|
||||
transitions['off']['locked'] = true
|
||||
elsif context.is_a?(Account) && from_state == 'allowed'
|
||||
transitions['off'] ||= {}
|
||||
transitions['off']['locked'] = true
|
||||
elsif context.is_a?(Account) && from_state == 'on'
|
||||
transitions['off'] ||= {}
|
||||
transitions['off']['locked'] = true
|
||||
transitions['allowed'] ||= {}
|
||||
transitions['allowed']['locked'] = true
|
||||
end
|
||||
end
|
||||
},
|
||||
'k12' =>
|
||||
{
|
||||
display_name: -> { I18n.t('features.k12', 'K-12 Specific Features') },
|
||||
|
@ -676,18 +703,6 @@ END
|
|||
applies_to: 'Course',
|
||||
state: 'allowed',
|
||||
development: true
|
||||
},
|
||||
'final_grades_override' => {
|
||||
display_name: -> { I18n.t('Final Grade Override') },
|
||||
description: -> {
|
||||
I18n.t <<~DESCRIPTION
|
||||
Enable ability to alter the final grade for the entire course without changing scores for assignments.
|
||||
DESCRIPTION
|
||||
},
|
||||
applies_to: 'Course',
|
||||
state: 'hidden',
|
||||
development: true,
|
||||
beta: true
|
||||
}
|
||||
)
|
||||
|
||||
|
|
|
@ -1151,7 +1151,7 @@ describe Course do
|
|||
it "should transfer favorites with the enrollments" do
|
||||
student_in_course(:course => @course)
|
||||
fav = @student.favorites.create!(:context => @course)
|
||||
|
||||
|
||||
@course.reload
|
||||
|
||||
@new_course = @course.reset_content
|
||||
|
@ -4012,7 +4012,7 @@ describe Course, "section_visibility" do
|
|||
limited_teacher = user_factory(:active_all => true)
|
||||
@course.enroll_user(limited_teacher, "TeacherEnrollment", :enrollment_state => "active",
|
||||
:section => section2, :limit_privileges_to_course_section => true)
|
||||
|
||||
|
||||
observer = user_factory(:active_all => true)
|
||||
@course.enroll_user(observer, "ObserverEnrollment", :enrollment_state => "active", :section => section2)
|
||||
expect(@course.users_visible_to(limited_student)).not_to include(observer)
|
||||
|
@ -5279,6 +5279,10 @@ describe Course, "#show_total_grade_as_points?" do
|
|||
describe Course, "#gradebook_backwards_incompatible_features_enabled?" do
|
||||
let(:course) { Course.create! }
|
||||
|
||||
it "returns false if there are no policies nor is final_grade_override enabled" do
|
||||
expect(course).not_to be_gradebook_backwards_incompatible_features_enabled
|
||||
end
|
||||
|
||||
it "returns true if a late policy is enabled" do
|
||||
course.late_policy = LatePolicy.new(late_submission_deduction_enabled: true)
|
||||
|
||||
|
@ -5291,6 +5295,11 @@ describe Course, "#show_total_grade_as_points?" do
|
|||
expect(course.gradebook_backwards_incompatible_features_enabled?).to be true
|
||||
end
|
||||
|
||||
it 'is backward incompatible if final_grades_override is enabled' do
|
||||
course.enable_feature!(:final_grades_override)
|
||||
expect(course).to be_gradebook_backwards_incompatible_features_enabled
|
||||
end
|
||||
|
||||
it "returns true if both a late and missing policy are enabled" do
|
||||
course.late_policy =
|
||||
LatePolicy.new(late_submission_deduction_enabled: true, missing_submission_deduction_enabled: true)
|
||||
|
@ -5298,10 +5307,6 @@ describe Course, "#show_total_grade_as_points?" do
|
|||
expect(course.gradebook_backwards_incompatible_features_enabled?).to be true
|
||||
end
|
||||
|
||||
it "returns false if there are no policies" do
|
||||
expect(course.gradebook_backwards_incompatible_features_enabled?).to be false
|
||||
end
|
||||
|
||||
it "returns false if both policies are disabled" do
|
||||
course.late_policy =
|
||||
LatePolicy.new(late_submission_deduction_enabled: false, missing_submission_deduction_enabled: false)
|
||||
|
|
Loading…
Reference in New Issue