Commit 363ca703 by ichuang

add coffeescript/js for conditional module, does XModule.loadModules

parent 19051e40
...@@ -21,12 +21,12 @@ class ConditionalModule(XModule): ...@@ -21,12 +21,12 @@ class ConditionalModule(XModule):
''' '''
js = {'coffee': [resource_string(__name__, 'js/src/capa/display.coffee'), js = {'coffee': [resource_string(__name__, 'js/src/conditional/display.coffee'),
resource_string(__name__, 'js/src/collapsible.coffee'), resource_string(__name__, 'js/src/collapsible.coffee'),
resource_string(__name__, 'js/src/javascript_loader.coffee'), resource_string(__name__, 'js/src/javascript_loader.coffee'),
]} ]}
js_module_name = "Problem" js_module_name = "Conditional"
css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]} css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]}
...@@ -74,7 +74,7 @@ class ConditionalModule(XModule): ...@@ -74,7 +74,7 @@ class ConditionalModule(XModule):
def get_html(self): def get_html(self):
self.is_condition_satisfied() self.is_condition_satisfied()
return self.system.render_template('problem_ajax.html', { return self.system.render_template('conditional_ajax.html', {
'element_id': self.location.html_id(), 'element_id': self.location.html_id(),
'id': self.id, 'id': self.id,
'ajax_url': self.system.ajax_url, 'ajax_url': self.system.ajax_url,
......
class @Conditional
constructor: (element) ->
@el = $(element).find('.conditional-wrapper')
@id = @el.data('problem-id')
@element_id = @el.attr('id')
@url = @el.data('url')
@render()
$: (selector) ->
$(selector, @el)
updateProgress: (response) =>
if response.progress_changed
@el.attr progress: response.progress_status
@el.trigger('progressChanged')
render: (content) ->
if content
@el.html(content)
XModule.loadModules('display', @el)
else
$.postWithPrefix "#{@url}/conditional_get", (response) =>
@el.html(response.html)
XModule.loadModules('display', @el)
<div id="conditional_${element_id}" class="conditional-wrapper" data-problem-id="${id}" data-url="${ajax_url}"></div>
...@@ -4,6 +4,6 @@ ...@@ -4,6 +4,6 @@
course_id = module.system.course_id course_id = module.system.course_id
%> %>
<p>Sorry, you must complete <a <p><a
href="${reverse('jump_to',kwargs=dict(course_id=course_id, location=reqm.location.url()))}">${reqm.display_name}</a> href="${reverse('jump_to',kwargs=dict(course_id=course_id, location=reqm.location.url()))}">${reqm.display_name}</a>
before this is visible.</p> must be completed before this will become visible.</p>
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