Commit 2dbec2ba by Your Name

next kpi

parent 50c92595
...@@ -94,6 +94,38 @@ namespace :kpis do ...@@ -94,6 +94,38 @@ namespace :kpis do
puts "\n" puts "\n"
end end
task :epu => :environment do
#USAGE
#SINATRA_ENV=development rake kpis:ppu
#or
#SINATRA_ENV=development bundle exed rake kpis:ppu
courses = Content.all.distinct("course_id")
puts "\n\n**************************************************************************************************************************************"
puts "Average contributions (votes, comments, endorsements, or threads or follows) per contributing user per course on edX (#{Date.today}) "
puts "******************************************************************************************************************************************\n\n"
courses.each do |c|
#first, get all the users who have contributed
contributors = Content.prolific_metric({"course_id" => c})
total_users = contributors.count
#now, get the threads
total_threads = Content.where("_type" => "CommentThread","course_id" => c).count
ratio = total_threads.to_f / total_users.to_f
#now output
puts c
puts "*********************"
puts "Total Threads: #{total_threads}"
puts "Total Users: #{total_users}"
puts "Average Thread/User: #{ratio}"
puts "\n"
end
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