AIdeaText commited on
Commit
84529da
verified
1 Parent(s): 6eebfe4

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,6 +561,31 @@ 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 conceptos clave
565
  st.subheader(t.get('key_concepts', 'Conceptos clave'))
566
  col1, col2 = st.columns(2)
@@ -580,20 +605,37 @@ def display_discourse_activities(username: str, t: dict):
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:'))
 
552
  for analysis in analyses:
553
  try:
554
  # Verificar campos m铆nimos necesarios
555
+ if not all(key in analysis for key in ['timestamp', 'graph1', 'graph2']):
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 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
  else:
606
  st.info(t.get('no_concepts', 'No hay conceptos disponibles'))
607
 
608
+ # Mostrar visualizaciones
609
  st.subheader(t.get('comparison_visualization', 'Visualizaci贸n comparativa'))
610
 
611
+ # Mostrar los gr谩ficos lado a lado
612
+ col1, col2 = st.columns(2)
613
+
614
+ # Gr谩fico 1
615
+ with col1:
616
+ st.markdown(f"**{t.get('analysis_doc1', 'An谩lisis del primer texto')}**")
617
+ if 'graph1' in analysis:
618
+ try:
619
+ image_bytes1 = base64.b64decode(analysis['graph1'])
620
+ st.image(image_bytes1, use_container_width=True)
621
+ except Exception as img_error:
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:'))