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
46fe3561
Commit
46fe3561
authored
Jul 23, 2014
by
Oleg Marshev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use data dir from course.
parent
bf8183f6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
23 deletions
+25
-23
common/lib/xmodule/xmodule/video_module/video_handlers.py
+6
-6
lms/djangoapps/courseware/tests/test_video_handlers.py
+19
-17
No files found.
common/lib/xmodule/xmodule/video_module/video_handlers.py
View file @
46fe3561
...
@@ -11,7 +11,7 @@ from webob import Response
...
@@ -11,7 +11,7 @@ from webob import Response
from
xblock.core
import
XBlock
from
xblock.core
import
XBlock
from
xmodule.
course_module
import
CourseDescriptor
from
xmodule.
modulestore.django
import
modulestore
from
xmodule.exceptions
import
NotFoundError
from
xmodule.exceptions
import
NotFoundError
from
xmodule.fields
import
RelativeTime
from
xmodule.fields
import
RelativeTime
...
@@ -196,12 +196,12 @@ class VideoStudentViewHandlers(object):
...
@@ -196,12 +196,12 @@ class VideoStudentViewHandlers(object):
if
transcript_name
:
if
transcript_name
:
# Get the asset path for course
# Get the asset path for course
asset_path
=
None
asset_path
=
None
if
hasattr
(
self
.
descriptor
.
runtime
,
'modulestore'
):
course
=
self
.
descriptor
.
runtime
.
modulestore
.
get_course
(
self
.
course_id
)
course
=
self
.
descriptor
.
runtime
.
modulestore
.
get_course
(
self
.
course_id
)
if
course
.
static_asset_path
:
asset_path
=
course
.
static_asset_path
asset_path
=
course
.
static_asset_path
else
:
else
:
#
Handle XML Courses that don't have modulestore in the runtime
#
It seems static_asset_path is not set in any XMLModuleStore courses.
asset_path
=
getattr
(
self
.
descriptor
,
'data_dir'
,
None
)
asset_path
=
getattr
(
course
,
'data_dir'
,
''
)
if
asset_path
:
if
asset_path
:
response
=
Response
(
response
=
Response
(
...
@@ -251,7 +251,7 @@ class VideoStudentViewHandlers(object):
...
@@ -251,7 +251,7 @@ class VideoStudentViewHandlers(object):
try
:
try
:
transcript
=
self
.
translation
(
request
.
GET
.
get
(
'videoId'
,
None
))
transcript
=
self
.
translation
(
request
.
GET
.
get
(
'videoId'
,
None
))
except
NotFoundError
,
ex
:
except
(
TypeError
,
NotFoundError
)
as
ex
:
log
.
info
(
ex
.
message
)
log
.
info
(
ex
.
message
)
# Try to return static URL redirection as last resort
# Try to return static URL redirection as last resort
# if no translation is required
# if no translation is required
...
...
lms/djangoapps/courseware/tests/test_video_handlers.py
View file @
46fe3561
...
@@ -8,6 +8,7 @@ import textwrap
...
@@ -8,6 +8,7 @@ import textwrap
import
json
import
json
from
datetime
import
timedelta
from
datetime
import
timedelta
from
webob
import
Request
from
webob
import
Request
from
mock
import
MagicMock
,
Mock
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.content
import
StaticContent
from
xmodule.contentstore.django
import
contentstore
from
xmodule.contentstore.django
import
contentstore
...
@@ -23,7 +24,6 @@ from xmodule.video_module.transcripts_utils import (
...
@@ -23,7 +24,6 @@ from xmodule.video_module.transcripts_utils import (
TranscriptException
,
TranscriptException
,
TranscriptsGenerationException
,
TranscriptsGenerationException
,
)
)
from
opaque_keys.edx.locations
import
AssetLocation
SRT_content
=
textwrap
.
dedent
(
"""
SRT_content
=
textwrap
.
dedent
(
"""
0
0
...
@@ -401,16 +401,18 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
...
@@ -401,16 +401,18 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
response
=
self
.
item
.
transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
response
=
self
.
item
.
transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
self
.
assertDictEqual
(
json
.
loads
(
response
.
body
),
subs
)
self
.
assertDictEqual
(
json
.
loads
(
response
.
body
),
subs
)
def
test_translation_static_transcript
(
self
):
def
test_translation_static_transcript
_xml_with_data_dirc
(
self
):
"""
"""
Set course static_asset_path and ensure we get redirected to that path
Test id data_dir is set in XML course.
if it isn't found in the contentstore
Set course data_dir and ensure we get redirected to that path
if it isn't found in the contentstore.
"""
"""
self
.
course
.
static_asset_path
=
'dummy/static'
# Simulate data_dir set in course.
self
.
course
.
save
()
test_modulestore
=
MagicMock
()
store
=
modulestore
()
attrs
=
{
'get_course.return_value'
:
Mock
(
data_dir
=
'dummy/static'
,
static_asset_path
=
''
)}
with
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
self
.
course
.
id
):
test_modulestore
.
configure_mock
(
**
attrs
)
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
self
.
item_descriptor
.
runtime
.
modulestore
=
test_modulestore
# Test youtube style en
# Test youtube style en
request
=
Request
.
blank
(
'/translation/en?videoId=12345'
)
request
=
Request
.
blank
(
'/translation/en?videoId=12345'
)
...
@@ -437,16 +439,16 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
...
@@ -437,16 +439,16 @@ class TestTranscriptTranslationGetDispatch(TestVideo):
response
=
self
.
item
.
transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
response
=
self
.
item
.
transcript
(
request
=
request
,
dispatch
=
'translation/uk'
)
self
.
assertEqual
(
response
.
status
,
'404 Not Found'
)
self
.
assertEqual
(
response
.
status
,
'404 Not Found'
)
def
test_
xml
_transcript
(
self
):
def
test_
translation_static
_transcript
(
self
):
"""
"""
Set
data_dir and remove runtime modulestore to simulate an XMLModuelStore course.
Set
course static_asset_path and ensure we get redirected to that path
Then run the same tests as static_asset_path run.
if it isn't found in the contentstore
"""
"""
# Simulate XMLModuleStore xmodule
self
.
course
.
static_asset_path
=
'dummy/static'
self
.
item_descriptor
.
data_dir
=
'dummy/static'
self
.
course
.
save
()
del
self
.
item_descriptor
.
runtime
.
modulestore
store
=
modulestore
()
with
store
.
branch_setting
(
ModuleStoreEnum
.
Branch
.
draft_preferred
,
self
.
course
.
id
):
self
.
assertFalse
(
self
.
course
.
static_asset_path
)
store
.
update_item
(
self
.
course
,
self
.
user
.
id
)
# Test youtube style en
# Test youtube style en
request
=
Request
.
blank
(
'/translation/en?videoId=12345'
)
request
=
Request
.
blank
(
'/translation/en?videoId=12345'
)
...
...
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