Download app.py from TTvi2024/README: direct link, hf CLI and curl.
- Browser
- Download file 1.64 kB
-
https://huggingface.co/spaces/TTvi2024/README/resolve/main/app.py
- Command line
-
hf download hf://spaces/TTvi2024/README/app.py
-
curl -L -o app.py https://huggingface.co/spaces/TTvi2024/README/resolve/main/app.py
1.64 kB
| import gradio as gr | |
| # Initialize student scores | |
| students = {f"Student {i+1}": 0 for i in range(40)} | |
| # Define teacher options | |
| teachers = [f"Teacher {i+1}" for i in range(5)] | |
| # Function to update scores | |
| 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 | |
| # Create a Gradio interface | |
| 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 | |
| ) | |
| # Launch the app | |
| app.launch() | |