Commit f292fefe by Vik Paruchuri

python code to add in hint box and persist

parent 0fe3c73a
...@@ -92,6 +92,7 @@ class SelfAssessmentModule(XModule): ...@@ -92,6 +92,7 @@ class SelfAssessmentModule(XModule):
self.correctness = "incorrect" self.correctness = "incorrect"
self.done = False self.done = False
self.max_attempts = self.metadata.get('attempts', None) self.max_attempts = self.metadata.get('attempts', None)
self.hint=""
#Pull variables from instance state if available #Pull variables from instance state if available
if self.max_attempts is not None: if self.max_attempts is not None:
...@@ -112,6 +113,9 @@ class SelfAssessmentModule(XModule): ...@@ -112,6 +113,9 @@ class SelfAssessmentModule(XModule):
if instance_state is not None and 'done' in instance_state: if instance_state is not None and 'done' in instance_state:
self.done = instance_state['done'] self.done = instance_state['done']
if instance_state is not None and 'hint' in instance_state:
self.hint = instance_state['hint']
if instance_state is not None and 'correct_map' in instance_state: if instance_state is not None and 'correct_map' in instance_state:
if 'self_assess' in instance_state['correct_map']: if 'self_assess' in instance_state['correct_map']:
self.score = instance_state['correct_map']['self_assess']['npoints'] self.score = instance_state['correct_map']['self_assess']['npoints']
...@@ -227,9 +231,10 @@ class SelfAssessmentModule(XModule): ...@@ -227,9 +231,10 @@ class SelfAssessmentModule(XModule):
''' '''
#Extract correctness from ajax and assign points #Extract correctness from ajax and assign points
log.debug(get.keys()) self.hint=get[get.keys()[1]]
log.debug(get) self.correctness = get[get.keys()[0]].lower()
self.correctness = 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
...@@ -241,6 +246,7 @@ class SelfAssessmentModule(XModule): ...@@ -241,6 +246,7 @@ class SelfAssessmentModule(XModule):
event_info = dict() event_info = dict()
event_info['state'] = {'seed': 1, event_info['state'] = {'seed': 1,
'student_answers': self.answer, 'student_answers': self.answer,
'hint' : self.hint,
'correct_map': {'self_assess': {'correctness': self.correctness, 'correct_map': {'self_assess': {'correctness': self.correctness,
'npoints': points, 'npoints': points,
'msg': "", 'msg': "",
......
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