youngtsai commited on
Commit
06ba552
·
1 Parent(s): 0e4505a

english_exam_practice_tab_button_js = """

Browse files
Files changed (1) hide show
  1. app.py +94 -36
app.py CHANGED
@@ -727,6 +727,45 @@ CSS = """
727
  }
728
  """
729
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
730
  with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary_hue=gr.themes.colors.orange), css=CSS) as demo:
731
 
732
  with gr.Row(visible=False) as english_group:
@@ -744,13 +783,13 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
744
  """)
745
  with gr.Row():
746
  with gr.Column():
747
- english_grapragh_practice_button = gr.Button("📝 英文段落寫作練習", variant="primary")
748
  with gr.Column():
749
- english_grapragh_evaluate_button = gr.Button("📊 英文段落寫作評分")
750
  with gr.Column():
751
- english_exam_practice_tab_button = gr.Button("🎯 英文考古題寫作練習")
752
  # ===== 英文段落寫作練習 =====
753
- with gr.Row(visible=True) as english_grapragh_practice_row:
754
  with gr.Column():
755
  with gr.Row():
756
  gr.Markdown("# 📝 英文段落寫作練習")
@@ -1624,7 +1663,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
1624
  )
1625
 
1626
  # ====="英文全文批改"=====
1627
- with gr.Row(visible=False) as english_grapragh_evaluate_row:
1628
  with gr.Column():
1629
  with gr.Row(visible=False) as full_paragraph_params:
1630
  full_paragraph_sys_content_input = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.")
@@ -1726,7 +1765,7 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
1726
  )
1727
 
1728
  # ====="英文考古題寫作練習====="
1729
- with gr.Row(visible=False) as english_exam_practice_row:
1730
 
1731
  with gr.Column():
1732
  with gr.Row():
@@ -1843,41 +1882,60 @@ with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary
1843
  outputs=past_exam_refine_output_diff
1844
  )
1845
 
 
 
 
 
 
 
 
 
 
 
 
 
1846
  english_grapragh_practice_button.click(
1847
- fn=update_english_grapragh_practice_rows,
1848
- inputs=[english_grapragh_practice_button],
1849
- outputs=[
1850
- english_grapragh_practice_row,
1851
- english_grapragh_evaluate_row,
1852
- english_exam_practice_row,
1853
- english_grapragh_practice_button,
1854
- english_grapragh_evaluate_button,
1855
- english_exam_practice_tab_button
1856
- ]
1857
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
1858
  english_grapragh_evaluate_button.click(
1859
- fn=update_english_grapragh_practice_rows,
1860
- inputs=[english_grapragh_evaluate_button],
1861
- outputs=[
1862
- english_grapragh_practice_row,
1863
- english_grapragh_evaluate_row,
1864
- english_exam_practice_row,
1865
- english_grapragh_practice_button,
1866
- english_grapragh_evaluate_button,
1867
- english_exam_practice_tab_button
1868
- ]
1869
  )
 
 
 
 
 
 
 
 
 
 
 
 
1870
  english_exam_practice_tab_button.click(
1871
- fn=update_english_grapragh_practice_rows,
1872
- inputs=[english_exam_practice_tab_button],
1873
- outputs=[
1874
- english_grapragh_practice_row,
1875
- english_grapragh_evaluate_row,
1876
- english_exam_practice_row,
1877
- english_grapragh_practice_button,
1878
- english_grapragh_evaluate_button,
1879
- english_exam_practice_tab_button
1880
- ]
1881
  )
1882
 
1883
 
 
727
  }
728
  """
729
 
730
+ english_grapragh_practice_button_js = """
731
+ function english_grapragh_practice_button_click() {
732
+ document.getElementById("english_grapragh_practice_row").style.display = "block";
733
+ document.getElementById("english_grapragh_evaluate_row").style.display = "none";
734
+ document.getElementById("english_exam_practice_row").style.display = "none";
735
+ document.getElementById("english_grapragh_practice_button").classList.add("primary");
736
+ document.getElementById("english_grapragh_evaluate_button").classList.remove("primary");
737
+ document.getElementById("english_exam_practice_tab_button").classList.remove("primary");
738
+
739
+ return true;
740
+ }
741
+ """
742
+
743
+ english_grapragh_evaluate_button_js = """
744
+ function english_grapragh_evaluate_button_click() {
745
+ document.getElementById("english_grapragh_practice_row").style.display = "none";
746
+ document.getElementById("english_grapragh_evaluate_row").style.display = "block";
747
+ document.getElementById("english_exam_practice_row").style.display = "none";
748
+ document.getElementById("english_grapragh_practice_button").classList.remove("primary");
749
+ document.getElementById("english_grapragh_evaluate_button").classList.add("primary");
750
+ document.getElementById("english_exam_practice_tab_button").classList.remove("primary");
751
+
752
+ return true;
753
+ }
754
+ """
755
+
756
+ english_exam_practice_tab_button_js = """
757
+ function english_exam_practice_tab_button_click() {
758
+ document.getElementById("english_grapragh_practice_row").style.display = "none";
759
+ document.getElementById("english_grapragh_evaluate_row").style.display = "none";
760
+ document.getElementById("english_exam_practice_row").style.display = "block";
761
+ document.getElementById("english_grapragh_practice_button").classList.remove("primary");
762
+ document.getElementById("english_grapragh_evaluate_button").classList.remove("primary");
763
+ document.getElementById("english_exam_practice_tab_button").classList.add("primary");
764
+
765
+ return true;
766
+ }
767
+ """
768
+
769
  with gr.Blocks(theme=gr.themes.Soft(primary_hue=gr.themes.colors.blue, secondary_hue=gr.themes.colors.orange), css=CSS) as demo:
770
 
771
  with gr.Row(visible=False) as english_group:
 
783
  """)
