Rathapoom commited on
Commit
a5ebfa5
·
verified ·
1 Parent(s): 8a7afb3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -49
app.py CHANGED
@@ -561,7 +561,7 @@ with col1:
561
 
562
  with col2:
563
  # Feedback Display
564
- if st.session_state.feedback:
565
  st.markdown("""
566
  <div class="thai-eng">
567
  <div class="thai">📝 คำแนะนำจากครู</div>
@@ -572,55 +572,53 @@ with col2:
572
  # แสดง feedback ในรูปแบบที่อ่านง่าย
573
  feedback_container = st.container()
574
  with feedback_container:
575
- if st.session_state.feedback.get('has_errors', False):
576
- st.markdown(f"""
577
- <div style='background-color: #f0f2f6;
578
- padding: 15px;
579
- border-radius: 8px;
580
- border-left: 4px solid #FF9800;
581
- margin: 5px 0;
582
- font-family: "Sarabun", sans-serif;'>
583
- <p style='color: #1e88e5; margin-bottom: 10px;'>
584
- {st.session_state.feedback['feedback']}
585
- </p>
586
- <p style='color: #666; font-size: 0.9em;'>
587
- ประโยคที่ถูกต้อง:<br/>
588
- <span style='color: #4CAF50; font-weight: bold;'>
589
- {st.session_state.feedback['corrected']}
590
- </span>
591
- </p>
592
- <button class='correction-button' onclick='submit_correction()'>
593
- ✍️ แก้ไขประโยคให้ถูกต้อง
594
- </button>
595
- </div>
596
- """, unsafe_allow_html=True)
597
-
598
- # ปุ่มแก้ไขประโยค
599
- if st.button("✍️ แก้ไขประโยคให้ถูกต้อง", key="correct_last"):
600
- last_user_entry_idx = next(
601
- (i for i, entry in reversed(list(enumerate(st.session_state.story)))
602
- if entry['role'] == 'You'),
603
- None
 
604
  )
605
- if last_user_entry_idx is not None:
606
- apply_correction(
607
- last_user_entry_idx,
608
- st.session_state.feedback['corrected']
609
- )
610
- st.rerun()
611
- else:
612
- st.markdown(f"""
613
- <div style='background-color: #f0f2f6;
614
- padding: 15px;
615
- border-radius: 8px;
616
- border-left: 4px solid #4CAF50;
617
- margin: 5px 0;
618
- font-family: "Sarabun", sans-serif;'>
619
- <p style='color: #1e88e5;'>
620
- {st.session_state.feedback['feedback']}
621
- </p>
622
- </div>
623
- """, unsafe_allow_html=True)
624
 
625
  # Help and Suggestions Box
626
  st.markdown("""
 
561
 
562
  with col2:
563
  # Feedback Display
564
+ if st.session_state.feedback and st.session_state.feedback.get('has_errors', False):
565
  st.markdown("""
566
  <div class="thai-eng">
567
  <div class="thai">📝 คำแนะนำจากครู</div>
 
572
  # แสดง feedback ในรูปแบบที่อ่านง่าย
573
  feedback_container = st.container()
574
  with feedback_container:
575
+ st.markdown(f"""
576
+ <div style='background-color: #f0f2f6;
577
+ padding: 15px;
578
+ border-radius: 8px;
579
+ border-left: 4px solid #FF9800;
580
+ margin: 5px 0;
581
+ font-family: "Sarabun", sans-serif;'>
582
+ <p style='color: #1e88e5; margin-bottom: 10px;'>
583
+ {st.session_state.feedback['feedback']}
584
+ </p>
585
+ <p style='color: #666; font-size: 0.9em;'>
586
+ ประโยคที่ถูกต้อง:<br/>
587
+ <span style='color: #4CAF50; font-weight: bold;'>
588
+ {st.session_state.feedback['corrected']}
589
+ </span>
590
+ </p>
591
+ </div>
592
+ """, unsafe_allow_html=True)
593
+
594
+ # แสดงปุ่มแก้ไขเพียงปุ่มเดียว
595
+ if st.button("✍️ แก้ไขประโยคให้ถูกต้อง", key="correct_button"):
596
+ last_user_entry_idx = next(
597
+ (i for i, entry in reversed(list(enumerate(st.session_state.story)))
598
+ if entry['role'] == 'You'),
599
+ None
600
+ )
601
+ if last_user_entry_idx is not None:
602
+ apply_correction(
603
+ last_user_entry_idx,
604
+ st.session_state.feedback['corrected']
605
  )
606
+ st.rerun()
607
+
608
+ elif st.session_state.feedback:
609
+ # กรณีไม่มีข้อผิดพลาด
610
+ st.markdown(f"""
611
+ <div style='background-color: #f0f2f6;
612
+ padding: 15px;
613
+ border-radius: 8px;
614
+ border-left: 4px solid #4CAF50;
615
+ margin: 5px 0;
616
+ font-family: "Sarabun", sans-serif;'>
617
+ <p style='color: #1e88e5;'>
618
+ {st.session_state.feedback['feedback']}
619
+ </p>
620
+ </div>
621
+ """, unsafe_allow_html=True)
 
 
 
622
 
623
  # Help and Suggestions Box
624
  st.markdown("""