| import gradio as gr |
|
|
| |
| students = {f"Student {i+1}": 0 for i in range(40)} |
|
|
| |
| teachers = [f"Teacher {i+1}" for i in range(5)] |
|
|
| |
| def update_score(teacher, student, action): |
| if student not in students: |
| return f"Student not found!", students |
| |
| if action == "Add 10 Points": |
| students[student] += 10 |
| elif action == "Deduct 10 Points": |
| students[student] -= 10 |
|
|
| return f"{teacher} updated {student}'s score!", students |
|
|
| |
| with gr.Blocks() as app: |
| gr.Markdown("# Teacher-Student Scoring System") |
|
|
| with gr.Row(): |
| teacher_dropdown = gr.Dropdown(label="Select Teacher", choices=teachers) |
| student_dropdown = gr.Dropdown(label="Select Student", choices=list(students.keys())) |
| action_dropdown = gr.Dropdown(label="Select Action", choices=["Add 10 Points", "Deduct 10 Points"]) |
| |
| update_button = gr.Button("Confirm") |
|
|
| feedback_text = gr.Textbox(label="Action Feedback", interactive=False) |
|
|
| with gr.Row(): |
| score_table = gr.Dataframe( |
| label="Student Scores Overview", |
| value=[[name, score] for name, score in students.items()], |
| headers=["Student", "Score"], |
| interactive=False |
| ) |
|
|
| def update_table(): |
| return [[name, score] for name, score in students.items()] |
|
|
| update_button.click( |
| update_score, |
| inputs=[teacher_dropdown, student_dropdown, action_dropdown], |
| outputs=[feedback_text, score_table], |
| postprocess=update_table |
| ) |
|
|
| |
| app.launch() |
|
|