Commit 9052a76c by Kevin Chugh

working kpi 4

parent 4eb8da90
......@@ -91,35 +91,38 @@ namespace :kpis do
puts "\n"
end
end
task :epu => :environment do
#USAGE
#SINATRA_ENV=development rake kpis:epu
#or
#SINATRA_ENV=development bundle exec rake kpis:epu
task :epu => :environment do
#USAGE
#SINATRA_ENV=development rake kpis:epu
#or
#SINATRA_ENV=development bundle exec rake kpis:epu
courses = Content.all.distinct("course_id")
puts "\n\n**************************************************************************************************************************************"
puts "Average contributions (votes, threads, or comments) per contributing user per course on edX (#{Date.today}) "
puts "******************************************************************************************************************************************\n\n"
courses.each do |c|
#first, get all the users who have contributed
summary = Content.summary({"course_id" => c})
total_users = summary["contributor_count"]
total_activity = summary['thread_count']
total_activity += summary['comment_count']
total_activity += summary['vote_count']
ratio = total_activity.to_f / total_users.to_f
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}"
courses = Content.all.distinct("course_id")
puts "\n\n*****************************************************************************************************************"
puts "Average contributions (votes, threads, or comments) per contributing user per course on edX (#{Date.today}) "
puts "*********************************************************************************************************************\n\n"
courses.each do |c|
#first, get all the users who have contributed
summary = Content.summary({"course_id" => c})
total_users = summary["contributor_count"]
total_activity = summary['thread_count']
total_activity += summary['comment_count']
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']}\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
......
......@@ -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