Commit 112fb453 by Vik Paruchuri

Correctly calculate score for combinedopenended and peer assessment

parent 45a3dd4e
......@@ -14,7 +14,7 @@ from xmodule.open_ended_grading_classes.xblock_field_types import StringyFloat
log = logging.getLogger("mitx.courseware")
V1_SETTINGS_ATTRIBUTES = ["display_name", "attempts", "is_graded", "accept_file_upload",
"skip_spelling_checks", "due", "graceperiod"]
"skip_spelling_checks", "due", "graceperiod", "weight"]
V1_STUDENT_ATTRIBUTES = ["current_task_number", "task_states", "state",
"student_attempts", "ready_to_reset"]
......
......@@ -131,6 +131,7 @@ class CombinedOpenEndedV1Module():
self.state = instance_state.get('state', self.INITIAL)
self.student_attempts = instance_state.get('student_attempts', 0)
self.weight = instance_state.get('weight', 1)
#Allow reset is true if student has failed the criteria to move to the next child task
self.ready_to_reset = instance_state.get('ready_to_reset', False)
......@@ -736,13 +737,17 @@ class CombinedOpenEndedV1Module():
max_score = None
score = None
if self.check_if_done_and_scored():
last_response = self.get_last_response(self.current_task_number)
max_score = last_response['max_score']
score = last_response['score']
scores = []
for i in xrange(0,self.current_task_number):
last_response = self.get_last_response(i)
max_score = last_response['max_score'] * float(self.weight)
score = last_response['score'] * float(self.weight)
scores.append(score)
score = max(scores)
score_dict = {
'score': score,
'total': max_score,
'score': score ,
'total': max_score ,
}
return score_dict
......
......@@ -178,8 +178,16 @@ class PeerGradingModule(PeerGradingFields, XModule):
pass
def get_score(self):
max_score = None
score = None
score_dict = {
'score': score,
'total': max_score,
}
if self.use_for_single_location not in TRUE_DICT or self.is_graded not in TRUE_DICT:
return None
return score_dict
try:
count_graded = self.student_data_for_location['count_graded']
......@@ -198,10 +206,13 @@ class PeerGradingModule(PeerGradingFields, XModule):
#Ensures that once a student receives a final score for peer grading, that it does not change.
self.student_data_for_location = response
score_dict = {
'score': int(count_graded >= count_required and count_graded>0) * int(self.weight),
'total': self.max_grade * int(self.weight),
}
try:
score = int(count_graded >= count_required and count_graded>0) * float(self.weight)
total = self.max_grade * float(self.weight)
score_dict['score'] = score
score_dict['total'] = total
except:
pass
return score_dict
......
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