Commit 9052a76c by Kevin Chugh

working kpi 4

parent 4eb8da90
...@@ -91,6 +91,7 @@ namespace :kpis do ...@@ -91,6 +91,7 @@ namespace :kpis do
puts "\n" puts "\n"
end end
end
task :epu => :environment do task :epu => :environment do
#USAGE #USAGE
...@@ -99,9 +100,9 @@ namespace :kpis do ...@@ -99,9 +100,9 @@ namespace :kpis do
#SINATRA_ENV=development bundle exec rake kpis:epu #SINATRA_ENV=development bundle exec rake kpis:epu
courses = Content.all.distinct("course_id") courses = Content.all.distinct("course_id")
puts "\n\n**************************************************************************************************************************************" puts "\n\n*****************************************************************************************************************"
puts "Average contributions (votes, threads, or comments) per contributing user per course on edX (#{Date.today}) " puts "Average contributions (votes, threads, or comments) per contributing user per course on edX (#{Date.today}) "
puts "******************************************************************************************************************************************\n\n" puts "*********************************************************************************************************************\n\n"
courses.each do |c| courses.each do |c|
#first, get all the users who have contributed #first, get all the users who have contributed
...@@ -112,16 +113,18 @@ namespace :kpis do ...@@ -112,16 +113,18 @@ namespace :kpis do
total_activity += summary['vote_count'] total_activity += summary['vote_count']
ratio = total_activity.to_f / total_users.to_f ratio = total_activity.to_f / total_users.to_f
puts c
puts "*********************"
puts "Total Threads: #{summary['thread_count']}" puts "Total Threads: #{summary['thread_count']}"
puts "Total Comments: #{summary['comment_count']}" puts "Total Comments: #{summary['comment_count']}"
puts "Total Votes: #{summary['vote_count']}" puts "Total Votes: #{summary['vote_count']}\n\n"
puts "--------------------------------------------------------" puts "Total Users: #{summary['contributor_count']}"
puts "Total Engagements: #{total_activity}" puts "Total Engagements: #{total_activity}\n\n"
puts "Average Engagement Per Engaging User: #{ratio}" puts "Average Engagement Per Engaging User: #{ratio}\n\n\n "
end end
end end
end
end end
...@@ -53,7 +53,7 @@ class Content ...@@ -53,7 +53,7 @@ class Content
contributors << c["votes"]["up"] contributors << c["votes"]["up"]
contributors << c["votes"]["down"] contributors << c["votes"]["down"]
vote_count += c["votes"]["count"] vote_count += c["votes"]["count"]
if c._type == "ContentThread" if c._type == "CommentThread"
thread_count += 1 thread_count += 1
elsif c._type == "Comment" elsif c._type == "Comment"
comment_count += 1 comment_count += 1
...@@ -66,9 +66,9 @@ class Content ...@@ -66,9 +66,9 @@ class Content
#assemble the answer and ship #assemble the answer and ship
answer["vote_count"] = vote_count answer["vote_count"] = vote_count
answer["thread_count"] = vote_count answer["thread_count"] = thread_count
answer["comment_count"] = vote_count answer["comment_count"] = comment_count
answer["contributor_count"] = contributor_count answer["contributor_count"] = contributors.count
answer answer
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment