AIdeaText commited on
Commit
bf5747b
verified
1 Parent(s): 26609dc

Update modules/studentact/student_activities_v2.py

Browse files
modules/studentact/student_activities_v2.py CHANGED
@@ -539,6 +539,7 @@ def display_semantic_activities(username: str, t: dict):
539
  def display_discourse_activities(username: str, t: dict):
540
  """
541
  Muestra actividades de an谩lisis del discurso en la secci贸n de historial
 
542
  """
543
  try:
544
  logger.info(f"Recuperando an谩lisis del discurso para {username}")
@@ -569,10 +570,51 @@ def display_discourse_activities(username: str, t: dict):
569
  # Usar la funci贸n de comparaci贸n existente para mostrar conceptos
570
  display_discourse_comparison(analysis, t)
571
 
572
- # Mostrar gr谩ficos - intentando diferentes campos y formatos
573
  has_graphs = False
574
 
575
- # Primero intentar el gr谩fico combinado
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
576
  if 'combined_graph' in analysis and analysis['combined_graph']:
577
  has_graphs = True
578
  st.markdown(f"### {t.get('combined_graph_title', 'Visualizaci贸n Comparativa')}")
@@ -582,43 +624,11 @@ def display_discourse_activities(username: str, t: dict):
582
  st.image(analysis['combined_graph'], use_column_width=True)
583
  # Si es string base64
584
  elif isinstance(analysis['combined_graph'], str):
585
- try:
586
- import base64
587
- image_bytes = base64.b64decode(analysis['combined_graph'])
588
- st.image(image_bytes, use_column_width=True)
589
- except:
590
- st.error(t.get('error_decoding', 'Error decodificando imagen'))
591
- else:
592
- st.error(t.get('unknown_format', 'Formato de imagen desconocido'))
593
  except Exception as e:
594
  logger.error(f"Error mostrando combined_graph: {str(e)}")
595
- st.error(t.get('error_graph', 'Error mostrando visualizaci贸n'))
596
-
597
- # Luego intentar gr谩ficos individuales
598
- for graph_key, title in [
599
- ('graph1', t.get('graph1_title', 'Visualizaci贸n Texto 1')),
600
- ('graph2', t.get('graph2_title', 'Visualizaci贸n Texto 2'))
601
- ]:
602
- if graph_key in analysis and analysis[graph_key]:
603
- has_graphs = True
604
- st.markdown(f"### {title}")
605
- try:
606
- # Si es bytes directamente
607
- if isinstance(analysis[graph_key], bytes):
608
- st.image(analysis[graph_key], use_column_width=True)
609
- # Si es string base64
610
- elif isinstance(analysis[graph_key], str):
611
- try:
612
- import base64
613
- image_bytes = base64.b64decode(analysis[graph_key])
614
- st.image(image_bytes, use_column_width=True)
615
- except:
616
- st.error(t.get('error_decoding', 'Error decodificando imagen'))
617
- else:
618
- st.error(t.get('unknown_format', 'Formato de imagen desconocido'))
619
- except Exception as e:
620
- logger.error(f"Error mostrando {graph_key}: {str(e)}")
621
- st.error(t.get('error_graph', f'Error mostrando {title}'))
622
 
623
  # Mensaje si no hay gr谩ficos
624
  if not has_graphs:
 
539
  def display_discourse_activities(username: str, t: dict):
540
  """
541
  Muestra actividades de an谩lisis del discurso en la secci贸n de historial
542
+ Ahora muestra los dos gr谩ficos principales uno al lado del otro
543
  """
544
  try:
545
  logger.info(f"Recuperando an谩lisis del discurso para {username}")
 
570
  # Usar la funci贸n de comparaci贸n existente para mostrar conceptos
571
  display_discourse_comparison(analysis, t)
572
 
573
+ # Mostrar gr谩ficos - ahora en dos columnas
574
  has_graphs = False
575
 
576
+ # Crear columnas para los gr谩ficos principales
577
+ if ('graph1' in analysis and analysis['graph1']) or ('graph2' in analysis and analysis['graph2']):
578
+ has_graphs = True
579
+ col1, col2 = st.columns(2)
580
+
581
+ # Gr谩fico 1 en la primera columna
582
+ with col1:
583
+ if 'graph1' in analysis and analysis['graph1']:
584
+ st.markdown(f"**{t.get('graph1_title', 'Visualizaci贸n Texto 1')}**")
585
+ try:
586
+ # Si es bytes directamente
587
+ if isinstance(analysis['graph1'], bytes):
588
+ st.image(analysis['graph1'], use_column_width=True)
589
+ # Si es string base64
590
+ elif isinstance(analysis['graph1'], str):
591
+ image_bytes = base64.b64decode(analysis['graph1'])
592
+ st.image(image_bytes, use_column_width=True)
593
+ except Exception as e:
594
+ logger.error(f"Error mostrando graph1: {str(e)}")
595
+ st.error(t.get('error_graph', 'Error mostrando visualizaci贸n del Texto 1'))
596
+ else:
597
+ st.info(t.get('no_graph1', 'No hay visualizaci贸n para el Texto 1'))
598
+
599
+ # Gr谩fico 2 en la segunda columna
600
+ with col2:
601
+ if 'graph2' in analysis and analysis['graph2']:
602
+ st.markdown(f"**{t.get('graph2_title', 'Visualizaci贸n Texto 2')}**")
603
+ try:
604
+ # Si es bytes directamente
605
+ if isinstance(analysis['graph2'], bytes):
606
+ st.image(analysis['graph2'], use_column_width=True)
607
+ # Si es string base64
608
+ elif isinstance(analysis['graph2'], str):
609
+ image_bytes = base64.b64decode(analysis['graph2'])
610
+ st.image(image_bytes, use_column_width=True)
611
+ except Exception as e:
612
+ logger.error(f"Error mostrando graph2: {str(e)}")
613
+ st.error(t.get('error_graph', 'Error mostrando visualizaci贸n del Texto 2'))
614
+ else:
615
+ st.info(t.get('no_graph2', 'No hay visualizaci贸n para el Texto 2'))
616
+
617
+ # Mostrar gr谩fico combinado si existe (debajo de los dos gr谩ficos)
618
  if 'combined_graph' in analysis and analysis['combined_graph']:
619
  has_graphs = True
620
  st.markdown(f"### {t.get('combined_graph_title', 'Visualizaci贸n Comparativa')}")
 
624
  st.image(analysis['combined_graph'], use_column_width=True)
625
  # Si es string base64
626
  elif isinstance(analysis['combined_graph'], str):
627
+ image_bytes = base64.b64decode(analysis['combined_graph'])
628
+ st.image(image_bytes, use_column_width=True)
 
 
 
 
 
 
629
  except Exception as e:
630
  logger.error(f"Error mostrando combined_graph: {str(e)}")
631
+ st.error(t.get('error_graph', 'Error mostrando visualizaci贸n comparativa'))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
632
 
633
  # Mensaje si no hay gr谩ficos
634
  if not has_graphs: