enable picking srgb as default
fixes CNVS-10403 test plan: - turn on srgb in course settings - in gb2, click the 'switch gradebooks' link - navigate to courses/:id/grades - it should load srgb - click the 'switch gradebooks' link - navigate to courses/:id/grades - it should load gb2 Change-Id: I8c41b9763be44c2c968d818ac4d8a909476361a7 Reviewed-on: https://gerrit.instructure.com/29841 Reviewed-by: Mike Nomitch <mnomitch@instructure.com> Tested-by: Jenkins <jenkins@instructure.com> Reviewed-by: Liz Abinante <labinante@instructure.com> QA-Review: Amber Taniuchi <amber@instructure.com> Product-Review: Cameron Sutter <csutter@instructure.com>
This commit is contained in:
parent
dfef9f1f64
commit
9691cd1242
|
@ -73,6 +73,10 @@ define [
|
|||
ENV.GRADEBOOK_OPTIONS.show_total_grade_as_points
|
||||
).property()
|
||||
|
||||
changeGradebookVersionUrl: (->
|
||||
"#{get(window, 'ENV.GRADEBOOK_OPTIONS.change_gradebook_version_url')}"
|
||||
).property()
|
||||
|
||||
hideStudentNames: false
|
||||
|
||||
showConcludedEnrollments: false
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<h1>{{#t 'screenreader_gradebook'}}Screenreader Gradebook{{/t}}</h1>
|
||||
<div>
|
||||
<a href="{{ unbound changeGradebookVersionUrl }}">{{#t "switch_to_gradebook2"}}Switch gradebooks{{/t}}</a>
|
||||
</div>
|
||||
<em>
|
||||
{{#t 'save_instructions'}}Note: Grades and notes will be saved automatically after moving out of the field.{{/t}}
|
||||
</em>
|
||||
|
|
|
@ -54,6 +54,7 @@ class Gradebook2Controller < ApplicationController
|
|||
:custom_column_datum_url => api_v1_course_custom_gradebook_column_datum_url(@context, ":id", ":user_id"),
|
||||
:reorder_custom_columns_url => api_v1_custom_gradebook_columns_reorder_url(@context),
|
||||
:teacher_notes => teacher_notes && custom_gradebook_column_json(teacher_notes, @current_user, session),
|
||||
:change_gradebook_version_url => context_url(@context, :change_gradebook_version_context_gradebook_url, :version => 2)
|
||||
}
|
||||
end
|
||||
end
|
||||
|
|
|
@ -419,7 +419,11 @@ class GradebooksController < ApplicationController
|
|||
end
|
||||
|
||||
def change_gradebook_version
|
||||
@current_user.preferences[:use_gradebook2] = params[:version] == '2'
|
||||
if @context.feature_enabled?(:screenreader_gradebook)
|
||||
@current_user.preferences[:gradebook_version] = params[:version]
|
||||
else
|
||||
@current_user.preferences[:use_gradebook2] = params[:version] == '2'
|
||||
end
|
||||
@current_user.save!
|
||||
redirect_to_appropriate_gradebook_version
|
||||
end
|
||||
|
|
|
@ -35,10 +35,15 @@ module GradebooksHelper
|
|||
end
|
||||
|
||||
def get_gradebook_version(user, context)
|
||||
if !context.old_gradebook_visible? || user.nil? || user.prefers_gradebook2?
|
||||
if user.nil? || user.prefers_gradebook2?(context)
|
||||
'gradebook2'
|
||||
else
|
||||
elsif context.feature_enabled?(:screenreader_gradebook) && user.gradebook_preference == 'srgb'
|
||||
'screenreader_gradebook'
|
||||
elsif context.old_gradebook_visible?
|
||||
'gradebook'
|
||||
else
|
||||
'gradebook2'
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -2596,8 +2596,18 @@ class User < ActiveRecord::Base
|
|||
@all_active_pseudonyms ||= self.pseudonyms.with_each_shard { |scope| scope.active }
|
||||
end
|
||||
|
||||
def prefers_gradebook2?
|
||||
preferences[:use_gradebook2] != false
|
||||
#when screenreader_gradebook is enabled by default, we won't need to pass in context anymore
|
||||
def prefers_gradebook2?(context)
|
||||
if context.feature_enabled?(:screenreader_gradebook)
|
||||
return true if preferences[:gradebook_version].nil?
|
||||
preferences[:gradebook_version] == '2'
|
||||
else
|
||||
preferences[:use_gradebook2] != false
|
||||
end
|
||||
end
|
||||
|
||||
def gradebook_preference
|
||||
preferences[:gradebook_version]
|
||||
end
|
||||
|
||||
def stamp_logout_time!
|
||||
|
|
|
@ -3,7 +3,9 @@
|
|||
@body_classes << "gradebook2 full-width"
|
||||
@show_left_side = false
|
||||
@show_embedded_chat = false
|
||||
if @context.old_gradebook_visible?
|
||||
if @context.feature_enabled?(:screenreader_gradebook)
|
||||
add_crumb t(:srgb_gradebook, "switch gradebooks"), context_url(@context, :change_gradebook_version_context_gradebook_url, :version => "srgb"), :id => 'change_gradebook_version_link_holder'
|
||||
elsif @context.old_gradebook_visible?
|
||||
add_crumb t(:old_gradebook, "old gradebook", :version => 1), context_url(@context, :change_gradebook_version_context_gradebook_url, :reset => true), :id => 'change_gradebook_version_link_holder'
|
||||
end
|
||||
jammit_css :slickgrid, :gradebook2
|
||||
|
|
|
@ -235,11 +235,9 @@ routes.draw do
|
|||
end
|
||||
end
|
||||
|
||||
resource :gradebook2, :controller => :gradebook2 do
|
||||
collection do
|
||||
get :screenreader
|
||||
end
|
||||
end
|
||||
resource :gradebook2, :controller => :gradebook2
|
||||
match 'screenreader_gradebook' => 'gradebook2#screenreader'
|
||||
|
||||
match 'attendance' => 'gradebooks#attendance', :as => :attendance
|
||||
match 'attendance/:user_id' => 'gradebooks#attendance', :as => :attendance_user
|
||||
concerns :zip_file_imports
|
||||
|
|
|
@ -440,7 +440,7 @@ describe GradebooksController do
|
|||
course_with_teacher_logged_in(:active_all => true)
|
||||
@user.preferences[:use_gradebook2] = false
|
||||
@user.save!
|
||||
@user.prefers_gradebook2?.should == false
|
||||
@user.prefers_gradebook2?(@course).should == false
|
||||
@course.large_roster = true
|
||||
@course.save!
|
||||
@course.reload
|
||||
|
|
|
@ -33,7 +33,10 @@ describe GradebooksHelper do
|
|||
end
|
||||
|
||||
context "when the user prefers gradebook1" do
|
||||
before { user.stubs(:prefers_gradebook2? => false) }
|
||||
before do
|
||||
user.stubs(:prefers_gradebook2? => false)
|
||||
context.stubs(:feature_enabled?).with(:screenreader_gradebook).returns(false)
|
||||
end
|
||||
|
||||
it { should match /#{"/courses/1/gradebook"}$/ }
|
||||
|
||||
|
@ -61,5 +64,25 @@ describe GradebooksHelper do
|
|||
let(:user) { nil }
|
||||
it { should match /#{"/courses/1/gradebook2"}$/ }
|
||||
end
|
||||
|
||||
context "with screenreader_gradebook enabled" do
|
||||
before do
|
||||
context.stubs(:feature_enabled?).with(:screenreader_gradebook).returns(true)
|
||||
end
|
||||
|
||||
context "when the user prefers srgb" do
|
||||
before {
|
||||
user.stubs(:prefers_gradebook2? => false)
|
||||
user.stubs(:gradebook_preference => 'srgb')
|
||||
}
|
||||
it { should match /#{"/courses/1/screenreader_gradebook"}$/ }
|
||||
end
|
||||
|
||||
context "when the user prefers gb2" do
|
||||
before { user.stubs(:gradebook_preference => '2') }
|
||||
it { should match /#{"/courses/1/gradebook2"}$/ }
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2230,7 +2230,11 @@ describe User do
|
|||
|
||||
describe "prefers_gradebook2?" do
|
||||
let(:user) { User.new }
|
||||
subject { user.prefers_gradebook2? }
|
||||
subject { user.prefers_gradebook2?(@ctx) }
|
||||
before {
|
||||
@ctx = mock()
|
||||
@ctx.stubs(:feature_enabled?).with(:screenreader_gradebook).returns(false)
|
||||
}
|
||||
|
||||
context "by default" do
|
||||
it { should be_true }
|
||||
|
@ -2250,6 +2254,27 @@ describe User do
|
|||
before { user.stubs(:preferences => { :use_gradebook2 => false }) }
|
||||
it { should be_false }
|
||||
end
|
||||
|
||||
context "with screenreader_gradebook enabled" do
|
||||
before {
|
||||
@ctx.stubs(:feature_enabled?).with(:screenreader_gradebook).returns(true)
|
||||
}
|
||||
|
||||
context "prefers gb2" do
|
||||
before { user.stubs(:preferences => { :gradebook_version => '2' }) }
|
||||
it {should be_true}
|
||||
end
|
||||
|
||||
context "prefers srgb" do
|
||||
before { user.stubs(:preferences => { :gradebook_version => 'srgb' }) }
|
||||
it {should be_false}
|
||||
end
|
||||
|
||||
context "nil preference" do
|
||||
before { user.stubs(:preferences => { :gradebook_version => nil }) }
|
||||
it {should be_true}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "manual_mark_as_read" do
|
||||
|
|
Loading…
Reference in New Issue