Skip to content
Snippets Groups Projects
Commit 3376eb27 authored by Martin Mareš's avatar Martin Mareš
Browse files

Fix calculation of total points in exports and API

Previously, multiple awards in a thread were added instead of the
last one taking precedence.

Also, point awards in global posts are no longer permitted,
so we can simiplify the code.
parent d909f1e7
No related branches found
No related tags found
No related merge requests found
...@@ -266,19 +266,15 @@ def get_points(course: db.Course, students: List[db.User]) -> Tuple[Dict[int, Di ...@@ -266,19 +266,15 @@ def get_points(course: db.Course, students: List[db.User]) -> Tuple[Dict[int, Di
)) ))
points: Dict[int, Dict[str, float]] = {s.uid: {} for s in students} points: Dict[int, Dict[str, float]] = {s.uid: {} for s in students}
total_points: Dict[int, float] = {s.uid: 0 for s in students}
for a in awards: for a in awards:
pts = float(a.points) pts = float(a.points)
if a.target_uid == -1: if a.target_uid in points:
for uid in points.keys():
points[uid][a.topic.ident] = pts
if not a.topic.standalone:
total_points[uid] += pts
elif a.target_uid in points:
points[a.target_uid][a.topic.ident] = pts points[a.target_uid][a.topic.ident] = pts
if not a.topic.standalone:
total_points[a.target_uid] += pts total_points: Dict[int, float] = {}
for s in students:
total_points[s.uid] = sum(points[s.uid].values())
return points, total_points return points, total_points
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment