diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 1d3646fefc..73056bc09e 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -735,3 +735,51 @@ class ChemicalEquationInput(InputTypeBase): registry.register(ChemicalEquationInput) #----------------------------------------------------------------------------- + +class OpenEndedInput(InputTypeBase): + """ + A text area input for code--uses codemirror, does syntax highlighting, special tab handling, + etc. + """ + + template = "openendedinput.html" + tags = ['openendedinput'] + + # pulled out for testing + submitted_msg = ("Feedback not yet available. Reload to check again. " + "Once the problem is graded, this message will be " + "replaced with the grader's feedback") + + @classmethod + def get_attributes(cls): + """ + Convert options to a convenient format. + """ + return [Attribute('rows', '30'), + Attribute('cols', '80'), + Attribute('hidden', ''), + ] + + def setup(self): + """ + Implement special logic: handle queueing state, and default input. + """ + # if no student input yet, then use the default input given by the problem + if not self.value: + self.value = self.xml.text + + # Check if problem has been queued + self.queue_len = 0 + # Flag indicating that the problem has been queued, 'msg' is length of queue + if self.status == 'incomplete': + self.status = 'queued' + self.queue_len = self.msg + self.msg = self.submitted_msg + + def _extra_context(self): + """Defined queue_len, add it """ + return {'queue_len': self.queue_len,} + +registry.register(OpenEndedInput) + +#----------------------------------------------------------------------------- diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 3d97cb0bea..98e36084a1 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -33,7 +33,7 @@ from correctmap import CorrectMap from datetime import datetime from util import * from lxml import etree -from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful Soup!!! FIXME? +from lxml.html.soupparser import fromstring as fromstring_bs # uses Beautiful Soup!!! FIXME? import xqueue_interface log = logging.getLogger('mitx.' + __name__) @@ -869,7 +869,9 @@ def sympy_check2(): response_tag = 'customresponse' - allowed_inputfields = ['textline', 'textbox', 'crystallography', 'chemicalequationinput', 'vsepr_input'] + allowed_inputfields = ['textline', 'textbox', 'crystallography', + 'chemicalequationinput', 'vsepr_input', + 'drag_and_drop'] def setup_response(self): xml = self.xml @@ -1044,7 +1046,7 @@ def sympy_check2(): pretty_print=True) #msg = etree.tostring(fromstring_bs(msg),pretty_print=True) msg = msg.replace(' ', '') - #msg = re.sub('(.*)','\\1',msg,flags=re.M|re.DOTALL) # python 2.7 + #msg = re.sub('(.*)','\\1',msg,flags=re.M|re.DOTALL) # python 2.7 msg = re.sub('(?ms)(.*)', '\\1', msg) messages[0] = msg @@ -1763,7 +1765,7 @@ class ImageResponse(LoncapaResponse): def get_score(self, student_answers): correct_map = CorrectMap() expectedset = self.get_answers() - for aid in self.answer_ids: # loop through IDs of + for aid in self.answer_ids: # loop through IDs of # fields in our stanza given = student_answers[aid] # this should be a string of the form '[x,y]' correct_map.set(aid, 'incorrect') diff --git a/common/lib/capa/capa/templates/drag_and_drop_input.html b/common/lib/capa/capa/templates/drag_and_drop_input.html new file mode 100644 index 0000000000..8613c97479 --- /dev/null +++ b/common/lib/capa/capa/templates/drag_and_drop_input.html @@ -0,0 +1,41 @@ +
+
+ +
+ + % if status == 'unsubmitted': +
+ % elif status == 'correct': +
+ % elif status == 'incorrect': +
+ % elif status == 'incomplete': +
+ % endif + + + + +

+ % if status == 'unsubmitted': + unanswered + % elif status == 'correct': + correct + % elif status == 'incorrect': + incorrect + % elif status == 'incomplete': + incomplete + % endif +

+ +

+ + % if msg: + ${msg|n} + % endif + + % if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']: +
+ % endif +
diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 1da271072a..00760dc855 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -83,7 +83,9 @@ class CapaModule(XModule): resource_string(__name__, 'js/src/javascript_loader.coffee'), ], 'js': [resource_string(__name__, 'js/src/capa/imageinput.js'), - resource_string(__name__, 'js/src/capa/schematic.js')]} + resource_string(__name__, 'js/src/capa/schematic.js'), + resource_string(__name__, 'js/src/capa/drag_and_drop.js') + ]} js_module_name = "Problem" css = {'scss': [resource_string(__name__, 'css/capa/display.scss')]} diff --git a/common/lib/xmodule/xmodule/js/src/capa/drag_and_drop.js b/common/lib/xmodule/xmodule/js/src/capa/drag_and_drop.js new file mode 100644 index 0000000000..73c9f606d1 --- /dev/null +++ b/common/lib/xmodule/xmodule/js/src/capa/drag_and_drop.js @@ -0,0 +1 @@ +alert('drag-and-drop js is loaded') \ No newline at end of file