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
f9b825fe
Commit
f9b825fe
authored
Jun 11, 2013
by
Peter Fogg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix failing acceptance tests and allow videos to be imported from XML.
parent
115ae42b
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
50 deletions
+61
-50
cms/djangoapps/contentstore/features/video-editor.py
+3
-4
common/lib/xmodule/xmodule/video_module.py
+57
-45
common/test/data/toy/chapter/secret/magic.xml
+1
-1
No files found.
cms/djangoapps/contentstore/features/video-editor.py
View file @
f9b825fe
...
@@ -9,9 +9,8 @@ def i_see_the_correct_settings_and_values(step):
...
@@ -9,9 +9,8 @@ def i_see_the_correct_settings_and_values(step):
world
.
verify_all_setting_entries
([[
'.75x'
,
'JMD_ifUUfsU'
,
False
],
world
.
verify_all_setting_entries
([[
'.75x'
,
'JMD_ifUUfsU'
,
False
],
[
'1.25x'
,
'AKqURZnYqpk'
,
False
],
[
'1.25x'
,
'AKqURZnYqpk'
,
False
],
[
'1.5x'
,
'DYpADpL7jAY'
,
False
],
[
'1.5x'
,
'DYpADpL7jAY'
,
False
],
[
'Display Name'
,
"default"
,
True
],
[
'Display Name'
,
'default'
,
True
],
[
'External Source'
,
''
,
False
],
[
'External Track'
,
''
,
False
],
[
'Normal Speed'
,
'OEoXaMPEzfM'
,
False
],
[
'Normal Speed'
,
'OEoXaMPEzfM'
,
False
],
[
'Show Captions'
,
'True'
,
False
],
[
'Show Captions'
,
'True'
,
False
],
])
[
'Source'
,
''
,
False
],
[
'Track'
,
''
,
False
]])
common/lib/xmodule/xmodule/video_module.py
View file @
f9b825fe
...
@@ -13,8 +13,6 @@ from xblock.core import Integer, Scope, String, Boolean, Float
...
@@ -13,8 +13,6 @@ from xblock.core import Integer, Scope, String, Boolean, Float
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
YOUTUBE_SPEEDS
=
[
'.75'
,
'1.0'
,
'1.25'
,
'1.5'
]
class
VideoFields
(
object
):
class
VideoFields
(
object
):
position
=
Integer
(
help
=
"Current position in the video"
,
scope
=
Scope
.
user_state
,
default
=
0
)
position
=
Integer
(
help
=
"Current position in the video"
,
scope
=
Scope
.
user_state
,
default
=
0
)
...
@@ -91,13 +89,7 @@ class VideoModule(VideoFields, XModule):
...
@@ -91,13 +89,7 @@ class VideoModule(VideoFields, XModule):
'end'
:
self
.
end_time
'end'
:
self
.
end_time
})
})
# TODO: (pfogg) I am highly uncertain about inheriting from
# RawDescriptor for the xml-related methods. This makes LMS unit tests
# pass, but this really shouldn't be a RawDescriptor if users can't
# see raw xml.
# also if it's just return super(...)... then we can just remove these methods, ha
class
VideoDescriptor
(
VideoFields
,
class
VideoDescriptor
(
VideoFields
,
MetadataOnlyEditingDescriptor
,
MetadataOnlyEditingDescriptor
,
RawDescriptor
):
RawDescriptor
):
...
@@ -124,42 +116,62 @@ class VideoDescriptor(VideoFields,
...
@@ -124,42 +116,62 @@ class VideoDescriptor(VideoFields,
org and course are optional strings that will be used in the generated modules
org and course are optional strings that will be used in the generated modules
url identifiers
url identifiers
"""
"""
return
super
(
RawDescriptor
,
cls
)
.
from_xml
(
xml_data
,
system
,
org
,
course
)
video
=
super
(
RawDescriptor
,
cls
)
.
from_xml
(
xml_data
,
system
,
org
,
course
)
xml
=
etree
.
fromstring
(
xml_data
)
def
export_to_xml
(
self
,
resource_fs
):
video
.
display_name
=
xml
.
get
(
'display_name'
)
"""
youtube
=
xml
.
get
(
'youtube'
)
Returns an xml string representign this module, and all modules
if
youtube
:
underneath it. May also write required resources out to resource_fs
speeds
=
_parse_youtube
(
youtube
)
if
speeds
[
'0.75'
]:
Assumes that modules have single parentage (that no module appears twice
video
.
youtube_id_0_75
=
speeds
[
'0.75'
]
in the same course), and that it is thus safe to nest modules as xml
if
speeds
[
'1.00'
]:
children as appropriate.
video
.
youtube_id_1_0
=
speeds
[
'1.00'
]
if
speeds
[
'1.25'
]:
video
.
youtube_id_1_25
=
speeds
[
'1.25'
]
if
speeds
[
'1.50'
]:
video
.
youtube_id_1_5
=
speeds
[
'1.50'
]
video
.
show_captions
=
True
if
xml
.
get
(
'show_captions'
)
==
'true'
else
False
source
=
_get_first_external
(
xml
,
'source'
)
if
source
:
video
.
source
=
source
tag
=
_get_first_external
(
xml
,
'tag'
)
if
tag
:
video
.
tag
=
tag
start_time
=
xml
.
get
(
'from'
)
if
start_time
:
video
.
start_time
=
start_time
end_time
=
xml
.
get
(
'to'
)
if
end_time
:
video
.
end_time
=
end_time
return
video
def
_get_first_external
(
xmltree
,
tag
):
'''
Returns the src attribute of the nested `tag` in `xmltree`, if it
exists.
'''
for
element
in
xmltree
.
findall
(
tag
):
src
=
element
.
get
(
'src'
)
if
src
:
return
src
return
None
The returned XML should be able to be parsed back into an identical
XModuleDescriptor using the from_xml method with the same system, org,
and course
resource_fs is a pyfilesystem object (from the fs package)
def
_parse_youtube
(
data
):
"""
'''
return
super
(
RawDescriptor
,
self
)
.
export_to_xml
(
resource_fs
)
Parses a string of Youtube IDs into a dictionary.
# xml = etree.Element('video')
'''
# xml.set('youtube', self.video_list())
ret
=
{
'0.75'
:
None
,
'1.00'
:
None
,
'1.25'
:
None
,
'1.50'
:
None
}
# xml.set('show_captions', self.show_captions)
videos
=
data
.
split
(
','
)
# xml.set('from', self.start_time)
for
video
in
videos
:
# xml.set('to', self.end_time)
pieces
=
video
.
split
(
':'
)
# HACK
# source_tag = etree.SubElement(xml, 'source')
# To elaborate somewhat: in many LMS tests, the keys for
# source_tag.set('src', self.source)
# Youtube IDs are inconsistent. Sometimes a particular
# speed isn't present, and formatting is also inconsistent
# track_tag = etree.SubElement(xml, 'track')
# ('1.0' versus '1.00'). So it's necessary to either do
# track_tag.set('src', self.track)
# something like this or update all the tests to work
# properly.
# return etree.tostring(xml, pretty_print=True, encoding='utf-8')
ret
[
'
%.2
f'
%
float
(
pieces
[
0
])]
=
pieces
[
1
]
return
ret
# def video_list(self):
# videos = [self.youtube_id_0_75, self.youtube_id_1_0,
# self.youtube_id_1_25, self.youtube_id_1_5]
# streams = [':'.join((video, youtube_id))
# for video, youtube_id
# in zip(YOUTUBE_SPEEDS, videos)]
# return ','.join(streams)
common/test/data/toy/chapter/secret/magic.xml
View file @
f9b825fe
<chapter>
<chapter>
<video
url_name=
"toyvideo"
youtube=
"
blahblah
"
/>
<video
url_name=
"toyvideo"
youtube=
"
1.00:OEoXaMPEzfM
"
/>
</chapter>
</chapter>
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