Commit 66769475a39d1aa1649839f34eab0bb73d9c198f

Authored by Miguel Barão
2 parents 8548cb5b ea60c949
Exists in master and in 1 other branch dev

Merge branch 'master' into dev

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