Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xblock-drag-and-drop-v2
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
xblock-drag-and-drop-v2
Commits
d5e315a4
Commit
d5e315a4
authored
Feb 17, 2016
by
Matt Drayer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mattdrayer/xblock-translations-proto
parent
cabfb810
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
8 deletions
+29
-8
drag_and_drop_v2/drag_and_drop_v2.py
+28
-8
drag_and_drop_v2/utils.py
+1
-0
No files found.
drag_and_drop_v2/drag_and_drop_v2.py
View file @
d5e315a4
...
@@ -27,6 +27,7 @@ loader = ResourceLoader(__name__)
...
@@ -27,6 +27,7 @@ loader = ResourceLoader(__name__)
# Classes ###########################################################
# Classes ###########################################################
@XBlock.wants
(
'settings'
)
@XBlock.wants
(
'settings'
)
@XBlock.needs
(
'i18n'
)
class
DragAndDropBlock
(
XBlock
,
XBlockWithSettingsMixin
,
ThemableXBlockMixin
):
class
DragAndDropBlock
(
XBlock
,
XBlockWithSettingsMixin
,
ThemableXBlockMixin
):
"""
"""
XBlock that implements a friendly Drag-and-Drop problem
XBlock that implements a friendly Drag-and-Drop problem
...
@@ -108,15 +109,24 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -108,15 +109,24 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
def
_
(
self
,
text
):
def
_
(
self
,
text
):
""" Translate text """
""" Translate text """
return
self
.
runtime
.
service
(
self
,
"i18n"
)
.
ugettext
(
text
)
print
"********** DRAG AND DROP V2: CALLING RUNTIME.i18n.ugettext for '{0}'"
.
format
(
text
)
# print self
# print self.runtime
runtime_service
=
self
.
runtime
.
service
(
self
,
"i18n"
)
runtime_ugettext
=
runtime_service
.
ugettext
response
=
runtime_ugettext
(
text
)
#from nose.tools import set_trace; set_trace()
return
response
@XBlock.supports
(
"multi_device"
)
# Enable this block for use in the mobile app via webview
@XBlock.supports
(
"multi_device"
)
# Enable this block for use in the mobile app via webview
def
student_view
(
self
,
context
):
def
student_view
(
self
,
context
):
"""
"""
Player view, displayed to the student
Player view, displayed to the student
"""
"""
print
"********** DRAG AND DROP V2 STUDENT VIEW **********"
fragment
=
Fragment
()
fragment
=
Fragment
()
# from nose.tools import set_trace; set_trace()
fragment
.
add_content
(
loader
.
render_template
(
'/templates/html/drag_and_drop.html'
))
fragment
.
add_content
(
loader
.
render_template
(
'/templates/html/drag_and_drop.html'
))
css_urls
=
(
css_urls
=
(
'public/css/vendor/jquery-ui-1.10.4.custom.min.css'
,
'public/css/vendor/jquery-ui-1.10.4.custom.min.css'
,
...
@@ -137,6 +147,9 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -137,6 +147,9 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
fragment
.
initialize_js
(
'DragAndDropBlock'
,
self
.
get_configuration
())
fragment
.
initialize_js
(
'DragAndDropBlock'
,
self
.
get_configuration
())
print
"********** DRAG AND DROP V2 STUDENT VIEW FRAGMENT **********"
print
fragment
.
__dict__
#from nose.tools import set_trace; set_trace()
return
fragment
return
fragment
def
get_configuration
(
self
):
def
get_configuration
(
self
):
...
@@ -146,12 +159,18 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -146,12 +159,18 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
and feedback.
and feedback.
"""
"""
def
items_without_answers
():
def
items_without_answers
(
self
):
print
"********** ITEMS WITHOUT ANSWERS **********"
items
=
copy
.
deepcopy
(
self
.
data
.
get
(
'items'
,
''
))
items
=
copy
.
deepcopy
(
self
.
data
.
get
(
'items'
,
''
))
for
item
in
items
:
for
item
in
items
:
if
'displayName'
in
item
:
item
[
'displayName'
]
=
self
.
_
(
item
[
'displayName'
])
if
'correct'
in
item
:
item
[
'correct'
]
=
self
,
_
(
item
[
'correct'
])
del
item
[
'feedback'
]
del
item
[
'feedback'
]
del
item
[
'zone'
]
del
item
[
'zone'
]
item
[
'inputOptions'
]
=
'inputOptions'
in
item
item
[
'inputOptions'
]
=
'inputOptions'
in
item
print
items
return
items
return
items
return
{
return
{
...
@@ -160,16 +179,16 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -160,16 +179,16 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
"url_name"
:
getattr
(
self
,
'url_name'
,
''
),
"url_name"
:
getattr
(
self
,
'url_name'
,
''
),
"display_zone_labels"
:
self
.
data
.
get
(
'displayLabels'
,
False
),
"display_zone_labels"
:
self
.
data
.
get
(
'displayLabels'
,
False
),
"display_zone_borders"
:
self
.
data
.
get
(
'displayBorders'
,
False
),
"display_zone_borders"
:
self
.
data
.
get
(
'displayBorders'
,
False
),
"items"
:
items_without_answers
(),
"items"
:
items_without_answers
(
self
),
"title"
:
self
.
display_name
,
"title"
:
self
.
_
(
self
.
display_name
)
,
"show_title"
:
self
.
show_title
,
"show_title"
:
self
.
show_title
,
"problem_text"
:
self
.
question_text
,
"problem_text"
:
self
.
_
(
self
.
question_text
)
,
"show_problem_header"
:
self
.
show_question_header
,
"show_problem_header"
:
self
.
show_question_header
,
"target_img_expanded_url"
:
self
.
target_img_expanded_url
,
"target_img_expanded_url"
:
self
.
target_img_expanded_url
,
"target_img_description"
:
self
.
target_img_description
,
"target_img_description"
:
self
.
_
(
self
.
target_img_description
)
,
"item_background_color"
:
self
.
item_background_color
or
None
,
"item_background_color"
:
self
.
item_background_color
or
None
,
"item_text_color"
:
self
.
item_text_color
or
None
,
"item_text_color"
:
self
.
item_text_color
or
None
,
"initial_feedback"
:
self
.
data
[
'feedback'
][
'start'
]
,
"initial_feedback"
:
self
.
_
(
self
.
data
[
'feedback'
][
'start'
])
,
# final feedback (data.feedback.finish) is not included - it may give away answers.
# final feedback (data.feedback.finish) is not included - it may give away answers.
}
}
...
@@ -411,6 +430,7 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -411,6 +430,7 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
zones
=
[]
zones
=
[]
for
zone
in
self
.
data
.
get
(
'zones'
,
[]):
for
zone
in
self
.
data
.
get
(
'zones'
,
[]):
zone
=
zone
.
copy
()
zone
=
zone
.
copy
()
zone
[
'title'
]
=
self
.
_
(
zone
[
'title'
])
if
"uid"
not
in
zone
:
if
"uid"
not
in
zone
:
zone
[
"uid"
]
=
zone
.
get
(
"title"
)
# Older versions used title as the zone UID
zone
[
"uid"
]
=
zone
.
get
(
"title"
)
# Older versions used title as the zone UID
# Remove old, now-unused zone attributes, if present:
# Remove old, now-unused zone attributes, if present:
...
...
drag_and_drop_v2/utils.py
View file @
d5e315a4
...
@@ -4,4 +4,5 @@
...
@@ -4,4 +4,5 @@
# Make '_' a no-op so we can scrape strings
# Make '_' a no-op so we can scrape strings
def
_
(
text
):
def
_
(
text
):
print
"********** DRAG AND DROP V2 UTILS TEXT WRAPPER: '{0}'**********"
.
format
(
text
)
return
text
return
text
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