Commit 973c53db by Braden MacDonald

Remove url_name implementation - defer to Studio's existing one

parent 14fdfb43
...@@ -79,14 +79,6 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -79,14 +79,6 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
scope=Scope.content, scope=Scope.content,
enforce_type=True enforce_type=True
) )
url_name = String(
help="Name of the current step, used for URL building",
default='mentoring-default',
scope=Scope.content
# TODO in future: set this field's default to xblock.fields.UNIQUE_ID
# and remove self.url_name_with_default. Waiting until UNIQUE_ID support
# is available in edx-platform's pinned version of xblock. (See XBlock PR 249)
)
enforce_dependency = Boolean( enforce_dependency = Boolean(
help="Should the next step be the current block to complete?", help="Should the next step be the current block to complete?",
default=False, default=False,
...@@ -239,7 +231,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -239,7 +231,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
def additional_publish_event_data(self): def additional_publish_event_data(self):
return { return {
'user_id': self.scope_ids.user_id, 'user_id': self.scope_ids.user_id,
'component_id': self.url_name_with_default, 'component_id': self.url_name,
} }
@property @property
...@@ -248,7 +240,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -248,7 +240,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
Returns True if the student needs to complete another step before being able to complete Returns True if the student needs to complete another step before being able to complete
the current one, and False otherwise the current one, and False otherwise
""" """
return self.enforce_dependency and (not self.completed) and (self.next_step != self.url_name_with_default) return self.enforce_dependency and (not self.completed) and (self.next_step != self.url_name)
@property @property
def next_step_url(self): def next_step_url(self):
...@@ -257,6 +249,17 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -257,6 +249,17 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
""" """
return '/jump_to_id/{}'.format(self.next_step) return '/jump_to_id/{}'.format(self.next_step)
@property
def url_name(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(MentoringBlock, self).url_name
except AttributeError:
return unicode(self.scope_ids.usage_id)
@XBlock.json_handler @XBlock.json_handler
def view(self, data, suffix=''): def view(self, data, suffix=''):
""" """
...@@ -312,7 +315,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -312,7 +315,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
if self.has_missing_dependency: if self.has_missing_dependency:
completed = False completed = False
message = 'You need to complete all previous steps before being able to complete the current one.' message = 'You need to complete all previous steps before being able to complete the current one.'
elif completed and self.next_step == self.url_name_with_default: elif completed and self.next_step == self.url_name:
self.next_step = self.followed_by self.next_step = self.followed_by
# Once it was completed, lock score # Once it was completed, lock score
...@@ -501,6 +504,9 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC ...@@ -501,6 +504,9 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
""" """
fragment = super(MentoringBlock, self).author_edit_view(context) fragment = super(MentoringBlock, self).author_edit_view(context)
fragment.add_content(loader.render_template('templates/html/mentoring_add_buttons.html', {})) fragment.add_content(loader.render_template('templates/html/mentoring_add_buttons.html', {}))
fragment.add_content(loader.render_template('templates/html/mentoring_url_name.html', {
"url_name": self.url_name
}))
fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/mentoring_edit.css')) fragment.add_css_url(self.runtime.local_resource_url(self, 'public/css/mentoring_edit.css'))
fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/mentoring_edit.js')) fragment.add_javascript_url(self.runtime.local_resource_url(self, 'public/js/mentoring_edit.js'))
fragment.initialize_js('MentoringEditComponents') fragment.initialize_js('MentoringEditComponents')
......
/* Display of url_name below content */
.url-name-footer {
font-style: italic;
}
.url-name-footer .url-name {
margin: 0 10px;
font-family: monospace;
}
/* Custom appearance for our "Add" buttons */ /* Custom appearance for our "Add" buttons */
.xblock[data-block-type=mentoring] .add-xblock-component .new-component .new-component-type .add-xblock-component-button { .xblock[data-block-type=mentoring] .add-xblock-component .new-component .new-component-type .add-xblock-component-button {
width: 200px; width: 200px;
......
{% load i18n %}
<div class="xblock-header-secondary url-name-footer">
<span class="url-name-label">{% trans "url_name for linking to this mentoring question set:" %}</span>
<span class="url-name">{{ url_name }}</span>
</div>
...@@ -21,8 +21,15 @@ ...@@ -21,8 +21,15 @@
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>. # "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
# #
from xblock.fields import String
from xblockutils.base_test import SeleniumBaseTest from xblockutils.base_test import SeleniumBaseTest
# Studio adds a url_name property to each XBlock but Workbench doesn't.
# Since we rely on it, we need to mock url_name support so it can be set via XML and
# accessed like a normal field.
from mentoring import MentoringBlock
MentoringBlock.url_name = String()
class MentoringBaseTest(SeleniumBaseTest): class MentoringBaseTest(SeleniumBaseTest):
module_name = __name__ module_name = __name__
......
<vertical_demo> <vertical_demo>
<mentoring url_name="answer_blank_read_only" enforce_dependency="false" display_submit="false"> <mentoring url_name="answer_no_display_submit" enforce_dependency="false" display_submit="false">
<answer name="answer_blank"/> <answer name="answer_blank"/>
</mentoring> </mentoring>
</vertical_demo> </vertical_demo>
<vertical_demo> <vertical_demo>
<mentoring url_name="table_1" enforce_dependency="false"> <mentoring enforce_dependency="false">
<answer name="table_1_answer_1" /> <answer name="table_1_answer_1" />
<answer name="table_1_answer_2" /> <answer name="table_1_answer_2" />
</mentoring> </mentoring>
......
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