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
23e99c14
Commit
23e99c14
authored
Jul 07, 2016
by
E. Kolpakov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Problem mode field and edit capabilities
parent
79af3f9d
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
39 additions
and
2 deletions
+39
-2
README.md
+2
-2
doc/img/edit-view.png
+0
-0
drag_and_drop_v2/drag_and_drop_v2.py
+23
-0
drag_and_drop_v2/public/js/drag_and_drop_edit.js
+1
-0
drag_and_drop_v2/templates/html/drag_and_drop_edit.html
+10
-0
tests/unit/test_basics.py
+3
-0
No files found.
README.md
View file @
23e99c14
...
@@ -97,8 +97,8 @@ and Drop component to a lesson, then click the `EDIT` button.
...
@@ -97,8 +97,8 @@ and Drop component to a lesson, then click the `EDIT` button.


In the first step, you can set some basic properties of the component,
In the first step, you can set some basic properties of the component,
such as the title,
the maximum score, the problem text to render
such as the title,
problem mode (Standard vs. Assessment), the maximum score,
above the background image, the introductory feedback (shown
the problem text to render
above the background image, the introductory feedback (shown
initially), and the final feedback (shown after the learner
initially), and the final feedback (shown after the learner
successfully completes the drag and drop problem).
successfully completes the drag and drop problem).
...
...
doc/img/edit-view.png
View replaced file @
79af3f9d
View file @
23e99c14
27.5 KB
|
W:
|
H:
32.2 KB
|
W:
|
H:
2-up
Swipe
Onion skin
drag_and_drop_v2/drag_and_drop_v2.py
View file @
23e99c14
...
@@ -32,6 +32,9 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -32,6 +32,9 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
"""
"""
XBlock that implements a friendly Drag-and-Drop problem
XBlock that implements a friendly Drag-and-Drop problem
"""
"""
STANDARD_MODE
=
"standard"
ASSESSMENT_MODE
=
"assessment"
display_name
=
String
(
display_name
=
String
(
display_name
=
_
(
"Title"
),
display_name
=
_
(
"Title"
),
help
=
_
(
"The title of the drag and drop problem. The title is displayed to learners."
),
help
=
_
(
"The title of the drag and drop problem. The title is displayed to learners."
),
...
@@ -39,6 +42,20 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -39,6 +42,20 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
default
=
_
(
"Drag and Drop"
),
default
=
_
(
"Drag and Drop"
),
)
)
mode
=
String
(
display_name
=
_
(
"Mode"
),
help
=
_
(
"Standard mode: feedback is provided to learner right after an item is dropped to a zone. "
"Assessment mode: learner must place all the items to zones to see the feedback."
),
scope
=
Scope
.
settings
,
values
=
[
{
"display_name"
:
_
(
"Standard"
),
"value"
:
STANDARD_MODE
},
{
"display_name"
:
_
(
"Assessment"
),
"value"
:
ASSESSMENT_MODE
},
],
default
=
STANDARD_MODE
)
show_title
=
Boolean
(
show_title
=
Boolean
(
display_name
=
_
(
"Show title"
),
display_name
=
_
(
"Show title"
),
help
=
_
(
"Display the title to the learner?"
),
help
=
_
(
"Display the title to the learner?"
),
...
@@ -185,9 +202,14 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -185,9 +202,14 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
field_name
:
self
.
ugettext
(
field
.
help
)
field_name
:
self
.
ugettext
(
field
.
help
)
for
field_name
,
field
in
self
.
fields
.
viewitems
()
if
hasattr
(
field
,
"help"
)
for
field_name
,
field
in
self
.
fields
.
viewitems
()
if
hasattr
(
field
,
"help"
)
}
}
field_values
=
{
field_name
:
field
.
values
for
field_name
,
field
in
self
.
fields
.
viewitems
()
if
hasattr
(
field
,
"values"
)
}
context
=
{
context
=
{
'js_templates'
:
js_templates
,
'js_templates'
:
js_templates
,
'help_texts'
:
help_texts
,
'help_texts'
:
help_texts
,
'field_values'
:
field_values
,
'self'
:
self
,
'self'
:
self
,
'data'
:
urllib
.
quote
(
json
.
dumps
(
self
.
data
)),
'data'
:
urllib
.
quote
(
json
.
dumps
(
self
.
data
)),
}
}
...
@@ -220,6 +242,7 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
...
@@ -220,6 +242,7 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
@XBlock.json_handler
@XBlock.json_handler
def
studio_submit
(
self
,
submissions
,
suffix
=
''
):
def
studio_submit
(
self
,
submissions
,
suffix
=
''
):
self
.
display_name
=
submissions
[
'display_name'
]
self
.
display_name
=
submissions
[
'display_name'
]
self
.
mode
=
submissions
[
'mode'
]
self
.
show_title
=
submissions
[
'show_title'
]
self
.
show_title
=
submissions
[
'show_title'
]
self
.
question_text
=
submissions
[
'problem_text'
]
self
.
question_text
=
submissions
[
'problem_text'
]
self
.
show_question_header
=
submissions
[
'show_problem_header'
]
self
.
show_question_header
=
submissions
[
'show_problem_header'
]
...
...
drag_and_drop_v2/public/js/drag_and_drop_edit.js
View file @
23e99c14
...
@@ -491,6 +491,7 @@ function DragAndDropEditBlock(runtime, element, params) {
...
@@ -491,6 +491,7 @@ function DragAndDropEditBlock(runtime, element, params) {
var
data
=
{
var
data
=
{
'display_name'
:
$element
.
find
(
'#display-name'
).
val
(),
'display_name'
:
$element
.
find
(
'#display-name'
).
val
(),
'mode'
:
$element
.
find
(
"#problem-mode"
).
val
(),
'show_title'
:
$element
.
find
(
'.show-title'
).
is
(
':checked'
),
'show_title'
:
$element
.
find
(
'.show-title'
).
is
(
':checked'
),
'weight'
:
$element
.
find
(
'#weight'
).
val
(),
'weight'
:
$element
.
find
(
'#weight'
).
val
(),
'problem_text'
:
$element
.
find
(
'#problem-text'
).
val
(),
'problem_text'
:
$element
.
find
(
'#problem-text'
).
val
(),
...
...
drag_and_drop_v2/templates/html/drag_and_drop_edit.html
View file @
23e99c14
...
@@ -21,6 +21,16 @@
...
@@ -21,6 +21,16 @@
<span
class=
"sr"
>
{{ help_texts.show_title }}
</span>
<span
class=
"sr"
>
{{ help_texts.show_title }}
</span>
</label>
</label>
<label
class=
"h3"
for=
"problem-mode"
title=
"{{ help_texts.mode }}"
>
{% trans "Problem mode" %}
</label>
<select
id=
"problem-mode"
>
{% for field_value in field_values.mode %}
<option
value=
"{{ field_value.value }}"
{%
if
self
.
mode =
=
field_value
.
value
%}
selected
{%
endif
%}
>
{{ field_value.display_name }}
</option>
{% endfor %}
</select>
<span
class=
"sr"
>
{{ help_texts.mode }}
</span>
<label
class=
"h3"
for=
"weight"
>
{% trans "Maximum score" %}
</label>
<label
class=
"h3"
for=
"weight"
>
{% trans "Maximum score" %}
</label>
<input
id=
"weight"
type=
"number"
step=
"0.1"
value=
"{{ self.weight|unlocalize }}"
/>
<input
id=
"weight"
type=
"number"
step=
"0.1"
value=
"{{ self.weight|unlocalize }}"
/>
...
...
tests/unit/test_basics.py
View file @
23e99c14
import
unittest
import
unittest
from
drag_and_drop_v2.drag_and_drop_v2
import
DragAndDropBlock
from
drag_and_drop_v2.default_data
import
(
from
drag_and_drop_v2.default_data
import
(
TARGET_IMG_DESCRIPTION
,
TOP_ZONE_ID
,
MIDDLE_ZONE_ID
,
BOTTOM_ZONE_ID
,
TARGET_IMG_DESCRIPTION
,
TOP_ZONE_ID
,
MIDDLE_ZONE_ID
,
BOTTOM_ZONE_ID
,
START_FEEDBACK
,
FINISH_FEEDBACK
,
DEFAULT_DATA
START_FEEDBACK
,
FINISH_FEEDBACK
,
DEFAULT_DATA
...
@@ -97,6 +98,7 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
...
@@ -97,6 +98,7 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
def
test_studio_submit
(
self
):
def
test_studio_submit
(
self
):
body
=
{
body
=
{
'display_name'
:
"Test Drag & Drop"
,
'display_name'
:
"Test Drag & Drop"
,
'mode'
:
DragAndDropBlock
.
ASSESSMENT_MODE
,
'show_title'
:
False
,
'show_title'
:
False
,
'problem_text'
:
"Problem Drag & Drop"
,
'problem_text'
:
"Problem Drag & Drop"
,
'show_problem_header'
:
False
,
'show_problem_header'
:
False
,
...
@@ -111,6 +113,7 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
...
@@ -111,6 +113,7 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
self
.
assertEqual
(
res
,
{
'result'
:
'success'
})
self
.
assertEqual
(
res
,
{
'result'
:
'success'
})
self
.
assertEqual
(
self
.
block
.
show_title
,
False
)
self
.
assertEqual
(
self
.
block
.
show_title
,
False
)
self
.
assertEqual
(
self
.
block
.
mode
,
DragAndDropBlock
.
ASSESSMENT_MODE
)
self
.
assertEqual
(
self
.
block
.
display_name
,
"Test Drag & Drop"
)
self
.
assertEqual
(
self
.
block
.
display_name
,
"Test Drag & Drop"
)
self
.
assertEqual
(
self
.
block
.
question_text
,
"Problem Drag & Drop"
)
self
.
assertEqual
(
self
.
block
.
question_text
,
"Problem Drag & Drop"
)
self
.
assertEqual
(
self
.
block
.
show_question_header
,
False
)
self
.
assertEqual
(
self
.
block
.
show_question_header
,
False
)
...
...
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