Commit ea60c94925e7ae4314d5cca2ea3ad307d74fad59
1 parent
230e84f2
Exists in
master
and in
1 other branch
hide rankings of users 0 to 99 from students
Showing
1 changed file
with
9 additions
and
6 deletions
Show diff stats
aprendizations/learnapp.py
| ... | ... | @@ -576,21 +576,24 @@ class LearnApp(object): |
| 576 | 576 | all()) |
| 577 | 577 | |
| 578 | 578 | # compute percentage of right answers |
| 579 | - perf: Dict[str, float] = {uid: right.get(uid, 0.0)/total[uid] | |
| 580 | - for uid in total} | |
| 579 | + perf: Dict[str, float] = {u: right.get(u, 0.0)/total[u] | |
| 580 | + for u in total} | |
| 581 | 581 | |
| 582 | 582 | # compute topic progress |
| 583 | 583 | now = datetime.now() |
| 584 | 584 | goals = self.courses[course_id]['goals'] |
| 585 | 585 | prog: DefaultDict[str, float] = defaultdict(int) |
| 586 | 586 | |
| 587 | - for uid, topic, level, date in student_topics: | |
| 587 | + for u, topic, level, date in student_topics: | |
| 588 | 588 | if topic in goals: |
| 589 | 589 | date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f") |
| 590 | - prog[uid] += level**(now - date).days / len(goals) | |
| 590 | + prog[u] += level**(now - date).days / len(goals) | |
| 591 | 591 | |
| 592 | - rankings = [(uid, name, prog[uid], perf.get(uid, 0.0)) | |
| 593 | - for uid, name in students if uid != '0' and uid in prog] | |
| 592 | + ghostuser = len(uid) <= 2 # ghosts are invisible to students | |
| 593 | + rankings = [(u, name, prog[u], perf.get(u, 0.0)) | |
| 594 | + for u, name in students | |
| 595 | + if u in prog | |
| 596 | + and (len(u) > 2 or ghostuser) and u != '0' ] | |
| 594 | 597 | rankings.sort(key=lambda x: x[2], reverse=True) |
| 595 | 598 | return rankings |
| 596 | 599 | ... | ... |