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
ef1c465d
Commit
ef1c465d
authored
Jan 23, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Video module set up to store last location. Several bug fixes too.
parent
d989621b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
16 deletions
+27
-16
courseware/content_parser.py
+3
-1
courseware/module_render.py
+1
-1
courseware/modules/video_module.py
+23
-14
No files found.
courseware/content_parser.py
View file @
ef1c465d
...
...
@@ -79,7 +79,9 @@ def id_tag(course):
if
elem
.
get
(
'id'
):
pass
elif
elem
.
get
(
default_ids
[
elem
.
tag
]):
elem
.
set
(
'id'
,
elem
.
get
(
default_ids
[
elem
.
tag
]))
new_id
=
elem
.
get
(
default_ids
[
elem
.
tag
])
# Convert to alphanumeric
new_id
=
""
.
join
([
a
for
a
in
new_id
if
a
.
isalnum
()])
elem
.
set
(
'id'
,
new_id
)
else
:
elem
.
set
(
'id'
,
fasthash
(
etree
.
tostring
(
elem
)))
...
...
courseware/module_render.py
View file @
ef1c465d
...
...
@@ -94,7 +94,7 @@ def render_x_module(request, xml_module):
# Check if problem has an instance in DB
module_type
=
xml_module
.
tag
module_class
=
modx_modules
[
module_type
]
module_id
=
xml_module
.
get
(
module_class
.
id_attribute
)
or
""
# TODO: remove or ""
module_id
=
xml_module
.
get
(
'id'
)
#module_class.id_attribute) or ""
# Grab state from database
s
=
StudentModule
.
objects
.
filter
(
student
=
request
.
user
,
...
...
courseware/modules/video_module.py
View file @
ef1c465d
from
x_module
import
XModule
from
lxml
import
etree
import
json
...
...
@@ -7,47 +8,55 @@ from django.conf import settings
from
djangomako.shortcuts
import
render_to_response
,
render_to_string
class
VideoModule
(
XModule
):
id_attribute
=
'youtube'
#
id_attribute = 'youtube'
video_time
=
0
def
handle_ajax
(
self
,
dispatch
,
get
):
if
dispatch
==
'time'
:
self
.
video_time
=
int
(
get
[
'time'
])
print
self
.
video_time
return
json
.
dumps
(
"True"
)
print
"GET"
,
get
print
"DISPATCH"
,
dispatch
if
dispatch
==
'goto_position'
:
self
.
position
=
int
(
float
(
get
[
'position'
]))
print
"NEW POSITION"
,
self
.
position
return
json
.
dumps
({
'success'
:
True
})
raise
Http404
()
def
get_state
(
self
):
return
json
.
dumps
({
'time'
:
self
.
video_time
})
print
"STATE POSITION"
,
self
.
position
return
json
.
dumps
({
'position'
:
self
.
position
})
def
get_xml_tags
():
''' Tags in the courseware file guaranteed to correspond to the module '''
return
"video"
def
video_list
(
self
):
l
=
self
.
item_id
.
split
(
','
)
l
=
self
.
youtube
.
split
(
','
)
l
=
[
i
.
split
(
":"
)
for
i
in
l
]
return
json
.
dumps
(
dict
(
l
))
def
get_html
(
self
):
return
render_to_string
(
'video.html'
,{
'streams'
:
self
.
video_list
(),
'id'
:
self
.
item_id
,
'
video_time'
:
self
.
video_time
})
'
position'
:
self
.
position
})
def
get_init_js
(
self
):
''' JavaScript code to be run when problem is shown. Be aware
that this may happen several times on the same page
(e.g. student switching tabs). Common functions should be put
in the main course .js files for now. '''
print
"INIT POSITION"
,
self
.
position
return
render_to_string
(
'video_init.js'
,{
'streams'
:
self
.
video_list
(),
'id'
:
self
.
item_id
,
'
video_time'
:
self
.
video_time
})
'
position'
:
self
.
position
})
def
get_destroy_js
(
self
):
return
"videoDestroy();"
return
"videoDestroy(
\"
"
+
self
.
item_id
+
"
\"
);"
def
__init__
(
self
,
xml
,
item_id
,
ajax_url
=
None
,
track_url
=
None
,
state
=
None
,
track_function
=
None
,
render_function
=
None
,
meta
=
None
):
XModule
.
__init__
(
self
,
xml
,
item_id
,
ajax_url
,
track_url
,
state
,
track_function
,
render_function
)
print
state
if
state
!=
None
and
"time"
not
in
json
.
loads
(
state
):
self
.
video_time
=
0
self
.
youtube
=
etree
.
XML
(
xml
)
.
get
(
'youtube'
)
self
.
position
=
0
if
state
!=
None
:
state
=
json
.
loads
(
state
)
if
'position'
in
state
:
self
.
position
=
int
(
float
(
state
[
'position'
]))
print
"POOSITION IN STATE"
print
"LOAD POSITION"
,
self
.
position
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