Commit 48b9846b by Tim Krones

Address review comments.

parent e8b10924
...@@ -29,7 +29,7 @@ DEFAULT_DATA = { ...@@ -29,7 +29,7 @@ DEFAULT_DATA = {
"correct": _("Yes, it's a 1") "correct": _("Yes, it's a 1")
}, },
"zone": "Zone 1", "zone": "Zone 1",
"backgroundImage": "", "imageURL": "",
"id": 0, "id": 0,
}, },
{ {
...@@ -39,7 +39,7 @@ DEFAULT_DATA = { ...@@ -39,7 +39,7 @@ DEFAULT_DATA = {
"correct": _("Yes, it's a 2") "correct": _("Yes, it's a 2")
}, },
"zone": "Zone 2", "zone": "Zone 2",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
}, },
{ {
...@@ -49,7 +49,7 @@ DEFAULT_DATA = { ...@@ -49,7 +49,7 @@ DEFAULT_DATA = {
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "", "imageURL": "",
"id": 2, "id": 2,
}, },
], ],
......
...@@ -198,7 +198,6 @@ class DragAndDropBlock(XBlock): ...@@ -198,7 +198,6 @@ class DragAndDropBlock(XBlock):
fragment.initialize_js('DragAndDropEditBlock', { fragment.initialize_js('DragAndDropEditBlock', {
'data': self.data, 'data': self.data,
'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,
'default_background_image_url': self.default_background_image_url, 'default_background_image_url': self.default_background_image_url,
}) })
......
...@@ -115,7 +115,8 @@ ...@@ -115,7 +115,8 @@
/* Focused option */ /* Focused option */
.xblock--drag-and-drop .drag-container .item-bank .option:focus, .xblock--drag-and-drop .drag-container .item-bank .option:focus,
.xblock--drag-and-drop .drag-container .item-bank .option:hover { .xblock--drag-and-drop .drag-container .item-bank .option:hover {
transform: scale(1.1); outline: 2px solid #fff;
outline-offset: -4px;
} }
.xblock--drag-and-drop .drag-container .ui-draggable-dragging { .xblock--drag-and-drop .drag-container .ui-draggable-dragging {
......
...@@ -103,7 +103,8 @@ ...@@ -103,7 +103,8 @@
margin: 10px 0 0 0; margin: 10px 0 0 0;
} }
.xblock--drag-and-drop--editor .target-image-form input { .xblock--drag-and-drop--editor .target-image-form input,
.xblock--drag-and-drop--editor .target-image-form textarea {
width: 50%; width: 50%;
} }
...@@ -141,8 +142,7 @@ ...@@ -141,8 +142,7 @@
width: 18%; width: 18%;
} }
.xblock--drag-and-drop--editor .zones-form .zone-row .title, .xblock--drag-and-drop--editor .zones-form .zone-row > input {
.xblock--drag-and-drop--editor .zones-form .zone-row .description {
width: 60%; width: 60%;
margin: 0 0 5px; margin: 0 0 5px;
line-height: 2.664rem; /* .title gets line-height from a Studio rule that does not apply to .description; line-height: 2.664rem; /* .title gets line-height from a Studio rule that does not apply to .description;
...@@ -191,6 +191,11 @@ ...@@ -191,6 +191,11 @@
width: 35%; width: 35%;
} }
.xblock--drag-and-drop--editor .items-form .item-image-url {
width: 81%;
margin-right: 1%;
}
.xblock--drag-and-drop--editor .items-form .item-width, .xblock--drag-and-drop--editor .items-form .item-width,
.xblock--drag-and-drop--editor .items-form .item-height { .xblock--drag-and-drop--editor .items-form .item-height {
width: 40px; width: 40px;
......
...@@ -167,11 +167,16 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -167,11 +167,16 @@ function DragAndDropBlock(runtime, element, configuration) {
revert: 'invalid', revert: 'invalid',
revertDuration: 150, revertDuration: 150,
start: function(evt, ui) { start: function(evt, ui) {
var item_id = $(this).data('value'); var $item = $(this);
$item.attr('aria-grabbed', true);
var item_id = $item.data('value');
publishEvent({ publishEvent({
event_type: 'xblock.drag-and-drop-v2.item.picked-up', event_type: 'xblock.drag-and-drop-v2.item.picked-up',
item_id: item_id item_id: item_id
}); });
},
stop: function(evt, ui) {
$(this).attr('aria-grabbed', false);
} }
}); });
} catch (e) { } catch (e) {
...@@ -311,18 +316,17 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -311,18 +316,17 @@ function DragAndDropBlock(runtime, element, configuration) {
input.class_name = item_user_state.correct_input ? 'correct' : 'incorrect'; input.class_name = item_user_state.correct_input ? 'correct' : 'incorrect';
} }
} }
var content_html = item.displayName; var imageURL = item.imageURL || item.backgroundImage; // Fall back on "backgroundImage" to be backward-compatible
if (item.backgroundImage) {
content_html = '<img src="' + item.backgroundImage + '" alt="' + item.backgroundDescription + '" />';
}
var itemProperties = { var itemProperties = {
value: item.id, value: item.id,
drag_disabled: Boolean(item_user_state || state.finished), drag_disabled: Boolean(item_user_state || state.finished),
class_name: item_user_state && ('input' in item_user_state || item_user_state.correct_input) ? 'fade': undefined, class_name: item_user_state && ('input' in item_user_state || item_user_state.correct_input) ? 'fade': undefined,
xhr_active: (item_user_state && item_user_state.submitting_location), xhr_active: (item_user_state && item_user_state.submitting_location),
input: input, input: input,
content_html: content_html, displayName: item.displayName,
has_image: !!item.backgroundImage imageURL: imageURL,
imageDescription: item.imageDescription,
has_image: !!imageURL,
}; };
if (item_user_state) { if (item_user_state) {
itemProperties.is_placed = true; itemProperties.is_placed = true;
......
...@@ -70,11 +70,11 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -70,11 +70,11 @@ function DragAndDropEditBlock(runtime, element, params) {
} }
// Set the target image and bind its event handler: // Set the target image and bind its event handler:
$('.target-image-form input.url-input', element).val(_fn.data.targetImg); $('.target-image-form .url-input', element).val(_fn.data.targetImg);
$('.target-image-form input.description-input', element).val(_fn.data.targetImgDescription); $('.target-image-form .description-input', element).val(_fn.data.targetImgDescription);
_fn.build.$el.targetImage.load(_fn.build.form.zone.imageLoaded); _fn.build.$el.targetImage.load(_fn.build.form.zone.imageLoaded);
_fn.build.$el.targetImage.attr('src', params.target_img_expanded_url); _fn.build.$el.targetImage.attr('src', params.target_img_expanded_url);
_fn.build.$el.targetImage.attr('alt', params.target_img_description); _fn.build.$el.targetImage.attr('alt', _fn.data.targetImgDescription);
if (_fn.data.displayLabels) { if (_fn.data.displayLabels) {
$('.display-labels-form input', element).prop('checked', true); $('.display-labels-form input', element).prop('checked', true);
...@@ -124,7 +124,7 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -124,7 +124,7 @@ function DragAndDropEditBlock(runtime, element, params) {
.on('click', '.target-image-form button', function(e) { .on('click', '.target-image-form button', function(e) {
e.preventDefault(); e.preventDefault();
var new_img_url = $.trim($('.target-image-form input.url-input', element).val()); var new_img_url = $.trim($('.target-image-form .url-input', element).val());
if (new_img_url) { if (new_img_url) {
// We may need to 'expand' the URL before it will be valid. // We may need to 'expand' the URL before it will be valid.
// e.g. '/static/blah.png' becomes '/asset-v1:course+id/blah.png' // e.g. '/static/blah.png' becomes '/asset-v1:course+id/blah.png'
...@@ -139,7 +139,7 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -139,7 +139,7 @@ function DragAndDropEditBlock(runtime, element, params) {
_fn.data.targetImg = new_img_url; _fn.data.targetImg = new_img_url;
var new_description = $.trim( var new_description = $.trim(
$('.target-image-form input.description-input', element).val() $('.target-image-form .description-input', element).val()
); );
_fn.build.$el.targetImage.attr('alt', new_description); _fn.build.$el.targetImage.attr('alt', new_description);
_fn.data.targetImgDescription = new_description; _fn.data.targetImgDescription = new_description;
...@@ -388,10 +388,10 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -388,10 +388,10 @@ function DragAndDropEditBlock(runtime, element, params) {
$form.each(function(i, el) { $form.each(function(i, el) {
var $el = $(el), var $el = $(el),
name = $el.find('.item-text').val(), name = $el.find('.item-text').val(),
backgroundImage = $el.find('.background-image-url').val(), imageURL = $el.find('.item-image-url').val(),
backgroundDescription = $el.find('.background-image-description').val(); imageDescription = $el.find('.item-image-description').val();
if (name.length > 0 || backgroundImage.length > 0) { if (name.length > 0 || imageURL.length > 0) {
// Item width/height are ignored, but preserve the data: // Item width/height are ignored, but preserve the data:
var width = $el.find('.item-width').val(), var width = $el.find('.item-width').val(),
height = $el.find('.item-height').val(); height = $el.find('.item-height').val();
...@@ -414,8 +414,8 @@ function DragAndDropEditBlock(runtime, element, params) { ...@@ -414,8 +414,8 @@ function DragAndDropEditBlock(runtime, element, params) {
width: width, width: width,
height: height height: height
}, },
backgroundImage: backgroundImage, imageURL: imageURL,
backgroundDescription: backgroundDescription imageDescription: imageDescription,
}; };
var numValue = parseFloat($el.find('.item-numerical-value').val()); var numValue = parseFloat($el.find('.item-numerical-value').val());
......
...@@ -71,6 +71,10 @@ ...@@ -71,6 +71,10 @@
if (item.has_image) { if (item.has_image) {
className += " " + "option-with-image"; className += " " + "option-with-image";
} }
var content_html = item.displayName;
if (item.imageURL) {
content_html = '<img src="' + item.imageURL + '" alt="' + item.imageDescription + '" />';
}
return ( return (
h('div.option', h('div.option',
{ {
...@@ -86,7 +90,7 @@ ...@@ -86,7 +90,7 @@
style: style style: style
}, [ }, [
itemSpinnerTemplate(item.xhr_active), itemSpinnerTemplate(item.xhr_active),
h('div', {innerHTML: item.content_html, className: "item-content"}), h('div', {innerHTML: content_html, className: "item-content"}),
itemInputTemplate(item.input) itemInputTemplate(item.input)
] ]
) )
......
...@@ -52,15 +52,14 @@ ...@@ -52,15 +52,14 @@
<h3 id="background-description-label"> <h3 id="background-description-label">
{% trans "Background description" %} {% trans "Background description" %}
</h3> </h3>
<input type="text" <textarea class="description-input"
class="description-input" aria-labelledby="background-description-label"
aria-labelledby="background-description-label" aria-describedby="background-description-description"></textarea>
aria-describedby="background-description-description">
<div id="background-description-description" class="target-image-form-help"> <div id="background-description-description" class="target-image-form-help">
{% blocktrans %} {% blocktrans %}
Please provide a description of the image for non-visual users. Please provide a description of the image for non-visual users.
The description should provide sufficient information that would allow anyone The description should provide sufficient information that would allow anyone
to solve the problem if the image did not load. to solve the problem even without seeing the image.
{% endblocktrans %} {% endblocktrans %}
</div> </div>
<button class="btn">{% trans "Change background" %}</button> <button class="btn">{% trans "Change background" %}</button>
......
...@@ -11,26 +11,42 @@ ...@@ -11,26 +11,42 @@
<script id="zone-input-tpl" type="text/html"> <script id="zone-input-tpl" type="text/html">
<div class="zone-row {{ id }}" data-index="{{index}}"> <div class="zone-row {{ id }}" data-index="{{index}}">
<label>{{i18n "Text"}}</label> <label for="zone-{{index}}-title">{{i18n "Text"}}</label>
<input type="text" class="title" value="{{ title }}" /> <input type="text"
id="zone-{{index}}-title"
class="title"
value="{{ title }}" />
<a href="#" class="remove-zone hidden"> <a href="#" class="remove-zone hidden">
<div class="icon remove"></div> <div class="icon remove"></div>
</a> </a>
<label>{{i18n "Description"}}</label> <label for="zone-{{index}}-description">{{i18n "Description"}}</label>
<input type="text" <input type="text"
id="zone-{{index}}-description"
class="description" class="description"
value="{{ description }}" value="{{ description }}"
placeholder="{{i18n 'Describe this zone to non-visual users'}}" /> placeholder="{{i18n 'Describe this zone to non-visual users'}}" />
<div class="layout"> <div class="layout">
<label>{{i18n "width"}}</label> <label for="zone-{{index}}-width">{{i18n "width"}}</label>
<input type="text" class="size width" value="{{ width }}" /> <input type="text"
<label>{{i18n "height"}}</label> id="zone-{{index}}-width"
<input type="text" class="size height" value="{{ height }}" /> class="size width"
value="{{ width }}" />
<label for="zone-{{index}}-height">{{i18n "height"}}</label>
<input type="text"
id="zone-{{index}}-height"
class="size height"
value="{{ height }}" />
<br /> <br />
<label>x</label> <label for="zone-{{index}}-x">x</label>
<input type="text" class="coord x" value="{{ x }}" /> <input type="text"
<label>y</label> id="zone-{{index}}-x"
<input type="text" class="coord y" value="{{ y }}" /> class="coord x"
value="{{ x }}" />
<label for="zone-{{index}}-y">y</label>
<input type="text"
id="zone-{{index}}-y"
class="coord y"
value="{{ y }}" />
</div> </div>
</div> </div>
</script> </script>
...@@ -42,29 +58,39 @@ ...@@ -42,29 +58,39 @@
<script id="item-input-tpl" type="text/html"> <script id="item-input-tpl" type="text/html">
<div class="item"> <div class="item">
<div class="row"> <div class="row">
<label>{{i18n "Text"}}</label> <label for="item-{{id}}-text">{{i18n "Text"}}</label>
<input type="text" class="item-text" value="{{ displayName }}"/> <input type="text"
<label>{{i18n "Zone"}}</label> id="item-{{id}}-text"
<select class="zone-select">{{ dropdown }}</select> class="item-text"
value="{{ displayName }}" />
<label for="item-{{id}}-zone">{{i18n "Zone"}}</label>
<select id="item-{{id}}-zone"
class="zone-select">{{ dropdown }}</select>
<a href="#" class="remove-item hidden"> <a href="#" class="remove-item hidden">
<div class="icon remove"></div> <div class="icon remove"></div>
</a> </a>
</div> </div>
<div class="row"> <div class="row">
<label>{{i18n "Background image URL (alternative to the text)"}}</label> <label for="item-{{id}}-image-url">{{i18n "Image URL (alternative to the text)"}}</label>
<textarea class="background-image-url">{{ backgroundImage }}</textarea> <input type="text"
id="item-{{id}}-image-url"
class="item-image-url"
value="{{ imageURL }}" />
</div> </div>
<div class="row"> <div class="row">
<label>{{i18n "Background image description (should provide sufficient information to place the item even if the image did not load)"}}</label> <label for="item-{{id}}-image-description">{{i18n "Image description (should provide sufficient information to place the item even if the image did not load)"}}</label>
<textarea class="background-image-description">{{ backgroundDescription }}</textarea> <textarea id="item-{{id}}-image-description"
class="item-image-description">{{ imageDescription }}</textarea>
</div> </div>
<div class="row"> <div class="row">
<label>{{i18n "Success Feedback"}}</label> <label for="item-{{id}}-success-feedback">{{i18n "Success Feedback"}}</label>
<textarea class="success-feedback">{{ feedback.correct }}</textarea> <textarea id="item-{{id}}-success-feedback"
class="success-feedback">{{ feedback.correct }}</textarea>
</div> </div>
<div class="row"> <div class="row">
<label>{{i18n "Error Feedback"}}</label> <label for="item-{{id}}-error-feedback">{{i18n "Error Feedback"}}</label>
<textarea class="error-feedback">{{ feedback.incorrect }}</textarea> <textarea id="item-{{id}}-error-feedback"
class="error-feedback">{{ feedback.incorrect }}</textarea>
</div> </div>
<div class="row" style="display: none;"> <div class="row" style="display: none;">
<!-- <!--
...@@ -75,16 +101,26 @@ ...@@ -75,16 +101,26 @@
If we do add them back in, we should only allow setting "width". Height will be If we do add them back in, we should only allow setting "width". Height will be
detected automatically based on font/image size requirements. detected automatically based on font/image size requirements.
--> -->
<label>{{i18n "Width in pixels (0 for auto)"}}</label> <label for="item-{{id}}-width">{{i18n "Width in pixels (0 for auto)"}}</label>
<input type="text" class="item-width" value="{{ width }}"></input> <input type="text"
<label>{{i18n "Height in pixels (0 for auto)"}}</label> id="item-{{id}}-width"
<input type="text" class="item-height" value="{{ height }}"></input> class="item-width"
value="{{ width }}" />
<label for="item-{{id}}-height">{{i18n "Height in pixels (0 for auto)"}}</label>
<input type="text"
id="item-{{id}}-height"
class="item-height"
value="{{ height }}" />
</div> </div>
<div class="row"> <div class="row">
<label>{{i18n "Optional numerical value"}}</label> <label for="item-{{id}}-numerical-value">{{i18n "Optional numerical value"}}</label>
<input type="text" class="item-numerical-value" value="{{ numericalValue }}"></input> <input type="text"
<label>{{i18n "Margin ±"}}</label> id="item-{{id}}-numerical-value"
<input type="text" class="item-numerical-margin" value="{{ numericalMargin }}"></input> class="item-numerical-value" value="{{ numericalValue }}" />
<label for="item-{{id}}-numerical-margin">{{i18n "Margin ±"}}</label>
<input type="text"
id="item-{{id}}-numerical-margin"
class="item-numerical-margin" value="{{ numericalMargin }}" />
</div> </div>
</div> </div>
</script> </script>
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"correct": "Yes 1" "correct": "Yes 1"
}, },
"zone": "Zone 1", "zone": "Zone 1",
"backgroundImage": "", "imageURL": "",
"id": 0 "id": 0
}, },
{ {
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"correct": "Yes 2" "correct": "Yes 2"
}, },
"zone": "Zone 2", "zone": "Zone 2",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"inputOptions": { "inputOptions": {
"value": 100, "value": 100,
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "", "imageURL": "",
"id": 2 "id": 2
} }
], ],
......
{ {
"zones": [ "zones": [
{ {
"index": 1, "index": 1,
"title": "Zone 1", "title": "Zone 1",
"description": "This describes zone 1", "description": "This describes zone 1",
"height": 178, "height": 178,
"width": 196, "width": 196,
"y": "30", "y": "30",
"x": "160", "x": "160",
"id": "zone-1" "id": "zone-1"
},
{
"index": 2,
"title": "Zone 2",
"description": "This describes zone 2",
"height": 140,
"width": 340,
"y": "210",
"x": "86",
"id": "zone-2"
}
],
"items": [
{
"displayName": "1",
"backgroundImage": "https://placehold.it/100x100",
"backgroundDescription": "This describes the background image of item 1",
"feedback": {
"incorrect": "No, 1 does not belong here",
"correct": "Yes, 1 goes here"
},
"zone": "Zone 1",
"id": 0
},
{
"displayName": "2",
"backgroundImage": "https://placehold.it/100x100",
"backgroundDescription": "This describes the background image of item 2",
"feedback": {
"incorrect": "No, 2 does not belong here",
"correct": "Yes, 2 goes here"
},
"zone": "Zone 2",
"id": 1
},
{
"displayName": "X",
"backgroundImage": "",
"feedback": {
"incorrect": "You silly, there are no zones for X",
"correct": ""
},
"zone": "none",
"id": 2
}
],
"feedback": {
"start": "Drag the items onto the image above.",
"finish": "Good work! You have completed this drag and drop exercise."
}, },
"targetImgDescription": "This describes the target image" {
"index": 2,
"title": "Zone 2",
"description": "This describes zone 2",
"height": 140,
"width": 340,
"y": "210",
"x": "86",
"id": "zone-2"
}
],
"items": [
{
"displayName": "1",
"imageURL": "https://placehold.it/100x100",
"imageDescription": "This describes the background image of item 1",
"feedback": {
"incorrect": "No, 1 does not belong here",
"correct": "Yes, 1 goes here"
},
"zone": "Zone 1",
"id": 0
},
{
"displayName": "2",
"imageURL": "https://placehold.it/100x100",
"imageDescription": "This describes the background image of item 2",
"feedback": {
"incorrect": "No, 2 does not belong here",
"correct": "Yes, 2 goes here"
},
"zone": "Zone 2",
"id": 1
},
{
"displayName": "X",
"imageURL": "",
"feedback": {
"incorrect": "You silly, there are no zones for X",
"correct": ""
},
"zone": "none",
"id": 2
}
],
"feedback": {
"start": "Drag the items onto the image above.",
"finish": "Good work! You have completed this drag and drop exercise."
},
"targetImgDescription": "This describes the target image"
} }
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"correct": "Correct 1" "correct": "Correct 1"
}, },
"zone": "Zone 51", "zone": "Zone 51",
"backgroundImage": "", "imageURL": "",
"id": 10 "id": 10
}, },
{ {
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"correct": "Correct 2" "correct": "Correct 2"
}, },
"zone": "Zone 52", "zone": "Zone 52",
"backgroundImage": "", "imageURL": "",
"id": 20, "id": 20,
"inputOptions": { "inputOptions": {
"value": 100, "value": 100,
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "", "imageURL": "",
"id": 30 "id": 30
} }
], ],
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"correct": "Yes <b>1</b>" "correct": "Yes <b>1</b>"
}, },
"zone": "Zone <i>1</i>", "zone": "Zone <i>1</i>",
"backgroundImage": "", "imageURL": "",
"id": 0 "id": 0
}, },
{ {
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
"correct": "Yes <i>2</i>" "correct": "Yes <i>2</i>"
}, },
"zone": "Zone <b>2</b>", "zone": "Zone <b>2</b>",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"inputOptions": { "inputOptions": {
"value": 100, "value": 100,
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "", "imageURL": "",
"id": 2 "id": 2
} }
], ],
......
...@@ -112,7 +112,9 @@ class TestDragAndDropRender(BaseIntegrationTest): ...@@ -112,7 +112,9 @@ class TestDragAndDropRender(BaseIntegrationTest):
self._test_items(color_settings=color_settings) self._test_items(color_settings=color_settings)
def _test_items(self, color_settings={}): # pylint: disable=dangerous-default-value def _test_items(self, color_settings=None):
color_settings = color_settings or {}
items = self._get_items() items = self._get_items()
self.assertEqual(len(items), 3) self.assertEqual(len(items), 3)
...@@ -155,12 +157,8 @@ class TestDragAndDropRender(BaseIntegrationTest): ...@@ -155,12 +157,8 @@ class TestDragAndDropRender(BaseIntegrationTest):
self.assertEqual(zone.get_attribute('data-zone'), 'Zone {}'.format(zone_number)) self.assertEqual(zone.get_attribute('data-zone'), 'Zone {}'.format(zone_number))
self.assertIn('ui-droppable', self.get_element_classes(zone)) self.assertIn('ui-droppable', self.get_element_classes(zone))
zone_box_percentages = box_percentages[index] zone_box_percentages = box_percentages[index]
self._assert_box_percentages( self._assert_box_percentages( # pylint: disable=star-args
'#zone-{}'.format(zone_number), '#zone-{}'.format(zone_number), **zone_box_percentages
left=zone_box_percentages['left'],
top=zone_box_percentages['top'],
width=zone_box_percentages['width'],
height=zone_box_percentages['height']
) )
zone_name = zone.find_element_by_css_selector('p.zone-name') zone_name = zone.find_element_by_css_selector('p.zone-name')
self.assertEqual(zone_name.text, 'ZONE {}'.format(zone_number)) self.assertEqual(zone_name.text, 'ZONE {}'.format(zone_number))
......
...@@ -34,25 +34,25 @@ ...@@ -34,25 +34,25 @@
"items": [ "items": [
{ {
"displayName": "<b>1</b>", "displayName": "<b>1</b>",
"backgroundImage": "", "imageURL": "",
"id": 0, "id": 0,
"inputOptions": false "inputOptions": false
}, },
{ {
"displayName": "<i>2</i>", "displayName": "<i>2</i>",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"inputOptions": true "inputOptions": true
}, },
{ {
"displayName": "X", "displayName": "X",
"backgroundImage": "", "imageURL": "",
"id": 2, "id": 2,
"inputOptions": false "inputOptions": false
}, },
{ {
"displayName": "", "displayName": "",
"backgroundImage": "http://placehold.it/100x300", "imageURL": "http://placehold.it/100x300",
"id": 3, "id": 3,
"inputOptions": false "inputOptions": false
} }
......
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
"correct": "Yes <b>1</b>" "correct": "Yes <b>1</b>"
}, },
"zone": "Zone <i>1</i>", "zone": "Zone <i>1</i>",
"backgroundImage": "", "imageURL": "",
"id": 0 "id": 0
}, },
{ {
...@@ -38,7 +38,7 @@ ...@@ -38,7 +38,7 @@
"correct": "Yes <i>2</i>" "correct": "Yes <i>2</i>"
}, },
"zone": "Zone <b>2</b>", "zone": "Zone <b>2</b>",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"inputOptions": { "inputOptions": {
"value": 100, "value": 100,
...@@ -52,7 +52,7 @@ ...@@ -52,7 +52,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "", "imageURL": "",
"id": 2 "id": 2
}, },
{ {
...@@ -62,7 +62,7 @@ ...@@ -62,7 +62,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "http://placehold.it/100x300", "imageURL": "http://placehold.it/100x300",
"id": 3 "id": 3
} }
], ],
......
...@@ -34,28 +34,28 @@ ...@@ -34,28 +34,28 @@
"items": [ "items": [
{ {
"displayName": "1", "displayName": "1",
"backgroundImage": "", "imageURL": "",
"id": 0, "id": 0,
"inputOptions": false, "inputOptions": false,
"size": {"height": "auto", "width": "190px"} "size": {"height": "auto", "width": "190px"}
}, },
{ {
"displayName": "2", "displayName": "2",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"inputOptions": true, "inputOptions": true,
"size": {"height": "auto", "width": "190px"} "size": {"height": "auto", "width": "190px"}
}, },
{ {
"displayName": "X", "displayName": "X",
"backgroundImage": "", "imageURL": "",
"id": 2, "id": 2,
"inputOptions": false, "inputOptions": false,
"size": {"height": "100px", "width": "100px"} "size": {"height": "100px", "width": "100px"}
}, },
{ {
"displayName": "", "displayName": "",
"backgroundImage": "http://i1.kym-cdn.com/entries/icons/square/000/006/151/tumblr_lltzgnHi5F1qzib3wo1_400.jpg", "imageURL": "http://i1.kym-cdn.com/entries/icons/square/000/006/151/tumblr_lltzgnHi5F1qzib3wo1_400.jpg",
"id": 3, "id": 3,
"inputOptions": false, "inputOptions": false,
"size": {"height": "auto", "width": "190px"} "size": {"height": "auto", "width": "190px"}
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
"correct": "Yes 1" "correct": "Yes 1"
}, },
"zone": "Zone 1", "zone": "Zone 1",
"backgroundImage": "", "imageURL": "",
"id": 0, "id": 0,
"size": { "size": {
"width": "190px", "width": "190px",
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
"correct": "Yes 2" "correct": "Yes 2"
}, },
"zone": "Zone 2", "zone": "Zone 2",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"size": { "size": {
"width": "190px", "width": "190px",
...@@ -59,7 +59,7 @@ ...@@ -59,7 +59,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "", "imageURL": "",
"id": 2, "id": 2,
"size": { "size": {
"width": "100px", "width": "100px",
...@@ -73,7 +73,7 @@ ...@@ -73,7 +73,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "http://i1.kym-cdn.com/entries/icons/square/000/006/151/tumblr_lltzgnHi5F1qzib3wo1_400.jpg", "imageURL": "http://i1.kym-cdn.com/entries/icons/square/000/006/151/tumblr_lltzgnHi5F1qzib3wo1_400.jpg",
"id": 3, "id": 3,
"size": { "size": {
"width": "190px", "width": "190px",
......
...@@ -34,25 +34,25 @@ ...@@ -34,25 +34,25 @@
"items": [ "items": [
{ {
"displayName": "1", "displayName": "1",
"backgroundImage": "", "imageURL": "",
"id": 0, "id": 0,
"inputOptions": false "inputOptions": false
}, },
{ {
"displayName": "2", "displayName": "2",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"inputOptions": true "inputOptions": true
}, },
{ {
"displayName": "X", "displayName": "X",
"backgroundImage": "", "imageURL": "",
"id": 2, "id": 2,
"inputOptions": false "inputOptions": false
}, },
{ {
"displayName": "", "displayName": "",
"backgroundImage": "http://placehold.it/200x100", "imageURL": "http://placehold.it/200x100",
"id": 3, "id": 3,
"inputOptions": false "inputOptions": false
} }
......
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"correct": "Yes 1" "correct": "Yes 1"
}, },
"zone": "Zone 1", "zone": "Zone 1",
"backgroundImage": "", "imageURL": "",
"id": 0 "id": 0
}, },
{ {
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
"correct": "Yes 2" "correct": "Yes 2"
}, },
"zone": "Zone 2", "zone": "Zone 2",
"backgroundImage": "", "imageURL": "",
"id": 1, "id": 1,
"inputOptions": { "inputOptions": {
"value": 100, "value": 100,
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "", "imageURL": "",
"id": 2 "id": 2
}, },
{ {
...@@ -63,7 +63,7 @@ ...@@ -63,7 +63,7 @@
"correct": "" "correct": ""
}, },
"zone": "none", "zone": "none",
"backgroundImage": "http://placehold.it/200x100", "imageURL": "http://placehold.it/200x100",
"id": 3 "id": 3
} }
], ],
......
...@@ -63,9 +63,9 @@ class BasicTests(TestCaseMixin, unittest.TestCase): ...@@ -63,9 +63,9 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
]) ])
# Items should contain no answer data: # Items should contain no answer data:
self.assertEqual(items, [ self.assertEqual(items, [
{"id": 0, "displayName": "1", "backgroundImage": "", "inputOptions": False}, {"id": 0, "displayName": "1", "imageURL": "", "inputOptions": False},
{"id": 1, "displayName": "2", "backgroundImage": "", "inputOptions": False}, {"id": 1, "displayName": "2", "imageURL": "", "inputOptions": False},
{"id": 2, "displayName": "X", "backgroundImage": "", "inputOptions": False}, {"id": 2, "displayName": "X", "imageURL": "", "inputOptions": False},
]) ])
def test_ajax_solve_and_reset(self): def test_ajax_solve_and_reset(self):
......
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