Commit a2cbbdcc by Tim Krones

Set up basic infrastructure for theming.

parent e5413899
...@@ -25,7 +25,8 @@ loader = ResourceLoader(__name__) ...@@ -25,7 +25,8 @@ loader = ResourceLoader(__name__)
# Classes ########################################################### # Classes ###########################################################
class DragAndDropBlock(XBlock): @XBlock.wants('settings')
class DragAndDropBlock(XBlock, XBlockWithSettingsMixin, ThemableXBlockMixin):
""" """
XBlock providing a Drag and Drop question XBlock providing a Drag and Drop question
""" """
...@@ -103,6 +104,7 @@ class DragAndDropBlock(XBlock): ...@@ -103,6 +104,7 @@ class DragAndDropBlock(XBlock):
default=False, default=False,
) )
block_settings_key = 'drag-and-drop-v2'
has_score = True has_score = True
def _(self, text): def _(self, text):
...@@ -132,6 +134,8 @@ class DragAndDropBlock(XBlock): ...@@ -132,6 +134,8 @@ class DragAndDropBlock(XBlock):
for js_url in js_urls: for js_url in js_urls:
fragment.add_javascript_url(self.runtime.local_resource_url(self, js_url)) fragment.add_javascript_url(self.runtime.local_resource_url(self, js_url))
self.include_theme_files(fragment)
fragment.initialize_js('DragAndDropBlock', self.get_configuration()) fragment.initialize_js('DragAndDropBlock', self.get_configuration())
return fragment return fragment
......
...@@ -39,10 +39,6 @@ ...@@ -39,10 +39,6 @@
background: #ebf0f2; background: #ebf0f2;
} }
/*.xblock--drag-and-drop .clear {
clear: both;
}*/
/** Draggable Items **/ /** Draggable Items **/
.xblock--drag-and-drop .item-bank { .xblock--drag-and-drop .item-bank {
display: -ms-flexbox; display: -ms-flexbox;
......
...@@ -303,7 +303,7 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -303,7 +303,7 @@ function DragAndDropBlock(runtime, element, configuration) {
// Make zone accept items that are dropped using the mouse // Make zone accept items that are dropped using the mouse
$root.find('.zone').droppable({ $root.find('.zone').droppable({
accept: '.xblock--drag-and-drop .item-bank .option', accept: '.item-bank .option',
tolerance: 'pointer', tolerance: 'pointer',
drop: function(evt, ui) { drop: function(evt, ui) {
var $zone = $(this); var $zone = $(this);
...@@ -331,9 +331,9 @@ function DragAndDropBlock(runtime, element, configuration) { ...@@ -331,9 +331,9 @@ function DragAndDropBlock(runtime, element, configuration) {
// Make item draggable using the mouse // Make item draggable using the mouse
try { try {
$item.draggable({ $item.draggable({
containment: $root.find('.xblock--drag-and-drop .drag-container'), containment: $root.find('.drag-container'),
cursor: 'move', cursor: 'move',
stack: $root.find('.xblock--drag-and-drop .item-bank .option'), stack: $root.find('.item-bank .option'),
revert: 'invalid', revert: 'invalid',
revertDuration: 150, revertDuration: 150,
start: function(evt, ui) { start: function(evt, ui) {
......
...@@ -199,7 +199,7 @@ ...@@ -199,7 +199,7 @@
var items_placed = $.grep(ctx.items, is_item_placed); var items_placed = $.grep(ctx.items, is_item_placed);
var items_in_bank = $.grep(ctx.items, is_item_placed, true); var items_in_bank = $.grep(ctx.items, is_item_placed, true);
return ( return (
h('section.xblock--drag-and-drop', [ h('section.themed-xblock.xblock--drag-and-drop', [
problemHeader, problemHeader,
h('section.problem', {role: 'application'}, [ h('section.problem', {role: 'application'}, [
questionHeader, questionHeader,
......
{% load i18n %} {% load i18n %}
<section class="xblock--drag-and-drop"> <section class="themed-xblock xblock--drag-and-drop">
<i class="fa fa-spin fa-spinner initial-load-spinner"></i>{% trans "Loading drag and drop exercise." %} <i class="fa fa-spin fa-spinner initial-load-spinner"></i>{% trans "Loading drag and drop exercise." %}
</section> </section>
...@@ -18,7 +18,7 @@ loader = ResourceLoader(__name__) ...@@ -18,7 +18,7 @@ loader = ResourceLoader(__name__)
class BaseIntegrationTest(SeleniumBaseTest): class BaseIntegrationTest(SeleniumBaseTest):
default_css_selector = 'section.xblock--drag-and-drop' default_css_selector = 'section.themed-xblock.xblock--drag-and-drop'
module_name = __name__ module_name = __name__
_additional_escapes = { _additional_escapes = {
......
...@@ -17,7 +17,7 @@ class BasicTests(TestCaseMixin, unittest.TestCase): ...@@ -17,7 +17,7 @@ class BasicTests(TestCaseMixin, unittest.TestCase):
def test_template_contents(self): def test_template_contents(self):
context = {} context = {}
student_fragment = self.block.runtime.render(self.block, 'student_view', context) student_fragment = self.block.runtime.render(self.block, 'student_view', context)
self.assertIn('<section class="xblock--drag-and-drop">', student_fragment.content) self.assertIn('<section class="themed-xblock xblock--drag-and-drop">', student_fragment.content)
self.assertIn('Loading drag and drop exercise.', student_fragment.content) self.assertIn('Loading drag and drop exercise.', student_fragment.content)
def test_get_configuration(self): def test_get_configuration(self):
......
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