Commit 8d8a8f96 by Kelketek

Merge pull request #73 from open-craft/nested-steps

Allow Videos and images to be added to Mentoring Step Block.
parents 2105c1b3 c131a90e
......@@ -5,6 +5,8 @@
/workbench.*
/dist
/templates
/var
*.iml
.idea/*
dump.rdb
problem_builder.tests.*
......@@ -127,11 +127,27 @@ class MentoringStepBlock(
NestedXBlockSpec allows explicitly setting disabled/enabled state, disabled reason (if any) and single/multiple
instances
"""
additional_blocks = []
try:
from xmodule.video_module.video_module import VideoDescriptor
additional_blocks.append(NestedXBlockSpec(
VideoDescriptor, category='video', label=_(u"Video")
))
except ImportError:
pass
try:
from imagemodal import ImageModal
additional_blocks.append(NestedXBlockSpec(
ImageModal, category='imagemodal', label=_(u"Image Modal")
))
except ImportError:
pass
return [
NestedXBlockSpec(AnswerBlock, boilerplate='studio_default'),
MCQBlock, RatingBlock, MRQBlock, HtmlBlockShim,
AnswerRecapBlock, MentoringTableBlock,
]
] + additional_blocks
@property
def has_question(self):
......
import unittest
from xblock.field_data import DictFieldData
from problem_builder.step import MentoringStepBlock
from problem_builder.mixins import QuestionMixin, StepParentMixin
from mock import Mock
from mock import Mock, patch
class Parent(StepParentMixin):
......@@ -92,3 +94,34 @@ class TestQuestionMixin(unittest.TestCase):
self.assertFalse(step1.lonely_child)
self.assertFalse(step2.lonely_child)
class TestMentoringStep(unittest.TestCase):
def get_allowed_blocks(self, block):
return [
getattr(allowed_block, 'category', getattr(allowed_block, 'CATEGORY', None))
for allowed_block in block.allowed_nested_blocks
]
def test_allowed_nested_blocks(self):
block = MentoringStepBlock(Mock(), DictFieldData({}), Mock())
self.assertEqual(
self.get_allowed_blocks(block),
['pb-answer', 'pb-mcq', 'pb-rating', 'pb-mrq', 'html', 'pb-answer-recap', 'pb-table']
)
from sys import modules
xmodule_mock = Mock()
fake_modules = {
'xmodule': xmodule_mock,
'xmodule.video_module': xmodule_mock.video_module,
'xmodule.video_module.video_module': xmodule_mock.video_module.video_module,
'imagemodal': Mock()
}
with patch.dict(modules, fake_modules):
self.assertEqual(
self.get_allowed_blocks(block), [
'pb-answer', 'pb-mcq', 'pb-rating', 'pb-mrq', 'html', 'pb-answer-recap',
'pb-table', 'video', 'imagemodal'
]
)
ddt
mock
unicodecsv==0.9.4
-e git+https://github.com/edx/xblock-utils.git@588f7fd3ee88847c57cf09d10e81caa6b267ec51#egg=xblock-utils
-e git+https://github.com/edx/xblock-utils.git@b4f9b51146c7fafa12f41d54af752b8f1516dffd#egg=xblock-utils
-e .
......@@ -24,6 +24,12 @@ if __name__ == "__main__":
# Configure a range of ports in case the default port of 8081 is in use
os.environ.setdefault("DJANGO_LIVE_TEST_SERVER_ADDRESS", "localhost:8081-8099")
try:
os.mkdir('var')
except OSError:
# May already exist.
pass
from django.conf import settings
settings.INSTALLED_APPS += ("problem_builder", )
......
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