File size: 1,642 Bytes
46de6d9
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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()