Commit e23fb12240eeb8ce7c0dbba1ab88ab1c59001452

Authored by Miguel Barão
1 parent 9b98821d
Exists in master and in 1 other branch dev

removes the thumbs up on rankings

it was causing problems with sqlalchemy.
aprendizations/learnapp.py
... ... @@ -599,7 +599,7 @@ class LearnApp():
599 599 return self.courses[course_id]
600 600  
601 601 # ------------------------------------------------------------------------
602   - def get_rankings(self, uid: str, course_id: str) -> Iterable[Tuple[str, str, float, float]]:
  602 + def get_rankings(self, uid: str, course_id: str) -> Iterable[Tuple[str, str, float]]:
603 603 '''
604 604 Returns rankings for a certain course_id.
605 605 User where uid have <=2 chars are considered ghosts are hidden from
... ... @@ -610,33 +610,19 @@ class LearnApp():
610 610 '''
611 611  
612 612 logger.info('User "%s" rankings for "%s"', uid, course_id)
613   - with Session(self._engine, future=True) as session:
614   - query_students = select(Student.id, Student.name)
615   - query_student_topics = select(StudentTopic.student_id,
616   - StudentTopic.topic_id,
617   - StudentTopic.level,
618   - StudentTopic.date)
619   - query_total = select(Answer.student_id, func.count(Answer.ref))
620   - query_right = select(Answer.student_id, func.count(Answer.ref)) \
621   - .where(Answer.grade == 1.0)
  613 + query_students = select(Student.id, Student.name)
  614 + query_student_topics = select(StudentTopic.student_id,
  615 + StudentTopic.topic_id,
  616 + StudentTopic.level,
  617 + StudentTopic.date)
622 618  
  619 + with Session(self._engine, future=True) as session:
623 620 # all students in the database FIXME only with answers of this course
624 621 students = session.execute(query_students).all()
625 622  
626 623 # topic levels FIXME only topics of this course
627 624 student_topics = session.execute(query_student_topics).all()
628 625  
629   - # answer performance
630   -
631   - # FIXME this does not work when nobody has done anything...
632   - # FIXME row to dict seems to be deprecated in 1.4+
633   - total = dict(session.execute(query_total).all())
634   - right = dict(session.execute(query_right).all())
635   -
636   - # compute percentage of right answers
637   - perf: Dict[str, float] = {u: right.get(u, 0.0) / total[u]
638   - for u in total}
639   -
640 626 # compute topic progress
641 627 now = datetime.now()
642 628 goals = self.courses[course_id]['goals']
... ... @@ -647,7 +633,7 @@ class LearnApp():
647 633 date = datetime.strptime(date, "%Y-%m-%d %H:%M:%S.%f")
648 634 progress[student] += level**(now - date).days / len(goals)
649 635  
650   - return sorted(((u, name, progress[u], perf.get(u, 0.0))
  636 + return sorted(((u, name, progress[u])
651 637 for u, name in students
652 638 if u in progress and (len(u) > 2 or len(uid) <= 2)),
653 639 key=lambda x: x[2], reverse=True)
... ...
aprendizations/templates/rankings.html
... ... @@ -61,7 +61,6 @@
61 61 <tr>
62 62 <th scope="col" class="text-center">Posição</th>
63 63 <th scope="col">Aluno</th>
64   - <th scope="col"></th>
65 64 <th scope="col">Progresso</th>
66 65 </tr>
67 66 </thead>
... ... @@ -76,9 +75,6 @@
76 75 <td> <!-- student name -->
77 76 {{ ' '.join(r[1].split()[n] for n in (0,-1)) }}
78 77 </td>
79   - <td> <!-- nice -->
80   - {{ '<i class="far fa-thumbs-up text-success" title="Mais de 75% de respostas correctas"></i>' if r[3] > 0.75 else '' }}
81   - </td>
82 78 <td> <!-- progress -->
83 79 <div class="progress" style="height: 24px;">
84 80 <div class="progress-bar" role="progressbar" style="width: {{ 100*r[2] }}%;" aria-valuenow="{{round(100*r[2])}}%" aria-valuemin="0" aria-valuemax="100">{{round(100*r[2])}}%</div>
... ...