Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
cs_comments_service
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
cs_comments_service
Commits
9052a76c
Commit
9052a76c
authored
Dec 17, 2012
by
Kevin Chugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working kpi 4
parent
4eb8da90
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
31 deletions
+34
-31
lib/tasks/kpis.rake
+30
-27
models/content.rb
+4
-4
No files found.
lib/tasks/kpis.rake
View file @
9052a76c
...
@@ -91,35 +91,38 @@ namespace :kpis do
...
@@ -91,35 +91,38 @@ namespace :kpis do
puts
"
\n
"
puts
"
\n
"
end
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
courses
=
Content
.
all
.
distinct
(
"course_id"
)
#USAGE
puts
"
\n\n
*****************************************************************************************************************"
#SINATRA_ENV=development rake kpis:epu
puts
"Average contributions (votes, threads, or comments) per contributing user per course on edX (
#{
Date
.
today
}
) "
#or
puts
"*********************************************************************************************************************
\n\n
"
#SINATRA_ENV=development bundle exec rake kpis:epu
courses
.
each
do
|
c
|
courses
=
Content
.
all
.
distinct
(
"course_id"
)
#first, get all the users who have contributed
puts
"
\n\n
**************************************************************************************************************************************"
summary
=
Content
.
summary
({
"course_id"
=>
c
})
puts
"Average contributions (votes, threads, or comments) per contributing user per course on edX (
#{
Date
.
today
}
) "
total_users
=
summary
[
"contributor_count"
]
puts
"******************************************************************************************************************************************
\n\n
"
total_activity
=
summary
[
'thread_count'
]
total_activity
+=
summary
[
'comment_count'
]
courses
.
each
do
|
c
|
total_activity
+=
summary
[
'vote_count'
]
#first, get all the users who have contributed
ratio
=
total_activity
.
to_f
/
total_users
.
to_f
summary
=
Content
.
summary
({
"course_id"
=>
c
})
total_users
=
summary
[
"contributor_count"
]
total_activity
=
summary
[
'thread_count'
]
puts
c
total_activity
+=
summary
[
'comment_count'
]
puts
"*********************"
total_activity
+=
summary
[
'vote_count'
]
puts
"Total Threads:
#{
summary
[
'thread_count'
]
}
"
ratio
=
total_activity
.
to_f
/
total_users
.
to_f
puts
"Total Comments:
#{
summary
[
'comment_count'
]
}
"
puts
"Total Votes:
#{
summary
[
'vote_count'
]
}
\n\n
"
puts
"Total Threads:
#{
summary
[
'thread_count'
]
}
"
puts
"Total Users:
#{
summary
[
'contributor_count'
]
}
"
puts
"Total Comments:
#{
summary
[
'comment_count'
]
}
"
puts
"Total Engagements:
#{
total_activity
}
\n\n
"
puts
"Total Votes:
#{
summary
[
'vote_count'
]
}
"
puts
"Average Engagement Per Engaging User:
#{
ratio
}
\n\n\n
"
puts
"--------------------------------------------------------"
puts
"Total Engagements:
#{
total_activity
}
"
puts
"Average Engagement Per Engaging User:
#{
ratio
}
"
end
end
end
end
end
...
...
models/content.rb
View file @
9052a76c
...
@@ -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
==
"Co
nt
entThread"
if
c
.
_type
==
"Co
mm
entThread"
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"
]
=
contributor
s
.
count
answer
answer
end
end
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment