1 """Embed widgets from MKWS, the MasterKey Widget Set"""
5 from xblock.core import XBlock
6 from xblock.fields import Integer, Scope, String, Any, Boolean, Dict
7 from xblock.fragment import Fragment
10 """Embed widgets from MKWS, the MasterKey Widget Set"""
19 def resource_string(self, path):
20 """Helper for accessing resources."""
21 data = pkg_resources.resource_string(__name__, path)
22 return data.decode("utf8")
24 def student_view(self, context=None):
25 """The primary view of the MKWS XBlock, shown to students when viewing courses."""
26 html = self.resource_string("static/html/mkwsxb.html")
27 frag = Fragment(html.format(query=self.query))
28 frag.add_javascript_url("//mkws.indexdata.com/mkws-complete.js")
29 frag.add_javascript_url("//example.indexdata.com/mkws-widget-ru.js")
30 frag.add_css(self.resource_string("static/css/mkws-widget-ru.css"))
31 frag.add_javascript(self.resource_string("static/js/src/mkwsxb.js"))
32 frag.initialize_js('MKWSXB')
35 def studio_view(self, context=None):
36 """Studio configuration view."""
37 html = self.resource_string("static/html/settings.html")
38 frag = Fragment(html.format(query=self.query))
39 frag.add_javascript(self.resource_string("static/js/src/settings.js"))
40 frag.initialize_js('MKWSXBSettings')
44 def update_settings(self, data, suffix=''):
45 """Studio configuration callback."""
46 self.query = data['query']
47 return {"result": "success"}
50 def workbench_scenarios():
51 """A canned scenario for display in the workbench."""