File size: 1,706 Bytes
12ffa62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
35
36
37
38
39
40
41
42
43
44
45
46
# modules/database/current_situation_mongo_db.py

from datetime import datetime, timezone
import logging
from .mongo_db import get_collection, insert_document, find_documents

logger = logging.getLogger(__name__)
COLLECTION_NAME = 'student_current_situation'

def store_current_situation_result(username, text_analyzed, metrics, feedback):
    """
    Almacena el resultado del an谩lisis de situaci贸n actual
    """
    try:
        analysis_document = {
            'username': username,
            'timestamp': datetime.now(timezone.utc).isoformat(),
            'text_analyzed': text_analyzed,
            'metrics': {
                'clarity_score': metrics['clarity'],
                'vocabulary_score': metrics['vocabulary'],
                'cohesion_score': metrics['cohesion'],
                'structure_score': metrics['structure']
            },
            'visual_analysis': {
                'sentence_complexity': metrics['sentence_graphs'],
                'vocabulary_network': metrics['word_connections'],
                'cohesion_patterns': metrics['connection_paths']
            },
            'feedback': {
                'strengths': feedback['strengths'],
                'development_areas': feedback['development_areas'],
                'suggested_exercises': feedback['exercises']
            }
        }
        
        result = insert_document(COLLECTION_NAME, analysis_document)
        if result:
            logger.info(f"An谩lisis de situaci贸n actual guardado para {username}")
            return True
            
        return False
        
    except Exception as e:
        logger.error(f"Error almacenando situaci贸n actual: {str(e)}")
        return False