784
  with gr.Row():
785
  with gr.Column():
786
+ english_grapragh_practice_button = gr.Button("📝 英文段落寫作練習", variant="primary", elem_id="english_grapragh_practice_button")
787
  with gr.Column():
788
+ english_grapragh_evaluate_button = gr.Button("📊 英文段落寫作評分", variant="", elem_id="english_grapragh_evaluate_button")
789
  with gr.Column():
790
+ english_exam_practice_tab_button = gr.Button("🎯 英文考古題寫作練習", variant="", elem_id="english_exam_practice_tab_button")
791
  # ===== 英文段落寫作練習 =====
792
+ with gr.Row(visible=True, elem_id="english_grapragh_practice_row") as english_grapragh_practice_row:
793
  with gr.Column():
794
  with gr.Row():
795
  gr.Markdown("# 📝 英文段落寫作練習")
 
1663
  )
1664
 
1665
  # ====="英文全文批改"=====
1666
+ with gr.Row(visible=False, elem_id="english_grapragh_evaluate_row") as english_grapragh_evaluate_row:
1667
  with gr.Column():
1668
  with gr.Row(visible=False) as full_paragraph_params:
1669
  full_paragraph_sys_content_input = gr.Textbox(label="System Prompt", value="You are an English teacher who is practicing with me to improve my English writing skill.")
 
1765
  )
1766
 
1767
  # ====="英文考古題寫作練習====="
1768
+ with gr.Row(visible=False, elem_id="english_exam_practice_row") as english_exam_practice_row:
1769
 
1770
  with gr.Column():
1771
  with gr.Row():
 
1882
  outputs=past_exam_refine_output_diff
1883
  )
1884
 
1885
+ # english_grapragh_practice_button.click(
1886
+ # fn=update_english_grapragh_practice_rows,
1887
+ # inputs=[english_grapragh_practice_button],
1888
+ # outputs=[
1889
+ # english_grapragh_practice_row,
1890
+ # english_grapragh_evaluate_row,
1891
+ # english_exam_practice_row,
1892
+ # english_grapragh_practice_button,
1893
+ # english_grapragh_evaluate_button,
1894
+ # english_exam_practice_tab_button
1895
+ # ]
1896
+ # )
1897
  english_grapragh_practice_button.click(
1898
+ None,
1899
+ None,
1900
+ None,
1901
+ js=english_grapragh_practice_button_js
 
 
 
 
 
 
1902
  )
1903
+
1904
+ # english_grapragh_evaluate_button.click(
1905
+ # fn=update_english_grapragh_practice_rows,
1906
+ # inputs=[english_grapragh_evaluate_button],
1907
+ # outputs=[
1908
+ # english_grapragh_practice_row,
1909
+ # english_grapragh_evaluate_row,
1910
+ # english_exam_practice_row,
1911
+ # english_grapragh_practice_button,
1912
+ # english_grapragh_evaluate_button,
1913
+ # english_exam_practice_tab_button
1914
+ # ]
1915
+ # )
1916
  english_grapragh_evaluate_button.click(
1917
+ None,
1918
+ None,
1919
+ None,
1920
+ js=english_grapragh_evaluate_button_js
 
 
 
 
 
 
1921
  )
1922
+ # english_exam_practice_tab_button.click(
1923
+ # fn=update_english_grapragh_practice_rows,
1924
+ # inputs=[english_exam_practice_tab_button],
1925
+ # outputs=[
1926
+ # english_grapragh_practice_row,
1927
+ # english_grapragh_evaluate_row,
1928
+ # english_exam_practice_row,
1929
+ # english_grapragh_practice_button,
1930
+ # english_grapragh_evaluate_button,
1931
+ # english_exam_practice_tab_button
1932
+ # ]
1933
+ # )
1934
  english_exam_practice_tab_button.click(
1935
+ None,
1936
+ None,
1937
+ None,
1938
+ js=english_exam_practice_tab_button_js
 
 
 
 
 
 
1939
  )
1940
 
1941