From a850fbe084f4ded2a81c36d05eb446ea173fd683 Mon Sep 17 00:00:00 2001 From: Miguel BarĂ£o Date: Fri, 1 Nov 2019 21:37:56 +0000 Subject: [PATCH] - show rankings by course - don't show students with no activity --- BUGS.md | 5 +++-- aprendizations/learnapp.py | 19 +++++++++++-------- aprendizations/templates/rankings.html | 2 -- 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/BUGS.md b/BUGS.md index 0d03bdc..a62b4e8 100644 --- a/BUGS.md +++ b/BUGS.md @@ -1,8 +1,7 @@ # BUGS -- obter rankings por curso GET course=course_id -- indicar qtos topicos faltam (>=50%) para terminar o curso. +- initdb da integrity error se no mesmo comando existirem alunos repetidos (p.ex em ficheiros csv diferentes ou entre csv e opcao -a) - permite definir goal, mas nao verifica se esta no grafo. rebenta no start_topic. - double click submits twice. - nao esta a seguir o max_tries definido no ficheiro de dependencias. @@ -29,6 +28,7 @@ sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in # TODO +- indicar qtos topicos faltam (>=50%) para terminar o curso. - use run_script_async to run run_script using asyncio.run? - ao fim de 3 tentativas de login, envial email para aluno com link para definir nova password (com timeout de 5 minutos). - mostrar capitulos e subtopicos de forma hierarquica. clicar no capitulo expande as dependencias. @@ -50,6 +50,7 @@ sqlite3.ProgrammingError: SQLite objects created in a thread can only be used in # FIXED +- obter rankings por curso GET course=course_id - no curso de linear algebra, as perguntas estao shuffled, mas nao deviam estar... nao esta a obedecer a keyword shuffle. - menu nao mostra as opcoes correctamente - finish topic vai para a lista de cursos. devia ficar no mesmo curso. diff --git a/aprendizations/learnapp.py b/aprendizations/learnapp.py index 274eb76..68d4ac1 100644 --- a/aprendizations/learnapp.py +++ b/aprendizations/learnapp.py @@ -1,6 +1,7 @@ # python standard library import asyncio +from collections import defaultdict from contextlib import contextmanager # `with` statement in db sessions from datetime import datetime import logging @@ -478,10 +479,9 @@ class LearnApp(object): # topic progress student_topics = s.query(StudentTopic.student_id, - StudentTopic.topic_id, # FIXME Filter topics of the course + StudentTopic.topic_id, StudentTopic.level, StudentTopic.date).all() - total_topics = s.query(Topic).count() # answer performance total = dict(s.query(Answer.student_id, sa.func.count(Answer.ref)). @@ -497,15 +497,18 @@ class LearnApp(object): for uid in total} # compute topic progress - prog: Dict[str, float] = {s[0]: 0.0 for s in students} now = datetime.now() + goals = self.courses[course_id]['goals'] + prog = defaultdict(int) + for uid, topic, level, date in student_topics: - date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f") - prog[uid] += level**(now - date).days / total_topics + if topic in goals: + date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f") + prog[uid] += level**(now - date).days / len(goals) rankings = [(uid, name, prog[uid], perf.get(uid, 0.0)) - for uid, name in students if uid != '0'] - - return sorted(rankings, key=lambda x: x[2], reverse=True) + for uid, name in students if uid != '0' and uid in prog] + rankings.sort(key=lambda x: x[2], reverse=True) + return rankings # ------------------------------------------------------------------------ diff --git a/aprendizations/templates/rankings.html b/aprendizations/templates/rankings.html index e1b7d13..4a28a00 100644 --- a/aprendizations/templates/rankings.html +++ b/aprendizations/templates/rankings.html @@ -71,8 +71,6 @@ {% for i,r in enumerate(rankings) %} {% if r[0] == uid %} - {% elif r[2] == 0 %} - {% else %} {% end %} -- libgit2 0.21.2