Update modules/studentact/student_activities_v2.py
Browse files
modules/studentact/student_activities_v2.py
CHANGED
@@ -565,29 +565,58 @@ def display_discourse_activities(username: str, t: dict):
|
|
565 |
col1, col2 = st.columns(2)
|
566 |
with col1:
|
567 |
st.markdown("**Texto 1:**")
|
568 |
-
st.text_area("", value=analysis['text1'], height=100, disabled=True)
|
569 |
with col2:
|
570 |
st.markdown("**Texto 2:**")
|
571 |
-
st.text_area("", value=analysis['text2'], height=100, disabled=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
572 |
|
573 |
# Mostrar gr谩ficos
|
574 |
st.markdown("### Visualizaci贸n comparativa")
|
575 |
|
576 |
# Verificar y mostrar gr谩ficos si existen
|
|
|
577 |
has_graphs = False
|
578 |
-
|
579 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
580 |
try:
|
581 |
# Verificar que sea bytes
|
582 |
-
if isinstance(analysis[
|
583 |
-
st.image(analysis[
|
584 |
-
caption=f"Gr谩fico {graph_key.replace('graph', '')}",
|
585 |
-
use_column_width=True)
|
586 |
has_graphs = True
|
587 |
else:
|
588 |
-
logger.warning(f"
|
589 |
except Exception as img_error:
|
590 |
-
logger.error(f"Error mostrando
|
591 |
|
592 |
if not has_graphs:
|
593 |
st.info(t.get('no_visualization', 'No hay visualizaci贸n comparativa disponible'))
|
|
|
565 |
col1, col2 = st.columns(2)
|
566 |
with col1:
|
567 |
st.markdown("**Texto 1:**")
|
568 |
+
st.text_area("", value=analysis['text1'], height=100, disabled=True, key=f"text1_{analysis.get('_id', 'unknown')}")
|
569 |
with col2:
|
570 |
st.markdown("**Texto 2:**")
|
571 |
+
st.text_area("", value=analysis['text2'], height=100, disabled=True, key=f"text2_{analysis.get('_id', 'unknown')}")
|
572 |
+
|
573 |
+
# Mostrar conceptos clave si est谩n disponibles
|
574 |
+
if 'key_concepts1' in analysis and 'key_concepts2' in analysis:
|
575 |
+
st.markdown("### Conceptos clave")
|
576 |
+
concept_col1, concept_col2 = st.columns(2)
|
577 |
+
|
578 |
+
with concept_col1:
|
579 |
+
st.markdown("**Documento 1**")
|
580 |
+
if analysis['key_concepts1']:
|
581 |
+
concept_df1 = pd.DataFrame(analysis['key_concepts1'], columns=['Concepto', 'Frecuencia'])
|
582 |
+
st.dataframe(concept_df1)
|
583 |
+
|
584 |
+
with concept_col2:
|
585 |
+
st.markdown("**Documento 2**")
|
586 |
+
if analysis['key_concepts2']:
|
587 |
+
concept_df2 = pd.DataFrame(analysis['key_concepts2'], columns=['Concepto', 'Frecuencia'])
|
588 |
+
st.dataframe(concept_df2)
|
589 |
|
590 |
# Mostrar gr谩ficos
|
591 |
st.markdown("### Visualizaci贸n comparativa")
|
592 |
|
593 |
# Verificar y mostrar gr谩ficos si existen
|
594 |
+
graph_col1, graph_col2 = st.columns(2)
|
595 |
has_graphs = False
|
596 |
+
|
597 |
+
with graph_col1:
|
598 |
+
if 'graph1' in analysis and analysis['graph1']:
|
599 |
+
try:
|
600 |
+
# Verificar que sea bytes
|
601 |
+
if isinstance(analysis['graph1'], bytes):
|
602 |
+
st.image(analysis['graph1'], caption="Documento 1", use_column_width=True)
|
603 |
+
has_graphs = True
|
604 |
+
else:
|
605 |
+
logger.warning(f"graph1 no es bytes: {type(analysis['graph1'])}")
|
606 |
+
except Exception as img_error:
|
607 |
+
logger.error(f"Error mostrando graph1: {str(img_error)}")
|
608 |
+
|
609 |
+
with graph_col2:
|
610 |
+
if 'graph2' in analysis and analysis['graph2']:
|
611 |
try:
|
612 |
# Verificar que sea bytes
|
613 |
+
if isinstance(analysis['graph2'], bytes):
|
614 |
+
st.image(analysis['graph2'], caption="Documento 2", use_column_width=True)
|
|
|
|
|
615 |
has_graphs = True
|
616 |
else:
|
617 |
+
logger.warning(f"graph2 no es bytes: {type(analysis['graph2'])}")
|
618 |
except Exception as img_error:
|
619 |
+
logger.error(f"Error mostrando graph2: {str(img_error)}")
|
620 |
|
621 |
if not has_graphs:
|
622 |
st.info(t.get('no_visualization', 'No hay visualizaci贸n comparativa disponible'))
|