From ea60c94925e7ae4314d5cca2ea3ad307d74fad59 Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Wed, 12 Feb 2020 15:30:15 +0000 Subject: [PATCH] hide rankings of users 0 to 99 from students --- aprendizations/learnapp.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/aprendizations/learnapp.py b/aprendizations/learnapp.py index 5afa575..c542f3a 100644 --- a/aprendizations/learnapp.py +++ b/aprendizations/learnapp.py @@ -576,21 +576,24 @@ class LearnApp(object): all()) # compute percentage of right answers - perf: Dict[str, float] = {uid: right.get(uid, 0.0)/total[uid] - for uid in total} + perf: Dict[str, float] = {u: right.get(u, 0.0)/total[u] + for u in total} # compute topic progress now = datetime.now() goals = self.courses[course_id]['goals'] prog: DefaultDict[str, float] = defaultdict(int) - for uid, topic, level, date in student_topics: + for u, topic, level, date in student_topics: if topic in goals: date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f") - prog[uid] += level**(now - date).days / len(goals) + prog[u] += level**(now - date).days / len(goals) - rankings = [(uid, name, prog[uid], perf.get(uid, 0.0)) - for uid, name in students if uid != '0' and uid in prog] + ghostuser = len(uid) <= 2 # ghosts are invisible to students + rankings = [(u, name, prog[u], perf.get(u, 0.0)) + for u, name in students + if u in prog + and (len(u) > 2 or ghostuser) and u != '0' ] rankings.sort(key=lambda x: x[2], reverse=True) return rankings -- libgit2 0.21.2