don't display student course nicknames to admins
test plan: - as a student, set up a nickname for a course - ensure this nickname is visible to you on your course index page ("Courses" / "All Courses") - as an account admin, find the student in the account (/accounts/X/users/Y) and ensure the student's nickname does not appear to you in the Enrollments section fixes CNVS-26884 Change-Id: Ia2360a67d9642bcd51711279b2a5cde05807a8f6 Reviewed-on: https://gerrit.instructure.com/72213 Tested-by: Jenkins Reviewed-by: James Williams <jamesw@instructure.com> QA-Review: Jahnavi Yetukuri <jyetukuri@instructure.com> Product-Review: Jeremy Stanley <jeremy@instructure.com>
This commit is contained in:
parent
4fbb52d681
commit
7ba3f13a06
|
@ -411,8 +411,8 @@ class CoursesController < ApplicationController
|
|||
end
|
||||
@visible_groups = @current_user.visible_groups
|
||||
|
||||
@past_enrollments.sort_by!{|e| Canvas::ICU.collation_key(e.long_name)}
|
||||
[@current_enrollments, @future_enrollments].each{|list| list.sort_by!{|e| [e.active? ? 1 : 0, Canvas::ICU.collation_key(e.long_name)] }}
|
||||
@past_enrollments.sort_by!{|e| Canvas::ICU.collation_key(e.long_name(@current_user))}
|
||||
[@current_enrollments, @future_enrollments].each{|list| list.sort_by!{|e| [e.active? ? 1 : 0, Canvas::ICU.collation_key(e.long_name(@current_user))] }}
|
||||
}
|
||||
|
||||
format.json {
|
||||
|
|
|
@ -532,22 +532,22 @@ class Enrollment < ActiveRecord::Base
|
|||
true
|
||||
end
|
||||
|
||||
def course_name
|
||||
self.course.nickname_for(self.user) || t('#enrollment.default_course_name', "Course")
|
||||
def course_name(display_user = nil)
|
||||
self.course.nickname_for(display_user) || t('#enrollment.default_course_name', "Course")
|
||||
end
|
||||
|
||||
def short_name(length=nil)
|
||||
def short_name(length = nil, display_user = nil)
|
||||
return @short_name if @short_name
|
||||
@short_name = self.course_section.display_name if self.course_section && self.root_account && self.root_account.show_section_name_as_course_name
|
||||
@short_name ||= self.course_name
|
||||
@short_name ||= self.course_name(display_user)
|
||||
@short_name = @short_name[0..length] if length
|
||||
@short_name
|
||||
end
|
||||
|
||||
def long_name
|
||||
def long_name(display_user = nil)
|
||||
return @long_name if @long_name
|
||||
@long_name = self.course_name
|
||||
@long_name = t('#enrollment.with_section', "%{course_name}, %{section_name}", :course_name => @long_name, :section_name => self.course_section.display_name) if self.course_section && self.course_section.display_name && self.course_section.display_name != self.course_name
|
||||
@long_name = self.course_name(display_user)
|
||||
@long_name = t('#enrollment.with_section', "%{course_name}, %{section_name}", :course_name => @long_name, :section_name => self.course_section.display_name) if self.course_section && self.course_section.display_name && self.course_section.display_name != self.course_name(display_user)
|
||||
@long_name
|
||||
end
|
||||
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
<li class="<%= 'unpublished' if enrollment.course.created? || enrollment.course.claimed? %> <%= enrollment.state_based_on_date %> clearfix">
|
||||
|
||||
<a href="<%= course_user_path(enrollment.course_id, enrollment.user_id) %>" style="float: left; max-width: 800px;">
|
||||
<span class="name" title="<%= enrollment.long_name %>">
|
||||
<%= enrollment.long_name %>
|
||||
<span class="name" title="<%= enrollment.long_name(@current_user) %>">
|
||||
<%= enrollment.long_name(@current_user) %>
|
||||
<% if enrollment.course.created? || enrollment.course.claimed? %>
|
||||
<%= image_tag "hammer.png", :title => t('course_not_published', "This course hasn't been published yet"), :alt => t('unpublished', "Unpublished"), :class => "unpublished_icon" %>
|
||||
<% end %>
|
||||
|
|
|
@ -76,4 +76,28 @@ describe "course" do
|
|||
expect(body.css('div.import-in-progress-notice')).to be_empty
|
||||
end
|
||||
end
|
||||
|
||||
it "should use nicknames in the course index" do
|
||||
course_with_student(:active_all => true, :course_name => "Course 1")
|
||||
course_with_student(:user => @student, :active_all => true, :course_name => "Course 2")
|
||||
@student.course_nicknames[@course.id] = 'A nickname or something'
|
||||
@student.save!
|
||||
user_session(@student)
|
||||
get "/courses"
|
||||
doc = Nokogiri::HTML(response.body)
|
||||
course_rows = doc.css('#my_courses_table tr')
|
||||
expect(course_rows.size).to eq 2
|
||||
expect(course_rows[0].to_s).to include 'A nickname or something'
|
||||
expect(course_rows[1].to_s).to include 'Course 1'
|
||||
end
|
||||
|
||||
it "should not show students' nicknames to admins on the student's account profile page" do
|
||||
course_with_student(:active_all => true)
|
||||
@student.course_nicknames[@course.id] = 'STUDENT_NICKNAME'; @student.save!
|
||||
user_session(account_admin_user)
|
||||
get "/accounts/#{@course.root_account.id}/users/#{@student.id}"
|
||||
doc = Nokogiri::HTML(response.body)
|
||||
course_list = doc.at_css('#courses_list').to_s
|
||||
expect(course_list).not_to include 'STUDENT_NICKNAME'
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue