Commit d240c922 by E. Kolpakov Committed by Jonathan Piacenti

Part of jump to children prototype - XBlock-side support for jumping to children

parent 42901b10
...@@ -7,3 +7,4 @@ from .mrq import MRQBlock ...@@ -7,3 +7,4 @@ from .mrq import MRQBlock
from .message import MentoringMessageBlock from .message import MentoringMessageBlock
from .table import MentoringTableBlock, MentoringTableColumn from .table import MentoringTableBlock, MentoringTableColumn
from .tip import TipBlock from .tip import TipBlock
from .beeper import BeeperBlock
from xblock.core import XBlock
from xblock.fields import Scope, String
from xblock.fragment import Fragment
from xblockutils.studio_editable import StudioEditableXBlockMixin
# Make '_' a no-op so we can scrape strings
def _(text):
return text
class BeeperBlock(StudioEditableXBlockMixin, XBlock):
""" Dummy XBlock to demonstrate navigation to children """
content = String(
display_name=_("Beeper Text"),
help=_("Text to display"),
scope=Scope.content,
default="",
)
editable_fields = ('content',)
def student_view(self, context):
normalized_id = self.scope_ids.usage_id.replace(run=None, branch=None, version_guid=None)
fragment = Fragment()
if context.get('activate_block_id', None) == normalized_id:
fragment.add_javascript("alert('{content}')".format(content=self.content))
return fragment
def author_view(self, content):
fragment = Fragment()
fragment.add_content(unicode(
_("<div>Beeper ID: {id}</div><div>Beeper Message: {message}</div>").format(id=self.id, message=self.content)
))
return fragment
@property
def id(self):
"""
Get the url_name for this block. In Studio/LMS it is provided by a mixin, so we just
defer to super(). In the workbench or any other platform, we use the usage_id.
"""
try:
return super(BeeperBlock, self).url_name
except AttributeError:
return unicode(self.scope_ids.usage_id)
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
<li><a href="#" class="single-template add-xblock-component-button" data-category="html">{% trans "HTML" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="html">{% trans "HTML" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="pb-answer-recap">{% trans "Long Answer Recap" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-answer-recap">{% trans "Long Answer Recap" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="pb-table">{% trans "Answer Recap Table" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-table">{% trans "Answer Recap Table" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="pb-beeper">{% trans "Beeper" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="completed">{% trans "Message (Complete)" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="completed">{% trans "Message (Complete)" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="incomplete">{% trans "Message (Incomplete)" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="incomplete">{% trans "Message (Incomplete)" %}</a></li>
<li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="max_attempts_reached">{% trans "Message (Max # Attempts)" %}</a></li> <li><a href="#" class="single-template add-xblock-component-button" data-category="pb-message" data-boilerplate="max_attempts_reached">{% trans "Message (Max # Attempts)" %}</a></li>
......
...@@ -54,6 +54,7 @@ BLOCKS = [ ...@@ -54,6 +54,7 @@ BLOCKS = [
'pb-choice = problem_builder:ChoiceBlock', 'pb-choice = problem_builder:ChoiceBlock',
'pb-dashboard = problem_builder:DashboardBlock', 'pb-dashboard = problem_builder:DashboardBlock',
'pb-beeper = problem_builder:BeeperBlock'
# Deprecated. You can temporarily uncomment and run 'python setup.py develop' if you have these blocks # Deprecated. You can temporarily uncomment and run 'python setup.py develop' if you have these blocks
# installed from testing mentoring v2 and need to get past an error message. # installed from testing mentoring v2 and need to get past an error message.
#'mentoring = problem_builder:MentoringBlock', # Deprecated alias for problem-builder #'mentoring = problem_builder:MentoringBlock', # Deprecated alias for problem-builder
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment