Spaces:
Sleeping
Sleeping
Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
|
@@ -94,6 +94,7 @@ def display_morphosyntax_activities(username: str, t: dict):
|
|
| 94 |
|
| 95 |
|
| 96 |
###############################################################################################
|
|
|
|
| 97 |
def display_semantic_activities(username: str, t: dict):
|
| 98 |
"""Muestra actividades de análisis semántico"""
|
| 99 |
try:
|
|
@@ -106,29 +107,34 @@ def display_semantic_activities(username: str, t: dict):
|
|
| 106 |
return
|
| 107 |
|
| 108 |
logger.info(f"Procesando {len(analyses)} análisis semánticos")
|
|
|
|
| 109 |
for analysis in analyses:
|
| 110 |
try:
|
| 111 |
-
#
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
# Verificar campos mínimos necesarios
|
| 115 |
-
if 'timestamp' not in analysis:
|
| 116 |
-
logger.warning("Análisis sin timestamp")
|
| 117 |
continue
|
| 118 |
-
|
| 119 |
# Formatear fecha
|
| 120 |
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 121 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 122 |
|
|
|
|
| 123 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 124 |
-
#
|
| 125 |
-
if
|
| 126 |
try:
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
|
| 131 |
-
# Debug: verificar contenido de bytes
|
| 132 |
logger.debug(f"Longitud de bytes de imagen: {len(image_bytes)}")
|
| 133 |
|
| 134 |
# Mostrar imagen
|
|
@@ -138,11 +144,11 @@ def display_semantic_activities(username: str, t: dict):
|
|
| 138 |
use_column_width=True
|
| 139 |
)
|
| 140 |
logger.debug("Gráfico mostrado exitosamente")
|
|
|
|
| 141 |
except Exception as img_error:
|
| 142 |
-
logger.error(f"Error
|
| 143 |
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 144 |
else:
|
| 145 |
-
logger.warning("No se encontró gráfico de conceptos o está vacío")
|
| 146 |
st.info(t.get('no_graph', 'No hay visualización disponible'))
|
| 147 |
|
| 148 |
except Exception as e:
|
|
@@ -153,6 +159,17 @@ def display_semantic_activities(username: str, t: dict):
|
|
| 153 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 154 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 155 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
###################################################################################################
|
| 157 |
def display_discourse_activities(username: str, t: dict):
|
| 158 |
"""Muestra actividades de análisis del discurso"""
|
|
|
|
| 94 |
|
| 95 |
|
| 96 |
###############################################################################################
|
| 97 |
+
|
| 98 |
def display_semantic_activities(username: str, t: dict):
|
| 99 |
"""Muestra actividades de análisis semántico"""
|
| 100 |
try:
|
|
|
|
| 107 |
return
|
| 108 |
|
| 109 |
logger.info(f"Procesando {len(analyses)} análisis semánticos")
|
| 110 |
+
|
| 111 |
for analysis in analyses:
|
| 112 |
try:
|
| 113 |
+
# Verificar campos necesarios
|
| 114 |
+
if not all(key in analysis for key in ['timestamp', 'concept_graph']):
|
| 115 |
+
logger.warning(f"Análisis incompleto: {analysis.keys()}")
|
|
|
|
|
|
|
|
|
|
| 116 |
continue
|
| 117 |
+
|
| 118 |
# Formatear fecha
|
| 119 |
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 120 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 121 |
|
| 122 |
+
# Crear expander
|
| 123 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 124 |
+
# Procesar y mostrar gráfico
|
| 125 |
+
if analysis.get('concept_graph'):
|
| 126 |
try:
|
| 127 |
+
# Convertir de base64 a bytes
|
| 128 |
+
logger.debug("Decodificando gráfico de conceptos")
|
| 129 |
+
image_data = analysis['concept_graph']
|
| 130 |
+
|
| 131 |
+
# Si el gráfico ya es bytes, usarlo directamente
|
| 132 |
+
if isinstance(image_data, bytes):
|
| 133 |
+
image_bytes = image_data
|
| 134 |
+
else:
|
| 135 |
+
# Si es string base64, decodificar
|
| 136 |
+
image_bytes = base64.b64decode(image_data)
|
| 137 |
|
|
|
|
| 138 |
logger.debug(f"Longitud de bytes de imagen: {len(image_bytes)}")
|
| 139 |
|
| 140 |
# Mostrar imagen
|
|
|
|
| 144 |
use_column_width=True
|
| 145 |
)
|
| 146 |
logger.debug("Gráfico mostrado exitosamente")
|
| 147 |
+
|
| 148 |
except Exception as img_error:
|
| 149 |
+
logger.error(f"Error procesando gráfico: {str(img_error)}")
|
| 150 |
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 151 |
else:
|
|
|
|
| 152 |
st.info(t.get('no_graph', 'No hay visualización disponible'))
|
| 153 |
|
| 154 |
except Exception as e:
|
|
|
|
| 159 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 160 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 161 |
|
| 162 |
+
|
| 163 |
+
|
| 164 |
+
|
| 165 |
+
|
| 166 |
+
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
|
| 170 |
+
|
| 171 |
+
|
| 172 |
+
|
| 173 |
###################################################################################################
|
| 174 |
def display_discourse_activities(username: str, t: dict):
|
| 175 |
"""Muestra actividades de análisis del discurso"""
|