Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
problem-builder
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
OpenEdx
problem-builder
Commits
76bf8031
Commit
76bf8031
authored
Oct 02, 2014
by
Jonathan Piacenti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Provide a path for default xml to load upon creation.
parent
b59e5e4f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
5 deletions
+17
-5
mentoring/light_children.py
+14
-3
mentoring/mentoring.py
+3
-2
No files found.
mentoring/light_children.py
View file @
76bf8031
...
@@ -55,6 +55,16 @@ from .utils import XBlockWithChildrenFragmentsMixin
...
@@ -55,6 +55,16 @@ from .utils import XBlockWithChildrenFragmentsMixin
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
def
get_xml_content
(
block
):
"""
Because we get the XML content dynamically, we can't use the String field's
default kwarg to fall back on. Therefore any time we need to access the
xml_content's value, we need to do it through this function.
"""
default
=
getattr
(
block
,
'default_xml_content'
,
''
)
value
=
getattr
(
block
,
'xml_content'
,
''
)
return
value
or
default
# Classes ###########################################################
# Classes ###########################################################
class
LightChildrenMixin
(
XBlockWithChildrenFragmentsMixin
):
class
LightChildrenMixin
(
XBlockWithChildrenFragmentsMixin
):
...
@@ -83,7 +93,7 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
...
@@ -83,7 +93,7 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
log
.
debug
(
'parse_xml called'
)
log
.
debug
(
'parse_xml called'
)
block
=
runtime
.
construct_xblock_from_class
(
cls
,
keys
)
block
=
runtime
.
construct_xblock_from_class
(
cls
,
keys
)
cls
.
init_block_from_node
(
block
,
node
,
node
.
items
())
cls
.
init_block_from_node
(
block
,
node
,
node
.
items
())
block
.
xml_content
=
get
attr
(
block
,
'xml_content'
,
''
)
or
etree
.
tostring
(
node
)
block
.
xml_content
=
get
_xml_content
(
block
)
or
etree
.
tostring
(
node
)
return
block
return
block
@classmethod
@classmethod
...
@@ -126,11 +136,12 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
...
@@ -126,11 +136,12 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
Load light children from the `xml_content` attribute
Load light children from the `xml_content` attribute
"""
"""
self
.
light_children
=
[]
self
.
light_children
=
[]
if
not
hasattr
(
self
,
'xml_content'
)
or
not
self
.
xml_content
:
xml_content
=
get_xml_content
(
self
)
if
not
xml_content
:
return
return
parser
=
etree
.
XMLParser
(
remove_comments
=
True
)
parser
=
etree
.
XMLParser
(
remove_comments
=
True
)
node
=
etree
.
parse
(
StringIO
(
self
.
xml_content
),
parser
=
parser
)
.
getroot
()
node
=
etree
.
parse
(
StringIO
(
xml_content
),
parser
=
parser
)
.
getroot
()
LightChildrenMixin
.
init_block_from_node
(
self
,
node
,
node
.
items
())
LightChildrenMixin
.
init_block_from_node
(
self
,
node
,
node
.
items
())
def
get_children_objects
(
self
):
def
get_children_objects
(
self
):
...
...
mentoring/mentoring.py
View file @
76bf8031
...
@@ -33,7 +33,7 @@ from xblock.core import XBlock
...
@@ -33,7 +33,7 @@ from xblock.core import XBlock
from
xblock.fields
import
Boolean
,
Scope
,
String
,
Integer
,
Float
,
List
from
xblock.fields
import
Boolean
,
Scope
,
String
,
Integer
,
Float
,
List
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
.light_children
import
XBlockWithLightChildren
from
.light_children
import
XBlockWithLightChildren
,
get_xml_content
from
.title
import
TitleBlock
from
.title
import
TitleBlock
from
.header
import
SharedHeaderBlock
from
.header
import
SharedHeaderBlock
from
.html
import
HTMLBlock
from
.html
import
HTMLBlock
...
@@ -71,6 +71,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
...
@@ -71,6 +71,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
enforce_dependency
=
Boolean
(
help
=
"Should the next step be the current block to complete?"
,
enforce_dependency
=
Boolean
(
help
=
"Should the next step be the current block to complete?"
,
default
=
False
,
scope
=
Scope
.
content
,
enforce_type
=
True
)
default
=
False
,
scope
=
Scope
.
content
,
enforce_type
=
True
)
display_submit
=
Boolean
(
help
=
"Allow to submit current block?"
,
default
=
True
,
scope
=
Scope
.
content
)
display_submit
=
Boolean
(
help
=
"Allow to submit current block?"
,
default
=
True
,
scope
=
Scope
.
content
)
# See get_xml_content from light_children.
xml_content
=
String
(
help
=
"XML content"
,
default
=
''
,
scope
=
Scope
.
content
)
xml_content
=
String
(
help
=
"XML content"
,
default
=
''
,
scope
=
Scope
.
content
)
weight
=
Float
(
help
=
"Defines the maximum total grade of the block."
,
weight
=
Float
(
help
=
"Defines the maximum total grade of the block."
,
default
=
1
,
scope
=
Scope
.
content
,
enforce_type
=
True
)
default
=
1
,
scope
=
Scope
.
content
,
enforce_type
=
True
)
...
@@ -373,7 +374,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
...
@@ -373,7 +374,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
fragment
=
Fragment
()
fragment
=
Fragment
()
fragment
.
add_content
(
render_template
(
'templates/html/mentoring_edit.html'
,
{
fragment
.
add_content
(
render_template
(
'templates/html/mentoring_edit.html'
,
{
'self'
:
self
,
'self'
:
self
,
'xml_content'
:
self
.
xml_content
or
self
.
default_xml_content
,
'xml_content'
:
get_xml_content
(
self
)
}))
}))
fragment
.
add_javascript_url
(
fragment
.
add_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring_edit.js'
))
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring_edit.js'
))
...
...
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