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
cb569289
Commit
cb569289
authored
Feb 27, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes TODOs
parent
390e447e
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
22 deletions
+29
-22
mentoring/html.py
+5
-3
mentoring/light_children.py
+17
-12
mentoring/message.py
+1
-0
mentoring/quizz.py
+1
-1
mentoring/table.py
+5
-6
No files found.
mentoring/html.py
View file @
cb569289
...
@@ -25,6 +25,8 @@
...
@@ -25,6 +25,8 @@
import
logging
import
logging
from
lxml
import
etree
from
xblock.fragment
import
Fragment
from
xblock.fragment
import
Fragment
from
.light_children
import
LightChild
,
Scope
,
String
from
.light_children
import
LightChild
,
Scope
,
String
...
@@ -46,9 +48,9 @@ class HTMLBlock(LightChild):
...
@@ -46,9 +48,9 @@ class HTMLBlock(LightChild):
@classmethod
@classmethod
def
init_block_from_node
(
cls
,
block
,
node
,
attr
):
def
init_block_from_node
(
cls
,
block
,
node
,
attr
):
block
.
light_children
=
[]
block
.
light_children
=
[]
# TODO-LIGHT-CHILDREN: get real value from `node` (lxml)
node
.
tag
=
'div'
block
.
content
=
'<div>Placeholder HTML content</div>'
block
.
content
=
etree
.
tostring
(
node
)
return
block
return
block
...
...
mentoring/light_children.py
View file @
cb569289
...
@@ -40,13 +40,6 @@ from .utils import XBlockWithChildrenFragmentsMixin
...
@@ -40,13 +40,6 @@ from .utils import XBlockWithChildrenFragmentsMixin
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
# Functions #########################################################
def
node_to_xml
(
node
):
# TODO-LIGHT-CHILDREN
return
'<mentoring><html>Hello</html><answer name="test1" /></mentoring>'
# Classes ###########################################################
# Classes ###########################################################
class
LightChildrenMixin
(
XBlockWithChildrenFragmentsMixin
):
class
LightChildrenMixin
(
XBlockWithChildrenFragmentsMixin
):
...
@@ -58,12 +51,12 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
...
@@ -58,12 +51,12 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
TODO: Replace this once the support for XBlock children has matured
TODO: Replace this once the support for XBlock children has matured
by a mixin implementing the following abstractions, used to keep
by a mixin implementing the following abstractions, used to keep
code reusable in the XBlocks:
code reusable in the XBlocks:
* get_children_objects()
* get_children_objects()
* Functionality of XBlockWithChildrenFragmentsMixin
* Functionality of XBlockWithChildrenFragmentsMixin
Other changes caused by LightChild use:
Other changes caused by LightChild use:
* overrides of `parse_xml()` have been replaced by overrides of
* overrides of `parse_xml()` have been replaced by overrides of
`init_block_from_node()` on LightChildren
`init_block_from_node()` on LightChildren
* fields on LightChild don't have any persistence
* fields on LightChild don't have any persistence
...
@@ -73,7 +66,7 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
...
@@ -73,7 +66,7 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
def
parse_xml
(
cls
,
node
,
runtime
,
keys
,
id_generator
):
def
parse_xml
(
cls
,
node
,
runtime
,
keys
,
id_generator
):
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
=
getattr
(
block
,
'xml_content'
,
''
)
or
node_to_xml
(
node
)
block
.
xml_content
=
getattr
(
block
,
'xml_content'
,
''
)
or
etree
.
tostring
(
node
)
return
block
return
block
@classmethod
@classmethod
...
@@ -97,6 +90,12 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
...
@@ -97,6 +90,12 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
# Add any children the child may itself have
# Add any children the child may itself have
child_class
.
init_block_from_node
(
child
,
xml_child
,
xml_child
.
items
())
child_class
.
init_block_from_node
(
child
,
xml_child
,
xml_child
.
items
())
text
=
xml_child
.
text
if
text
:
text
=
text
.
strip
()
if
text
:
child
.
content
=
text
block
.
light_children
.
append
(
child
)
block
.
light_children
.
append
(
child
)
@classmethod
@classmethod
...
@@ -162,10 +161,16 @@ class LightChildField(object):
...
@@ -162,10 +161,16 @@ class LightChildField(object):
Fake field with no persistence - allows to keep XBlocks fields definitions on LightChild
Fake field with no persistence - allows to keep XBlocks fields definitions on LightChild
"""
"""
def
__init__
(
self
,
*
args
,
**
kwargs
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
pass
self
.
value
=
kwargs
.
get
(
'default'
,
''
)
def
__nonzero__
(
self
):
return
bool
(
self
.
value
)
class
String
(
LightChildField
):
class
String
(
LightChildField
):
pass
def
__str__
(
self
):
return
self
.
value
class
Boolean
(
LightChildField
):
class
Boolean
(
LightChildField
):
pass
pass
...
...
mentoring/message.py
View file @
cb569289
...
@@ -43,6 +43,7 @@ class MentoringMessageBlock(LightChild):
...
@@ -43,6 +43,7 @@ class MentoringMessageBlock(LightChild):
"""
"""
content
=
String
(
help
=
"Message to display upon completion"
,
scope
=
Scope
.
content
,
default
=
""
)
content
=
String
(
help
=
"Message to display upon completion"
,
scope
=
Scope
.
content
,
default
=
""
)
type
=
String
(
help
=
"Type of message"
,
scope
=
Scope
.
content
,
default
=
"completed"
)
type
=
String
(
help
=
"Type of message"
,
scope
=
Scope
.
content
,
default
=
"completed"
)
has_children
=
True
def
mentoring_view
(
self
,
context
=
None
):
def
mentoring_view
(
self
,
context
=
None
):
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_view'
)
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_view'
)
...
...
mentoring/quizz.py
View file @
cb569289
...
@@ -81,7 +81,7 @@ class QuizzBlock(LightChild):
...
@@ -81,7 +81,7 @@ class QuizzBlock(LightChild):
return
block
return
block
def
mentoring_view
(
self
,
context
=
None
):
def
mentoring_view
(
self
,
context
=
None
):
if
s
elf
.
type
not
in
(
'rating'
,
'choices'
):
if
s
tr
(
self
.
type
)
not
in
(
'rating'
,
'choices'
):
raise
ValueError
,
u'Invalid value for QuizzBlock.type: `{}`'
.
format
(
self
.
type
)
raise
ValueError
,
u'Invalid value for QuizzBlock.type: `{}`'
.
format
(
self
.
type
)
template_path
=
'templates/html/quizz_{}.html'
.
format
(
self
.
type
)
template_path
=
'templates/html/quizz_{}.html'
.
format
(
self
.
type
)
...
...
mentoring/table.py
View file @
cb569289
...
@@ -26,9 +26,9 @@
...
@@ -26,9 +26,9 @@
import
errno
import
errno
import
logging
import
logging
from
xblock.fields
import
Scope
,
String
from
xblock.fields
import
Scope
from
.light_children
import
LightChild
,
XBlockWithLightChildren
,
String
as
Light
String
from
.light_children
import
LightChild
,
String
from
.utils
import
load_resource
,
render_template
from
.utils
import
load_resource
,
render_template
...
@@ -39,8 +39,7 @@ log = logging.getLogger(__name__)
...
@@ -39,8 +39,7 @@ log = logging.getLogger(__name__)
# Classes ###########################################################
# Classes ###########################################################
# TODO-LIGHT-CHILDREN: Transform this into always using as LightChildren
class
MentoringTableBlock
(
LightChild
):
class
MentoringTableBlock
(
XBlockWithLightChildren
):
"""
"""
Table-type display of information from mentoring blocks
Table-type display of information from mentoring blocks
...
@@ -90,7 +89,7 @@ class MentoringTableColumnBlock(LightChild):
...
@@ -90,7 +89,7 @@ class MentoringTableColumnBlock(LightChild):
"""
"""
Individual column of a mentoring table
Individual column of a mentoring table
"""
"""
header
=
Light
String
(
help
=
"Header of the column"
,
scope
=
Scope
.
content
,
default
=
None
)
header
=
String
(
help
=
"Header of the column"
,
scope
=
Scope
.
content
,
default
=
None
)
has_children
=
True
has_children
=
True
def
mentoring_table_view
(
self
,
context
):
def
mentoring_table_view
(
self
,
context
):
...
@@ -124,7 +123,7 @@ class MentoringTableColumnHeaderBlock(LightChild):
...
@@ -124,7 +123,7 @@ class MentoringTableColumnHeaderBlock(LightChild):
"""
"""
Header content for a given column
Header content for a given column
"""
"""
content
=
Light
String
(
help
=
"Body of the header"
,
scope
=
Scope
.
content
,
default
=
''
)
content
=
String
(
help
=
"Body of the header"
,
scope
=
Scope
.
content
,
default
=
''
)
def
mentoring_table_header_view
(
self
,
context
):
def
mentoring_table_header_view
(
self
,
context
):
fragment
=
super
(
MentoringTableColumnHeaderBlock
,
self
)
.
children_view
(
context
)
fragment
=
super
(
MentoringTableColumnHeaderBlock
,
self
)
.
children_view
(
context
)
...
...
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