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
acafd3f6
Commit
acafd3f6
authored
Jan 23, 2012
by
Piotr Mitros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Nasty bug fixes in when we can render. Need to apply to vertical too
parent
f3eb22e0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
20 deletions
+31
-20
courseware/module_render.py
+2
-2
courseware/modules/seq_module.py
+29
-18
No files found.
courseware/module_render.py
View file @
acafd3f6
...
...
@@ -30,7 +30,7 @@ import urllib
from
django.conf
import
settings
import
courseware.content_parser
import
courseware.content_parser
as
content_parser
import
sys
...
...
@@ -79,7 +79,7 @@ def modx_dispatch(request, module=None, dispatch=None, id=None):
id_tag
=
modx_modules
[
module
]
.
id_attribute
# Grab the XML corresponding to the request from course.xml
xml
=
co
urseware
.
co
ntent_parser
.
module_xml
(
content_parser
.
course_file
(
request
.
user
),
module
,
id_tag
,
id
)
xml
=
content_parser
.
module_xml
(
content_parser
.
course_file
(
request
.
user
),
module
,
id_tag
,
id
)
# Create the module
instance
=
modx_modules
[
module
](
xml
,
...
...
courseware/modules/seq_module.py
View file @
acafd3f6
...
...
@@ -20,12 +20,15 @@ class SequentialModule(XModule):
return
[
"sequential"
,
'tab'
]
def
get_html
(
self
):
self
.
render
()
return
self
.
content
def
get_init_js
(
self
):
self
.
render
()
return
self
.
init_js
def
get_destroy_js
(
self
):
self
.
render
()
return
self
.
destroy_js
def
handle_ajax
(
self
,
dispatch
,
get
):
...
...
@@ -36,16 +39,9 @@ class SequentialModule(XModule):
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
):
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
render
(
self
):
if
self
.
rendered
:
return
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
...
...
@@ -60,13 +56,13 @@ class SequentialModule(XModule):
'init_js'
:
m
[
'init_js'
],
'type'
:
m
[
'type'
]}
contents
=
[(
e
.
get
(
"name"
),
j
(
render_function
(
e
)))
\
for
e
in
xmltree
]
self
.
contents
=
[(
e
.
get
(
"name"
),
j
(
self
.
render_function
(
e
)))
\
for
e
in
self
.
xmltree
]
js
=
""
params
=
{
'items'
:
contents
,
'id'
:
item_id
,
params
=
{
'items'
:
self
.
contents
,
'id'
:
self
.
item_id
,
'position'
:
self
.
position
}
# TODO/BUG: Destroy JavaScript should only be called for the active view
...
...
@@ -74,14 +70,29 @@ class SequentialModule(XModule):
#
# To fix this, we'd probably want to have some way of assigning unique
# IDs to sequences.
destroy_js
=
""
.
join
([
e
[
1
][
'destroy_js'
]
for
e
in
contents
if
'destroy_js'
in
e
[
1
]])
if
xmltree
.
tag
==
'sequential'
:
destroy_js
=
""
.
join
([
e
[
1
][
'destroy_js'
]
for
e
in
self
.
contents
if
'destroy_js'
in
e
[
1
]])
if
self
.
xmltree
.
tag
==
'sequential'
:
self
.
init_js
=
js
+
render_to_string
(
'seq_module.js'
,
params
)
self
.
destroy_js
=
destroy_js
self
.
content
=
render_to_string
(
'seq_module.html'
,
params
)
if
xmltree
.
tag
==
'tab'
:
if
self
.
xmltree
.
tag
==
'tab'
:
params
[
'id'
]
=
'tab'
self
.
init_js
=
js
+
render_to_string
(
'tab_module.js'
,
params
)
self
.
destroy_js
=
destroy_js
self
.
content
=
render_to_string
(
'tab_module.html'
,
params
)
self
.
rendered
=
True
def
__init__
(
self
,
xml
,
item_id
,
ajax_url
=
None
,
track_url
=
None
,
state
=
None
,
track_function
=
None
,
render_function
=
None
):
XModule
.
__init__
(
self
,
xml
,
item_id
,
ajax_url
,
track_url
,
state
,
track_function
,
render_function
)
self
.
xmltree
=
etree
.
fromstring
(
xml
)
self
.
position
=
1
if
state
!=
None
:
state
=
json
.
loads
(
state
)
if
'position'
in
state
:
self
.
position
=
int
(
state
[
'position'
])
self
.
rendered
=
False
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