Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
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-platform
Commits
c7ebda8f
Commit
c7ebda8f
authored
Mar 06, 2015
by
Ali Mohammad
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #7223 from edx/cgoldberg/video-cdn-experiment
china video cdn experiment
parents
3604e2dd
1fc9c837
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
0 deletions
+63
-0
common/lib/xmodule/xmodule/video_module/video_module.py
+17
-0
lms/djangoapps/courseware/tests/test_video_mongo.py
+21
-0
lms/templates/video.html
+25
-0
No files found.
common/lib/xmodule/xmodule/video_module/video_module.py
View file @
c7ebda8f
...
...
@@ -16,6 +16,7 @@ Examples of html5 videos for manual testing:
import
copy
import
json
import
logging
import
random
from
collections
import
OrderedDict
from
operator
import
itemgetter
...
...
@@ -232,10 +233,26 @@ class VideoModule(VideoFields, VideoTranscriptsMixin, VideoStudentViewHandlers,
track_url
,
transcript_language
,
sorted_languages
=
self
.
get_transcripts_for_student
()
# CDN_VIDEO_URLS is only to be used here and will be deleted
# TODO(ali@edx.org): Delete this after the CDN experiment has completed.
if
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
)
!=
''
and
\
self
.
system
.
user_location
==
'CN'
and
\
getattr
(
settings
,
'ENABLE_VIDEO_BEACON'
,
False
)
and
\
self
.
edx_video_id
in
getattr
(
settings
,
'CDN_VIDEO_URLS'
,
{})
.
keys
():
cdn_urls
=
getattr
(
settings
,
'CDN_VIDEO_URLS'
,
{})[
self
.
edx_video_id
]
cdn_exp_group
,
sources
[
0
]
=
random
.
choice
(
zip
(
range
(
len
(
cdn_urls
)),
cdn_urls
))
cdn_eval
=
True
else
:
cdn_eval
=
False
cdn_exp_group
=
None
return
self
.
system
.
render_template
(
'video.html'
,
{
'ajax_url'
:
self
.
system
.
ajax_url
+
'/save_user_state'
,
'autoplay'
:
settings
.
FEATURES
.
get
(
'AUTOPLAY_VIDEOS'
,
False
),
'branding_info'
:
branding_info
,
'cdn_eval'
:
cdn_eval
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
cdn_exp_group
,
# This won't work when we move to data that
# isn't on the filesystem
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
...
...
lms/djangoapps/courseware/tests/test_video_mongo.py
View file @
c7ebda8f
...
...
@@ -29,6 +29,9 @@ class TestVideoYouTube(TestVideo):
'ajax_url'
:
self
.
item_descriptor
.
xmodule_runtime
.
ajax_url
+
'/save_user_state'
,
'autoplay'
:
settings
.
FEATURES
.
get
(
'AUTOPLAY_VIDEOS'
,
False
),
'branding_info'
:
None
,
'cdn_eval'
:
False
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
None
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
'display_name'
:
u'A Name'
,
'end'
:
3610.0
,
...
...
@@ -93,6 +96,9 @@ class TestVideoNonYouTube(TestVideo):
expected_context
=
{
'ajax_url'
:
self
.
item_descriptor
.
xmodule_runtime
.
ajax_url
+
'/save_user_state'
,
'branding_info'
:
None
,
'cdn_eval'
:
False
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
None
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
'show_captions'
:
'true'
,
'handout'
:
None
,
...
...
@@ -197,6 +203,9 @@ class TestGetHtmlMethod(BaseTestXmodule):
expected_context
=
{
'branding_info'
:
None
,
'cdn_eval'
:
False
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
None
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
'show_captions'
:
'true'
,
'handout'
:
None
,
...
...
@@ -314,6 +323,9 @@ class TestGetHtmlMethod(BaseTestXmodule):
initial_context
=
{
'branding_info'
:
None
,
'cdn_eval'
:
False
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
None
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
'show_captions'
:
'true'
,
'handout'
:
None
,
...
...
@@ -454,6 +466,9 @@ class TestGetHtmlMethod(BaseTestXmodule):
# Video found for edx_video_id
initial_context
=
{
'branding_info'
:
None
,
'cdn_eval'
:
False
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
None
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
'show_captions'
:
'true'
,
'handout'
:
None
,
...
...
@@ -572,6 +587,9 @@ class TestGetHtmlMethod(BaseTestXmodule):
# Video found for edx_video_id
initial_context
=
{
'branding_info'
:
None
,
'cdn_eval'
:
False
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
None
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
'show_captions'
:
'true'
,
'handout'
:
None
,
...
...
@@ -691,6 +709,9 @@ class TestGetHtmlMethod(BaseTestXmodule):
'logo_tag'
:
'Video hosted by XuetangX.com'
,
'url'
:
'http://www.xuetangx.com'
},
'cdn_eval'
:
False
,
'cdn_eval_endpoint'
:
getattr
(
settings
,
'PERFORMANCE_GRAPHITE_URL'
,
''
),
'cdn_exp_group'
:
None
,
'data_dir'
:
getattr
(
self
,
'data_dir'
,
None
),
'show_captions'
:
'true'
,
'handout'
:
None
,
...
...
lms/templates/video.html
View file @
c7ebda8f
...
...
@@ -150,3 +150,28 @@
% endif
</ul>
</div>
% if cdn_eval:
<script>
function
sendMetricToGraphite
(
metricName
,
value
)
{
var
url
=
"${cdn_eval_endpoint}"
;
var
request
=
new
XMLHttpRequest
();
request
.
open
(
"POST"
,
url
,
true
);
// send asynchronously
request
.
send
(
metricName
+
" "
+
value
);
};
var
cdnStartTime
,
beaconSent
=
false
;
function
initializeCDNExperiment
()
{
cdnStartTime
=
Date
.
now
();
$
(
"#video_${id}"
).
bind
(
"html5:canplaythrough"
,
null
,
function
()
{
if
(
!
beaconSent
)
{
timeElapsed
=
Date
.
now
()
-
cdnStartTime
;
sendMetricToGraphite
(
"loadtime_${cdn_exp_group}"
,
timeElapsed
);
}
beaconSent
=
true
;
});
}
$
(
"#video_${id}"
).
bind
(
"initialize"
,
null
,
initializeCDNExperiment
);
if
(
$
(
"#video_${id}"
).
hasClass
(
"is-initialized"
))
{
initializeCDNExperiment
();
}
</script>
% endif;
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