Commit aa34c9d3 by Vasyl Nakvasiuk

remove 'passed' feature

parent a70cb2e1
...@@ -115,8 +115,7 @@ class ConditionalModule(XModule): ...@@ -115,8 +115,7 @@ class ConditionalModule(XModule):
'message': message} 'message': message}
html = self.system.render_template('conditional_module.html', html = self.system.render_template('conditional_module.html',
context) context)
return json.dumps({'html': [html], 'passed': False, return json.dumps({'html': [html], 'message': bool(message)})
'message': bool(message)})
if self.contents is None: if self.contents is None:
self.contents = [self.system.get_module(child_descriptor).get_html() self.contents = [self.system.get_module(child_descriptor).get_html()
...@@ -124,7 +123,7 @@ class ConditionalModule(XModule): ...@@ -124,7 +123,7 @@ class ConditionalModule(XModule):
html = self.contents html = self.contents
return json.dumps({'html': html, 'passed': True}) return json.dumps({'html': html})
def get_icon_class(self): def get_icon_class(self):
new_class = 'other' new_class = 'other'
...@@ -165,7 +164,7 @@ class ConditionalDescriptor(SequenceDescriptor): ...@@ -165,7 +164,7 @@ class ConditionalDescriptor(SequenceDescriptor):
if sources: if sources:
locations = [location.strip() for location in sources.split(';')] locations = [location.strip() for location in sources.split(';')]
for location in locations: for location in locations:
if Location.is_valid(location): # Check valid location url. if Location.is_valid(location): # Check valid location url.
try: try:
if return_descriptor: if return_descriptor:
descriptor = system.load_item(location) descriptor = system.load_item(location)
......
class @Conditional class @Conditional
constructor: (element, callerElId, reset) -> constructor: (element, callerElId) ->
@el = $(element).find('.conditional-wrapper') @el = $(element).find('.conditional-wrapper')
@callerElId = callerElId @callerElId = callerElId
if reset is true if callerElId isnt undefined
@el.data('passed', null)
@passed = null
else
if @el.data('passed') is true
return
else if @el.data('passed') is false
@passed = false
else
@passed = null
if callerElId isnt undefined and @passed isnt null
dependencies = @el.data('depends') dependencies = @el.data('depends')
if (typeof dependencies is 'string') and (dependencies.length > 0) and (dependencies.indexOf(callerElId) is -1) if (typeof dependencies is 'string') and (dependencies.length > 0) and (dependencies.indexOf(callerElId) is -1)
return return
...@@ -26,24 +15,21 @@ class @Conditional ...@@ -26,24 +15,21 @@ class @Conditional
render: (element) -> render: (element) ->
$.postWithPrefix "#{@url}/conditional_get", (response) => $.postWithPrefix "#{@url}/conditional_get", (response) =>
if (((response.passed is true) && (@passed is false)) || (@passed is null)) @el.html ''
@el.data 'passed', response.passed @el.append(i) for i in response.html
@el.html '' parentEl = $(element).parent()
@el.append(i) for i in response.html parentId = parentEl.attr 'id'
parentEl = $(element).parent() if response.message is false
parentId = parentEl.attr 'id' if parentId.indexOf('vert') is 0
parentEl.hide()
if response.message is false else
if parentId.indexOf('vert') is 0 $(element).hide()
parentEl.hide() else
else if parentId.indexOf('vert') is 0
$(element).hide() parentEl.show()
else else
if parentId.indexOf('vert') is 0 $(element).show()
parentEl.show()
else
$(element).show()
XModule.loadModules @el XModule.loadModules @el
...@@ -104,7 +104,7 @@ PollMain.prototype = { ...@@ -104,7 +104,7 @@ PollMain.prototype = {
// notifying the constructor that this is a reset operation. // notifying the constructor that this is a reset operation.
if (_this.wrapperSectionEl !== null) { if (_this.wrapperSectionEl !== null) {
$(_this.wrapperSectionEl).find('.xmodule_ConditionalModule').each(function (index, value) { $(_this.wrapperSectionEl).find('.xmodule_ConditionalModule').each(function (index, value) {
new window.Conditional(value, _this.id.replace(/^poll_/, ''), true); new window.Conditional(value, _this.id.replace(/^poll_/, ''));
}); });
} }
} }
......
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