Commit ef7d7ca6 by Vik Paruchuri

add state functions

parent 19483b70
...@@ -84,6 +84,21 @@ class SelfAssessmentModule(XModule): ...@@ -84,6 +84,21 @@ class SelfAssessmentModule(XModule):
self.submit_message=etree.tostring(dom2.xpath('submitmessage')[0]) self.submit_message=etree.tostring(dom2.xpath('submitmessage')[0])
log.debug(self.submit_message) log.debug(self.submit_message)
self.attempts = 0
self.max_attempts = 1
self.max_attempts = self.metadata.get('attempts', None)
if self.max_attempts is not None:
self.max_attempts = int(self.max_attempts)
else:
self.max_attempts=1
if instance_state is not None:
instance_state = json.loads(instance_state)
if instance_state is not None and 'attempts' in instance_state:
self.attempts = instance_state['attempts']
self.correctness="incorrect"
def get_score(self): def get_score(self):
return self.score return self.score
...@@ -145,15 +160,15 @@ class SelfAssessmentModule(XModule): ...@@ -145,15 +160,15 @@ class SelfAssessmentModule(XModule):
with the error key only present if success is False. with the error key only present if success is False.
''' '''
correctness=get.keys()[0].lower() self.correctness=get.keys()[0].lower()
log.debug(correctness) log.debug(self.correctness)
points=0 points=0
if correctness=="correct" : if self.correctness=="correct" :
points=1 points=1
event_info = dict() event_info = dict()
event_info['state'] = {'seed': 1, event_info['state'] = {'seed': 1,
'student_answers': self.answer, 'student_answers': self.answer,
'correct_map': {'self_assess' : {'correctness': correctness, 'correct_map': {'self_assess' : {'correctness': self.correctness,
'npoints': points, 'npoints': points,
'msg': "", 'msg': "",
'hint': "", 'hint': "",
...@@ -170,6 +185,24 @@ class SelfAssessmentModule(XModule): ...@@ -170,6 +185,24 @@ class SelfAssessmentModule(XModule):
return {'success': True, 'message' : self.submit_message} return {'success': True, 'message' : self.submit_message}
def get_instance_state(self):
points=0
if self.correctness=="correct" :
points=1
state= return {'seed': 1,
'student_answers': self.answer,
'correct_map': {'self_assess' : {'correctness': self.correctness,
'npoints': points,
'msg': "",
'hint': "",
'hintmode': "",
'queuestate': "",
}},
'done': self.done}
state['attempts'] = self.attempts
return json.dumps(state)
class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor): class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
""" """
Module for putting raw html in a course Module for putting raw html in a course
......
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