From d663d23257299d2f0a3d397b6665ee1fee5de60d Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Wed, 12 Dec 2012 10:33:36 -0500 Subject: [PATCH] Work on adding in a new ajax post type --- common/lib/capa/capa/inputtypes.py | 2 +- common/lib/capa/capa/responsetypes.py | 1 + common/lib/capa/capa/templates/openendedinput.html | 7 +++++++ common/lib/xmodule/xmodule/capa_module.py | 14 ++++++++++++++ .../lib/xmodule/xmodule/js/src/capa/display.coffee | 6 ++++++ 5 files changed, 29 insertions(+), 1 deletion(-) diff --git a/common/lib/capa/capa/inputtypes.py b/common/lib/capa/capa/inputtypes.py index 73056bc09e..e3eb47acc5 100644 --- a/common/lib/capa/capa/inputtypes.py +++ b/common/lib/capa/capa/inputtypes.py @@ -748,7 +748,7 @@ class OpenEndedInput(InputTypeBase): # 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") + "replaced with the grader's feedback.") @classmethod def get_attributes(cls): diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 8517e71d04..989e29c7a2 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1836,6 +1836,7 @@ class OpenEndedResponse(LoncapaResponse): """ DEFAULT_QUEUE = 'open-ended' + DEFAULT_MESSAGE_QUEUE = 'open-ended-message' response_tag = 'openendedresponse' allowed_inputfields = ['openendedinput'] max_inputfields = 1 diff --git a/common/lib/capa/capa/templates/openendedinput.html b/common/lib/capa/capa/templates/openendedinput.html index 65fc7fb9bb..3d51b7c3b2 100644 --- a/common/lib/capa/capa/templates/openendedinput.html +++ b/common/lib/capa/capa/templates/openendedinput.html @@ -28,5 +28,12 @@ % endif
${msg|n} + % if status in ['correct','incorrect']: +
+ Score Evaluation: + + +
+ % endif
diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 4c10a1703a..8ce0b17190 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -380,6 +380,7 @@ class CapaModule(XModule): 'problem_save': self.save_problem, 'problem_show': self.get_answer, 'score_update': self.update_score, + 'message_post' : self.message_post, } if dispatch not in handlers: @@ -394,6 +395,19 @@ class CapaModule(XModule): }) return json.dumps(d, cls=ComplexEncoder) + def feedback_post(self, get): + """ + Posts a message from a form to an appropriate location + """ + event_info = dict() + event_info['state'] = self.lcp.get_state() + event_info['problem_id'] = self.location.url() + + answers = self.make_dict_of_responses(get) + log.debug(answers) + + + def closed(self): ''' Is the student still allowed to submit answers? ''' if self.attempts == self.max_attempts: diff --git a/common/lib/xmodule/xmodule/js/src/capa/display.coffee b/common/lib/xmodule/xmodule/js/src/capa/display.coffee index 1c0ace9e59..2c676e1e52 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/capa/display.coffee @@ -25,6 +25,7 @@ class @Problem @$('section.action input.reset').click @reset @$('section.action input.show').click @show @$('section.action input.save').click @save + @$('section.evaluation input.submit-message').click @message_post # Collapsibles Collapsible.setCollapsibles(@el) @@ -197,6 +198,11 @@ class @Problem else @gentle_alert response.success + message_post: => + Logger.log 'message_post', @answers + $.postWithPrefix "#{@url}/message_post", @answers, (response) => + @gentle_alert response.success + reset: => Logger.log 'problem_reset', @answers $.postWithPrefix "#{@url}/problem_reset", id: @id, (response) =>