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
7b5a900c
Commit
7b5a900c
authored
Oct 08, 2014
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #86 from Kelketek/master
Provide a path for default xml to load upon creation.
parents
b59e5e4f
0875f5bc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
mentoring/light_children.py
+3
-1
mentoring/mentoring.py
+10
-9
No files found.
mentoring/light_children.py
View file @
7b5a900c
...
@@ -126,7 +126,9 @@ class LightChildrenMixin(XBlockWithChildrenFragmentsMixin):
...
@@ -126,7 +126,9 @@ 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
:
no_content
=
(
not
hasattr
(
self
,
'xml_content'
)
or
not
self
.
xml_content
or
callable
(
self
.
xml_content
))
if
no_content
:
return
return
parser
=
etree
.
XMLParser
(
remove_comments
=
True
)
parser
=
etree
.
XMLParser
(
remove_comments
=
True
)
...
...
mentoring/mentoring.py
View file @
7b5a900c
...
@@ -47,8 +47,14 @@ from .utils import get_scenarios_from_path, load_resource, render_template
...
@@ -47,8 +47,14 @@ from .utils import get_scenarios_from_path, load_resource, render_template
log
=
logging
.
getLogger
(
__name__
)
log
=
logging
.
getLogger
(
__name__
)
def
default_xml_content
():
return
render_template
(
'templates/xml/mentoring_default.xml'
,
{
'url_name'
:
'mentoring-{}'
.
format
(
uuid
.
uuid4
())})
# Classes ###########################################################
# Classes ###########################################################
class
MentoringBlock
(
XBlockWithLightChildren
,
StepParentMixin
):
class
MentoringBlock
(
XBlockWithLightChildren
,
StepParentMixin
):
"""
"""
An XBlock providing mentoring capabilities
An XBlock providing mentoring capabilities
...
@@ -71,7 +77,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
...
@@ -71,7 +77,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
)
xml_content
=
String
(
help
=
"XML content"
,
default
=
''
,
scope
=
Scope
.
content
)
xml_content
=
String
(
help
=
"XML content"
,
default
=
default_xml_content
,
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
)
num_attempts
=
Integer
(
help
=
"Number of attempts a user has answered for this questions"
,
num_attempts
=
Integer
(
help
=
"Number of attempts a user has answered for this questions"
,
...
@@ -94,6 +100,8 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
...
@@ -94,6 +100,8 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
FLOATING_BLOCKS
=
(
TitleBlock
,
MentoringMessageBlock
,
SharedHeaderBlock
)
FLOATING_BLOCKS
=
(
TitleBlock
,
MentoringMessageBlock
,
SharedHeaderBlock
)
FIELDS_TO_INIT
=
(
'xml_content'
,)
@property
@property
def
is_assessment
(
self
):
def
is_assessment
(
self
):
return
self
.
mode
==
'assessment'
return
self
.
mode
==
'assessment'
...
@@ -373,7 +381,7 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
...
@@ -373,7 +381,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'
:
self
.
xml_content
,
}))
}))
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'
))
...
@@ -421,13 +429,6 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
...
@@ -421,13 +429,6 @@ class MentoringBlock(XBlockWithLightChildren, StepParentMixin):
return
response
return
response
@property
@property
def
default_xml_content
(
self
):
return
render_template
(
'templates/xml/mentoring_default.xml'
,
{
'self'
:
self
,
'url_name'
:
self
.
url_name_with_default
,
})
@property
def
url_name_with_default
(
self
):
def
url_name_with_default
(
self
):
"""
"""
Ensure the `url_name` is set to a unique, non-empty value.
Ensure the `url_name` is set to a unique, non-empty value.
...
...
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