Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-pipeline
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-pipeline
Commits
900d3f69
Unverified
Commit
900d3f69
authored
Nov 15, 2017
by
Muhammad Ammar
Committed by
GitHub
Nov 15, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #443 from edx/ammar/use-video-duration-in-event
use video duration from events
parents
973856c6
1c10f9a7
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
4 deletions
+24
-4
edx/analytics/tasks/insights/tests/test_video.py
+0
-0
edx/analytics/tasks/insights/video.py
+9
-4
edx/analytics/tasks/tests/acceptance/fixtures/input/video_timeline.log
+4
-0
edx/analytics/tasks/tests/acceptance/test_video.py
+11
-0
No files found.
edx/analytics/tasks/insights/tests/test_video.py
View file @
900d3f69
This diff is collapsed.
Click to expand it.
edx/analytics/tasks/insights/video.py
View file @
900d3f69
...
@@ -212,6 +212,8 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
...
@@ -212,6 +212,8 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
## self.incr_counter(self.counter_category_name, 'Discard Video Missing encoded_module_id', 1)
## self.incr_counter(self.counter_category_name, 'Discard Video Missing encoded_module_id', 1)
return
return
video_duration
=
event_data
.
get
(
'duration'
,
VIDEO_UNKNOWN_DURATION
)
# self.incr_counter(self.counter_category_name, 'Video Events Before Time Check', 1)
# self.incr_counter(self.counter_category_name, 'Video Events Before Time Check', 1)
current_time
=
None
current_time
=
None
...
@@ -262,7 +264,7 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
...
@@ -262,7 +264,7 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
# self.incr_counter(self.counter_category_name, 'Output Video Events from Mapper', 1)
# self.incr_counter(self.counter_category_name, 'Output Video Events from Mapper', 1)
yield
(
yield
(
(
username
.
encode
(
'utf8'
),
course_id
.
encode
(
'utf8'
),
encoded_module_id
.
encode
(
'utf8'
)),
(
username
.
encode
(
'utf8'
),
course_id
.
encode
(
'utf8'
),
encoded_module_id
.
encode
(
'utf8'
)),
(
timestamp
,
event_type
,
current_time
,
old_time
,
youtube_id
)
(
timestamp
,
event_type
,
current_time
,
old_time
,
youtube_id
,
video_duration
)
)
)
def
_check_time_offset
(
self
,
time_value
,
line
):
def
_check_time_offset
(
self
,
time_value
,
line
):
...
@@ -326,7 +328,7 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
...
@@ -326,7 +328,7 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
for
event
in
sorted_events
:
for
event
in
sorted_events
:
# self.incr_counter(self.counter_category_name, 'Input User_course_video events', 1)
# self.incr_counter(self.counter_category_name, 'Input User_course_video events', 1)
timestamp
,
event_type
,
current_time
,
old_time
,
youtube_id
=
event
timestamp
,
event_type
,
current_time
,
old_time
,
youtube_id
,
duration
=
event
parsed_timestamp
=
ciso8601
.
parse_datetime
(
timestamp
)
parsed_timestamp
=
ciso8601
.
parse_datetime
(
timestamp
)
if
current_time
is
not
None
:
if
current_time
is
not
None
:
current_time
=
float
(
current_time
)
current_time
=
float
(
current_time
)
...
@@ -336,8 +338,11 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
...
@@ -336,8 +338,11 @@ class UserVideoViewingTask(EventLogSelectionMixin, MapReduceJobTask):
def
start_viewing
():
def
start_viewing
():
"""Returns a 'viewing' object representing the point where a video began to be played."""
"""Returns a 'viewing' object representing the point where a video began to be played."""
# self.incr_counter(self.counter_category_name, 'Viewing Start', 1)
# self.incr_counter(self.counter_category_name, 'Viewing Start', 1)
video_duration
=
VIDEO_UNKNOWN_DURATION
if
youtube_id
:
video_duration
=
duration
# video_duration is set to VIDEO_UNKNOWN_DURATION only when duration is not present in
# a video event, In that case fetch duration using youtube API if video is from youtube.
if
video_duration
==
VIDEO_UNKNOWN_DURATION
and
youtube_id
:
# self.incr_counter(self.counter_category_name, 'Viewing Start with Video Id', 1)
# self.incr_counter(self.counter_category_name, 'Viewing Start with Video Id', 1)
video_duration
=
self
.
video_durations
.
get
(
youtube_id
)
video_duration
=
self
.
video_durations
.
get
(
youtube_id
)
if
not
video_duration
:
if
not
video_duration
:
...
...
edx/analytics/tasks/tests/acceptance/fixtures/input/video_timeline.log
View file @
900d3f69
...
@@ -23,3 +23,7 @@
...
@@ -23,3 +23,7 @@
# Different course.
# Different course.
{"username": "dummy_username_1", "event_type": "play_video", "ip": "127.0.0.1", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36", "host": "example.m.sandbox.edx.org", "session": "495604b91e7522ca25b9da1a15384aaa", "event": "{\"id\":\"0b9e39477cf34507a7a48f74be381fdd\",\"currentTime\":0,\"code\":\"b7xgknqkQk8\"}", "event_source": "browser", "context": {"user_id": 10001, "org_id": "edX", "course_id": "course-v1:edX+DemoX+Test_2014", "path": "/event"}, "time": "2014-05-02T17:47:25.605078+00:00", "page": "http://example.m.sandbox.edx.org/courses/course-v1:edX+DemoX+Test_2014/courseware/d8a6192ade314473a78242dfeedfbf5b/edx_introduction/"}
{"username": "dummy_username_1", "event_type": "play_video", "ip": "127.0.0.1", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36", "host": "example.m.sandbox.edx.org", "session": "495604b91e7522ca25b9da1a15384aaa", "event": "{\"id\":\"0b9e39477cf34507a7a48f74be381fdd\",\"currentTime\":0,\"code\":\"b7xgknqkQk8\"}", "event_source": "browser", "context": {"user_id": 10001, "org_id": "edX", "course_id": "course-v1:edX+DemoX+Test_2014", "path": "/event"}, "time": "2014-05-02T17:47:25.605078+00:00", "page": "http://example.m.sandbox.edx.org/courses/course-v1:edX+DemoX+Test_2014/courseware/d8a6192ade314473a78242dfeedfbf5b/edx_introduction/"}
{"username": "dummy_username_1", "event_type": "stop_video", "ip": "127.0.0.1", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36", "host": "example.m.sandbox.edx.org", "session": "495604b91e7522ca25b9da1a15384aaa", "event": "{\"id\":\"0b9e39477cf34507a7a48f74be381fdd\",\"currentTime\":4,\"code\":\"b7xgknqkQk8\"}", "event_source": "browser", "context": {"user_id": 10001, "org_id": "edX", "course_id": "course-v1:edX+DemoX+Test_2014", "path": "/event"}, "time": "2014-05-02T17:47:35.605078+00:00", "page": "http://example.m.sandbox.edx.org/courses/course-v1:edX+DemoX+Test_2014/courseware/d8a6192ade314473a78242dfeedfbf5b/edx_introduction/"}
{"username": "dummy_username_1", "event_type": "stop_video", "ip": "127.0.0.1", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36", "host": "example.m.sandbox.edx.org", "session": "495604b91e7522ca25b9da1a15384aaa", "event": "{\"id\":\"0b9e39477cf34507a7a48f74be381fdd\",\"currentTime\":4,\"code\":\"b7xgknqkQk8\"}", "event_source": "browser", "context": {"user_id": 10001, "org_id": "edX", "course_id": "course-v1:edX+DemoX+Test_2014", "path": "/event"}, "time": "2014-05-02T17:47:35.605078+00:00", "page": "http://example.m.sandbox.edx.org/courses/course-v1:edX+DemoX+Test_2014/courseware/d8a6192ade314473a78242dfeedfbf5b/edx_introduction/"}
# events for video duration
{"username": "dummy_username_1", "event_type": "play_video", "ip": "127.0.0.1", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36", "host": "example.m.sandbox.edx.org", "session": "495604b91e7522ca25b9da1a15384aaa1", "event": "{\"id\":\"0b9e39477cf34507a7a48f74be381fdd1\",\"currentTime\":0,\"code\":\"3_yD_cEKoCk\",\"duration\":444}", "event_source": "browser", "context": {"user_id": 10001, "org_id": "edX", "course_id": "course-v1:edX+DemoX+Test_2015", "path": "/event"}, "time": "2014-05-02T17:47:25.605078+00:00", "page": "http://example.m.sandbox.edx.org/courses/course-v1:edX+DemoX+Test_2015/courseware/d8a6192ade314473a78242dfeedfbf5b1/edx_introduction1/"}
{"username": "dummy_username_1", "event_type": "stop_video", "ip": "127.0.0.1", "agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/36.0.1985.143 Safari/537.36", "host": "example.m.sandbox.edx.org", "session": "495604b91e7522ca25b9da1a15384aaa1", "event": "{\"id\":\"0b9e39477cf34507a7a48f74be381fdd1\",\"currentTime\":4,\"code\":\"3_yD_cEKoCk\",\"duration\":444}", "event_source": "browser", "context": {"user_id": 10001, "org_id": "edX", "course_id": "course-v1:edX+DemoX+Test_2015", "path": "/event"}, "time": "2014-05-02T17:47:35.605078+00:00", "page": "http://example.m.sandbox.edx.org/courses/course-v1:edX+DemoX+Test_2015/courseware/d8a6192ade314473a78242dfeedfbf5b1/edx_introduction1/"}
edx/analytics/tasks/tests/acceptance/test_video.py
View file @
900d3f69
...
@@ -69,6 +69,16 @@ class VideoAcceptanceTest(AcceptanceTestCase):
...
@@ -69,6 +69,16 @@ class VideoAcceptanceTest(AcceptanceTestCase):
1
,
1
,
15
,
15
,
),
),
(
'course-v1:edX+DemoX+Test_2015|0b9e39477cf34507a7a48f74be381fdd1'
,
'course-v1:edX+DemoX+Test_2015'
,
'0b9e39477cf34507a7a48f74be381fdd1'
,
444
,
5
,
1
,
0
,
5
),
]
]
self
.
assertItemsEqual
(
expected
,
results
)
self
.
assertItemsEqual
(
expected
,
results
)
...
@@ -91,5 +101,6 @@ class VideoAcceptanceTest(AcceptanceTestCase):
...
@@ -91,5 +101,6 @@ class VideoAcceptanceTest(AcceptanceTestCase):
(
'edX/DemoX/Demo_Course|i4x-edX-DemoX-video-8c0028eb2a724f48a074bc184cd8635f'
,
2
,
1
,
1
),
(
'edX/DemoX/Demo_Course|i4x-edX-DemoX-video-8c0028eb2a724f48a074bc184cd8635f'
,
2
,
1
,
1
),
(
'edX/DemoX/Demo_Course|i4x-edX-DemoX-video-8c0028eb2a724f48a074bc184cd8635f'
,
3
,
1
,
1
),
(
'edX/DemoX/Demo_Course|i4x-edX-DemoX-video-8c0028eb2a724f48a074bc184cd8635f'
,
3
,
1
,
1
),
(
'edX/DemoX/Demo_Course|i4x-edX-DemoX-video-8c0028eb2a724f48a074bc184cd8635f'
,
4
,
1
,
1
),
(
'edX/DemoX/Demo_Course|i4x-edX-DemoX-video-8c0028eb2a724f48a074bc184cd8635f'
,
4
,
1
,
1
),
(
'course-v1:edX+DemoX+Test_2015|0b9e39477cf34507a7a48f74be381fdd1'
,
0
,
1
,
1
),
]
]
self
.
assertItemsEqual
(
expected
,
results
)
self
.
assertItemsEqual
(
expected
,
results
)
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