Unverified Commit 66fc6d9b by Eugeny Kolpakov Committed by GitHub

Added publishing progress event no matter if grade is updated or not (#145) (#147)

parent 9046ba05
......@@ -12,7 +12,7 @@ install:
- "pip install selenium==2.53.0"
- "pip uninstall -y xblock-drag-and-drop-v2"
- "python setup.py sdist"
- "pip install dist/xblock-drag-and-drop-v2-2.1.3.tar.gz"
- "pip install dist/xblock-drag-and-drop-v2-2.1.4.tar.gz"
script:
- pep8 drag_and_drop_v2 tests --max-line-length=120
- pylint drag_and_drop_v2
......
Version 2.1.4 (2017-11-06)
---------------------------
* Make XBlock always emit `progress` event explicitly when it is marked as complete.
Version 2.1.3 (2017-10-05)
---------------------------
......
......@@ -773,6 +773,9 @@ class DragAndDropBlock(
self.raw_earned = current_raw_earned
self._publish_grade(Score(self.raw_earned, self.max_score()))
# and no matter what - emit progress event for current user
self.runtime.publish(self, "progress", {})
def _publish_item_dropped_event(self, attempt, is_correct):
"""
Publishes item dropped event.
......
File mode changed from 100644 to 100755
......@@ -23,7 +23,7 @@ def package_data(pkg, root_list):
setup(
name='xblock-drag-and-drop-v2',
version='2.1.3',
version='2.1.4',
description='XBlock - Drag-and-Drop v2',
packages=['drag_and_drop_v2'],
install_requires=[
......
......@@ -44,6 +44,10 @@ class EventsFiredTest(DefaultDataTestMixin, ParameterizedTestsMixin, BaseEventsT
'data': {'max_value': 1, 'value': (2.0 / 5), 'only_if_higher': None},
},
{
'name': 'progress',
'data': {}
},
{
'name': 'edx.drag_and_drop_v2.item.dropped',
'data': {
'is_correct': True,
......@@ -124,6 +128,10 @@ class AssessmentEventsFiredTest(
'data': {'max_value': 1, 'value': (1.0 / 5), 'only_if_higher': None},
},
{
'name': 'progress',
'data': {}
},
{
'name': 'edx.drag_and_drop_v2.feedback.opened',
'data': {
'content': "\n".join([ITEM_INCORRECT_FEEDBACK, ITEM_INCORRECT_FEEDBACK]),
......
......@@ -405,14 +405,19 @@ class AssessmentModeFixture(BaseDragAndDropAjaxFixture):
res = self.call_handler(self.DO_ATTEMPT_HANDLER, data={})
self.assertTrue(self.block.completed)
patched_publish.assert_called_once_with(self.block, 'grade', {
'value': 1,
'max_value': 1,
'only_if_higher': None,
})
self.assertTrue(res['correct'])
self.assertEqual(res['grade'], self.block.weight)
expected_calls = [
mock.call(self.block, 'grade', {
'value': 1,
'max_value': 1,
'only_if_higher': None,
}),
mock.call(self.block, 'progress', {})
]
self.assertEqual(patched_publish.mock_calls, expected_calls)
@ddt.data(*[random.randint(1, 50) for _ in xrange(5)]) # pylint: disable=star-args
def test_do_attempt_incorrect_publish_grade(self, weight):
self.block.weight = weight
......@@ -423,14 +428,19 @@ class AssessmentModeFixture(BaseDragAndDropAjaxFixture):
res = self.call_handler(self.DO_ATTEMPT_HANDLER, data={})
self.assertFalse(self.block.completed)
patched_publish.assert_called_once_with(self.block, 'grade', {
'value': correctness,
'max_value': 1,
'only_if_higher': None,
})
self.assertFalse(res['correct'])
self.assertEqual(res['grade'], correctness * self.block.weight)
expected_calls = [
mock.call(self.block, 'grade', {
'value': correctness,
'max_value': 1,
'only_if_higher': None,
}),
mock.call(self.block, 'progress', {})
]
self.assertEqual(patched_publish.mock_calls, expected_calls)
@ddt.data(*[random.randint(1, 50) for _ in xrange(5)]) # pylint: disable=star-args
def test_do_attempt_post_correct_no_publish_grade(self, weight):
self.block.weight = weight
......@@ -444,7 +454,7 @@ class AssessmentModeFixture(BaseDragAndDropAjaxFixture):
self.assertTrue(self.block.completed)
self.assertEqual(self.block.raw_earned, 1)
self.assertFalse(patched_publish.called)
self.assertEqual(patched_publish.mock_calls, [mock.call(self.block, 'progress', {})])
def test_get_user_state_finished_after_final_attempt(self):
self._set_final_attempt()
......@@ -469,11 +479,6 @@ class AssessmentModeFixture(BaseDragAndDropAjaxFixture):
res = self.call_handler(self.DO_ATTEMPT_HANDLER, data={})
self.assertTrue(self.block.completed)
patched_publish.assert_called_once_with(self.block, 'grade', {
'value': expected_raw_grade,
'max_value': 1,
'only_if_higher': None,
})
expected_grade_feedback = self._make_feedback_message(
FeedbackMessages.FINAL_ATTEMPT_TPL.format(score=expected_weighted_grade),
......@@ -482,6 +487,16 @@ class AssessmentModeFixture(BaseDragAndDropAjaxFixture):
self.assertIn(expected_grade_feedback, res[self.OVERALL_FEEDBACK_KEY])
self.assertEqual(res['grade'], expected_weighted_grade)
expected_calls = [
mock.call(self.block, 'grade', {
'value': expected_raw_grade,
'max_value': 1,
'only_if_higher': None,
}),
mock.call(self.block, 'progress', {})
]
self.assertEqual(patched_publish.mock_calls, expected_calls)
@ddt.data(*[random.randint(1, 50) for _ in xrange(5)]) # pylint: disable=star-args
def test_do_attempt_incorrect_final_attempt_after_correct(self, weight):
self.block.weight = weight
......@@ -505,9 +520,9 @@ class AssessmentModeFixture(BaseDragAndDropAjaxFixture):
FeedbackMessages.FINAL_ATTEMPT_TPL.format(score=float(weight)),
FeedbackMessages.MessageClasses.PARTIAL_SOLUTION
)
self.assertFalse(patched_publish.called)
self.assertIn(expected_grade_feedback, res[self.OVERALL_FEEDBACK_KEY])
self.assertEqual(self.block.raw_earned, 1)
self.assertEqual(patched_publish.mock_calls, [mock.call(self.block, 'progress', {})])
def test_do_attempt_misplaced_ids(self):
misplaced_ids = self._submit_incorrect_solution()
......
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