Commit 84eba0da by Vik Paruchuri

Proper instance state storage, remove correctmap vars

parent ea54454c
...@@ -33,6 +33,10 @@ log = logging.getLogger("mitx.courseware") ...@@ -33,6 +33,10 @@ log = logging.getLogger("mitx.courseware")
# attempts specified in xml definition overrides this. # attempts specified in xml definition overrides this.
MAX_ATTEMPTS = 1 MAX_ATTEMPTS = 1
#Set maximum available number of points. Should be set to 1 for now due to correctness handling,
# which only allows for correct/incorrect.
MAX_SCORE=1
class SelfAssessmentModule(XModule): class SelfAssessmentModule(XModule):
js = {'coffee': [resource_string(__name__, 'js/src/selfassessment/display.coffee')] js = {'coffee': [resource_string(__name__, 'js/src/selfassessment/display.coffee')]
} }
...@@ -89,7 +93,7 @@ class SelfAssessmentModule(XModule): ...@@ -89,7 +93,7 @@ class SelfAssessmentModule(XModule):
# Used for progress / grading. Currently get credit just for completion (doesn't matter if you self-assessed # Used for progress / grading. Currently get credit just for completion (doesn't matter if you self-assessed
# correct/incorrect). # correct/incorrect).
self.score = instance_state.get('score', 0) self.score = instance_state.get('score', 0)
self.top_score = instance_state.get('top_score', 1) self.top_score = instance_state.get('top_score', MAX_SCORE)
# TODO: do we need this? True once everything is done # TODO: do we need this? True once everything is done
self.done = instance_state.get('done', False) self.done = instance_state.get('done', False)
...@@ -176,7 +180,7 @@ class SelfAssessmentModule(XModule): ...@@ -176,7 +180,7 @@ class SelfAssessmentModule(XModule):
# Dump to temp to keep answer in sync with correctness and hint # Dump to temp to keep answer in sync with correctness and hint
# TODO: expecting something like get['answer'] # TODO: expecting something like get['answer']
self.temp_answer = get.keys()[0] self.temp_answer = get['student_answer']
log.debug(self.temp_answer) log.debug(self.temp_answer)
return { return {
'success': True, 'success': True,
...@@ -200,8 +204,8 @@ class SelfAssessmentModule(XModule): ...@@ -200,8 +204,8 @@ class SelfAssessmentModule(XModule):
log.debug(self.temp_answer) log.debug(self.temp_answer)
if self.temp_answer is not "": if self.temp_answer is not "":
#Extract correctness and hint from ajax and assign points #Extract correctness and hint from ajax and assign points
self.hints.append(get[get.keys()[1]]) self.hints.append(get['hint'])
curr_correctness = get[get.keys()[0]].lower() curr_correctness = get['assessment'].lower()
if curr_correctness == "correct": if curr_correctness == "correct":
points = 1 points = 1
self.correctness.append(curr_correctness) self.correctness.append(curr_correctness)
...@@ -213,21 +217,16 @@ class SelfAssessmentModule(XModule): ...@@ -213,21 +217,16 @@ class SelfAssessmentModule(XModule):
# TODO: simplify tracking info to just log the relevant stuff # TODO: simplify tracking info to just log the relevant stuff
event_info = dict() event_info = dict()
event_info['state'] = {'seed': 1, event_info['state'] = {
'student_answers': self.student_answers, 'student_answers': self.student_answers,
'hint' : self.hints, 'hint' : self.hints,
'correct_map': {'self_assess': {'correctness': self.correctness, 'correctness': self.correctness,
'npoints': points, 'score': points,
'msg': "", 'done': self.done
'hint': "", }
'hintmode': "",
'queuestate': "",
}},
'done': self.done}
# TODO: figure out how to identify self assessment. May not want to confuse with problems. # TODO: figure out how to identify self assessment. May not want to confuse with problems.
event_info['selfassessment_id'] = self.location.url() event_info['selfassessment_id'] = self.location.url()
event_info['answers'] = self.student_answers
self.system.track_function('save_problem_succeed', event_info) self.system.track_function('save_problem_succeed', event_info)
...@@ -248,19 +247,16 @@ class SelfAssessmentModule(XModule): ...@@ -248,19 +247,16 @@ class SelfAssessmentModule(XModule):
if self.correctness[len(self.correctness)-1]== "correct": if self.correctness[len(self.correctness)-1]== "correct":
points = 1 points = 1
state = {'seed': 1, state = {
'student_answers': self.student_answers, 'student_answers': self.student_answers,
'temp_answer': self.temp_answer, 'temp_answer': self.temp_answer,
'hint' : self.hints, 'hint' : self.hints,
'correct_map': {'self_assess': {'correctness': self.correctness, 'correctness': self.correctness,
'npoints': points, 'score': points,
'msg': "", 'top_score' : MAX_SCORE,
'hint': "", 'done': self.done,
'hintmode': "", 'attempts' : self.attempts
'queuestate': "", }
}},
'done': self.done}
state['attempts'] = self.attempts
return json.dumps(state) return json.dumps(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