Commit 24c6ceda by Tim Krones Committed by GitHub

Merge pull request #106 from arbrandes/final_state

Don't delete misplaced items on final attempt
parents 45b0e1a6 3a91a7ce
......@@ -9,7 +9,7 @@ install:
- "sh install_test_deps.sh"
- "pip uninstall -y xblock-drag-and-drop-v2"
- "python setup.py sdist"
- "pip install dist/xblock-drag-and-drop-v2-2.0.10.tar.gz"
- "pip install dist/xblock-drag-and-drop-v2-2.0.11.tar.gz"
script:
- pep8 drag_and_drop_v2 tests --max-line-length=120
- pylint drag_and_drop_v2
......
Version 2.0.11 (2016-10-03)
---------------------------
* ([#106](https://github.com/edx-solutions/xblock-drag-and-drop-v2/pull/106)) Don't delete misplaced items on final attempt
Version 2.0.10 (2016-09-22)
---------------------------
......
......@@ -403,6 +403,8 @@ class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
misplaced_items = []
for item_id in misplaced_ids:
# Don't delete misplaced item states on the final attempt.
if self.attempts_remain:
del self.item_state[item_id]
misplaced_items.append(self._get_item_definition(int(item_id)))
......
......@@ -23,7 +23,7 @@ def package_data(pkg, root_list):
setup(
name='xblock-drag-and-drop-v2',
version='2.0.10',
version='2.0.11',
description='XBlock - Drag-and-Drop v2',
packages=['drag_and_drop_v2'],
install_requires=[
......
......@@ -139,6 +139,36 @@ class AssessmentInteractionTest(
for item_id in misplaced_items:
self.assert_reverted_item(item_id)
def test_misplaced_items_not_returned_to_bank_on_final_attempt(self):
"""
Test items placed on incorrect zones are not returned to item bank
after submitting solution on the final attempt, and remain placed after
subsequently refreshing the page.
"""
self.place_item(0, TOP_ZONE_ID, action_key=Keys.RETURN)
# Reach final attempt
for _ in xrange(self.MAX_ATTEMPTS-1):
self.click_submit()
# Place incorrect item on final attempt
self.place_item(1, TOP_ZONE_ID, action_key=Keys.RETURN)
self.click_submit()
# Incorrect item remains placed
def _assert_placed(item_id, zone_title):
item = self._get_placed_item_by_value(item_id)
item_description = item.find_element_by_css_selector('.sr')
self.assertEqual(item_description.text, 'Placed in: {}'.format(zone_title))
_assert_placed(1, TOP_ZONE_TITLE)
# Refresh the page
self._page = self.go_to_page(self.PAGE_TITLE)
# Incorrect item remains placed after refresh
_assert_placed(1, TOP_ZONE_TITLE)
def test_max_attempts_reached_submit_and_reset_disabled(self):
"""
Test "Submit" and "Reset" buttons are disabled when no more attempts remaining
......
......@@ -404,6 +404,21 @@ class AssessmentModeFixture(BaseDragAndDropAjaxFixture):
expected_message = self._make_feedback_message(self.FINAL_FEEDBACK)
self.assertIn(expected_message, res[self.OVERALL_FEEDBACK_KEY])
def test_do_attempt_does_not_delete_misplaced_items_at_last_attempt(self):
"""
Upon submitting the final attempt, test that misplaced items are not
deleted from the item state.
"""
self._set_final_attempt()
misplaced_ids = self._submit_incorrect_solution()
self.call_handler(self.DO_ATTEMPT_HANDLER, data={})
self.assertFalse(self.block.attempts_remain) # precondition check
for i in misplaced_ids:
self.assertIn(str(i), self.block.item_state.keys())
def test_get_user_state_does_not_include_correctness(self):
self._submit_complete_solution()
original_item_state = self.block.item_state
......
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