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
d989621b
Commit
d989621b
authored
Jan 21, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Series remembers last spot
parent
29d23d15
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
5 deletions
+25
-5
courseware/content_parser.py
+1
-1
courseware/module_render.py
+6
-2
courseware/modules/seq_module.py
+18
-2
No files found.
courseware/content_parser.py
View file @
d989621b
...
...
@@ -18,7 +18,7 @@ TODO: Shift everything from xml.dom.minidom to XPath (or XQuery)
def
fasthash
(
string
):
m
=
hashlib
.
new
(
"md4"
)
m
.
update
(
string
)
return
m
.
hexdigest
()
return
"id"
+
m
.
hexdigest
()
def
xpath
(
xml
,
query_string
,
**
args
):
''' Safe xpath query into an xml tree:
...
...
courseware/module_render.py
View file @
d989621b
...
...
@@ -52,11 +52,12 @@ def make_track_function(request):
def
modx_dispatch
(
request
,
module
=
None
,
dispatch
=
None
,
id
=
None
):
''' Generic view for extensions. '''
# Grab the student information for the module from the database
print
module
,
request
.
user
,
id
s
=
StudentModule
.
objects
.
filter
(
module_type
=
module
,
student
=
request
.
user
,
module_id
=
id
)
if
len
(
s
)
==
0
:
print
"ls404"
print
"ls404"
,
module
,
request
.
user
,
id
raise
Http404
s
=
s
[
0
]
...
...
@@ -75,11 +76,14 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
s
.
module_id
,
ajax_url
=
ajax_url
,
state
=
s
.
state
,
track_function
=
make_track_function
(
request
))
track_function
=
make_track_function
(
request
),
render_function
=
render_module
,
meta
=
request
)
# Let the module handle the AJAX
ajax_return
=
instance
.
handle_ajax
(
dispatch
,
request
.
POST
)
# Save the state back to the database
s
.
state
=
instance
.
get_state
()
if
instance
.
get_score
()
!=
None
:
s
.
grade
=
instance
.
get_score
()[
'score'
]
s
.
save
()
# Return whatever the module wanted to return to the client/caller
...
...
courseware/modules/seq_module.py
View file @
d989621b
from
x_module
import
XModule
from
lxml
import
etree
from
django.http
import
Http404
import
json
...
...
@@ -13,7 +14,7 @@ class SequentialModule(XModule):
id_attribute
=
'id'
def
get_state
(
self
):
return
json
.
dumps
({
})
return
json
.
dumps
({
'position'
:
self
.
position
})
def
get_xml_tags
():
return
[
"sequential"
,
'tab'
]
...
...
@@ -27,10 +28,24 @@ class SequentialModule(XModule):
def
get_destroy_js
(
self
):
return
self
.
destroy_js
def
handle_ajax
(
self
,
dispatch
,
get
):
print
"GET"
,
get
print
"DISPATCH"
,
dispatch
if
dispatch
==
'goto_position'
:
self
.
position
=
int
(
get
[
'position'
])
return
json
.
dumps
({
'success'
:
True
})
raise
Http404
()
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
)
xmltree
=
etree
.
fromstring
(
xml
)
self
.
position
=
1
if
state
!=
None
:
state
=
json
.
loads
(
state
)
if
'position'
in
state
:
self
.
position
=
int
(
state
[
'position'
])
def
j
(
m
):
''' jsonify contents so it can be embedded in a js array
We also need to split </script> tags so they don't break
...
...
@@ -51,7 +66,8 @@ class SequentialModule(XModule):
js
=
""
params
=
{
'items'
:
contents
,
'id'
:
"seq"
}
'id'
:
item_id
,
'position'
:
self
.
position
}
# TODO/BUG: Destroy JavaScript should only be called for the active view
# This calls it for all the views
...
...
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