Update written_module.py
Browse files- written_module.py +15 -9
written_module.py
CHANGED
|
@@ -21,11 +21,11 @@ You are a writing coach helping a student improve their writing for the followin
|
|
| 21 |
|
| 22 |
First, return a JSON object with scores (0β10) for each of these:
|
| 23 |
{focus_str}
|
| 24 |
-
|
| 25 |
Then write:
|
| 26 |
-
- A
|
| 27 |
- A summary of strengths and improvements
|
| 28 |
-
- One motivational line
|
| 29 |
|
| 30 |
Current text:
|
| 31 |
{text}
|
|
@@ -86,6 +86,12 @@ def written_dashboard(nickname_input):
|
|
| 86 |
goal_dropdown = gr.Dropdown(label="π― Writing Goal", choices=["Essay for school", "Job application", "Blog post", "Creative writing", "General improvement"], value="General improvement")
|
| 87 |
focus_checkboxes = gr.CheckboxGroup(label="π§ Focus Areas", choices=["Clarity", "Organization", "Grammar", "Vocabulary", "Tone", "Creativity"], value=["Clarity", "Organization", "Grammar", "Vocabulary", "Tone", "Creativity"])
|
| 88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 89 |
input_text = gr.Textbox(label="π Your Writing", lines=10, elem_id="input_text", elem_classes=["text_area"], interactive=True)
|
| 90 |
submit_button = gr.Button("π Submit", variant="primary", size="sm")
|
| 91 |
|
|
@@ -96,7 +102,7 @@ def written_dashboard(nickname_input):
|
|
| 96 |
|
| 97 |
with gr.Row():
|
| 98 |
score_chart = gr.Plot(label="π Score Comparison")
|
| 99 |
-
trend_chart = gr.Plot(label="π
|
| 100 |
|
| 101 |
milestone_box = gr.Markdown(visible=False)
|
| 102 |
|
|
@@ -108,11 +114,11 @@ def written_dashboard(nickname_input):
|
|
| 108 |
|
| 109 |
file_input.change(fn=extract_text, inputs=file_input, outputs=input_text)
|
| 110 |
|
| 111 |
-
def tutor_written(text, language, goal, focus_areas, nickname):
|
| 112 |
if hasattr(nickname, "value"):
|
| 113 |
nickname = nickname.value
|
| 114 |
if not text.strip():
|
| 115 |
-
return "", "", [], render_empty_chart("π Score Comparison"), render_empty_chart("π
|
| 116 |
|
| 117 |
sessions = fetch_user_sessions(nickname)
|
| 118 |
previous_text = sessions[-1].transcript if sessions else None
|
|
@@ -126,8 +132,8 @@ def written_dashboard(nickname_input):
|
|
| 126 |
session_table = [[s.timestamp, s.language, s.transcript[:40], s.feedback[:40]] for s in sessions]
|
| 127 |
|
| 128 |
score_plot = render_score_chart(build_score_comparison_data(full_feedback, previous_feedback)) if previous_feedback else render_empty_chart("π Score Comparison")
|
| 129 |
-
dates,
|
| 130 |
-
trend_plot = render_trend_chart(dates,
|
| 131 |
|
| 132 |
milestone_msg = ""
|
| 133 |
if len(sessions) in [3, 5, 10]:
|
|
@@ -138,7 +144,7 @@ def written_dashboard(nickname_input):
|
|
| 138 |
|
| 139 |
submit_button.click(
|
| 140 |
fn=tutor_written,
|
| 141 |
-
inputs=[input_text, language_dropdown, goal_dropdown, focus_checkboxes, nickname_input],
|
| 142 |
outputs=[feedback_box, improved_box, history_table, score_chart, trend_chart, milestone_box]
|
| 143 |
)
|
| 144 |
|
|
|
|
| 21 |
|
| 22 |
First, return a JSON object with scores (0β10) for each of these:
|
| 23 |
{focus_str}
|
| 24 |
+
|
| 25 |
Then write:
|
| 26 |
+
- A brief explanation per score
|
| 27 |
- A summary of strengths and improvements
|
| 28 |
+
- One motivational line
|
| 29 |
|
| 30 |
Current text:
|
| 31 |
{text}
|
|
|
|
| 86 |
goal_dropdown = gr.Dropdown(label="π― Writing Goal", choices=["Essay for school", "Job application", "Blog post", "Creative writing", "General improvement"], value="General improvement")
|
| 87 |
focus_checkboxes = gr.CheckboxGroup(label="π§ Focus Areas", choices=["Clarity", "Organization", "Grammar", "Vocabulary", "Tone", "Creativity"], value=["Clarity", "Organization", "Grammar", "Vocabulary", "Tone", "Creativity"])
|
| 88 |
|
| 89 |
+
trend_category_dropdown = gr.Dropdown(
|
| 90 |
+
label="π Track Progress In",
|
| 91 |
+
choices=["Clarity", "Organization", "Grammar", "Vocabulary", "Tone", "Creativity"],
|
| 92 |
+
value="Clarity"
|
| 93 |
+
)
|
| 94 |
+
|
| 95 |
input_text = gr.Textbox(label="π Your Writing", lines=10, elem_id="input_text", elem_classes=["text_area"], interactive=True)
|
| 96 |
submit_button = gr.Button("π Submit", variant="primary", size="sm")
|
| 97 |
|
|
|
|
| 102 |
|
| 103 |
with gr.Row():
|
| 104 |
score_chart = gr.Plot(label="π Score Comparison")
|
| 105 |
+
trend_chart = gr.Plot(label="π Progress Over Time")
|
| 106 |
|
| 107 |
milestone_box = gr.Markdown(visible=False)
|
| 108 |
|
|
|
|
| 114 |
|
| 115 |
file_input.change(fn=extract_text, inputs=file_input, outputs=input_text)
|
| 116 |
|
| 117 |
+
def tutor_written(text, language, goal, focus_areas, trend_category, nickname):
|
| 118 |
if hasattr(nickname, "value"):
|
| 119 |
nickname = nickname.value
|
| 120 |
if not text.strip():
|
| 121 |
+
return "", "", [], render_empty_chart("π Score Comparison"), render_empty_chart("π Progress Over Time"), gr.update(visible=False)
|
| 122 |
|
| 123 |
sessions = fetch_user_sessions(nickname)
|
| 124 |
previous_text = sessions[-1].transcript if sessions else None
|
|
|
|
| 132 |
session_table = [[s.timestamp, s.language, s.transcript[:40], s.feedback[:40]] for s in sessions]
|
| 133 |
|
| 134 |
score_plot = render_score_chart(build_score_comparison_data(full_feedback, previous_feedback)) if previous_feedback else render_empty_chart("π Score Comparison")
|
| 135 |
+
dates, trend_scores = build_trend_data(sessions, trend_category)
|
| 136 |
+
trend_plot = render_trend_chart(dates, trend_scores, trend_category) if trend_scores else render_empty_chart(f"π {trend_category} Progress")
|
| 137 |
|
| 138 |
milestone_msg = ""
|
| 139 |
if len(sessions) in [3, 5, 10]:
|
|
|
|
| 144 |
|
| 145 |
submit_button.click(
|
| 146 |
fn=tutor_written,
|
| 147 |
+
inputs=[input_text, language_dropdown, goal_dropdown, focus_checkboxes, trend_category_dropdown, nickname_input],
|
| 148 |
outputs=[feedback_box, improved_box, history_table, score_chart, trend_chart, milestone_box]
|
| 149 |
)
|
| 150 |
|