Skip to content

Commit

Permalink
Merge pull request #106 from arbrandes/final_state
Browse files Browse the repository at this point in the history
Don't delete misplaced items on final attempt
  • Loading branch information
itsjeyd authored Oct 18, 2016
2 parents 45b0e1a + 3a91a7c commit 24c6ced
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
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)
---------------------------

Expand Down
4 changes: 3 additions & 1 deletion drag_and_drop_v2/drag_and_drop_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,9 @@ def do_attempt(self, data, suffix=''):

misplaced_items = []
for item_id in misplaced_ids:
del self.item_state[item_id]
# 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)))

feedback_msgs = [FeedbackMessage(item['feedback']['incorrect'], None) for item in misplaced_items]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
30 changes: 30 additions & 0 deletions tests/integration/test_interaction_assessment.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,36 @@ def test_misplaced_items_returned_to_bank(self):
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
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/test_advanced.py
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,21 @@ def test_do_attempt_shows_final_feedback_at_last_attempt(self):
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
Expand Down

0 comments on commit 24c6ced

Please sign in to comment.