Skip to content
Snippets Groups Projects
Unverified Commit 15f73195 authored by AsadAzam's avatar AsadAzam Committed by GitHub
Browse files

Merge pull request #23451 from edx/asad/prod-1369

Fixed comparison mismatch
parents 0f125e7b fc3e6371
No related branches found
Tags release-2021-03-23-15.07
No related merge requests found
......@@ -380,7 +380,7 @@ class AssignmentFormatGrader(CourseGrader):
scores = list(grade_sheet.get(self.type, {}).values())
breakdown = []
labeler = get_short_labeler(self.short_label)
for i in range(max(self.min_count, len(scores))):
for i in range(max(int(float(self.min_count)), len(scores))):
if i < len(scores) or generate_random_scores:
if generate_random_scores: # for debugging!
earned = random.randint(2, 15)
......
......@@ -252,6 +252,40 @@ class GraderTest(unittest.TestCase):
self.assertEqual(len(graded['section_breakdown']), 0)
self.assertEqual(len(graded['grade_breakdown']), 0)
def test_grade_with_string_min_count(self):
"""
Test that the grading succeeds in case the min_count is set to a string
"""
weighted_grader = graders.grader_from_conf([
{
'type': "Homework",
'min_count': '12',
'drop_count': 2,
'short_label': "HW",
'weight': 0.25,
},
{
'type': "Lab",
'min_count': '7',
'drop_count': 3,
'category': "Labs",
'weight': 0.25
},
{
'type': "Midterm",
'min_count': '0',
'drop_count': 0,
'name': "Midterm Exam",
'short_label': "Midterm",
'weight': 0.5,
},
])
graded = weighted_grader.grade(self.test_gradesheet)
self.assertAlmostEqual(graded['percent'], 0.50812499999999994)
self.assertEqual(len(graded['section_breakdown']), (12 + 1) + (7 + 1) + 1)
self.assertEqual(len(graded['grade_breakdown']), 3)
def test_grader_from_conf(self):
# Confs always produce a graders.WeightedSubsectionsGrader, so we test this by repeating the test
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment