Commit e4a783b1 by Isaac Chuang Committed by Piotr Mitros

Minor cleanups to capa_module (comments, formatting, etc.)

parent f5c41668
...@@ -196,6 +196,9 @@ class Module(XModule): ...@@ -196,6 +196,9 @@ class Module(XModule):
self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, state, seed = seed) self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, state, seed = seed)
def handle_ajax(self, dispatch, get): def handle_ajax(self, dispatch, get):
'''
This is called by courseware.module_render, to handle an AJAX call. "get" is request.POST
'''
if dispatch=='problem_get': if dispatch=='problem_get':
response = self.get_problem(get) response = self.get_problem(get)
elif False: #self.close_date > elif False: #self.close_date >
...@@ -246,10 +249,16 @@ class Module(XModule): ...@@ -246,10 +249,16 @@ class Module(XModule):
raise self.system.exception404 #TODO: Not 404 raise self.system.exception404 #TODO: Not 404
def get_answer(self, get): def get_answer(self, get):
'''
For the "show answer" button.
TODO: show answer events should be logged here, not just in the problem.js
'''
if not self.answer_available(): if not self.answer_available():
raise self.system.exception404 raise self.system.exception404
else: else:
return json.dumps(self.lcp.get_question_answers(), answers = self.lcp.get_question_answers()
return json.dumps(answers,
cls=ComplexEncoder) cls=ComplexEncoder)
# Figure out if we should move these to capa_problem? # Figure out if we should move these to capa_problem?
...@@ -265,6 +274,7 @@ class Module(XModule): ...@@ -265,6 +274,7 @@ class Module(XModule):
event_info['state'] = self.lcp.get_state() event_info['state'] = self.lcp.get_state()
event_info['filename'] = self.filename event_info['filename'] = self.filename
# make a dict of all the student responses ("answers").
answers=dict() answers=dict()
# input_resistor_1 ==> resistor_1 # input_resistor_1 ==> resistor_1
for key in get: for key in get:
...@@ -299,7 +309,6 @@ class Module(XModule): ...@@ -299,7 +309,6 @@ class Module(XModule):
raise raise
return json.dumps({'success':'Unknown Error'}) return json.dumps({'success':'Unknown Error'})
self.attempts = self.attempts + 1 self.attempts = self.attempts + 1
self.lcp.done=True self.lcp.done=True
...@@ -371,6 +380,7 @@ class Module(XModule): ...@@ -371,6 +380,7 @@ class Module(XModule):
self.lcp.context=dict() self.lcp.context=dict()
self.lcp.questions=dict() # Detailed info about questions in problem instance. TODO: Should be by id and not lid. self.lcp.questions=dict() # Detailed info about questions in problem instance. TODO: Should be by id and not lid.
self.lcp.seed=None self.lcp.seed=None
self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, self.lcp.get_state()) self.lcp=LoncapaProblem(self.filestore.open(self.filename), self.item_id, self.lcp.get_state())
event_info['new_state']=self.lcp.get_state() event_info['new_state']=self.lcp.get_state()
......
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