From ce3b84d0e59fc4361814bbc1b0ffcf74f110fd6e Mon Sep 17 00:00:00 2001 From: Vik Paruchuri Date: Wed, 12 Dec 2012 11:55:03 -0500 Subject: [PATCH] Message passing in lms --- common/lib/capa/capa/capa_problem.py | 8 ++++++++ common/lib/capa/capa/responsetypes.py | 8 +++++++- common/lib/xmodule/xmodule/capa_module.py | 4 ++-- common/lib/xmodule/xmodule/js/src/capa/display.coffee | 2 +- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/common/lib/capa/capa/capa_problem.py b/common/lib/capa/capa/capa_problem.py index 2eaa0e4286..585e087b36 100644 --- a/common/lib/capa/capa/capa_problem.py +++ b/common/lib/capa/capa/capa_problem.py @@ -186,6 +186,14 @@ class LoncapaProblem(object): maxscore += responder.get_max_score() return maxscore + def message_post(self,event_info): + """ + Handle an ajax post that contains feedback on feedback + """ + for responder in self.responders.values(): + if hasattr(responder, 'message_post'): + responder.message_post(event_info) + def get_score(self): """ Compute score for this problem. The score is the number of points awarded. diff --git a/common/lib/capa/capa/responsetypes.py b/common/lib/capa/capa/responsetypes.py index 989e29c7a2..f8ee12650e 100644 --- a/common/lib/capa/capa/responsetypes.py +++ b/common/lib/capa/capa/responsetypes.py @@ -1854,6 +1854,10 @@ class OpenEndedResponse(LoncapaResponse): prompt = self.xml.find('prompt') rubric = self.xml.find('openendedrubric') + #This is needed to attach feedback to specific responses later + self.submission_id=None + self.grader_id=None + if oeparam is None: raise ValueError("No oeparam found in problem xml.") if prompt is None: @@ -2139,13 +2143,15 @@ class OpenEndedResponse(LoncapaResponse): " Received score_result = {0}".format(score_result)) return fail - for tag in ['score', 'feedback', 'grader_type', 'success']: + for tag in ['score', 'feedback', 'grader_type', 'success', 'grader_id', 'submission_id']: if tag not in score_result: log.error("External grader message is missing required tag: {0}" .format(tag)) return fail feedback = self._format_feedback(score_result) + self.submission_id=score_result['submission_id'] + self.grader_id=score_result['grader_id'] # HACK: for now, just assume it's correct if you got more than 2/3. # Also assumes that score_result['score'] is an integer. diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 08f57ba14c..727449ea99 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -402,10 +402,10 @@ class CapaModule(XModule): event_info = dict() event_info['state'] = self.lcp.get_state() event_info['problem_id'] = self.location.url() - event_info['student_id'] = self.system.anonymous_system_id + event_info['student_id'] = self.system.anonymous_student_id event_info['survey_responses']= get - log.debug(event_info) + success_dict = self.lcp.message_post(event_info) return {'success' : True} diff --git a/common/lib/xmodule/xmodule/js/src/capa/display.coffee b/common/lib/xmodule/xmodule/js/src/capa/display.coffee index e75d3a5a1d..204080dd64 100644 --- a/common/lib/xmodule/xmodule/js/src/capa/display.coffee +++ b/common/lib/xmodule/xmodule/js/src/capa/display.coffee @@ -203,7 +203,7 @@ class @Problem fd = new FormData() feedback = @$('section.evaluation textarea.feedback-on-feedback')[0] - fd.append(feedback.class, feedback.value) + fd.append('feedback', feedback.value) settings = type: "POST"