diff --git a/common/lib/xmodule/xmodule/gst_module.py b/common/lib/xmodule/xmodule/gst_module.py index 2d65b768ec..60c03dec10 100644 --- a/common/lib/xmodule/xmodule/gst_module.py +++ b/common/lib/xmodule/xmodule/gst_module.py @@ -13,6 +13,7 @@ from xmodule.mako_module import MakoModuleDescriptor from xmodule.xml_module import XmlDescriptor from xmodule.x_module import XModule from xmodule.stringify import stringify_children +from pkg_resources import resource_string log = logging.getLogger("mitx.common.lib.gst_module") @@ -21,9 +22,8 @@ log = logging.getLogger("mitx.common.lib.gst_module") class GraphicalSliderToolModule(XModule): ''' Graphical-Slider-Tool Module ''' - # js = {'js': [resource_string(__name__, 'js/src/gst/gst.js')]} - # #css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]} - # js_module_name = "GST" + js = {'js': [resource_string(__name__, 'js/src/graphical_slider_tool/gst.js')]} + js_module_name = "GraphicalSliderTool" def __init__(self, system, location, definition, descriptor, instance_state=None, shared_state=None, **kwargs): @@ -37,30 +37,55 @@ class GraphicalSliderToolModule(XModule): - Graphic slider tool html. Can include - 'number', 'slider' and plot tags. They will be replaced - by proper number, slider and plot widgets. +

Graphic slider tool html.

+

Can include 'input', 'slider' and 'plot' tags. + They will be replaced by proper number, slider and plot + widgets.

+ For example: $slider a$, second $slider b$, + number $input a$, and, plot: + $plot$ + +
- + + + - - - + + + + - - - - -10, 1, 10 - - 1 - 1 + + + + + + + + -10, 10 + + 60 + + -9, 1, 9 + -9, 1, 9 + + + + +
@@ -73,12 +98,13 @@ class GraphicalSliderToolModule(XModule): self.html_id = self.location.html_id() self.html_class = self.location.category gst_html = self.substitute_controls(self.definition['render'].strip()) - + # import ipdb; ipdb.set_trace() params = { 'gst_html': gst_html, 'element_id': self.html_id, 'element_class': self.html_class, - 'configuration_json': self.configuration_json + 'configuration_json': self.configuration_json, + 'plot_code': self.definition['plot_code'] } self.content = (self.system.render_template( 'graphical_slider_tool.html', params)) @@ -157,11 +183,12 @@ class GraphicalSliderToolDescriptor(MakoModuleDescriptor, XmlDescriptor): dict """ # check for presense of required tags in xml - expected_children_level_0 = ['render', 'configuration'] + expected_children_level_0 = ['render', 'configuration', 'plot_code'] for child in expected_children_level_0: if len(xml_object.xpath(child)) != 1: raise ValueError("Self a\ssessment definition must include \ exactly one '{0}' tag".format(child)) + expected_children_level_1 = ['plot'] for child in expected_children_level_1: if len(xml_object.xpath('configuration')[0].xpath(child)) != 1: @@ -176,6 +203,7 @@ class GraphicalSliderToolDescriptor(MakoModuleDescriptor, XmlDescriptor): return { 'render': parse('render'), 'configuration': xml_object.xpath('configuration')[0], + 'plot_code': parse('plot_code'), } def definition_to_xml(self, resource_fs): diff --git a/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/gst.js b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/gst.js new file mode 100644 index 0000000000..03778ea437 --- /dev/null +++ b/common/lib/xmodule/xmodule/js/src/graphical_slider_tool/gst.js @@ -0,0 +1,17 @@ +// Graphical Slider Tool module + +(function() { + this.GraphicalSliderTool = (function() { + function GST(el) { + console.log(el); + // element is : + //
+ } + // console.log('in GST'); + return GST; + + })(); +}).call(this); +// this=window, after call +// window['Graphical_Slider_Tool'] is available. \ No newline at end of file diff --git a/lms/templates/graphical_slider_tool.html b/lms/templates/graphical_slider_tool.html index 920e53cab3..fc5052893a 100644 --- a/lms/templates/graphical_slider_tool.html +++ b/lms/templates/graphical_slider_tool.html @@ -4,7 +4,19 @@
+ +
+ ${gst_html} + + +