Commit 89ea8b31 by Nimisha Asthagiri

MA-725 responsive_ui indication on responsive xBlocks.

parent 4921ec48
...@@ -527,6 +527,13 @@ class LoncapaProblem(object): ...@@ -527,6 +527,13 @@ class LoncapaProblem(object):
log.warning("Could not find matching input for id: %s", input_id) log.warning("Could not find matching input for id: %s", input_id)
return {} return {}
@property
def has_responsive_ui(self):
"""
Returns whether this capa problem has support for responsive UI.
"""
return all(responder.has_responsive_ui for responder in self.responders.values())
# ======= Private Methods Below ======== # ======= Private Methods Below ========
def _process_includes(self): def _process_includes(self):
......
...@@ -138,6 +138,11 @@ class LoncapaResponse(object): ...@@ -138,6 +138,11 @@ class LoncapaResponse(object):
allowed_inputfields = [] allowed_inputfields = []
required_attributes = [] required_attributes = []
# Overridable field that specifies whether this capa response type has support for
# responsive UI, for rendering on devices of different sizes and shapes.
# By default, we set this to False, allowing subclasses to override as appropriate.
has_responsive_ui = False
def __init__(self, xml, inputfields, context, system): def __init__(self, xml, inputfields, context, system):
""" """
Init is passed the following arguments: Init is passed the following arguments:
...@@ -692,6 +697,7 @@ class ChoiceResponse(LoncapaResponse): ...@@ -692,6 +697,7 @@ class ChoiceResponse(LoncapaResponse):
max_inputfields = 1 max_inputfields = 1
allowed_inputfields = ['checkboxgroup', 'radiogroup'] allowed_inputfields = ['checkboxgroup', 'radiogroup']
correct_choices = None correct_choices = None
has_responsive_ui = True
def setup_response(self): def setup_response(self):
...@@ -763,6 +769,7 @@ class MultipleChoiceResponse(LoncapaResponse): ...@@ -763,6 +769,7 @@ class MultipleChoiceResponse(LoncapaResponse):
max_inputfields = 1 max_inputfields = 1
allowed_inputfields = ['choicegroup'] allowed_inputfields = ['choicegroup']
correct_choices = None correct_choices = None
has_responsive_ui = True
def setup_response(self): def setup_response(self):
# call secondary setup for MultipleChoice questions, to set name # call secondary setup for MultipleChoice questions, to set name
...@@ -1084,6 +1091,7 @@ class OptionResponse(LoncapaResponse): ...@@ -1084,6 +1091,7 @@ class OptionResponse(LoncapaResponse):
hint_tag = 'optionhint' hint_tag = 'optionhint'
allowed_inputfields = ['optioninput'] allowed_inputfields = ['optioninput']
answer_fields = None answer_fields = None
has_responsive_ui = True
def setup_response(self): def setup_response(self):
self.answer_fields = self.inputfields self.answer_fields = self.inputfields
...@@ -1136,6 +1144,7 @@ class NumericalResponse(LoncapaResponse): ...@@ -1136,6 +1144,7 @@ class NumericalResponse(LoncapaResponse):
allowed_inputfields = ['textline', 'formulaequationinput'] allowed_inputfields = ['textline', 'formulaequationinput']
required_attributes = ['answer'] required_attributes = ['answer']
max_inputfields = 1 max_inputfields = 1
has_responsive_ui = True
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.correct_answer = '' self.correct_answer = ''
...@@ -1338,6 +1347,7 @@ class StringResponse(LoncapaResponse): ...@@ -1338,6 +1347,7 @@ class StringResponse(LoncapaResponse):
required_attributes = ['answer'] required_attributes = ['answer']
max_inputfields = 1 max_inputfields = 1
correct_answer = [] correct_answer = []
has_responsive_ui = True
def setup_response_backward(self): def setup_response_backward(self):
self.correct_answer = [ self.correct_answer = [
......
...@@ -187,6 +187,13 @@ class CapaDescriptor(CapaFields, RawDescriptor): ...@@ -187,6 +187,13 @@ class CapaDescriptor(CapaFields, RawDescriptor):
registered_tags = responsetypes.registry.registered_tags() registered_tags = responsetypes.registry.registered_tags()
return set([node.tag for node in tree.iter() if node.tag in registered_tags]) return set([node.tag for node in tree.iter() if node.tag in registered_tags])
@property
def has_responsive_ui(self):
"""
Returns whether this module has support for responsive UI.
"""
return self.lcp.has_responsive_ui
def index_dictionary(self): def index_dictionary(self):
""" """
Return dictionary prepared with module content and type for indexing. Return dictionary prepared with module content and type for indexing.
......
...@@ -95,6 +95,7 @@ class HtmlDescriptor(HtmlFields, XmlDescriptor, EditingDescriptor): # pylint: d ...@@ -95,6 +95,7 @@ class HtmlDescriptor(HtmlFields, XmlDescriptor, EditingDescriptor): # pylint: d
module_class = HtmlModule module_class = HtmlModule
filename_extension = "xml" filename_extension = "xml"
template_dir_name = "html" template_dir_name = "html"
has_responsive_ui = True
js = {'coffee': [resource_string(__name__, 'js/src/html/edit.coffee')]} js = {'coffee': [resource_string(__name__, 'js/src/html/edit.coffee')]}
js_module_name = "HTMLEditingDescriptor" js_module_name = "HTMLEditingDescriptor"
......
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