Commit 32f7e7b3 by Jonathan Piacenti

Allow Videos and images to be added to Mentoring Step Block.

parent 2105c1b3
...@@ -127,11 +127,27 @@ class MentoringStepBlock( ...@@ -127,11 +127,27 @@ class MentoringStepBlock(
NestedXBlockSpec allows explicitly setting disabled/enabled state, disabled reason (if any) and single/multiple NestedXBlockSpec allows explicitly setting disabled/enabled state, disabled reason (if any) and single/multiple
instances 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 [ return [
NestedXBlockSpec(AnswerBlock, boilerplate='studio_default'), NestedXBlockSpec(AnswerBlock, boilerplate='studio_default'),
MCQBlock, RatingBlock, MRQBlock, HtmlBlockShim, MCQBlock, RatingBlock, MRQBlock, HtmlBlockShim,
AnswerRecapBlock, MentoringTableBlock, AnswerRecapBlock, MentoringTableBlock,
] ] + additional_blocks
@property @property
def has_question(self): def has_question(self):
......
import unittest import unittest
from xblock.field_data import DictFieldData
from problem_builder.step import MentoringStepBlock
from problem_builder.mixins import QuestionMixin, StepParentMixin from problem_builder.mixins import QuestionMixin, StepParentMixin
from mock import Mock from mock import Mock, patch
class Parent(StepParentMixin): class Parent(StepParentMixin):
...@@ -92,3 +94,34 @@ class TestQuestionMixin(unittest.TestCase): ...@@ -92,3 +94,34 @@ class TestQuestionMixin(unittest.TestCase):
self.assertFalse(step1.lonely_child) self.assertFalse(step1.lonely_child)
self.assertFalse(step2.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 ddt
mock mock
unicodecsv==0.9.4 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 . -e .
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