Commit 9052a76c by Kevin Chugh

working kpi 4

parent 4eb8da90
......@@ -91,6 +91,7 @@ namespace :kpis do
puts "\n"
end
end
task :epu => :environment do
#USAGE
......@@ -99,9 +100,9 @@ namespace :kpis do
#SINATRA_ENV=development bundle exec rake kpis:epu
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 "******************************************************************************************************************************************\n\n"
puts "*********************************************************************************************************************\n\n"
courses.each do |c|
#first, get all the users who have contributed
......@@ -112,16 +113,18 @@ namespace :kpis do
total_activity += summary['vote_count']
ratio = total_activity.to_f / total_users.to_f
puts c
puts "*********************"
puts "Total Threads: #{summary['thread_count']}"
puts "Total Comments: #{summary['comment_count']}"
puts "Total Votes: #{summary['vote_count']}"
puts "--------------------------------------------------------"
puts "Total Engagements: #{total_activity}"
puts "Average Engagement Per Engaging User: #{ratio}"
puts "Total Votes: #{summary['vote_count']}\n\n"
puts "Total Users: #{summary['contributor_count']}"
puts "Total Engagements: #{total_activity}\n\n"
puts "Average Engagement Per Engaging User: #{ratio}\n\n\n "
end
end
end
end
......@@ -53,7 +53,7 @@ class Content
contributors << c["votes"]["up"]
contributors << c["votes"]["down"]
vote_count += c["votes"]["count"]
if c._type == "ContentThread"
if c._type == "CommentThread"
thread_count += 1
elsif c._type == "Comment"
comment_count += 1
......@@ -66,9 +66,9 @@ class Content
#assemble the answer and ship
answer["vote_count"] = vote_count
answer["thread_count"] = vote_count
answer["comment_count"] = vote_count
answer["contributor_count"] = contributor_count
answer["thread_count"] = thread_count
answer["comment_count"] = comment_count
answer["contributor_count"] = contributors.count
answer
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