Spaces:
Running
Running
# 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 |