AIdeaText commited on
Commit
8fe4473
verified
1 Parent(s): 8a9afa6

Update modules/studentact/student_activities_v2.py

Browse files
modules/studentact/student_activities_v2.py CHANGED
@@ -263,6 +263,7 @@ def display_chat_activities(username: str, t: dict):
263
  st.error(t.get('error_chat', 'Error al mostrar historial del chat'))
264
 
265
  #################################################################################
 
266
  def display_current_situation_activities(username: str, t: dict):
267
  """
268
  Muestra an谩lisis de situaci贸n actual junto con las recomendaciones de Claude
@@ -320,7 +321,7 @@ def display_current_situation_activities(username: str, t: dict):
320
  logger.info(f"Procesando {len(paired_analyses)} pares de an谩lisis")
321
 
322
  # Mostrar cada par de an谩lisis
323
- for timestamp_key, analysis_pair in paired_analyses:
324
  try:
325
  # Obtener datos de situaci贸n y recomendaci贸n
326
  situation_data = analysis_pair.get('situation', {})
@@ -354,23 +355,30 @@ def display_current_situation_activities(username: str, t: dict):
354
  }.get(text_type, text_type)
355
  title += f" - {text_type_display}"
356
 
 
 
 
357
  # Mostrar el an谩lisis en un expander
358
- with st.expander(title, expanded=False):
359
  # Mostrar texto analizado
360
  st.subheader(t.get('analyzed_text', 'Texto analizado'))
 
 
361
  st.text_area(
362
- "",
363
  value=text_to_show,
364
  height=100,
365
  disabled=True,
366
- label_visibility="collapsed"
 
367
  )
368
 
369
  # Crear tabs para separar diagn贸stico y recomendaciones
 
370
  diagnosis_tab, recommendations_tab = st.tabs([
371
  t.get('diagnosis_tab', 'Diagn贸stico'),
372
  t.get('recommendations_tab', 'Recomendaciones')
373
- ])
374
 
375
  # Tab de diagn贸stico
376
  with diagnosis_tab:
@@ -401,41 +409,45 @@ def display_current_situation_activities(username: str, t: dict):
401
  color = "#ccffcc" # light green
402
 
403
  # Mostrar la m茅trica con estilo
 
404
  st.markdown(f"""
405
  <div style="background-color:{color}; padding:10px; border-radius:5px; margin-bottom:10px;">
406
  <b>{emoji} {metric_name.capitalize()}:</b> {score:.2f}
407
  </div>
408
- """, unsafe_allow_html=True)
409
 
410
  # Mostrar detalles adicionales si est谩n disponibles
411
  with col2:
412
  st.subheader(t.get('details', 'Detalles'))
413
 
414
- # Recursivamente mostrar detalles de las m茅tricas
415
  for metric_name, metric_data in metrics.items():
416
  if isinstance(metric_data, dict) and 'details' in metric_data and metric_data['details']:
417
- with st.expander(f"{metric_name.capitalize()} - {t.get('details', 'Detalles')}"):
418
- # Mostrar detalles como JSON
419
- st.json(metric_data['details'])
 
420
  else:
421
  st.info(t.get('no_diagnosis', 'No hay datos de diagn贸stico disponibles'))
422
 
423
  # Tab de recomendaciones
424
  with recommendations_tab:
425
  if recommendation_data and 'recommendations' in recommendation_data:
 
426
  st.markdown(f"""
427
  <div style="padding: 20px; border-radius: 10px;
428
  background-color: #f8f9fa; margin-bottom: 20px;">
429
  {recommendation_data['recommendations']}
430
  </div>
431
- """, unsafe_allow_html=True)
432
  elif recommendation_data and 'feedback' in recommendation_data:
 
433
  st.markdown(f"""
434
  <div style="padding: 20px; border-radius: 10px;
435
  background-color: #f8f9fa; margin-bottom: 20px;">
436
  {recommendation_data['feedback']}
437
  </div>
438
- """, unsafe_allow_html=True)
439
  else:
440
  st.info(t.get('no_recommendations', 'No hay recomendaciones disponibles'))
441
 
 
263
  st.error(t.get('error_chat', 'Error al mostrar historial del chat'))
264
 
265
  #################################################################################
266
+
267
  def display_current_situation_activities(username: str, t: dict):
268
  """
