Commit e91ce124 by Eugeny Kolpakov

Merge pull request #2 from open-craft/real-children

Automatically send progress event when rendered with display_submit=False
parents b02b1e4e 8d5a730e
......@@ -98,7 +98,12 @@ class MentoringBlock(XBlock, StepParentMixin):
scope=Scope.content,
enforce_type=True
)
display_submit = Boolean(help="Allow to submit current block?", default=True, scope=Scope.content)
display_submit = Boolean(
help="Allow submission of the current block?",
default=True,
scope=Scope.content,
enforce_type=True
)
xml_content = String(help="XML content", default=default_xml_content, scope=Scope.content)
# Settings
......@@ -213,6 +218,9 @@ class MentoringBlock(XBlock, StepParentMixin):
fragment.initialize_js('MentoringBlock')
if not self.display_submit:
self.runtime.publish(self, 'progress', {})
return fragment
def migrate_fields(self):
......
from selenium.common.exceptions import NoSuchElementException
from .base_test import MentoringBaseTest
class MentoringTest(MentoringBaseTest):
def test_display_submit_false_does_not_display_submit(self):
mentoring = self.go_to_page('No Display Submit')
with self.assertRaises(NoSuchElementException):
mentoring.find_element_by_css_selector('.submit input.input-main')
<vertical_demo>
<mentoring url_name="answer_blank_read_only" enforce_dependency="false" display_submit="false">
<answer name="answer_blank"/>
</mentoring>
</vertical_demo>
import unittest
from mock import MagicMock, Mock, patch
from xblock.field_data import DictFieldData
from mentoring import MentoringBlock
class TestMentoringBlock(unittest.TestCase):
def test_sends_progress_event_when_rendered_student_view_with_display_submit_false(self):
block = MentoringBlock(MagicMock(), DictFieldData({
'display_submit': False
}), Mock())
with patch.object(block, 'runtime') as patched_runtime:
patched_runtime.publish = Mock()
block.student_view(context={})
patched_runtime.publish.assert_called_once_with(block, 'progress', {})
def test_does_not_send_progress_event_when_rendered_student_view_with_display_submit_true(self):
block = MentoringBlock(MagicMock(), DictFieldData({
'display_submit': True
}), Mock())
with patch.object(block, 'runtime') as patched_runtime:
patched_runtime.publish = Mock()
block.student_view(context={})
self.assertFalse(patched_runtime.publish.called)
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