Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
@@ -25,7 +25,6 @@ from ..database.chat_mongo_db import get_chat_history
|
|
25 |
logger = logging.getLogger(__name__)
|
26 |
|
27 |
###################################################################################
|
28 |
-
|
29 |
def display_student_activities(username: str, lang_code: str, t: dict):
|
30 |
"""
|
31 |
Muestra todas las actividades del estudiante
|
@@ -65,52 +64,61 @@ 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 |
|
69 |
###################################################################################
|
70 |
def display_semantic_activities(username: str, t: dict):
|
71 |
"""Muestra actividades de análisis semántico"""
|
72 |
try:
|
73 |
-
logger.info(f"Recuperando análisis semántico para {username}")
|
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 |
-
|
84 |
-
|
|
|
|
|
85 |
|
86 |
-
#
|
87 |
-
if '
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
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
|
114 |
|
115 |
except Exception as e:
|
116 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
@@ -121,54 +129,60 @@ def display_semantic_activities(username: str, t: dict):
|
|
121 |
def display_discourse_activities(username: str, t: dict):
|
122 |
"""Muestra actividades de análisis del discurso"""
|
123 |
try:
|
124 |
-
logger.info(f"Recuperando análisis del discurso para {username}")
|
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 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
|
|
141 |
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
st.
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
165 |
|
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'))
|
|
|
25 |
logger = logging.getLogger(__name__)
|
26 |
|
27 |
###################################################################################
|
|
|
28 |
def display_student_activities(username: str, lang_code: str, t: dict):
|
29 |
"""
|
30 |
Muestra todas las actividades del estudiante
|
|
|
64 |
logger.error(f"Error mostrando actividades: {str(e)}")
|
65 |
st.error(t.get('error_loading_activities', 'Error al cargar las actividades'))
|
66 |
|
67 |
+
###################################################################################
|
68 |
+
def display_morphosyntax_activities(username: str, t: dict):
|
69 |
+
"""Muestra actividades de análisis morfosintáctico"""
|
70 |
+
try:
|
71 |
+
analyses = get_student_morphosyntax_analysis(username)
|
72 |
+
if not analyses:
|
73 |
+
st.info(t.get('no_morpho_analyses', 'No hay análisis morfosintácticos registrados'))
|
74 |
+
return
|
75 |
+
|
76 |
+
for analysis in analyses:
|
77 |
+
with st.expander(
|
78 |
+
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
79 |
+
expanded=False
|
80 |
+
):
|
81 |
+
st.text(f"{t.get('analyzed_text', 'Texto analizado')}:")
|
82 |
+
st.write(analysis['text'])
|
83 |
+
|
84 |
+
if 'arc_diagrams' in analysis:
|
85 |
+
st.subheader(t.get('syntactic_diagrams', 'Diagramas sintácticos'))
|
86 |
+
for diagram in analysis['arc_diagrams']:
|
87 |
+
st.write(diagram, unsafe_allow_html=True)
|
88 |
+
|
89 |
+
except Exception as e:
|
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 |
###################################################################################
|
94 |
def display_semantic_activities(username: str, t: dict):
|
95 |
"""Muestra actividades de análisis semántico"""
|
96 |
try:
|
|
|
97 |
analyses = get_student_semantic_analysis(username)
|
|
|
98 |
if not analyses:
|
|
|
99 |
st.info(t.get('no_semantic_analyses', 'No hay análisis semánticos registrados'))
|
100 |
return
|
101 |
|
|
|
102 |
for analysis in analyses:
|
103 |
+
with st.expander(
|
104 |
+
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
105 |
+
expanded=False
|
106 |
+
):
|
107 |
|
108 |
+
# Mostrar conceptos clave
|
109 |
+
if 'key_concepts' in analysis:
|
110 |
+
st.subheader(t.get('key_concepts', 'Conceptos clave'))
|
111 |
+
df = pd.DataFrame(
|
112 |
+
analysis['key_concepts'],
|
113 |
+
columns=['Concepto', 'Frecuencia']
|
114 |
+
)
|
115 |
+
st.dataframe(df)
|
116 |
+
|
117 |
+
# Mostrar gráfico de conceptos
|
118 |
+
if 'concept_graph' in analysis and analysis['concept_graph']:
|
119 |
+
st.subheader(t.get('concept_graph', 'Grafo de conceptos'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
120 |
image_bytes = base64.b64decode(analysis['concept_graph'])
|
121 |
st.image(image_bytes)
|
|
|
|
|
|
|
|
|
|
|
122 |
|
123 |
except Exception as e:
|
124 |
logger.error(f"Error mostrando análisis semántico: {str(e)}")
|
|
|
129 |
def display_discourse_activities(username: str, t: dict):
|
130 |
"""Muestra actividades de análisis del discurso"""
|
131 |
try:
|
|
|
132 |
analyses = get_student_discourse_analysis(username)
|
|
|
133 |
if not analyses:
|
|
|
134 |
st.info(t.get('no_discourse_analyses', 'No hay análisis del discurso registrados'))
|
135 |
return
|
136 |
|
|
|
137 |
for analysis in analyses:
|
138 |
+
with st.expander(
|
139 |
+
f"{t.get('analysis_date', 'Fecha')}: {analysis['timestamp']}",
|
140 |
+
expanded=False
|
141 |
+
):
|
142 |
+
|
143 |
+
# Mostrar conceptos clave
|
144 |
+
if 'key_concepts1' in analysis and 'key_concepts2' in analysis:
|
145 |
+
st.subheader(t.get('comparison_results', 'Resultados de la comparación'))
|
146 |
|
147 |
+
col1, col2 = st.columns(2)
|
148 |
+
with col1:
|
149 |
+
st.markdown(f"**{t.get('concepts_text_1', 'Conceptos Texto 1')}**")
|
150 |
+
df1 = pd.DataFrame(
|
151 |
+
analysis['key_concepts1'],
|
152 |
+
columns=['Concepto', 'Frecuencia']
|
153 |
+
)
|
154 |
+
st.dataframe(df1)
|
155 |
+
|
156 |
+
with col2:
|
157 |
+
st.markdown(f"**{t.get('concepts_text_2', 'Conceptos Texto 2')}**")
|
158 |
+
df2 = pd.DataFrame(
|
159 |
+
analysis['key_concepts2'],
|
160 |
+
columns=['Concepto', 'Frecuencia']
|
161 |
+
)
|
162 |
+
st.dataframe(df2)
|
163 |
+
|
164 |
+
# Mostrar gráficos
|
165 |
+
if all(key in analysis for key in ['graph1', 'graph2']):
|
166 |
+
st.subheader(t.get('visualizations', 'Visualizaciones'))
|
167 |
+
|
168 |
+
col1, col2 = st.columns(2)
|
169 |
+
with col1:
|
170 |
+
st.markdown(f"**{t.get('graph_text_1', 'Grafo Texto 1')}**")
|
171 |
+
if analysis['graph1']:
|
172 |
+
image_bytes = base64.b64decode(analysis['graph1'])
|
173 |
+
st.image(image_bytes)
|
174 |
+
|
175 |
+
with col2:
|
176 |
+
st.markdown(f"**{t.get('graph_text_2', 'Grafo Texto 2')}**")
|
177 |
+
if analysis['graph2']:
|
178 |
+
image_bytes = base64.b64decode(analysis['graph2'])
|
179 |
+
st.image(image_bytes)
|
180 |
|
181 |
except Exception as e:
|
182 |
logger.error(f"Error mostrando análisis del discurso: {str(e)}")
|
183 |
st.error(t.get('error_discourse', 'Error al mostrar análisis del discurso'))
|
184 |
#################################################################################
|
185 |
|
|
|
186 |
def display_discourse_comparison(analysis: dict, t: dict):
|
187 |
"""Muestra la comparación de análisis del discurso"""
|
188 |
st.subheader(t.get('comparison_results', 'Resultados de la comparación'))
|