Commit 5bcfba9e by Vik Paruchuri

add in ability to store multiple answers

parent a60b914b
...@@ -113,7 +113,7 @@ class SelfAssessmentModule(XModule): ...@@ -113,7 +113,7 @@ class SelfAssessmentModule(XModule):
if instance_state is not None and 'student_answers' in instance_state: if instance_state is not None and 'student_answers' in instance_state:
if(type(instance_state['student_answers']) in [type(u''),type('')]): if(type(instance_state['student_answers']) in [type(u''),type('')]):
self.answer = self.answer.append(instance_state['student_answers']) self.answer.append(instance_state['student_answers'])
elif(type(instance_state['student_answers'])==type([])): elif(type(instance_state['student_answers'])==type([])):
self.answer = instance_state['student_answers'] self.answer = instance_state['student_answers']
...@@ -165,9 +165,12 @@ class SelfAssessmentModule(XModule): ...@@ -165,9 +165,12 @@ class SelfAssessmentModule(XModule):
rubric_header=('<br/><br/><b>Rubric</b>') rubric_header=('<br/><br/><b>Rubric</b>')
#Combine problem, rubric, and the forms #Combine problem, rubric, and the forms
if type(self.answer)==type([]) and self.answer is not [] : if type(self.answer)==type([]):
answer_html="<br/>Previous answer: {0}<br/>".format(self.answer[len(self.answer)-1]) if len(self.answer)>0:
self.problem = ''.join([self.problem, answer_html, problem_form]) answer_html="<br/>Previous answer: {0}<br/>".format(self.answer[len(self.answer)-1])
self.problem = ''.join([self.problem, answer_html, problem_form])
else:
self.problem = ''.join([self.problem, problem_form])
else: else:
self.problem = ''.join([self.problem, problem_form]) self.problem = ''.join([self.problem, problem_form])
...@@ -231,8 +234,7 @@ class SelfAssessmentModule(XModule): ...@@ -231,8 +234,7 @@ class SelfAssessmentModule(XModule):
""" """
#Check to see if attempts are less than max #Check to see if attempts are less than max
if(self.attempts < self.max_attempts): if(self.attempts < self.max_attempts):
self.answer = self.answer.append(get.keys()[0]) self.answer.append(get.keys()[0])
log.debug(self.answer)
return {'success': True, 'rubric': self.rubric} return {'success': True, 'rubric': self.rubric}
else: else:
return{'success': False, 'message': 'Too many attempts.'} return{'success': False, 'message': 'Too many attempts.'}
...@@ -247,8 +249,6 @@ class SelfAssessmentModule(XModule): ...@@ -247,8 +249,6 @@ class SelfAssessmentModule(XModule):
#Extract correctness from ajax and assign points #Extract correctness from ajax and assign points
self.hint=get[get.keys()[1]] self.hint=get[get.keys()[1]]
self.correctness = get[get.keys()[0]].lower() self.correctness = get[get.keys()[0]].lower()
log.debug(self.hint)
log.debug(self.correctness)
points = 0 points = 0
if self.correctness == "correct": if self.correctness == "correct":
points = 1 points = 1
......
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