Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-data-api
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
edx-analytics-data-api
Commits
6a67dc83
Commit
6a67dc83
authored
Jan 04, 2016
by
Dennis Jen
Committed by
Daniel Friedman
Apr 11, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Renamed learner API field.
- discussions_contributed renamed to discussion_contributions
parent
66f541c4
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
30 additions
and
32 deletions
+30
-32
analytics_data_api/constants/engagement_entity_types.py
+1
-3
analytics_data_api/constants/engagement_events.py
+2
-3
analytics_data_api/v0/models.py
+4
-3
analytics_data_api/v0/serializers.py
+3
-3
analytics_data_api/v0/tests/views/test_engagement_timelines.py
+6
-6
analytics_data_api/v0/tests/views/test_learners.py
+12
-12
analytics_data_api/v0/views/learners.py
+2
-2
No files found.
analytics_data_api/constants/engagement_entity_types.py
View file @
6a67dc83
...
...
@@ -3,14 +3,12 @@ PROBLEM = 'problem'
VIDEO
=
'video'
INDIVIDUAL_TYPES
=
[
DISCUSSION
,
PROBLEM
,
VIDEO
]
DISCUSSIONS
=
'discussions'
PROBLEMS
=
'problems'
VIDEOS
=
'videos'
AGGREGATE_TYPES
=
[
DISCUSSION
S
,
PROBLEMS
,
VIDEOS
]
AGGREGATE_TYPES
=
[
DISCUSSION
,
PROBLEMS
,
VIDEOS
]
# useful for agregating ModuleEngagement to ModuleEngagementTimeline
SINGULAR_TO_PLURAL
=
{
DISCUSSION
:
DISCUSSIONS
,
PROBLEM
:
PROBLEMS
,
VIDEO
:
VIDEOS
,
}
analytics_data_api/constants/engagement_events.py
View file @
6a67dc83
...
...
@@ -2,13 +2,12 @@ from analytics_data_api.constants import engagement_entity_types
ATTEMPTED
=
'attempted'
COMPLETED
=
'completed'
CONTRIBUT
ED
=
'contributed
'
CONTRIBUT
IONS
=
'contributions
'
VIEWED
=
'viewed'
# map entity types to events
EVENTS
=
{
engagement_entity_types
.
DISCUSSION
:
[
CONTRIBUTED
],
engagement_entity_types
.
DISCUSSIONS
:
[
CONTRIBUTED
],
engagement_entity_types
.
DISCUSSION
:
[
CONTRIBUTIONS
],
engagement_entity_types
.
PROBLEM
:
[
ATTEMPTED
,
COMPLETED
],
engagement_entity_types
.
PROBLEMS
:
[
ATTEMPTED
,
COMPLETED
],
engagement_entity_types
.
VIDEO
:
[
VIEWED
],
...
...
analytics_data_api/v0/models.py
View file @
6a67dc83
...
...
@@ -245,7 +245,7 @@ class RosterEntry(DocType):
# problem_attempts_per_completed is > 1 and set to -problem_attempts if
# problem_attempts_per_completed = 1.
attempt_ratio_order
=
Integer
()
discussion
s_contributed
=
Integer
()
discussion
_contributions
=
Integer
()
videos_watched
=
Integer
()
enrollment_date
=
Date
()
last_updated
=
Date
()
...
...
@@ -302,7 +302,7 @@ class RosterEntry(DocType):
))
order_by_options
=
(
'username'
,
'email'
,
'discussion
s_contributed
'
,
'problems_attempted'
,
'problems_completed'
,
'username'
,
'email'
,
'discussion
_contributions
'
,
'problems_attempted'
,
'problems_completed'
,
'problem_attempts_per_completed'
,
'attempt_ratio_order'
,
'videos_viewed'
)
sort_order_options
=
(
'asc'
,
'desc'
)
...
...
@@ -405,7 +405,8 @@ class ModuleEngagementTimelineManager(models.Manager):
u'date'
:
key
,
}
for
engagement
in
group
:
entity_type
=
engagement_entity_types
.
SINGULAR_TO_PLURAL
[
engagement
[
'entity_type'
]]
entity_type
=
engagement_entity_types
.
SINGULAR_TO_PLURAL
.
get
(
engagement
[
'entity_type'
],
engagement
[
'entity_type'
])
engagement_type
=
'{}_{}'
.
format
(
entity_type
,
engagement
[
'event'
])
count
=
item
.
get
(
engagement_type
,
0
)
count
+=
engagement
[
'count'
]
...
...
analytics_data_api/v0/serializers.py
View file @
6a67dc83
...
...
@@ -345,7 +345,7 @@ class LearnerSerializer(serializers.Serializer, DefaultIfNoneMixin):
engagements
=
{}
# fill in these fields will 0 if values not returned/found
default_if_none_fields
=
[
'discussion
s_contributed
'
,
'problems_attempted'
,
default_if_none_fields
=
[
'discussion
_contributions
'
,
'problems_attempted'
,
'problems_completed'
,
'videos_viewed'
]
for
field
in
default_if_none_fields
:
engagements
[
field
]
=
self
.
default_if_none
(
getattr
(
obj
,
field
,
None
),
0
)
...
...
@@ -381,7 +381,7 @@ class EngagementDaySerializer(DefaultIfNoneMixin, serializers.Serializer):
date
=
serializers
.
DateField
(
format
=
settings
.
DATE_FORMAT
)
problems_attempted
=
serializers
.
IntegerField
(
required
=
True
,
default
=
0
)
problems_completed
=
serializers
.
IntegerField
(
required
=
True
,
default
=
0
)
discussion
s_contributed
=
serializers
.
IntegerField
(
required
=
True
,
default
=
0
)
discussion
_contributions
=
serializers
.
IntegerField
(
required
=
True
,
default
=
0
)
videos_viewed
=
serializers
.
IntegerField
(
required
=
True
,
default
=
0
)
def
transform_problems_attempted
(
self
,
_obj
,
value
):
...
...
@@ -390,7 +390,7 @@ class EngagementDaySerializer(DefaultIfNoneMixin, serializers.Serializer):
def
transform_problems_completed
(
self
,
_obj
,
value
):
return
self
.
default_if_none
(
value
,
0
)
def
transform_discussion
s_contributed
(
self
,
_obj
,
value
):
def
transform_discussion
_contributions
(
self
,
_obj
,
value
):
return
self
.
default_if_none
(
value
,
0
)
def
transform_videos_viewed
(
self
,
_obj
,
value
):
...
...
analytics_data_api/v0/tests/views/test_engagement_timelines.py
View file @
6a67dc83
...
...
@@ -26,7 +26,7 @@ class EngagementTimelineTests(DemoCourseMixin, VerifyCourseIdMixin, TestCaseWith
entity_id
=
'some-type-of-id'
,
event
=
engagement_events
.
COMPLETED
,
count
=
12
)
G
(
models
.
ModuleEngagement
,
course_id
=
self
.
course_id
,
username
=
self
.
DEFAULT_USERNAME
,
date
=
datetime
.
datetime
(
2015
,
1
,
2
,
tzinfo
=
pytz
.
utc
),
entity_type
=
engagement_entity_types
.
DISCUSSION
,
entity_id
=
'some-type-of-id'
,
event
=
engagement_events
.
CONTRIBUT
ED
,
count
=
10
)
entity_id
=
'some-type-of-id'
,
event
=
engagement_events
.
CONTRIBUT
IONS
,
count
=
10
)
G
(
models
.
ModuleEngagement
,
course_id
=
self
.
course_id
,
username
=
self
.
DEFAULT_USERNAME
,
date
=
datetime
.
datetime
(
2015
,
1
,
2
,
tzinfo
=
pytz
.
utc
),
entity_type
=
engagement_entity_types
.
VIDEO
,
entity_id
=
'some-type-of-id'
,
event
=
engagement_events
.
VIEWED
,
count
=
44
)
...
...
@@ -44,14 +44,14 @@ class EngagementTimelineTests(DemoCourseMixin, VerifyCourseIdMixin, TestCaseWith
'days'
:
[
{
'date'
:
'2015-01-01'
,
'discussion
s_contributed
'
:
0
,
'discussion
_contributions
'
:
0
,
'problems_attempted'
:
100
,
'problems_completed'
:
12
,
'videos_viewed'
:
0
},
{
'date'
:
'2015-01-02'
,
'discussion
s_contributed
'
:
10
,
'discussion
_contributions
'
:
10
,
'problems_attempted'
:
8
,
'problems_completed'
:
0
,
'videos_viewed'
:
44
...
...
@@ -71,7 +71,7 @@ class EngagementTimelineTests(DemoCourseMixin, VerifyCourseIdMixin, TestCaseWith
'days'
:
[
{
'date'
:
'2015-05-28'
,
'discussion
s_contributed
'
:
0
,
'discussion
_contributions
'
:
0
,
'problems_attempted'
:
6923
,
'problems_completed'
:
0
,
'videos_viewed'
:
0
...
...
@@ -94,14 +94,14 @@ class EngagementTimelineTests(DemoCourseMixin, VerifyCourseIdMixin, TestCaseWith
'days'
:
[
{
'date'
:
'2015-05-26'
,
'discussion
s_contributed
'
:
0
,
'discussion
_contributions
'
:
0
,
'problems_attempted'
:
0
,
'problems_completed'
:
0
,
'videos_viewed'
:
1
},
{
'date'
:
'2015-05-28'
,
'discussion
s_contributed
'
:
0
,
'discussion
_contributions
'
:
0
,
'problems_attempted'
:
6923
,
'problems_completed'
:
0
,
'videos_viewed'
:
0
...
...
analytics_data_api/v0/tests/views/test_learners.py
View file @
6a67dc83
...
...
@@ -60,7 +60,7 @@ class LearnerAPITestMixin(object):
'cohort'
:
{
'type'
:
'string'
,
'index'
:
'not_analyzed'
,
'doc_values'
:
True
},
'disc
sussions_contributed
'
:
{
'disc
ussion_contributions
'
:
{
'type'
:
'integer'
,
'doc_values'
:
True
},
'problems_attempted'
:
{
...
...
@@ -109,7 +109,7 @@ class LearnerAPITestMixin(object):
enrollment_mode
=
'honor'
,
segments
=
None
,
cohort
=
'Team edX'
,
discussion
s_contributed
=
0
,
discussion
_contributions
=
0
,
problems_attempted
=
0
,
problems_completed
=
0
,
problem_attempts_per_completed
=
None
,
...
...
@@ -129,7 +129,7 @@ class LearnerAPITestMixin(object):
'enrollment_mode'
:
enrollment_mode
,
'segments'
:
segments
if
segments
is
not
None
else
list
(),
'cohort'
:
cohort
,
'discussion
s_contributed'
:
discussions_contributed
,
'discussion
_contributions'
:
discussion_contributions
,
'problems_attempted'
:
problems_attempted
,
'problems_completed'
:
problems_completed
,
'problem_attempts_per_completed'
:
problem_attempts_per_completed
,
...
...
@@ -179,7 +179,7 @@ class LearnerTests(VerifyCourseIdMixin, LearnerAPITestMixin, TestCaseWithAuthent
@ddt.unpack
def
test_get_user
(
self
,
username
,
name
,
course_id
,
enrollment_mode
,
segments
=
None
,
cohort
=
None
,
problems_attempted
=
None
,
problems_completed
=
None
,
videos_viewed
=
None
,
discussion
s_contributed
=
None
,
problem_attempts_per_completed
=
None
,
discussion
_contributions
=
None
,
problem_attempts_per_completed
=
None
,
attempt_ratio_order
=
None
,
enrollment_date
=
None
,
last_updated
=
None
):
self
.
create_learners
([{
...
...
@@ -192,7 +192,7 @@ class LearnerTests(VerifyCourseIdMixin, LearnerAPITestMixin, TestCaseWithAuthent
"problems_attempted"
:
problems_attempted
,
"problems_completed"
:
problems_completed
,
"videos_viewed"
:
videos_viewed
,
"discussion
s_contributed"
:
discussions_contributed
,
"discussion
_contributions"
:
discussion_contributions
,
"problem_attempts_per_completed"
:
problem_attempts_per_completed
,
"attempt_ratio_order"
:
attempt_ratio_order
,
"enrollment_date"
:
enrollment_date
,
...
...
@@ -214,7 +214,7 @@ class LearnerTests(VerifyCourseIdMixin, LearnerAPITestMixin, TestCaseWithAuthent
"problems_attempted"
:
problems_attempted
or
0
,
"problems_completed"
:
problems_completed
or
0
,
"videos_viewed"
:
videos_viewed
or
0
,
"discussion
s_contributed"
:
discussions_contributed
or
0
,
"discussion
_contributions"
:
discussion_contributions
or
0
,
"problem_attempts_per_completed"
:
problem_attempts_per_completed
,
},
"enrollment_date"
:
enrollment_date
,
...
...
@@ -301,7 +301,7 @@ class LearnerListTests(LearnerAPITestMixin, VerifyCourseIdMixin, TestCaseWithAut
"problems_attempted"
:
43
,
"problems_completed"
:
3
,
"videos_viewed"
:
6
,
"discussion
s_contributed
"
:
0
,
"discussion
_contributions
"
:
0
,
"problem_attempts_per_completed"
:
23.14
,
}])
response
=
self
.
_get
(
self
.
course_id
)
...
...
@@ -314,7 +314,7 @@ class LearnerListTests(LearnerAPITestMixin, VerifyCourseIdMixin, TestCaseWithAut
"problems_attempted"
:
43
,
"problems_completed"
:
3
,
"videos_viewed"
:
6
,
"discussion
s_contributed
"
:
0
,
"discussion
_contributions
"
:
0
,
"problem_attempts_per_completed"
:
23.14
,
},
'last_updated'
:
'2015-09-28'
,
...
...
@@ -376,12 +376,12 @@ class LearnerListTests(LearnerAPITestMixin, VerifyCourseIdMixin, TestCaseWithAut
([{
'username'
:
'a'
},
{
'username'
:
'b'
}],
'email'
,
'asc'
,
[{
'username'
:
'a'
},
{
'username'
:
'b'
}]),
([{
'username'
:
'a'
},
{
'username'
:
'b'
}],
'email'
,
'desc'
,
[{
'username'
:
'b'
},
{
'username'
:
'a'
}]),
(
[{
'username'
:
'a'
,
'discussion
s_contributed'
:
0
},
{
'username'
:
'b'
,
'discussions_contributed
'
:
1
}],
'discussion
s_contributed
'
,
'asc'
,
[{
'username'
:
'a'
},
{
'username'
:
'b'
}]
[{
'username'
:
'a'
,
'discussion
_contributions'
:
0
},
{
'username'
:
'b'
,
'discussion_contributions
'
:
1
}],
'discussion
_contributions
'
,
'asc'
,
[{
'username'
:
'a'
},
{
'username'
:
'b'
}]
),
(
[{
'username'
:
'a'
,
'discussion
s_contributed'
:
0
},
{
'username'
:
'b'
,
'discussions_contributed
'
:
1
}],
'discussion
s_contributed
'
,
'desc'
,
[{
'username'
:
'b'
},
{
'username'
:
'a'
}]
[{
'username'
:
'a'
,
'discussion
_contributions'
:
0
},
{
'username'
:
'b'
,
'discussion_contributions
'
:
1
}],
'discussion
_contributions
'
,
'desc'
,
[{
'username'
:
'b'
},
{
'username'
:
'a'
}]
),
(
[{
'username'
:
'a'
,
'problems_attempted'
:
0
},
{
'username'
:
'b'
,
'problems_attempted'
:
1
}],
...
...
analytics_data_api/v0/views/learners.py
View file @
6a67dc83
...
...
@@ -75,7 +75,7 @@ class LearnerView(LastUpdateMixin, CourseViewMixin, generics.RetrieveAPIView):
This is a count of the individual problems the learner
tried. Each problem in a course can increment this count by
a maximum of 1.
* discussion
s_contributed
: Number of posts, responses, or
* discussion
_contributions
: Number of posts, responses, or
comments the learner contributed to course discussions.
**Parameters**
...
...
@@ -358,7 +358,7 @@ class CourseLearnerMetadata(CourseViewMixin, generics.RetrieveAPIView):
* problem_attempts_per_completed: Engagement ranges for the
number of problem attempts per completed problem in the date
range.
* discussion
s_contributed
: Engagement ranges for the number of
* discussion
_contributions
: Engagement ranges for the number of
times learners participated in discussions in the date range.
"""
...
...
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