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
973c53db
Commit
973c53db
authored
Feb 23, 2015
by
Braden MacDonald
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove url_name implementation - defer to Studio's existing one
parent
14fdfb43
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
13 deletions
+41
-13
mentoring/mentoring.py
+17
-11
mentoring/public/css/mentoring_edit.css
+10
-0
mentoring/templates/html/mentoring_url_name.html
+5
-0
mentoring/tests/integration/base_test.py
+7
-0
mentoring/tests/integration/xml/no_display_submit.xml
+1
-1
mentoring/tests/integration/xml/table_1.xml
+1
-1
No files found.
mentoring/mentoring.py
View file @
973c53db
...
...
@@ -79,14 +79,6 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
scope
=
Scope
.
content
,
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
(
help
=
"Should the next step be the current block to complete?"
,
default
=
False
,
...
...
@@ -239,7 +231,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
def
additional_publish_event_data
(
self
):
return
{
'user_id'
:
self
.
scope_ids
.
user_id
,
'component_id'
:
self
.
url_name
_with_default
,
'component_id'
:
self
.
url_name
,
}
@property
...
...
@@ -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
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
def
next_step_url
(
self
):
...
...
@@ -257,6 +249,17 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
"""
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
def
view
(
self
,
data
,
suffix
=
''
):
"""
...
...
@@ -312,7 +315,7 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
if
self
.
has_missing_dependency
:
completed
=
False
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
# Once it was completed, lock score
...
...
@@ -501,6 +504,9 @@ class MentoringBlock(XBlock, StepParentMixin, StudioEditableXBlockMixin, StudioC
"""
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_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_javascript_url
(
self
.
runtime
.
local_resource_url
(
self
,
'public/js/mentoring_edit.js'
))
fragment
.
initialize_js
(
'MentoringEditComponents'
)
...
...
mentoring/public/css/mentoring_edit.css
View file @
973c53db
/* 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 */
.xblock
[
data-block-type
=
mentoring
]
.add-xblock-component
.new-component
.new-component-type
.add-xblock-component-button
{
width
:
200px
;
...
...
mentoring/templates/html/mentoring_url_name.html
0 → 100644
View file @
973c53db
{% 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>
mentoring/tests/integration/base_test.py
View file @
973c53db
...
...
@@ -21,8 +21,15 @@
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
#
from
xblock.fields
import
String
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
):
module_name
=
__name__
...
...
mentoring/tests/integration/xml/no_display_submit.xml
View file @
973c53db
<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"
/>
</mentoring>
</vertical_demo>
mentoring/tests/integration/xml/table_1.xml
View file @
973c53db
<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_2"
/>
</mentoring>
...
...
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