Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
|
@@ -78,7 +78,7 @@ def display_student_activities(username: str, lang_code: str, t: dict):
|
|
| 78 |
###############################################################################################
|
| 79 |
|
| 80 |
def display_semantic_live_activities(username: str, t: dict):
|
| 81 |
-
"""Muestra actividades de análisis semántico en vivo"""
|
| 82 |
try:
|
| 83 |
analyses = get_student_semantic_live_analysis(username)
|
| 84 |
|
|
@@ -88,7 +88,12 @@ def display_semantic_live_activities(username: str, t: dict):
|
|
| 88 |
|
| 89 |
for analysis in analyses:
|
| 90 |
try:
|
| 91 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 93 |
|
| 94 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
|
@@ -100,17 +105,24 @@ def display_semantic_live_activities(username: str, t: dict):
|
|
| 100 |
disabled=True
|
| 101 |
)
|
| 102 |
|
| 103 |
-
# Mostrar gráfico si existe
|
| 104 |
if analysis.get('concept_graph'):
|
| 105 |
try:
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
except Exception as img_error:
|
| 115 |
logger.error(f"Error procesando gráfico: {str(img_error)}")
|
| 116 |
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
|
|
|
| 78 |
###############################################################################################
|
| 79 |
|
| 80 |
def display_semantic_live_activities(username: str, t: dict):
|
| 81 |
+
"""Muestra actividades de análisis semántico en vivo (CORREGIDO)"""
|
| 82 |
try:
|
| 83 |
analyses = get_student_semantic_live_analysis(username)
|
| 84 |
|
|
|
|
| 88 |
|
| 89 |
for analysis in analyses:
|
| 90 |
try:
|
| 91 |
+
# Manejar formato de fecha (CORREGIDO)
|
| 92 |
+
if isinstance(analysis['timestamp'], str):
|
| 93 |
+
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 94 |
+
else:
|
| 95 |
+
timestamp = analysis['timestamp']
|
| 96 |
+
|
| 97 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 98 |
|
| 99 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
|
|
|
| 105 |
disabled=True
|
| 106 |
)
|
| 107 |
|
| 108 |
+
# Mostrar gráfico si existe (CORREGIDO)
|
| 109 |
if analysis.get('concept_graph'):
|
| 110 |
try:
|
| 111 |
+
# Manejar diferentes formatos de imagen
|
| 112 |
+
if isinstance(analysis['concept_graph'], bytes):
|
| 113 |
+
st.image(
|
| 114 |
+
analysis['concept_graph'],
|
| 115 |
+
caption=t.get('concept_network', 'Red de Conceptos'),
|
| 116 |
+
use_container_width=True
|
| 117 |
+
)
|
| 118 |
+
elif isinstance(analysis['concept_graph'], str):
|
| 119 |
+
# Decodificar si está en base64
|
| 120 |
+
image_bytes = base64.b64decode(analysis['concept_graph'])
|
| 121 |
+
st.image(
|
| 122 |
+
image_bytes,
|
| 123 |
+
caption=t.get('concept_network', 'Red de Conceptos'),
|
| 124 |
+
use_container_width=True
|
| 125 |
+
)
|
| 126 |
except Exception as img_error:
|
| 127 |
logger.error(f"Error procesando gráfico: {str(img_error)}")
|
| 128 |
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|