Commit 23e99c14 by E. Kolpakov

Problem mode field and edit capabilities

parent 79af3f9d
...@@ -97,10 +97,10 @@ and Drop component to a lesson, then click the `EDIT` button. ...@@ -97,10 +97,10 @@ and Drop component to a lesson, then click the `EDIT` button.
![Edit view](https://raw.githubusercontent.com/edx-solutions/xblock-drag-and-drop-v2/c955a38dc3a1aaf609c586d293ce19b282e11ffd/doc/img/edit-view.png) ![Edit view](https://raw.githubusercontent.com/edx-solutions/xblock-drag-and-drop-v2/c955a38dc3a1aaf609c586d293ce19b282e11ffd/doc/img/edit-view.png)
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).
![Drop zone edit](https://raw.githubusercontent.com/edx-solutions/xblock-drag-and-drop-v2/ebd0b52d971bbf93b9c3873f310bd72d336d865b/doc/img/edit-view-zones.png) ![Drop zone edit](https://raw.githubusercontent.com/edx-solutions/xblock-drag-and-drop-v2/ebd0b52d971bbf93b9c3873f310bd72d336d865b/doc/img/edit-view-zones.png)
......
doc/img/edit-view.png

27.5 KB | W: | H:

doc/img/edit-view.png

32.2 KB | W: | H:

doc/img/edit-view.png
doc/img/edit-view.png
doc/img/edit-view.png
doc/img/edit-view.png
  • 2-up
  • Swipe
  • Onion skin
...@@ -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']
......
...@@ -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(),
......
...@@ -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 }}" />
......
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)
......
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