Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
|
@@ -552,7 +552,7 @@ def display_discourse_activities(username: str, t: dict):
|
|
| 552 |
for analysis in analyses:
|
| 553 |
try:
|
| 554 |
# Verificar campos mínimos necesarios
|
| 555 |
-
if not all(key in analysis for key in ['timestamp'
|
| 556 |
logger.warning(f"Análisis incompleto: {analysis.keys()}")
|
| 557 |
continue
|
| 558 |
|
|
@@ -561,31 +561,6 @@ def display_discourse_activities(username: str, t: dict):
|
|
| 561 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 562 |
|
| 563 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
| 564 |
-
# Mostrar textos originales si están disponibles
|
| 565 |
-
if 'text1' in analysis and 'text2' in analysis:
|
| 566 |
-
st.subheader(t.get('analyzed_texts', 'Textos analizados'))
|
| 567 |
-
col1, col2 = st.columns(2)
|
| 568 |
-
with col1:
|
| 569 |
-
st.markdown(f"**{t.get('doc1_title', 'Documento 1')}**")
|
| 570 |
-
st.text_area(
|
| 571 |
-
"Text Content 1",
|
| 572 |
-
value=analysis['text1'],
|
| 573 |
-
height=100,
|
| 574 |
-
disabled=True,
|
| 575 |
-
label_visibility="collapsed",
|
| 576 |
-
key=f"text_area_1_{timestamp}"
|
| 577 |
-
)
|
| 578 |
-
with col2:
|
| 579 |
-
st.markdown(f"**{t.get('doc2_title', 'Documento 2')}**")
|
| 580 |
-
st.text_area(
|
| 581 |
-
"Text Content 2",
|
| 582 |
-
value=analysis['text2'],
|
| 583 |
-
height=100,
|
| 584 |
-
disabled=True,
|
| 585 |
-
label_visibility="collapsed",
|
| 586 |
-
key=f"text_area_2_{timestamp}"
|
| 587 |
-
)
|
| 588 |
-
|
| 589 |
# Mostrar conceptos clave
|
| 590 |
st.subheader(t.get('key_concepts', 'Conceptos clave'))
|
| 591 |
col1, col2 = st.columns(2)
|
|
@@ -605,37 +580,20 @@ def display_discourse_activities(username: str, t: dict):
|
|
| 605 |
else:
|
| 606 |
st.info(t.get('no_concepts', 'No hay conceptos disponibles'))
|
| 607 |
|
| 608 |
-
# Mostrar
|
| 609 |
st.subheader(t.get('comparison_visualization', 'Visualización comparativa'))
|
| 610 |
|
| 611 |
-
|
| 612 |
-
|
| 613 |
-
|
| 614 |
-
|
| 615 |
-
|
| 616 |
-
|
| 617 |
-
|
| 618 |
-
|
| 619 |
-
|
| 620 |
-
|
| 621 |
-
|
| 622 |
-
logger.error(f"Error decodificando imagen 1: {str(img_error)}")
|
| 623 |
-
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 624 |
-
else:
|
| 625 |
-
st.info(t.get('no_visualization', 'No hay visualización disponible'))
|
| 626 |
-
|
| 627 |
-
# Gráfico 2
|
| 628 |
-
with col2:
|
| 629 |
-
st.markdown(f"**{t.get('analysis_doc2', 'Análisis del segundo texto')}**")
|
| 630 |
-
if 'graph2' in analysis:
|
| 631 |
-
try:
|
| 632 |
-
image_bytes2 = base64.b64decode(analysis['graph2'])
|
| 633 |
-
st.image(image_bytes2, use_container_width=True)
|
| 634 |
-
except Exception as img_error:
|
| 635 |
-
logger.error(f"Error decodificando imagen 2: {str(img_error)}")
|
| 636 |
-
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 637 |
-
else:
|
| 638 |
-
st.info(t.get('no_visualization', 'No hay visualización disponible'))
|
| 639 |
|
| 640 |
# Añadir leyenda de interpretación
|
| 641 |
st.markdown("### 📊 " + t.get('graph_interpretation', 'Interpretación del grafo:'))
|
|
|
|
| 552 |
for analysis in analyses:
|
| 553 |
try:
|
| 554 |
# Verificar campos mínimos necesarios
|
| 555 |
+
if not all(key in analysis for key in ['timestamp']):
|
| 556 |
logger.warning(f"Análisis incompleto: {analysis.keys()}")
|
| 557 |
continue
|
| 558 |
|
|
|
|
| 561 |
formatted_date = timestamp.strftime("%d/%m/%Y %H:%M:%S")
|
| 562 |
|
| 563 |
with st.expander(f"{t.get('analysis_date', 'Fecha')}: {formatted_date}", expanded=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 564 |
# Mostrar conceptos clave
|
| 565 |
st.subheader(t.get('key_concepts', 'Conceptos clave'))
|
| 566 |
col1, col2 = st.columns(2)
|
|
|
|
| 580 |
else:
|
| 581 |
st.info(t.get('no_concepts', 'No hay conceptos disponibles'))
|
| 582 |
|
| 583 |
+
# Mostrar visualización combinada
|
| 584 |
st.subheader(t.get('comparison_visualization', 'Visualización comparativa'))
|
| 585 |
|
| 586 |
+
if 'combined_graph' in analysis and analysis['combined_graph']:
|
| 587 |
+
try:
|
| 588 |
+
logger.debug("Decodificando gráfico combinado")
|
| 589 |
+
image_bytes = base64.b64decode(analysis['combined_graph'])
|
| 590 |
+
st.image(image_bytes, use_container_width=True)
|
| 591 |
+
logger.debug("Gráfico combinado mostrado exitosamente")
|
| 592 |
+
except Exception as img_error:
|
| 593 |
+
logger.error(f"Error decodificando imagen combinada: {str(img_error)}")
|
| 594 |
+
st.error(t.get('error_loading_graph', 'Error al cargar el gráfico'))
|
| 595 |
+
else:
|
| 596 |
+
st.info(t.get('no_visualization', 'No hay visualización comparativa disponible'))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 597 |
|
| 598 |
# Añadir leyenda de interpretación
|
| 599 |
st.markdown("### 📊 " + t.get('graph_interpretation', 'Interpretación del grafo:'))
|