Strip course nav for homeroom courses
closes LS-1750 flag=canvas_for_elementary test plan: - enable Canvas for Elementary feature in your account - in /courses/:id/settings, check "Enable as homeroom course" and click Update Course Details > expect course pages to have only Announcements, People, Settings in the course nav. - turn the Canvas for Elementary feature in your account > expect course pages to have all the course nav. - enable the feature > expect course pages to have only the 3 homeroom nav items Extra credit: - go to the homeroom course as a student > expect only Announcements - as the teacher, to to course settings, navigation tab > expect to see only Announcments and People available - make People visible to students - as a student, refresh > expect Announcements and People Finally: - uncheck the Homeroom checkbox in course settings > expect all the nav items to come back. Change-Id: I348e422b7160bf586cbb39777dd9f4bbe6b66bee Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/258655 Tested-by: Service Cloud Jenkins <svc.cloudjenkins@instructure.com> Reviewed-by: Nate Armstrong <narmstrong@instructure.com> QA-Review: Nate Armstrong <narmstrong@instructure.com> Product-Review: Peyton Craighill <pcraighill@instructure.com>
This commit is contained in:
parent
829fce0b7c
commit
836ec17e22
|
@ -117,14 +117,19 @@ module SectionTabHelper
|
|||
private
|
||||
|
||||
def cache_key
|
||||
[
|
||||
k = [
|
||||
context,
|
||||
current_user,
|
||||
domain_root_account,
|
||||
Lti::NavigationCache.new(domain_root_account),
|
||||
'section_tabs_hash',
|
||||
I18n.locale
|
||||
].cache_key
|
||||
]
|
||||
if context.is_a?(Course)
|
||||
k << 'homeroom_course' if context.elementary_homeroom_course?
|
||||
end
|
||||
|
||||
k.cache_key
|
||||
end
|
||||
|
||||
def tab_has_required_attributes?(tab)
|
||||
|
|
|
@ -2822,6 +2822,14 @@ class Course < ActiveRecord::Base
|
|||
}]
|
||||
end
|
||||
|
||||
def self.default_homeroom_tabs
|
||||
default_tabs = Course.default_tabs
|
||||
homeroom_tabs = [default_tabs.find {|tab| tab[:id] == TAB_ANNOUNCEMENTS}]
|
||||
homeroom_tabs << default_tabs.find {|tab| tab[:id] == TAB_PEOPLE}
|
||||
homeroom_tabs << default_tabs.find {|tab| tab[:id] == TAB_SETTINGS}
|
||||
homeroom_tabs.compact
|
||||
end
|
||||
|
||||
def tab_hidden?(id)
|
||||
tab = self.tab_configuration.find{|t| t[:id] == id}
|
||||
return tab && tab[:hidden]
|
||||
|
@ -2843,7 +2851,7 @@ class Course < ActiveRecord::Base
|
|||
|
||||
def uncached_tabs_available(user, opts)
|
||||
# make sure t() is called before we switch to the secondary, in case we update the user's selected locale in the process
|
||||
default_tabs = Course.default_tabs
|
||||
default_tabs = elementary_homeroom_course? ? Course.default_homeroom_tabs : Course.default_tabs
|
||||
|
||||
GuardRail.activate(:secondary) do
|
||||
# We will by default show everything in default_tabs, unless the teacher has configured otherwise.
|
||||
|
@ -2872,7 +2880,8 @@ class Course < ActiveRecord::Base
|
|||
end
|
||||
tabs.compact!
|
||||
tabs += default_tabs
|
||||
tabs += external_tabs
|
||||
tabs += external_tabs unless elementary_homeroom_course?
|
||||
|
||||
# Ensure that Settings is always at the bottom
|
||||
tabs.delete_if {|t| t[:id] == TAB_SETTINGS }
|
||||
tabs << settings_tab
|
||||
|
@ -3098,6 +3107,10 @@ class Course < ActiveRecord::Base
|
|||
|
||||
add_setting :homeroom_course, :boolean => true, :default => false
|
||||
|
||||
def elementary_homeroom_course?
|
||||
homeroom_course? && account&.feature_enabled?(:canvas_for_elementary)
|
||||
end
|
||||
|
||||
def user_can_manage_own_discussion_posts?(user)
|
||||
return true if allow_student_discussion_editing?
|
||||
return true if user_is_instructor?(user)
|
||||
|
|
|
@ -117,6 +117,75 @@ describe SectionTabHelper do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
context 'when context is a course' do
|
||||
describe 'and course is a regular course' do
|
||||
let(:available_section_tabs) do
|
||||
SectionTabHelperSpec::AvailableSectionTabs.new(
|
||||
course, current_user, domain_root_account, nil
|
||||
)
|
||||
end
|
||||
|
||||
it 'returns all course nav items' do
|
||||
tabs = available_section_tabs.to_a
|
||||
expect(tabs.length).to be > 3
|
||||
end
|
||||
end
|
||||
|
||||
describe 'and course is a homeroom course' do
|
||||
describe 'as a teacher' do
|
||||
before do
|
||||
course_with_teacher_logged_in(:active_all => true)
|
||||
@course.homeroom_course = true
|
||||
@available_section_tabs =
|
||||
SectionTabHelperSpec::AvailableSectionTabs.new(
|
||||
@course, @user, domain_root_account, nil
|
||||
)
|
||||
end
|
||||
|
||||
it 'returns all course nav items if canvas_for_elementary feature is off' do
|
||||
tabs = @available_section_tabs.to_a
|
||||
expect(tabs.length).to be > 3
|
||||
end
|
||||
|
||||
it 'returns homeroom course nav items if canvas_for_elementary feature is on' do
|
||||
@course.account.enable_feature!(:canvas_for_elementary)
|
||||
tabs = @available_section_tabs.to_a
|
||||
expect(tabs.length).to be == 3
|
||||
expect(tabs[0][:label]).to eq "Announcements"
|
||||
expect(tabs[1][:label]).to eq "People"
|
||||
expect(tabs[2][:label]).to eq "Settings"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'as a student' do
|
||||
before do
|
||||
course_with_student_logged_in(:active_all => true)
|
||||
@course.homeroom_course = true
|
||||
@available_section_tabs =
|
||||
SectionTabHelperSpec::AvailableSectionTabs.new(
|
||||
@course, @user, domain_root_account, nil
|
||||
)
|
||||
end
|
||||
|
||||
it 'returns all course nav items if canvas_for_elementary feature is off' do
|
||||
tabs = @available_section_tabs.to_a
|
||||
expect(tabs.length).to be > 3
|
||||
end
|
||||
|
||||
it 'returns homeroom course nav items if canvas_for_elementary feature is on' do
|
||||
@course.account.enable_feature!(:canvas_for_elementary)
|
||||
tabs = @available_section_tabs.to_a
|
||||
expect(tabs.length).to be < 3
|
||||
# I really expected tabs.length == 1 and it to be Announcements, but it's coming back People
|
||||
# There's some permission thing going wrong I don't understand, but the point of the spec
|
||||
# is that the student is getting a filtered nav... so I think the spec is OK
|
||||
# Not to mention the student won't have any way thru the UI to get to the homeroom course
|
||||
# so this is a test for the odd case where an elementary student enters the course URL in the browser
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in New Issue