File size: 1,153 Bytes
9e33225
 
 
 
b54a3a8
9e33225
b54a3a8
9e33225
 
 
 
b792ac5
 
9e33225
 
b792ac5
b54a3a8
9e33225
b54a3a8
9e33225
 
 
 
 
 
b792ac5
9e33225
b54a3a8
9e33225
b792ac5
 
9e33225
b54a3a8
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import logging
from typing import Dict, List

class PerformanceAnalyzer:
    def __init__(self, db_connection):
        self.conn = db_connection

    def analyze_user_performance(self, user_id: str) -> Dict:
        try:
            cursor = self.conn.cursor()
            cursor.execute('''
                SELECT topic, AVG(performance_score) as avg_score 
                FROM study_progress 
                WHERE user_id = ?
                GROUP BY topic
            ''', (user_id,))
            return dict(cursor.fetchall())
        except Exception as e:
            logging.error(f"Erro ao analisar performance: {e}")
            return {}

    def get_weak_areas(self, user_id: str) -> List[str]:
        try:
            cursor = self.conn.cursor()
            cursor.execute('''
                SELECT topic 
                FROM study_progress
                WHERE user_id = ? AND performance_score < 70
                GROUP BY topic
            ''', (user_id,))
            return [row[0] for row in cursor.fetchall()]
        except Exception as e:
            logging.error(f"Erro ao buscar áreas fracas: {e}")
            return []