269
  Muestra an谩lisis de situaci贸n actual junto con las recomendaciones de Claude
 
321
  logger.info(f"Procesando {len(paired_analyses)} pares de an谩lisis")
322
 
323
  # Mostrar cada par de an谩lisis
324
+ for i, (timestamp_key, analysis_pair) in enumerate(paired_analyses):
325
  try:
326
  # Obtener datos de situaci贸n y recomendaci贸n
327
  situation_data = analysis_pair.get('situation', {})
 
355
  }.get(text_type, text_type)
356
  title += f" - {text_type_display}"
357
 
358
+ # Generar clave 煤nica para este expander
359
+ expander_key = generate_unique_key("situation", f"expander_{i}", username)
360
+
361
  # Mostrar el an谩lisis en un expander
362
+ with st.expander(title, expanded=False, key=expander_key):
363
  # Mostrar texto analizado
364
  st.subheader(t.get('analyzed_text', 'Texto analizado'))
365
+ # Usar clave 煤nica para el text_area
366
+ text_area_key = generate_unique_key("situation", f"text_area_{i}", username)
367
  st.text_area(
368
+ label="Texto analizado",
369
  value=text_to_show,
370
  height=100,
371
  disabled=True,
372
+ key=text_area_key,
373
+ label_visibility="hidden"
374
  )
375
 
376
  # Crear tabs para separar diagn贸stico y recomendaciones
377
+ tab_key = generate_unique_key("situation", f"tabs_{i}", username)
378
  diagnosis_tab, recommendations_tab = st.tabs([
379
  t.get('diagnosis_tab', 'Diagn贸stico'),
380
  t.get('recommendations_tab', 'Recomendaciones')
381
+ ], key=tab_key)
382
 
383
  # Tab de diagn贸stico
384
  with diagnosis_tab:
 
409
  color = "#ccffcc" # light green
410
 
411
  # Mostrar la m茅trica con estilo
412
+ metric_key = generate_unique_key("situation", f"metric_{i}_{metric_name}", username)
413
  st.markdown(f"""
414
  <div style="background-color:{color}; padding:10px; border-radius:5px; margin-bottom:10px;">
415
  <b>{emoji} {metric_name.capitalize()}:</b> {score:.2f}
416
  </div>
417
+ """, unsafe_allow_html=True, key=metric_key)
418
 
419
  # Mostrar detalles adicionales si est谩n disponibles
420
  with col2:
421
  st.subheader(t.get('details', 'Detalles'))
422
 
423
+ # Recursivamente mostrar detalles de las m茅tricas como JSON o texto plano
424
  for metric_name, metric_data in metrics.items():
425
  if isinstance(metric_data, dict) and 'details' in metric_data and metric_data['details']:
426
+ detail_key = generate_unique_key("situation", f"detail_{i}_{metric_name}", username)
427
+ with st.container():
428
+ st.markdown(f"**{metric_name.capitalize()}**")
429
+ st.json(metric_data['details'], key=detail_key)
430
  else:
431
  st.info(t.get('no_diagnosis', 'No hay datos de diagn贸stico disponibles'))
432
 
433
  # Tab de recomendaciones
434
  with recommendations_tab:
435
  if recommendation_data and 'recommendations' in recommendation_data:
436
+ recom_key = generate_unique_key("situation", f"recom_{i}", username)
437
  st.markdown(f"""
438
  <div style="padding: 20px; border-radius: 10px;
439
  background-color: #f8f9fa; margin-bottom: 20px;">
440
  {recommendation_data['recommendations']}
441
  </div>
442
+ """, unsafe_allow_html=True, key=recom_key)
443
  elif recommendation_data and 'feedback' in recommendation_data:
444
+ feedback_key = generate_unique_key("situation", f"feedback_{i}", username)
445
  st.markdown(f"""
446
  <div style="padding: 20px; border-radius: 10px;
447
  background-color: #f8f9fa; margin-bottom: 20px;">
448
  {recommendation_data['feedback']}
449
  </div>
450
+ """, unsafe_allow_html=True, key=feedback_key)
451
  else:
452
  st.info(t.get('no_recommendations', 'No hay recomendaciones disponibles'))
453