diff --git a/common/lib/xmodule/xmodule/self_assessment_module.py b/common/lib/xmodule/xmodule/self_assessment_module.py
index a7e9567c8c..02e2b0ab32 100644
--- a/common/lib/xmodule/xmodule/self_assessment_module.py
+++ b/common/lib/xmodule/xmodule/self_assessment_module.py
@@ -69,7 +69,7 @@ class SelfAssessmentModule(XModule):
instance_state, shared_state, **kwargs)
"""
- Definition file should have 3 blocks -- problem, rubric, and submitmessage
+ Definition file should have 4 blocks -- problem, rubric, submitmessage, and maxattempts
Sample file:
@@ -82,11 +82,14 @@ class SelfAssessmentModule(XModule):
Thanks for submitting!
+
+ 1
+
"""
#Initialize variables
- self.answer = ""
+ self.answer = []
self.score = 0
self.top_score = 1
self.attempts = 0
@@ -109,7 +112,10 @@ class SelfAssessmentModule(XModule):
self.attempts = instance_state['attempts']
if instance_state is not None and 'student_answers' in instance_state:
- self.answer = instance_state['student_answers']
+ if(type(instance_state['student_answers']) in [type(u''),type('')]):
+ self.answer = self.answer.append(instance_state['student_answers'])
+ elif(type(instance_state['student_answers'])==type([])):
+ self.answer = instance_state['student_answers']
if instance_state is not None and 'done' in instance_state:
self.done = instance_state['done']
@@ -125,6 +131,13 @@ class SelfAssessmentModule(XModule):
#Parse definition file
dom2 = etree.fromstring("" + self.definition['data'] + "")
+ max_attempt_parsed=dom2.xpath('maxattempts')[0].text
+
+ try:
+ self.max_attempts=int(max_attempt_parsed)
+ except:
+ pass
+
#Extract problem, submission message and rubric from definition file
self.rubric = "
" + ''.join([etree.tostring(child) for child in only_one(dom2.xpath('rubric'))])
self.problem = ''.join([etree.tostring(child) for child in only_one(dom2.xpath('problem'))])
@@ -152,8 +165,8 @@ class SelfAssessmentModule(XModule):
rubric_header=('
Rubric')
#Combine problem, rubric, and the forms
- if self.answer is not "" :
- answer_html="
Previous answer: {0}
".format(self.answer)
+ if type(self.answer)==type([]) and self.answer is not [] :
+ answer_html="
Previous answer: {0}
".format(self.answer[len(self.answer)-1])
self.problem = ''.join([self.problem, answer_html, problem_form])
else:
self.problem = ''.join([self.problem, problem_form])
@@ -218,7 +231,7 @@ class SelfAssessmentModule(XModule):
"""
#Check to see if attempts are less than max
if(self.attempts < self.max_attempts):
- self.answer = get.keys()[0]
+ self.answer = self.answer.append(get.keys()[0])
log.debug(self.answer)
return {'success': True, 'rubric': self.rubric}
else: