README / app.py
Maxi924's picture
Update app.py
46de6d9 verified
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()