Spaces:
Sleeping
Sleeping
Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
|
@@ -66,32 +66,6 @@ def display_student_activities(username: str, lang_code: str, t: dict):
|
|
| 66 |
st.error(t.get('error_loading_activities', 'Error al cargar las actividades'))
|
| 67 |
|
| 68 |
|
| 69 |
-
###################################################################################
|
| 70 |
-
def display_morphosyntax_activities(username: str, t: dict):
|
| 71 |
-
"""Muestra actividades de análisis morfosintáctico"""
|
| 72 |
-
try:
|
| 73 |
-
analyses = get_student_morphosyntax_analysis(username)
|
| 74 |
-
if not analyses:
|
| 75 |
-
st.info(t.get('no_morpho_analyses', 'No hay análisis morfosintácticos registrados'))
|
| 76 |
-
return
|
| 77 |
-
|
| 78 |
-
for analysis in analyses:
|
| 79 |
-
with st.expander(
|
| 80 |
-
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
| 81 |
-
expanded=False
|
| 82 |
-
):
|
| 83 |
-
st.text(f"{t.get('analyzed_text', 'Texto analizado')}:")
|
| 84 |
-
st.write(analysis['text'])
|
| 85 |
-
|
| 86 |
-
if 'arc_diagrams' in analysis:
|
| 87 |
-
st.subheader(t.get('syntactic_diagrams', 'Diagramas sintácticos'))
|
| 88 |
-
for diagram in analysis['arc_diagrams']:
|
| 89 |
-
st.write(diagram, unsafe_allow_html=True)
|
| 90 |
-
|
| 91 |
-
except Exception as e:
|
| 92 |
-
logger.error(f"Error mostrando análisis morfosintáctico: {str(e)}")
|
| 93 |
-
st.error(t.get('error_morpho', 'Error al mostrar análisis morfosintáctico'))
|
| 94 |
-
|
| 95 |
###################################################################################
|
| 96 |
def display_semantic_activities(username: str, t: dict):
|
| 97 |
"""Muestra actividades de análisis semántico"""
|
|
@@ -100,31 +74,40 @@ def display_semantic_activities(username: str, t: dict):
|
|
| 100 |
analyses = get_student_semantic_analysis(username)
|
| 101 |
|
| 102 |
if not analyses:
|
|
|
|
| 103 |
st.info(t.get('no_semantic_analyses', 'No hay análisis semánticos registrados'))
|
| 104 |
return
|
| 105 |
|
|
|
|
| 106 |
for analysis in analyses:
|
| 107 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 109 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 110 |
|
| 111 |
-
with st.expander(
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
logger.debug("Gráfico mostrado exitosamente")
|
| 121 |
-
except Exception as img_error:
|
| 122 |
-
logger.error(f"Error decodificando imagen: {str(img_error)}")
|
| 123 |
-
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 124 |
-
else:
|
| 125 |
-
logger.warning("No se encontró gráfico de conceptos")
|
| 126 |
st.info(t.get('no_graph', 'No hay visualización disponible'))
|
|
|
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
except Exception as e:
|
| 129 |
logger.error(f"Error procesando análisis individual: {str(e)}")
|
| 130 |
continue
|
|
@@ -133,7 +116,8 @@ def display_semantic_activities(username: str, t: dict):
|
|
| 133 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 134 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 135 |
|
| 136 |
-
|
|
|
|
| 137 |
def display_discourse_activities(username: str, t: dict):
|
| 138 |
"""Muestra actividades de análisis del discurso"""
|
| 139 |
try:
|
|
@@ -141,31 +125,40 @@ def display_discourse_activities(username: str, t: dict):
|
|
| 141 |
analyses = get_student_discourse_analysis(username)
|
| 142 |
|
| 143 |
if not analyses:
|
|
|
|
| 144 |
st.info(t.get('no_discourse_analyses', 'No hay análisis del discurso registrados'))
|
| 145 |
return
|
| 146 |
|
|
|
|
| 147 |
for analysis in analyses:
|
| 148 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 150 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 151 |
|
| 152 |
-
with st.expander(
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
if 'combined_graph' in analysis and analysis['combined_graph']:
|
| 157 |
-
logger.debug("Decodificando gráfico combinado")
|
| 158 |
-
try:
|
| 159 |
-
image_bytes = base64.b64decode(analysis['combined_graph'])
|
| 160 |
-
st.image(image_bytes)
|
| 161 |
-
logger.debug("Gráfico mostrado exitosamente")
|
| 162 |
-
except Exception as img_error:
|
| 163 |
-
logger.error(f"Error decodificando imagen: {str(img_error)}")
|
| 164 |
-
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 165 |
-
else:
|
| 166 |
-
logger.warning("No se encontró gráfico combinado")
|
| 167 |
st.info(t.get('no_visualization', 'No hay visualización comparativa disponible'))
|
|
|
|
| 168 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 169 |
except Exception as e:
|
| 170 |
logger.error(f"Error procesando análisis individual: {str(e)}")
|
| 171 |
continue
|
|
@@ -173,8 +166,9 @@ def display_discourse_activities(username: str, t: dict):
|
|
| 173 |
except Exception as e:
|
| 174 |
logger.error(f"Error mostrando análisis del discurso: {str(e)}")
|
| 175 |
st.error(t.get('error_discourse', 'Error al mostrar análisis del discurso'))
|
| 176 |
-
|
| 177 |
#################################################################################
|
|
|
|
|
|
|
| 178 |
def display_discourse_comparison(analysis: dict, t: dict):
|
| 179 |
"""Muestra la comparación de análisis del discurso"""
|
| 180 |
st.subheader(t.get('comparison_results', 'Resultados de la comparación'))
|
|
@@ -191,6 +185,8 @@ def display_discourse_comparison(analysis: dict, t: dict):
|
|
| 191 |
st.dataframe(df2)
|
| 192 |
|
| 193 |
#################################################################################
|
|
|
|
|
|
|
| 194 |
def display_chat_activities(username: str, t: dict):
|
| 195 |
"""
|
| 196 |
Muestra historial de conversaciones del chat
|
|
|
|
| 66 |
st.error(t.get('error_loading_activities', 'Error al cargar las actividades'))
|
| 67 |
|
| 68 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
###################################################################################
|
| 70 |
def display_semantic_activities(username: str, t: dict):
|
| 71 |
"""Muestra actividades de análisis semántico"""
|
|
|
|
| 74 |
analyses = get_student_semantic_analysis(username)
|
| 75 |
|
| 76 |
if not analyses:
|
| 77 |
+
logger.info("No se encontraron análisis semánticos")
|
| 78 |
st.info(t.get('no_semantic_analyses', 'No hay análisis semánticos registrados'))
|
| 79 |
return
|
| 80 |
|
| 81 |
+
logger.info(f"Procesando {len(analyses)} análisis semánticos")
|
| 82 |
for analysis in analyses:
|
| 83 |
try:
|
| 84 |
+
logger.debug(f"Datos del análisis: {analysis.keys()}")
|
| 85 |
+
|
| 86 |
+
# Verificar timestamp
|
| 87 |
+
if 'timestamp' not in analysis:
|
| 88 |
+
logger.warning("Análisis sin timestamp")
|
| 89 |
+
continue
|
| 90 |
+
|
| 91 |
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 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):
|
| 95 |
+
# Verificar gráfico
|
| 96 |
+
if 'concept_graph' not in analysis:
|
| 97 |
+
logger.warning("Análisis sin gráfico de conceptos")
|
| 98 |
+
st.info(t.get('no_graph', 'No hay visualización disponible'))
|
| 99 |
+
continue
|
| 100 |
+
|
| 101 |
+
if not analysis['concept_graph']:
|
| 102 |
+
logger.warning("Gráfico de conceptos vacío")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
st.info(t.get('no_graph', 'No hay visualización disponible'))
|
| 104 |
+
continue
|
| 105 |
|
| 106 |
+
logger.debug("Decodificando gráfico de conceptos")
|
| 107 |
+
image_bytes = base64.b64decode(analysis['concept_graph'])
|
| 108 |
+
st.image(image_bytes)
|
| 109 |
+
logger.debug("Gráfico mostrado exitosamente")
|
| 110 |
+
|
| 111 |
except Exception as e:
|
| 112 |
logger.error(f"Error procesando análisis individual: {str(e)}")
|
| 113 |
continue
|
|
|
|
| 116 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 117 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 118 |
|
| 119 |
+
###################################################################################
|
| 120 |
+
|
| 121 |
def display_discourse_activities(username: str, t: dict):
|
| 122 |
"""Muestra actividades de análisis del discurso"""
|
| 123 |
try:
|
|
|
|
| 125 |
analyses = get_student_discourse_analysis(username)
|
| 126 |
|
| 127 |
if not analyses:
|
| 128 |
+
logger.info("No se encontraron análisis del discurso")
|
| 129 |
st.info(t.get('no_discourse_analyses', 'No hay análisis del discurso registrados'))
|
| 130 |
return
|
| 131 |
|
| 132 |
+
logger.info(f"Procesando {len(analyses)} análisis del discurso")
|
| 133 |
for analysis in analyses:
|
| 134 |
try:
|
| 135 |
+
logger.debug(f"Datos del análisis: {analysis.keys()}")
|
| 136 |
+
|
| 137 |
+
# Verificar timestamp
|
| 138 |
+
if 'timestamp' not in analysis:
|
| 139 |
+
logger.warning("Análisis sin timestamp")
|
| 140 |
+
continue
|
| 141 |
+
|
| 142 |
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 143 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 144 |
|
| 145 |
+
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 146 |
+
# Verificar gráfico
|
| 147 |
+
if 'combined_graph' not in analysis:
|
| 148 |
+
logger.warning("Análisis sin gráfico combinado")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 149 |
st.info(t.get('no_visualization', 'No hay visualización comparativa disponible'))
|
| 150 |
+
continue
|
| 151 |
|
| 152 |
+
if not analysis['combined_graph']:
|
| 153 |
+
logger.warning("Gráfico combinado vacío")
|
| 154 |
+
st.info(t.get('no_visualization', 'No hay visualización comparativa disponible'))
|
| 155 |
+
continue
|
| 156 |
+
|
| 157 |
+
logger.debug("Decodificando gráfico combinado")
|
| 158 |
+
image_bytes = base64.b64decode(analysis['combined_graph'])
|
| 159 |
+
st.image(image_bytes)
|
| 160 |
+
logger.debug("Gráfico mostrado exitosamente")
|
| 161 |
+
|
| 162 |
except Exception as e:
|
| 163 |
logger.error(f"Error procesando análisis individual: {str(e)}")
|
| 164 |
continue
|
|
|
|
| 166 |
except Exception as e:
|
| 167 |
logger.error(f"Error mostrando análisis del discurso: {str(e)}")
|
| 168 |
st.error(t.get('error_discourse', 'Error al mostrar análisis del discurso'))
|
|
|
|
| 169 |
#################################################################################
|
| 170 |
+
|
| 171 |
+
|
| 172 |
def display_discourse_comparison(analysis: dict, t: dict):
|
| 173 |
"""Muestra la comparación de análisis del discurso"""
|
| 174 |
st.subheader(t.get('comparison_results', 'Resultados de la comparación'))
|
|
|
|
| 185 |
st.dataframe(df2)
|
| 186 |
|
| 187 |
#################################################################################
|
| 188 |
+
|
| 189 |
+
|
| 190 |
def display_chat_activities(username: str, t: dict):
|
| 191 |
"""
|
| 192 |
Muestra historial de conversaciones del chat
|