Set a default weight

This commit is contained in:
Vik Paruchuri
2013-06-28 15:09:19 -04:00
parent 8930e753e4
commit 2246944594
3 changed files with 24 additions and 12 deletions

View File

@@ -82,7 +82,8 @@ class CombinedOpenEndedFields(object):
display_name="Maximum Attempts",
help="The number of times the student can try to answer this problem.",
default=1,
scope=Scope.settings, values={"min" : 1 }
scope=Scope.settings,
values={"min" : 1 }
)
is_graded = Boolean(
display_name="Graded",
@@ -99,7 +100,8 @@ class CombinedOpenEndedFields(object):
skip_spelling_checks = Boolean(
display_name="Disable Quality Filter",
help="If False, the Quality Filter is enabled and submissions with poor spelling, short length, or poor grammar will not be peer reviewed.",
default=False, scope=Scope.settings
default=False,
scope=Scope.settings
)
due = Date(
help="Date that this problem is due by",
@@ -123,7 +125,8 @@ class CombinedOpenEndedFields(object):
weight = Float(
display_name="Problem Weight",
help="Defines the number of points each problem is worth. If the value is not set, each problem is worth one point.",
scope=Scope.settings, values={"min" : 0 , "step": ".1"},
scope=Scope.settings,
values={"min" : 0 , "step": ".1"},
default=1
)
markdown = String(

View File

@@ -727,7 +727,12 @@ class CombinedOpenEndedV1Module():
"""
max_score = None
score = None
if self.is_scored and self.weight is not None:
#The old default was None, so set to 1 if it is the old default weight
weight = self.weight
if weight is None:
weight = 1
if self.is_scored:
# Finds the maximum score of all student attempts and keeps it.
score_mat = []
for i in xrange(0, len(self.task_states)):
@@ -740,7 +745,7 @@ class CombinedOpenEndedV1Module():
for z in xrange(0, len(score)):
if score[z] is None:
score[z] = 0
score[z] *= float(self.weight)
score[z] *= float(weight)
score_mat.append(score)
if len(score_mat) > 0:
@@ -754,7 +759,7 @@ class CombinedOpenEndedV1Module():
if max_score is not None:
# Weight the max score if it is not None
max_score *= float(self.weight)
max_score *= float(weight)
else:
# Without a max_score, we cannot have a score!
score = None

View File

@@ -57,7 +57,7 @@ class PeerGradingFields(object):
scope=Scope.settings
)
max_grade = Integer(
help="The maximum grade that a student can receive for this problem.",
help="The maximum grade that a student can receive for this problem.",
default=MAX_SCORE,
scope=Scope.settings,
values={"min": 0}
@@ -214,6 +214,11 @@ class PeerGradingModule(PeerGradingFields, XModule):
def get_score(self):
max_score = None
score = None
weight = self.weight
#The old default was None, so set to 1 if it is the old default weight
if weight is None:
weight = 1
score_dict = {
'score': score,
'total': max_score,
@@ -238,11 +243,10 @@ 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
if self.weight is not None:
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
score = int(count_graded >= count_required and count_graded > 0) * float(weight)
total = self.max_grade * float(weight)
score_dict['score'] = score
score_dict['total'] = total
return score_dict