Create current_situation_mongo_db.py
Browse files
modules/database/current_situation_mongo_db.py
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# modules/database/current_situation_mongo_db.py
|
2 |
+
|
3 |
+
from datetime import datetime, timezone
|
4 |
+
import logging
|
5 |
+
from .mongo_db import get_collection, insert_document, find_documents
|
6 |
+
|
7 |
+
logger = logging.getLogger(__name__)
|
8 |
+
COLLECTION_NAME = 'student_current_situation'
|
9 |
+
|
10 |
+
def store_current_situation_result(username, text_analyzed, metrics, feedback):
|
11 |
+
"""
|
12 |
+
Almacena el resultado del an谩lisis de situaci贸n actual
|
13 |
+
"""
|
14 |
+
try:
|
15 |
+
analysis_document = {
|
16 |
+
'username': username,
|
17 |
+
'timestamp': datetime.now(timezone.utc).isoformat(),
|
18 |
+
'text_analyzed': text_analyzed,
|
19 |
+
'metrics': {
|
20 |
+
'clarity_score': metrics['clarity'],
|
21 |
+
'vocabulary_score': metrics['vocabulary'],
|
22 |
+
'cohesion_score': metrics['cohesion'],
|
23 |
+
'structure_score': metrics['structure']
|
24 |
+
},
|
25 |
+
'visual_analysis': {
|
26 |
+
'sentence_complexity': metrics['sentence_graphs'],
|
27 |
+
'vocabulary_network': metrics['word_connections'],
|
28 |
+
'cohesion_patterns': metrics['connection_paths']
|
29 |
+
},
|
30 |
+
'feedback': {
|
31 |
+
'strengths': feedback['strengths'],
|
32 |
+
'development_areas': feedback['development_areas'],
|
33 |
+
'suggested_exercises': feedback['exercises']
|
34 |
+
}
|
35 |
+
}
|
36 |
+
|
37 |
+
result = insert_document(COLLECTION_NAME, analysis_document)
|
38 |
+
if result:
|
39 |
+
logger.info(f"An谩lisis de situaci贸n actual guardado para {username}")
|
40 |
+
return True
|
41 |
+
|
42 |
+
return False
|
43 |
+
|
44 |
+
except Exception as e:
|
45 |
+
logger.error(f"Error almacenando situaci贸n actual: {str(e)}")
|
46 |
+
return False
|