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
78bf201b
Commit
78bf201b
authored
Aug 28, 2014
by
dragonfi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add shared header sub-XBlock
parent
f340d55a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
81 additions
and
5 deletions
+81
-5
mentoring/__init__.py
+1
-0
mentoring/header.py
+58
-0
mentoring/mentoring.py
+14
-3
mentoring/templates/html/mentoring.html
+2
-1
mentoring/templates/xml/mentoring_assessment.xml
+4
-0
setup.py
+2
-1
No files found.
mentoring/__init__.py
View file @
78bf201b
...
...
@@ -9,3 +9,4 @@ from .message import MentoringMessageBlock
from
.table
import
MentoringTableBlock
,
MentoringTableColumnBlock
,
MentoringTableColumnHeaderBlock
from
.tip
import
TipBlock
from
.title
import
TitleBlock
from
.header
import
SharedHeaderBlock
mentoring/header.py
0 → 100644
View file @
78bf201b
# -*- coding: utf-8 -*-
#
# Copyright (C) 2014 Harvard
#
# Authors:
# Xavier Antoviaque <xavier@antoviaque.org>
#
# This software's license gives you freedom; you can copy, convey,
# propagate, redistribute and/or modify this program under the terms of
# the GNU Affero General Public License (AGPL) as published by the Free
# Software Foundation (FSF), either version 3 of the License, or (at your
# option) any later version of the AGPL published by the FSF.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero
# General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program in a file in the toplevel directory called
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
#
import
logging
from
lxml
import
etree
from
xblock.fragment
import
Fragment
from
.light_children
import
LightChild
,
Scope
,
String
log
=
logging
.
getLogger
(
__name__
)
class
SharedHeaderBlock
(
LightChild
):
"""
A shared header block shown under the title.
"""
content
=
String
(
help
=
"HTML content of the header"
,
scope
=
Scope
.
content
,
default
=
""
)
@classmethod
def
init_block_from_node
(
cls
,
block
,
node
,
attr
):
block
.
light_children
=
[]
node
.
tag
=
'div'
block
.
content
=
unicode
(
etree
.
tostring
(
node
))
node
.
tag
=
'shared-header'
return
block
def
student_view
(
self
,
context
=
None
):
return
Fragment
(
u"<script type='text/template' id='{}'>
\n
{}
\n
</script>"
.
format
(
'light-child-template'
,
self
.
content
))
def
mentoring_view
(
self
,
context
=
None
):
return
self
.
student_view
(
context
)
def
mentoring_table_view
(
self
,
context
=
None
):
return
self
.
student_view
(
context
)
mentoring/mentoring.py
View file @
78bf201b
...
...
@@ -35,6 +35,7 @@ from xblock.fragment import Fragment
from
.light_children
import
XBlockWithLightChildren
from
.title
import
TitleBlock
from
.header
import
SharedHeaderBlock
from
.html
import
HTMLBlock
from
.message
import
MentoringMessageBlock
from
.utils
import
get_scenarios_from_path
,
load_resource
,
render_template
...
...
@@ -97,7 +98,7 @@ class MentoringBlock(XBlockWithLightChildren):
@property
def
steps
(
self
):
return
[
child
for
child
in
self
.
get_children_objects
()
if
not
isinstance
(
child
,
(
HTMLBlock
,
TitleBlock
,
MentoringMessageBlock
))]
not
isinstance
(
child
,
(
HTMLBlock
,
TitleBlock
,
MentoringMessageBlock
,
SharedHeaderBlock
))]
@property
def
score
(
self
):
...
...
@@ -115,7 +116,7 @@ class MentoringBlock(XBlockWithLightChildren):
def
student_view
(
self
,
context
):
fragment
,
named_children
=
self
.
get_children_fragment
(
context
,
view_name
=
'mentoring_view'
,
not_instance_of
=
(
MentoringMessageBlock
,
TitleBlock
)
not_instance_of
=
(
MentoringMessageBlock
,
TitleBlock
,
SharedHeaderBlock
)
)
fragment
.
add_content
(
render_template
(
'templates/html/mentoring.html'
,
{
...
...
@@ -170,6 +171,16 @@ class MentoringBlock(XBlockWithLightChildren):
return
None
@property
def
header
(
self
):
"""
Return the header child.
"""
for
child
in
self
.
get_children_objects
():
if
isinstance
(
child
,
SharedHeaderBlock
):
return
child
return
None
@property
def
has_missing_dependency
(
self
):
"""
Returns True if the student needs to complete another step before being able to complete
...
...
@@ -265,7 +276,7 @@ class MentoringBlock(XBlockWithLightChildren):
completed
=
False
current_child
=
None
children
=
[
child
for
child
in
self
.
get_children_objects
()
\
if
not
isinstance
(
child
,
TitleBlock
)]
if
not
isinstance
(
child
,
(
TitleBlock
,
SharedHeaderBlock
)
)]
for
child
in
children
:
if
child
.
name
and
child
.
name
in
submissions
:
...
...
mentoring/templates/html/mentoring.html
View file @
78bf201b
...
...
@@ -3,9 +3,10 @@
You need to complete
<a
href=
"{{ missing_dependency_url }}"
>
the previous step
</a>
before
attempting this step.
</div>
{% if self.title %}
{% if self.title
or self.header
%}
<div
class=
"title"
>
<h2
class=
"main"
>
{{ self.title.content }}
</h2>
<div
class=
"header"
>
{{ self.header.content|safe }}
</div>
</div>
{% endif %}
{% for name, c in named_children %}
...
...
mentoring/templates/xml/mentoring_assessment.xml
View file @
78bf201b
<mentoring
url_name=
"{{ url_name }}"
display_name=
"Nav tooltip title"
weight=
"1"
mode=
"assessment"
>
<title>
Default Title
</title>
<shared-header>
<p>
This paragraph is shared between
<strong>
all
</strong>
questions.
</p>
</shared-header>
<html>
<p>
What is your goal?
</p>
</html>
...
...
setup.py
View file @
78bf201b
...
...
@@ -59,7 +59,8 @@ BLOCKS_CHILDREN = [
'tip = mentoring:TipBlock'
,
'choice = mentoring:ChoiceBlock'
,
'html = mentoring:HTMLBlock'
,
'title = mentoring:TitleBlock'
'title = mentoring:TitleBlock'
,
'shared-header = mentoring:SharedHeaderBlock'
,
]
setup
(
...
...
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