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
cde5657b
Commit
cde5657b
authored
Dec 08, 2013
by
Xavier Antoviaque
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow tips to include both content and children (like <html>)
parent
452a56a7
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
13 deletions
+19
-13
mentoring/quizz.py
+13
-10
templates/html/tip.html
+4
-1
templates/html/tip_group.html
+2
-2
No files found.
mentoring/quizz.py
View file @
cde5657b
...
...
@@ -9,7 +9,7 @@ from xblock.core import XBlock
from
xblock.fields
import
Scope
,
String
from
xblock.fragment
import
Fragment
from
.utils
import
load_resource
,
render_template
from
.utils
import
load_resource
,
render_template
,
XBlockWithChildrenFragmentsMixin
# Globals ###########################################################
...
...
@@ -97,16 +97,16 @@ class QuizzBlock(XBlock):
log
.
debug
(
u'Received quizz submission: "
%
s"'
,
submission
)
completed
=
True
formatted_tips_list
=
[]
tips_fragments
=
[]
for
tip
in
self
.
get_tips
():
completed
=
completed
and
tip
.
is_completed
(
submission
)
if
tip
.
is_tip_displayed
(
submission
):
formatted_tips_list
.
append
(
tip
.
render
(
submission
))
tips_fragments
.
append
(
tip
.
render
(
submission
))
if
formatted_tips_list
:
if
tips_fragments
:
formatted_tips
=
render_template
(
'templates/html/tip_group.html'
,
{
'self'
:
self
,
'tips
'
:
formatted_tips_list
,
'tips
_fragments'
:
tips_fragments
,
'submission'
:
submission
,
'submission_display'
:
self
.
get_submission_display
(
submission
),
})
...
...
@@ -143,7 +143,7 @@ class QuizzBlock(XBlock):
return
tips
class
QuizzTipBlock
(
XBlock
):
class
QuizzTipBlock
(
XBlock
,
XBlockWithChildrenFragmentsMixin
):
"""
Each quizz
"""
...
...
@@ -154,11 +154,14 @@ class QuizzTipBlock(XBlock):
def
render
(
self
,
submission
):
"""
Returns a
string
containing the formatted tip
Returns a
fragment
containing the formatted tip
"""
return
render_template
(
'templates/html/tip.html'
,
{
fragment
,
named_children
=
self
.
get_children_fragment
({})
fragment
.
add_content
(
render_template
(
'templates/html/tip.html'
,
{
'self'
:
self
,
})
'named_children'
:
named_children
,
}))
return
fragment
def
is_completed
(
self
,
submission
):
return
submission
and
submission
not
in
self
.
reject_with_defaults
...
...
@@ -180,7 +183,7 @@ class QuizzTipBlock(XBlock):
def
reject_with_defaults
(
self
):
reject
=
commas_to_list
(
self
.
reject
)
log
.
debug
(
reject
)
return
reject
return
reject
or
[]
class
QuizzChoiceBlock
(
XBlock
):
...
...
templates/html/tip.html
View file @
cde5657b
<p>
{{ self.content }}
</p>
{% if self.content %}
<p>
{{ self.content }}
</p>
{% endif %}
{% for name, c in named_children %}
{{c.body_html|safe}}
{% endfor %}
templates/html/tip_group.html
View file @
cde5657b
...
...
@@ -7,7 +7,7 @@
you have not provided an answer.
{% endif %}
</strong>
{% for tip
in tip
s %}
{{ tip }}
{% for tip
_fragment in tips_fragment
s %}
{{ tip
_fragment.body_html|safe
}}
{% endfor %}
</div>
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