show user name in user profile rows on access report
test plan: * enable page views * as a user, visit the course profile page of another user * the visitor's access report should show the visited user's name, rather than a blank "Content" column closes #CNVS-22233 Change-Id: Ifaa4bd9fcdee7a805e00dc23f313262e9925325a Reviewed-on: https://gerrit.instructure.com/59836 Tested-by: Jenkins Reviewed-by: Jeremy Stanley <jeremy@instructure.com> QA-Review: Charles Kimball <ckimball@instructure.com> Product-Review: James Williams <jamesw@instructure.com>
This commit is contained in:
parent
25da9adf7a
commit
bae5a781f8
|
@ -58,7 +58,7 @@ class AssetUserAccess < ActiveRecord::Base
|
|||
res[:totals] = {}
|
||||
res[:prior_totals] = {}
|
||||
Rails.cache.fetch(['access_by_category', list.first, list.last, list.length].cache_key) do
|
||||
list.each{|a|
|
||||
list.each{|a|
|
||||
a.category ||= 'unknown'
|
||||
cat = res[:categories][a.category] || {}
|
||||
cat[:view_tally] ||= 0
|
||||
|
@ -83,7 +83,7 @@ class AssetUserAccess < ActiveRecord::Base
|
|||
res[:totals][:participate_tally] ||= 0
|
||||
res[:totals][:participate_tally] += a.participate_score || 0
|
||||
}
|
||||
(old_list || []).each{|a|
|
||||
(old_list || []).each{|a|
|
||||
a.category ||= 'unknown'
|
||||
cat = res[:categories][a.category] || {}
|
||||
cat[:prior_view_tally] ||= 0
|
||||
|
@ -103,7 +103,7 @@ class AssetUserAccess < ActiveRecord::Base
|
|||
res[:prior_totals][:participate_tally] ||= 0
|
||||
res[:prior_totals][:participate_tally] += a.participate_score || 0
|
||||
}
|
||||
res[:categories].each{|key, val|
|
||||
res[:categories].each{|key, val|
|
||||
res[:categories][key][:participate_average] = (res[:categories][key][:participate_tally].to_f / res[:totals][:participate_tally].to_f * 100).round / 100.0 rescue 0
|
||||
res[:categories][key][:view_average] = (res[:categories][key][:view_tally].to_f / res[:totals][:view_tally].to_f * 100).round rescue 0
|
||||
res[:categories][key][:interaction_seconds_average] = (res[:categories][key][:interaction_seconds].to_f / res[:categories][key][:view_tally].to_f * 100).round / 100.0 rescue 0
|
||||
|
@ -160,6 +160,7 @@ class AssetUserAccess < ActiveRecord::Base
|
|||
return nil unless asset_code
|
||||
asset_code, general = self.asset_code.split(":").reverse
|
||||
asset = Context.find_asset_by_asset_string(asset_code, context)
|
||||
asset ||= (match = asset_code.match(/enrollment_(\d+)/)) && Enrollment.where(:id => match[1]).first
|
||||
asset
|
||||
end
|
||||
|
||||
|
|
|
@ -86,4 +86,10 @@ describe "user asset accesses" do
|
|||
expect(html.css('#usage_report .access.assignment .last_viewed').text.strip).to eq datetime_string(now2)
|
||||
expect(AssetUserAccess.where(:user_id => @student).first.last_access.to_i).to eq now2.to_i
|
||||
end
|
||||
|
||||
it "should record user names when viewing profiles" do
|
||||
user_session(@student)
|
||||
get "/courses/#{@course.id}/users/#{@teacher.id}"
|
||||
expect(AssetUserAccess.where(:user_id => @student).first.display_name).to eq @teacher.name
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue