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
551bceb0
Commit
551bceb0
authored
Dec 17, 2012
by
Kevin Chugh
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new kpi
parent
c1136868
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
58 additions
and
22 deletions
+58
-22
lib/tasks/kpis.rake
+19
-22
models/content.rb
+39
-0
No files found.
lib/tasks/kpis.rake
View file @
551bceb0
...
...
@@ -11,7 +11,7 @@ namespace :kpis do
#USAGE
#SINATRA_ENV=development rake kpis:prolific
#or
#SINATRA_ENV=development bundle exe
d
rake kpis:prolific
#SINATRA_ENV=development bundle exe
c
rake kpis:prolific
courses
=
Content
.
all
.
distinct
(
"course_id"
)
puts
"
\n\n
*********************************************************************"
...
...
@@ -38,7 +38,7 @@ namespace :kpis do
#USAGE
#SINATRA_ENV=development rake kpis:starters
#or
#SINATRA_ENV=development bundle exe
d
rake kpis:starters
#SINATRA_ENV=development bundle exe
c
rake kpis:starters
courses
=
Content
.
all
.
distinct
(
"course_id"
)
puts
"
\n\n
*********************************************************************"
...
...
@@ -64,7 +64,7 @@ namespace :kpis do
#USAGE
#SINATRA_ENV=development rake kpis:ppu
#or
#SINATRA_ENV=development bundle exe
d
rake kpis:ppu
#SINATRA_ENV=development bundle exe
c
rake kpis:ppu
courses
=
Content
.
all
.
distinct
(
"course_id"
)
puts
"
\n\n
*********************************************************************"
...
...
@@ -94,33 +94,30 @@ namespace :kpis do
task
:epu
=>
:environment
do
#USAGE
#SINATRA_ENV=development rake kpis:
p
pu
#SINATRA_ENV=development rake kpis:
e
pu
#or
#SINATRA_ENV=development bundle exe
d rake kpis:p
pu
#SINATRA_ENV=development bundle exe
c rake kpis:e
pu
courses
=
Content
.
all
.
distinct
(
"course_id"
)
puts
"
\n\n
**************************************************************************************************************************************"
puts
"Average contributions (votes,
comments, endorsements, or threads or follow
s) per contributing user per course on edX (
#{
Date
.
today
}
) "
puts
"Average contributions (votes,
threads, or comment
s) 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
"
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
}
"
end
end
...
...
models/content.rb
View file @
551bceb0
...
...
@@ -36,4 +36,43 @@ class Content
contributors
end
def
self
.
summary
what
#take a hash of criteria (where) and return a hash of hashes
#of total users, votes, comments, endorsements,
answer
=
{}
vote_count
=
0
thread_count
=
0
comment_count
=
0
contributors
=
[]
content
=
self
.
where
(
what
)
content
.
each
do
|
c
|
contributors
<<
c
.
author_id
contributors
<<
c
[
"votes"
][
"up"
]
contributors
<<
c
[
"votes"
][
"down"
]
votes
+=
c
.
votes
[
"count"
]
if
c
.
_type
==
"ContentThread"
thread_count
+=
1
elsif
c
.
_type
==
"Comment"
comment_count
+=
1
end
end
#uniquify contributors
contributors
=
contributors
.
uniq
#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
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