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
4b148f9a
Commit
4b148f9a
authored
Feb 08, 2013
by
Alexander Kryklia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
working import
parent
2625d7cb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
5 deletions
+22
-5
common/lib/xmodule/xmodule/conditional_module.py
+22
-5
No files found.
common/lib/xmodule/xmodule/conditional_module.py
View file @
4b148f9a
...
@@ -32,6 +32,7 @@ class ConditionalModule(XModule):
...
@@ -32,6 +32,7 @@ class ConditionalModule(XModule):
# xml_object = String(scope=Scope.content)
# xml_object = String(scope=Scope.content)
contents
=
String
(
scope
=
Scope
.
content
)
contents
=
String
(
scope
=
Scope
.
content
)
show_modules
=
String
(
scope
=
Scope
.
content
)
def
_get_required_modules
(
self
):
def
_get_required_modules
(
self
):
self
.
required_modules
=
[]
self
.
required_modules
=
[]
...
@@ -84,6 +85,16 @@ class ConditionalModule(XModule):
...
@@ -84,6 +85,16 @@ class ConditionalModule(XModule):
'ajax_url'
:
self
.
system
.
ajax_url
,
'ajax_url'
:
self
.
system
.
ajax_url
,
})
})
def
_get_modules_to_show
(
self
):
to_show
=
[
tuple
(
x
.
strip
()
.
split
(
'/'
,
1
))
for
x
in
self
.
show_modules
.
split
(
';'
)]
self
.
modules_to_show
=
[]
for
(
tag
,
name
)
in
to_show
:
loc
=
self
.
location
.
dict
()
loc
[
'category'
]
=
tag
loc
[
'name'
]
=
name
self
.
modules_to_show
.
append
(
Location
(
loc
))
def
handle_ajax
(
self
,
dispatch
,
post
):
def
handle_ajax
(
self
,
dispatch
,
post
):
'''
'''
This is called by courseware.moduleodule_render, to handle an AJAX call.
This is called by courseware.moduleodule_render, to handle an AJAX call.
...
@@ -98,9 +109,11 @@ class ConditionalModule(XModule):
...
@@ -98,9 +109,11 @@ class ConditionalModule(XModule):
if
self
.
contents
is
None
:
if
self
.
contents
is
None
:
import
ipdb
;
ipdb
.
set_trace
()
import
ipdb
;
ipdb
.
set_trace
()
# self.contents = [child.get_html() for child in self.get_display_items()]
# self.contents = [child.get_html() for child in self.get_display_items()]
self
.
contents
=
[
self
.
system
.
get_module
(
child_descriptor
.
location
)
.
get_html
()
self
.
contents
=
[
self
.
system
.
get_module
(
x
)
.
get_html
()
for
x
in
self
.
modules_to_show
]
self
.
contents
+=
[
self
.
system
.
get_module
(
child_descriptor
.
location
)
.
get_html
()
for
child_descriptor
in
self
.
descriptor
.
get_children
()]
for
child_descriptor
in
self
.
descriptor
.
get_children
()]
html
=
self
.
contents
html
=
self
.
contents
#log.debug('rendered conditional module %s' % str(self.location))
#log.debug('rendered conditional module %s' % str(self.location))
return
json
.
dumps
({
'html'
:
html
})
return
json
.
dumps
({
'html'
:
html
})
...
@@ -114,16 +127,19 @@ class ConditionalDescriptor(SequenceDescriptor):
...
@@ -114,16 +127,19 @@ class ConditionalDescriptor(SequenceDescriptor):
stores_state
=
True
stores_state
=
True
has_score
=
False
has_score
=
False
show_modules
=
String
(
scope
=
Scope
.
content
)
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
(
ConditionalDescriptor
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
super
(
ConditionalDescriptor
,
self
)
.
__init__
(
*
args
,
**
kwargs
)
# import ipdb; ipdb.set_trace()
# import ipdb; ipdb.set_trace()
required_module_list
=
[
tuple
(
x
.
strip
()
.
split
(
'/'
,
1
))
for
x
in
self
.
xml_attributes
.
get
(
'required
'
,
''
)
.
split
(
';'
)]
required_module_list
=
[
(
x
.
strip
()
.
split
(
'/'
,
5
)[
4
:
6
])
for
x
in
self
.
xml_attributes
.
get
(
'source
'
,
''
)
.
split
(
';'
)]
self
.
required_module_locations
=
[]
self
.
required_module_locations
=
[]
for
(
tag
,
name
)
in
required_module_list
:
for
(
tag
,
name
)
in
required_module_list
:
loc
=
self
.
location
.
dict
()
loc
=
self
.
location
.
dict
()
loc
[
'category'
]
=
tag
loc
[
'category'
]
=
tag
loc
[
'name'
]
=
name
loc
[
'name'
]
=
name
self
.
required_module_locations
.
append
(
Location
(
loc
))
self
.
required_module_locations
.
append
(
Location
(
loc
))
# import ipdb; ipdb.set_trace()
log
.
debug
(
'ConditionalDescriptor required_module_locations=
%
s'
%
self
.
required_module_locations
)
log
.
debug
(
'ConditionalDescriptor required_module_locations=
%
s'
%
self
.
required_module_locations
)
def
get_required_module_descriptors
(
self
):
def
get_required_module_descriptors
(
self
):
...
@@ -133,9 +149,9 @@ class ConditionalDescriptor(SequenceDescriptor):
...
@@ -133,9 +149,9 @@ class ConditionalDescriptor(SequenceDescriptor):
@classmethod
@classmethod
def
definition_from_xml
(
cls
,
xml_object
,
system
):
def
definition_from_xml
(
cls
,
xml_object
,
system
):
# import ipdb; ipdb.set_trace()
children
=
[]
children
=
[]
for
child
in
xml_object
:
for
child
in
xml_object
:
if
child
.
tag
!=
'show'
:
try
:
try
:
children
.
append
(
system
.
process_xml
(
etree
.
tostring
(
child
))
.
location
.
url
())
children
.
append
(
system
.
process_xml
(
etree
.
tostring
(
child
))
.
location
.
url
())
except
Exception
,
e
:
except
Exception
,
e
:
...
@@ -143,8 +159,9 @@ class ConditionalDescriptor(SequenceDescriptor):
...
@@ -143,8 +159,9 @@ class ConditionalDescriptor(SequenceDescriptor):
if
system
.
error_tracker
is
not
None
:
if
system
.
error_tracker
is
not
None
:
system
.
error_tracker
(
"ERROR: "
+
str
(
e
))
system
.
error_tracker
(
"ERROR: "
+
str
(
e
))
continue
continue
# import ipdb; ipdb.set_trace()
else
:
return
{},
children
cls
.
show_modules
=
child
.
get
(
'source'
)
return
{
'show_modules'
:
''
},
children
def
definition_to_xml
(
self
,
resource_fs
):
def
definition_to_xml
(
self
,
resource_fs
):
xml_object
=
etree
.
Element
(
'sequential'
)
xml_object
=
etree
.
Element
(
'sequential'
)
...
...
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