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
8ef9d743
Commit
8ef9d743
authored
Nov 18, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Display children of `mentoring` block using custom template
parent
5f739291
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
22 deletions
+20
-22
mentoring/mentoring.py
+16
-20
static/html/mentoring.html
+4
-2
No files found.
mentoring/mentoring.py
View file @
8ef9d743
...
...
@@ -9,7 +9,7 @@ from xblock.problem import ProblemBlock
from
xblock.fields
import
Integer
,
Scope
,
String
from
xblock.fragment
import
Fragment
from
.utils
import
create_fragment
,
load_resourc
e
from
.utils
import
load_resource
,
render_templat
e
# Globals ###########################################################
...
...
@@ -34,22 +34,17 @@ class MentoringBlock(ProblemBlock):
completed
=
Integer
(
help
=
"How many times the student has completed this"
,
default
=
0
,
scope
=
Scope
.
user_state
)
has_children
=
True
@classmethod
def
parse_xml
(
cls
,
node
,
runtime
,
keys
):
log
.
info
(
u'cls={}, node={}, runtime={}, keys={}'
.
format
(
cls
,
node
,
runtime
,
keys
))
block
=
runtime
.
construct_xblock_from_class
(
cls
,
keys
)
# Find <script> children, turn them into script content.
for
child
in
node
:
if
child
.
tag
==
"script"
:
block
.
script
+=
child
.
text
else
:
block
.
runtime
.
add_node_as_child
(
block
,
child
)
return
block
def
_TODO_student_view
(
self
,
context
):
def
get_children_fragment
(
self
,
context
):
fragment
=
Fragment
()
named_child_frags
=
[]
for
child_id
in
self
.
children
:
# pylint: disable=E1101
child
=
self
.
runtime
.
get_block
(
child_id
)
frag
=
self
.
runtime
.
render_child
(
child
,
"mentoring_view"
,
context
)
fragment
.
add_frag_resources
(
frag
)
named_child_frags
.
append
((
child
.
name
,
frag
))
return
fragment
,
named_child_frags
def
student_view
(
self
,
context
):
"""
Create a fragment used to display the XBlock to a student.
`context` is a dictionary used to configure the display (unused)
...
...
@@ -57,11 +52,12 @@ class MentoringBlock(ProblemBlock):
Returns a `Fragment` object specifying the HTML, CSS, and JavaScript
to display.
"""
fragment
,
named_children
=
self
.
get_children_fragment
(
context
)
fragment
=
create_fragment
(
'static/html/mentoring.html'
,
{
fragment
.
add_content
(
render_template
(
'static/html/mentoring.html'
,
{
'self'
:
self
,
'
prompt'
:
self
.
prompt
,
})
'
named_children'
:
named_children
,
})
)
fragment
.
add_css
(
load_resource
(
'static/css/mentoring.css'
))
fragment
.
add_javascript
(
load_resource
(
'static/js/mentoring.js'
))
fragment
.
initialize_js
(
'MentoringBlock'
)
...
...
static/html/mentoring.html
View file @
8ef9d743
<div
class=
"mentoring"
>
<div>
{prompt}
</div>
<textarea></textarea>
{% for name, c in named_children %}
{{c.body_html|safe}}
{% endfor %}
</div>
<input
type=
'button'
value=
'check'
class=
'check'
></input>
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