Commit c1136868 by Kevin Chugh

fix mssing end

parent 2dbec2ba
...@@ -7,20 +7,17 @@ ROOT = roots[ENV['SINATRA_ENV']] ...@@ -7,20 +7,17 @@ ROOT = roots[ENV['SINATRA_ENV']]
namespace :kpis do namespace :kpis do
task :prolific => :environment do task :prolific => :environment do
#USAGE #USAGE
#SINATRA_ENV=development rake kpis:prolific #SINATRA_ENV=development rake kpis:prolific
#or #or
#SINATRA_ENV=development bundle exed rake kpis:prolific #SINATRA_ENV=development bundle exed rake kpis:prolific
courses = Content.all.distinct("course_id") courses = Content.all.distinct("course_id")
puts "\n\n*********************************************************************" puts "\n\n*********************************************************************"
puts " Users who have created the most forum content on edX (#{Date.today}) " puts " Users who have created the most forum content on edX (#{Date.today}) "
puts "*********************************************************************\n\n" puts "*********************************************************************\n\n"
courses.each do |c| courses.each do |c|
contributors = Content.prolific_metric({"course_id" => c}) contributors = Content.prolific_metric({"course_id" => c})
#now output #now output
...@@ -30,13 +27,13 @@ namespace :kpis do ...@@ -30,13 +27,13 @@ namespace :kpis do
url = ROOT + "/courses/#{c}/discussion/forum/users/#{p['_id']}" url = ROOT + "/courses/#{c}/discussion/forum/users/#{p['_id']}"
count_string = "#{p['value'].to_i} contributions:".rjust(25) count_string = "#{p['value'].to_i} contributions:".rjust(25)
puts "#{count_string} #{url} " puts "#{count_string} #{url} "
end end
puts "\n" puts "\n"
end end
end end
task :starters => :environment do task :starters => :environment do
#USAGE #USAGE
#SINATRA_ENV=development rake kpis:starters #SINATRA_ENV=development rake kpis:starters
...@@ -44,10 +41,10 @@ namespace :kpis do ...@@ -44,10 +41,10 @@ namespace :kpis do
#SINATRA_ENV=development bundle exed rake kpis:starters #SINATRA_ENV=development bundle exed rake kpis:starters
courses = Content.all.distinct("course_id") courses = Content.all.distinct("course_id")
puts "\n\n*********************************************************************" puts "\n\n*********************************************************************"
puts " Users who have started the most threads on edX (#{Date.today}) " puts " Users who have started the most threads on edX (#{Date.today}) "
puts "*********************************************************************\n\n" puts "*********************************************************************\n\n"
courses.each do |c| courses.each do |c|
contributors = Content.prolific_metric({"course_id" => c, "_type" => "CommentThread"}) contributors = Content.prolific_metric({"course_id" => c, "_type" => "CommentThread"})
#now output #now output
...@@ -57,12 +54,12 @@ namespace :kpis do ...@@ -57,12 +54,12 @@ namespace :kpis do
url = ROOT + "/courses/#{c}/discussion/forum/users/#{p['_id']}" url = ROOT + "/courses/#{c}/discussion/forum/users/#{p['_id']}"
count_string = "#{p['value'].to_i} contributions:".rjust(25) count_string = "#{p['value'].to_i} contributions:".rjust(25)
puts "#{count_string} #{url} " puts "#{count_string} #{url} "
end end
puts "\n" puts "\n"
end end
end end
task :ppu => :environment do task :ppu => :environment do
#USAGE #USAGE
#SINATRA_ENV=development rake kpis:ppu #SINATRA_ENV=development rake kpis:ppu
...@@ -70,63 +67,64 @@ namespace :kpis do ...@@ -70,63 +67,64 @@ namespace :kpis do
#SINATRA_ENV=development bundle exed rake kpis:ppu #SINATRA_ENV=development bundle exed rake kpis:ppu
courses = Content.all.distinct("course_id") courses = Content.all.distinct("course_id")
puts "\n\n*********************************************************************" puts "\n\n*********************************************************************"
puts "Average threads per contributing user per course on edX (#{Date.today}) " puts "Average threads 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
contributors = Content.prolific_metric({"course_id" => c}) contributors = Content.prolific_metric({"course_id" => c})
total_users = contributors.count total_users = contributors.count
#now, get the threads #now, get the threads
total_threads = Content.where("_type" => "CommentThread","course_id" => c).count total_threads = Content.where("_type" => "CommentThread","course_id" => c).count
ratio = total_threads.to_f / total_users.to_f ratio = total_threads.to_f / total_users.to_f
#now output #now output
puts c puts c
puts "*********************" puts "*********************"
puts "Total Threads: #{total_threads}" puts "Total Threads: #{total_threads}"
puts "Total Users: #{total_users}" puts "Total Users: #{total_users}"
puts "Average Thread/User: #{ratio}" puts "Average Thread/User: #{ratio}"
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") 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 "\n\n**************************************************************************************************************************************"
puts "Average contributions (votes, comments, endorsements, or threads or follows) per contributing user per course on edX (#{Date.today}) " puts "Average contributions (votes, comments, endorsements, or threads or follows) 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
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"
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
end 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