forked from openedx-unsupported/edx-analytics-data-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now distinguishes between metrics which are aggregated by unique entity id (such as problems or videos) and those which simply add up the total number of interactions, regardless of which module they were acted upon.
- Loading branch information
Showing
6 changed files
with
148 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
from analytics_data_api.constants.engagement_entity_types import DISCUSSION, PROBLEM, VIDEO | ||
from analytics_data_api.constants.engagement_events import ATTEMPTED, COMPLETED, CONTRIBUTED, VIEWED | ||
|
||
|
||
class EngagementType(object): | ||
""" | ||
Encapsulates: | ||
- The API consumer-facing display name for engagement types | ||
- The internal question of whether the metric should be counted in terms | ||
of the entity type or the raw number of events. | ||
""" | ||
def __init__(self, entity_type, event_type): | ||
""" | ||
Initializes an EngagementType for a particular entity and event type. | ||
Arguments: | ||
entity_type (str): the type of module interacted with | ||
event_type (str): the type of interaction on that entity | ||
""" | ||
if entity_type == PROBLEM: | ||
if event_type == ATTEMPTED: | ||
self.name = 'problems_attempted' | ||
self.is_counted_by_entity = True | ||
if event_type == COMPLETED: | ||
self.name = 'problems_completed' | ||
self.is_counted_by_entity = True | ||
elif entity_type == VIDEO: | ||
if event_type == VIEWED: | ||
self.name = 'videos_viewed' | ||
self.is_counted_by_entity = True | ||
elif entity_type == DISCUSSION: | ||
if event_type == CONTRIBUTED: | ||
# Note that the discussion contribution metric counts | ||
# total discussion contributions, not number of | ||
# discussions contributed to. | ||
self.name = 'discussion_contributions' | ||
self.is_counted_by_entity = False | ||
else: | ||
raise ValueError( | ||
'No display name found for entity type "{entity_type}" and event type "{event_type}"'.format( | ||
entity_type=entity_type, | ||
event_type=event_type, | ||
) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters