Commit a83fdc71 by Calen Pennington

Document the aggregate_scores function

parent 4a0969df
...@@ -9,26 +9,34 @@ log = logging.getLogger("mitx.courseware") ...@@ -9,26 +9,34 @@ log = logging.getLogger("mitx.courseware")
# Section either indicates the name of the problem or the name of the section # Section either indicates the name of the problem or the name of the section
Score = namedtuple("Score", "earned possible graded section") Score = namedtuple("Score", "earned possible graded section")
def aggregate_scores(scores, section_name = "summary"):
def aggregate_scores(scores, section_name="summary"):
"""
scores: A list of Score objects
returns: A tuple (all_total, graded_total).
all_total: A Score representing the total score summed over all input scores
graded_total: A Score representing the score summed over all graded input scores
"""
total_correct_graded = sum(score.earned for score in scores if score.graded) total_correct_graded = sum(score.earned for score in scores if score.graded)
total_possible_graded = sum(score.possible for score in scores if score.graded) total_possible_graded = sum(score.possible for score in scores if score.graded)
total_correct = sum(score.earned for score in scores) total_correct = sum(score.earned for score in scores)
total_possible = sum(score.possible for score in scores) total_possible = sum(score.possible for score in scores)
#regardless of whether or not it is graded #regardless of whether or not it is graded
all_total = Score(total_correct, all_total = Score(total_correct,
total_possible, total_possible,
False, False,
section_name) section_name)
#selecting only graded things #selecting only graded things
graded_total = Score(total_correct_graded, graded_total = Score(total_correct_graded,
total_possible_graded, total_possible_graded,
True, True,
section_name) section_name)
return all_total, graded_total return all_total, graded_total
def grader_from_conf(conf): def grader_from_conf(conf):
""" """
This creates a CourseGrader from a configuration (such as in course_settings.py). This creates a CourseGrader from a configuration (such as in course_settings.py).
......
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