Update modules/ui.py
Browse files- modules/ui.py +33 -11
modules/ui.py
CHANGED
@@ -158,7 +158,7 @@ def display_chat_interface():
|
|
158 |
|
159 |
##########################################################################
|
160 |
|
161 |
-
def display_student_progress(username, lang_code='es'):
|
162 |
print("lang_code:", lang_code)
|
163 |
student_data = get_student_data(username)
|
164 |
|
@@ -175,11 +175,6 @@ def display_student_progress(username, lang_code='es'): # Añade el parámetro
|
|
175 |
# Mostrar estadísticas generales
|
176 |
st.header("Estadísticas Generales")
|
177 |
st.metric("Total de entradas", student_data['entries_count'])
|
178 |
-
|
179 |
-
print("student_data['word_count']:", student_data['word_count'])
|
180 |
-
print("df:", df)
|
181 |
-
print("colors:", colors)
|
182 |
-
print("labels:", df['label'].tolist())
|
183 |
|
184 |
# Treemap para el conteo de palabras por categoría
|
185 |
if student_data['word_count']:
|
@@ -188,12 +183,15 @@ def display_student_progress(username, lang_code='es'): # Añade el parámetro
|
|
188 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
189 |
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
|
190 |
|
|
|
|
|
|
|
191 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=80)
|
192 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
193 |
-
|
|
|
|
|
194 |
squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax, text=df['label'])
|
195 |
-
squarify.plot(sizes=df['count'], label=df['label'], color=list(POS_COLORS.values())[:len(df)], alpha=0.8, ax=ax, text=df['label'])
|
196 |
-
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
|
197 |
plt.title('Treemap del total de palabras por categoria gramátical')
|
198 |
plt.axis('off')
|
199 |
print(fig)
|
@@ -201,8 +199,32 @@ def display_student_progress(username, lang_code='es'): # Añade el parámetro
|
|
201 |
else:
|
202 |
st.info("No hay datos de conteo de palabras disponibles.")
|
203 |
|
204 |
-
#
|
205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
206 |
else:
|
207 |
st.warning("No se encontraron entradas para este estudiante.")
|
208 |
st.info("Intenta realizar algunos análisis de texto primero.")
|
|
|
158 |
|
159 |
##########################################################################
|
160 |
|
161 |
+
def display_student_progress(username, lang_code='es'):
|
162 |
print("lang_code:", lang_code)
|
163 |
student_data = get_student_data(username)
|
164 |
|
|
|
175 |
# Mostrar estadísticas generales
|
176 |
st.header("Estadísticas Generales")
|
177 |
st.metric("Total de entradas", student_data['entries_count'])
|
|
|
|
|
|
|
|
|
|
|
178 |
|
179 |
# Treemap para el conteo de palabras por categoría
|
180 |
if student_data['word_count']:
|
|
|
183 |
df = pd.DataFrame(list(student_data['word_count'].items()), columns=['category', 'count'])
|
184 |
df['label'] = df.apply(lambda x: f"{POS_TRANSLATIONS[lang_code].get(x['category'], x['category'])}\n({x['count']})", axis=1)
|
185 |
|
186 |
+
print("student_data['word_count']:", student_data['word_count'])
|
187 |
+
print("df:", df)
|
188 |
+
|
189 |
fig, ax = plt.subplots(figsize=(12, 8), dpi=80)
|
190 |
colors = [POS_COLORS.get(cat, '#CCCCCC') for cat in df['category']]
|
191 |
+
print("colors:", colors)
|
192 |
+
print("labels:", df['label'].tolist())
|
193 |
+
|
194 |
squarify.plot(sizes=df['count'], label=df['label'], color=colors, alpha=0.8, ax=ax, text=df['label'])
|
|
|
|
|
195 |
plt.title('Treemap del total de palabras por categoria gramátical')
|
196 |
plt.axis('off')
|
197 |
print(fig)
|
|
|
199 |
else:
|
200 |
st.info("No hay datos de conteo de palabras disponibles.")
|
201 |
|
202 |
+
# Diagramas de Arco (consolidados)
|
203 |
+
st.header("Diagramas de Arco")
|
204 |
+
with st.expander("Ver todos los Diagramas de Arco"):
|
205 |
+
for i, entry in enumerate(student_data['entries']):
|
206 |
+
if 'arc_diagrams' in entry and entry['arc_diagrams']:
|
207 |
+
st.subheader(f"Entrada {i+1} - {entry['timestamp']}")
|
208 |
+
st.write(entry['arc_diagrams'][0], unsafe_allow_html=True)
|
209 |
+
|
210 |
+
# Diagramas de Red (consolidados)
|
211 |
+
st.header("Diagramas de Red")
|
212 |
+
with st.expander("Ver todos los Diagramas de Red"):
|
213 |
+
for i, entry in enumerate(student_data['entries']):
|
214 |
+
if 'network_diagram' in entry and entry['network_diagram']:
|
215 |
+
st.subheader(f"Entrada {i+1} - {entry['timestamp']}")
|
216 |
+
try:
|
217 |
+
# Decodificar la imagen base64
|
218 |
+
image_bytes = base64.b64decode(entry['network_diagram'])
|
219 |
+
st.image(image_bytes)
|
220 |
+
except Exception as e:
|
221 |
+
st.error(f"Error al mostrar el diagrama de red: {str(e)}")
|
222 |
+
|
223 |
+
# Mostrar entradas recientes
|
224 |
+
st.header("Entradas Recientes")
|
225 |
+
for i, entry in enumerate(student_data['entries'][:5]): # Mostrar las 5 entradas más recientes
|
226 |
+
with st.expander(f"Entrada {i+1} - {entry['timestamp']}"):
|
227 |
+
st.write(entry['text'])
|
228 |
else:
|
229 |
st.warning("No se encontraron entradas para este estudiante.")
|
230 |
st.info("Intenta realizar algunos análisis de texto primero.")
|