Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -22,7 +22,8 @@ def admin_login_function(email, password):
|
|
22 |
|
23 |
# Intern login function
|
24 |
def intern_login(email):
|
25 |
-
|
|
|
26 |
|
27 |
# Admin upload function
|
28 |
def admin_upload(file):
|
@@ -64,11 +65,13 @@ def performance_analysis():
|
|
64 |
else:
|
65 |
return None, None, None, None
|
66 |
|
67 |
-
MAX_SCORE =
|
68 |
|
69 |
def intern_view(email):
|
70 |
if grades_df is not None:
|
71 |
intern_grades = grades_df[grades_df['Email'] == email]
|
|
|
|
|
72 |
if not intern_grades.empty:
|
73 |
total_grade = intern_grades['Grade'].sum()
|
74 |
average_grade = intern_grades['Grade'].mean()
|
@@ -78,14 +81,8 @@ def intern_view(email):
|
|
78 |
normalized_score = min(total_grade / MAX_SCORE, 1)
|
79 |
|
80 |
# Determine the color level
|
81 |
-
if normalized_score <= 0.
|
82 |
color = "red"
|
83 |
-
elif normalized_score <= 0.4:
|
84 |
-
color = "orange"
|
85 |
-
elif normalized_score <= 0.6:
|
86 |
-
color = "yellow"
|
87 |
-
elif normalized_score <= 0.8:
|
88 |
-
color = "lightgreen"
|
89 |
else:
|
90 |
color = "green"
|
91 |
|
@@ -93,18 +90,19 @@ def intern_view(email):
|
|
93 |
return f"""
|
94 |
### Grade Analysis for {email}
|
95 |
|
96 |
-
- **
|
97 |
-
- **
|
98 |
|
99 |
<div style="background-color:{color}; padding:10px; border-radius:5px;">
|
100 |
**Performance Level**: {color.capitalize()}
|
101 |
</div>
|
102 |
-
|
|
|
|
|
103 |
else:
|
104 |
-
return "No records found for this email."
|
105 |
else:
|
106 |
-
return "No grades file uploaded. Please contact the admin."
|
107 |
-
|
108 |
|
109 |
# Create the Gradio interface
|
110 |
with gr.Blocks() as demo:
|
@@ -151,11 +149,12 @@ with gr.Blocks() as demo:
|
|
151 |
|
152 |
with gr.Column(visible=False) as intern_info_section:
|
153 |
intern_output = gr.Markdown(label="Grade Analysis")
|
|
|
154 |
|
155 |
intern_login_button.click(
|
156 |
intern_login,
|
157 |
inputs=[intern_email],
|
158 |
-
outputs=[intern_login_section, intern_info_section, intern_output],
|
159 |
show_progress=True,
|
160 |
)
|
161 |
|
|
|
22 |
|
23 |
# Intern login function
|
24 |
def intern_login(email):
|
25 |
+
results = intern_view(email)
|
26 |
+
return gr.update(visible=False), gr.update(visible=True), results[0], results[1]
|
27 |
|
28 |
# Admin upload function
|
29 |
def admin_upload(file):
|
|
|
65 |
else:
|
66 |
return None, None, None, None
|
67 |
|
68 |
+
MAX_SCORE = 25 # Assuming the maximum possible score is 100
|
69 |
|
70 |
def intern_view(email):
|
71 |
if grades_df is not None:
|
72 |
intern_grades = grades_df[grades_df['Email'] == email]
|
73 |
+
daily_performance = intern_grades.groupby('Date')['Grade'].sum().reset_index()
|
74 |
+
line_chart = px.line(daily_performance, x='Date', y='Grade', title='Daily Performance (Total Grades)')
|
75 |
if not intern_grades.empty:
|
76 |
total_grade = intern_grades['Grade'].sum()
|
77 |
average_grade = intern_grades['Grade'].mean()
|
|
|
81 |
normalized_score = min(total_grade / MAX_SCORE, 1)
|
82 |
|
83 |
# Determine the color level
|
84 |
+
if normalized_score <= 0.8:
|
85 |
color = "red"
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
else:
|
87 |
color = "green"
|
88 |
|
|
|
90 |
return f"""
|
91 |
### Grade Analysis for {email}
|
92 |
|
93 |
+
- **Tổng điểm**: {normalized_score}
|
94 |
+
- **số lần upload**: {num_records}
|
95 |
|
96 |
<div style="background-color:{color}; padding:10px; border-radius:5px;">
|
97 |
**Performance Level**: {color.capitalize()}
|
98 |
</div>
|
99 |
+
|
100 |
+
- Quá 3 assignment đạt level đỏ sẽ phải liên hệ manager để giải trình
|
101 |
+
""", line_chart
|
102 |
else:
|
103 |
+
return gr.Error("No records found for this email. 💥!", duration=5)
|
104 |
else:
|
105 |
+
return gr.Error("No grades file uploaded. Please contact the admin.", duration=5)
|
|
|
106 |
|
107 |
# Create the Gradio interface
|
108 |
with gr.Blocks() as demo:
|
|
|
149 |
|
150 |
with gr.Column(visible=False) as intern_info_section:
|
151 |
intern_output = gr.Markdown(label="Grade Analysis")
|
152 |
+
intern_charts = gr.Plot()
|
153 |
|
154 |
intern_login_button.click(
|
155 |
intern_login,
|
156 |
inputs=[intern_email],
|
157 |
+
outputs=[intern_login_section, intern_info_section, intern_output, intern_charts],
|
158 |
show_progress=True,
|
159 |
)
|
160 |
|