Spaces:
Sleeping
Sleeping
Update modules/studentact/student_activities_v2-complet.py
Browse files
modules/studentact/student_activities_v2-complet.py
CHANGED
|
@@ -65,6 +65,8 @@ def display_student_activities(username: str, lang_code: str, t: dict):
|
|
| 65 |
logger.error(f"Error mostrando actividades: {str(e)}")
|
| 66 |
st.error(t.get('error_loading_activities', 'Error al cargar las actividades'))
|
| 67 |
|
|
|
|
|
|
|
| 68 |
def display_morphosyntax_activities(username: str, t: dict):
|
| 69 |
"""Muestra actividades de análisis morfosintáctico"""
|
| 70 |
try:
|
|
@@ -90,110 +92,93 @@ def display_morphosyntax_activities(username: str, t: dict):
|
|
| 90 |
logger.error(f"Error mostrando análisis morfosintáctico: {str(e)}")
|
| 91 |
st.error(t.get('error_morpho', 'Error al mostrar análisis morfosintáctico'))
|
| 92 |
|
|
|
|
|
|
|
| 93 |
def display_semantic_activities(username: str, t: dict):
|
| 94 |
"""Muestra actividades de análisis semántico"""
|
| 95 |
try:
|
|
|
|
| 96 |
analyses = get_student_semantic_analysis(username)
|
|
|
|
| 97 |
if not analyses:
|
|
|
|
| 98 |
st.info(t.get('no_semantic_analyses', 'No hay análisis semánticos registrados'))
|
| 99 |
return
|
| 100 |
|
|
|
|
| 101 |
for analysis in analyses:
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
|
|
|
|
|
|
| 109 |
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
|
|
|
|
|
|
| 124 |
|
| 125 |
except Exception as e:
|
| 126 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 127 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 128 |
|
| 129 |
-
###################################################################################################
|
| 130 |
-
|
| 131 |
|
|
|
|
| 132 |
def display_discourse_activities(username: str, t: dict):
|
| 133 |
"""Muestra actividades de análisis del discurso"""
|
| 134 |
try:
|
|
|
|
| 135 |
analyses = get_student_discourse_analysis(username)
|
|
|
|
| 136 |
if not analyses:
|
|
|
|
| 137 |
st.info(t.get('no_discourse_analyses', 'No hay análisis del discurso registrados'))
|
| 138 |
return
|
| 139 |
|
|
|
|
| 140 |
for analysis in analyses:
|
| 141 |
-
|
| 142 |
-
|
| 143 |
-
|
| 144 |
-
|
| 145 |
-
|
| 146 |
-
|
| 147 |
-
|
| 148 |
-
|
| 149 |
-
|
| 150 |
-
|
| 151 |
-
|
| 152 |
-
|
| 153 |
-
|
| 154 |
-
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
|
| 158 |
-
|
| 159 |
-
|
| 160 |
-
|
| 161 |
-
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
with col2:
|
| 168 |
-
st.markdown(f"**{t.get('concepts_text_2', 'Conceptos Texto 2')}**")
|
| 169 |
-
df2 = pd.DataFrame(
|
| 170 |
-
analysis['key_concepts2'],
|
| 171 |
-
columns=['Concepto', 'Frecuencia']
|
| 172 |
-
)
|
| 173 |
-
st.dataframe(df2)
|
| 174 |
-
|
| 175 |
-
# Mostrar gráficos
|
| 176 |
-
if all(key in analysis for key in ['graph1', 'graph2']):
|
| 177 |
-
st.subheader(t.get('visualizations', 'Visualizaciones'))
|
| 178 |
-
|
| 179 |
-
col1, col2 = st.columns(2)
|
| 180 |
-
with col1:
|
| 181 |
-
st.markdown(f"**{t.get('graph_text_1', 'Grafo Texto 1')}**")
|
| 182 |
-
if analysis['graph1']:
|
| 183 |
-
image_bytes = base64.b64decode(analysis['graph1'])
|
| 184 |
-
st.image(image_bytes)
|
| 185 |
-
|
| 186 |
-
with col2:
|
| 187 |
-
st.markdown(f"**{t.get('graph_text_2', 'Grafo Texto 2')}**")
|
| 188 |
-
if analysis['graph2']:
|
| 189 |
-
image_bytes = base64.b64decode(analysis['graph2'])
|
| 190 |
-
st.image(image_bytes)
|
| 191 |
-
|
| 192 |
-
# Mostrar gráfico combinado si existe
|
| 193 |
-
if 'combined_graph' in analysis and analysis['combined_graph']:
|
| 194 |
-
st.subheader(t.get('combined_visualization', 'Visualización Combinada'))
|
| 195 |
-
image_bytes = base64.b64decode(analysis['combined_graph'])
|
| 196 |
-
st.image(image_bytes)
|
| 197 |
|
| 198 |
except Exception as e:
|
| 199 |
logger.error(f"Error mostrando análisis del discurso: {str(e)}")
|
|
|
|
| 65 |
logger.error(f"Error mostrando actividades: {str(e)}")
|
| 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:
|
|
|
|
| 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 |
+
###############################################################################################
|
| 97 |
def display_semantic_activities(username: str, t: dict):
|
| 98 |
"""Muestra actividades de análisis semántico"""
|
| 99 |
try:
|
| 100 |
+
logger.info(f"Recuperando análisis semántico para {username}")
|
| 101 |
analyses = get_student_semantic_analysis(username)
|
| 102 |
+
|
| 103 |
if not analyses:
|
| 104 |
+
logger.info("No se encontraron análisis semánticos")
|
| 105 |
st.info(t.get('no_semantic_analyses', 'No hay análisis semánticos registrados'))
|
| 106 |
return
|
| 107 |
|
| 108 |
+
logger.info(f"Procesando {len(analyses)} análisis semánticos")
|
| 109 |
for analysis in analyses:
|
| 110 |
+
try:
|
| 111 |
+
# Verificar campos mínimos necesarios
|
| 112 |
+
if not all(key in analysis for key in ['timestamp', 'concept_graph']):
|
| 113 |
+
logger.warning(f"Análisis incompleto: {analysis.keys()}")
|
| 114 |
+
continue
|
| 115 |
+
|
| 116 |
+
# Formatear fecha
|
| 117 |
+
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 118 |
+
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 119 |
|
| 120 |
+
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 121 |
+
if analysis['concept_graph']:
|
| 122 |
+
logger.debug("Decodificando gráfico de conceptos")
|
| 123 |
+
try:
|
| 124 |
+
image_bytes = base64.b64decode(analysis['concept_graph'])
|
| 125 |
+
st.image(image_bytes, use_column_width=True)
|
| 126 |
+
logger.debug("Gráfico mostrado exitosamente")
|
| 127 |
+
except Exception as img_error:
|
| 128 |
+
logger.error(f"Error decodificando imagen: {str(img_error)}")
|
| 129 |
+
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 130 |
+
else:
|
| 131 |
+
st.info(t.get('no_graph', 'No hay visualización disponible'))
|
| 132 |
+
|
| 133 |
+
except Exception as e:
|
| 134 |
+
logger.error(f"Error procesando análisis individual: {str(e)}")
|
| 135 |
+
continue
|
| 136 |
|
| 137 |
except Exception as e:
|
| 138 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
| 139 |
st.error(t.get('error_semantic', 'Error al mostrar análisis semántico'))
|
| 140 |
|
|
|
|
|
|
|
| 141 |
|
| 142 |
+
###################################################################################################
|
| 143 |
def display_discourse_activities(username: str, t: dict):
|
| 144 |
"""Muestra actividades de análisis del discurso"""
|
| 145 |
try:
|
| 146 |
+
logger.info(f"Recuperando análisis del discurso para {username}")
|
| 147 |
analyses = get_student_discourse_analysis(username)
|
| 148 |
+
|
| 149 |
if not analyses:
|
| 150 |
+
logger.info("No se encontraron análisis del discurso")
|
| 151 |
st.info(t.get('no_discourse_analyses', 'No hay análisis del discurso registrados'))
|
| 152 |
return
|
| 153 |
|
| 154 |
+
logger.info(f"Procesando {len(analyses)} análisis del discurso")
|
| 155 |
for analysis in analyses:
|
| 156 |
+
try:
|
| 157 |
+
# Verificar campos mínimos necesarios
|
| 158 |
+
if not all(key in analysis for key in ['timestamp', 'combined_graph']):
|
| 159 |
+
logger.warning(f"Análisis incompleto: {analysis.keys()}")
|
| 160 |
+
continue
|
| 161 |
+
|
| 162 |
+
# Formatear fecha
|
| 163 |
+
timestamp = datetime.fromisoformat(analysis['timestamp'].replace('Z', '+00:00'))
|
| 164 |
+
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 165 |
+
|
| 166 |
+
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 167 |
+
if analysis['combined_graph']:
|
| 168 |
+
logger.debug("Decodificando gráfico combinado")
|
| 169 |
+
try:
|
| 170 |
+
image_bytes = base64.b64decode(analysis['combined_graph'])
|
| 171 |
+
st.image(image_bytes, use_column_width=True)
|
| 172 |
+
logger.debug("Gráfico mostrado exitosamente")
|
| 173 |
+
except Exception as img_error:
|
| 174 |
+
logger.error(f"Error decodificando imagen: {str(img_error)}")
|
| 175 |
+
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 176 |
+
else:
|
| 177 |
+
st.info(t.get('no_visualization', 'No hay visualización comparativa disponible'))
|
| 178 |
+
|
| 179 |
+
except Exception as e:
|
| 180 |
+
logger.error(f"Error procesando análisis individual: {str(e)}")
|
| 181 |
+
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
|
| 183 |
except Exception as e:
|
| 184 |
logger.error(f"Error mostrando análisis del discurso: {str(e)}")
|