dramit80 commited on
Commit
46b756d
·
verified ·
1 Parent(s): 632a78e

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +205 -0
app.py ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import sqlite3
4
+ from datetime import datetime, date
5
+ import os
6
+ from utils.database import *
7
+ from utils.reports import *
8
+ from utils.auth import *
9
+
10
+ # Initialize Database
11
+ init_database()
12
+
13
+ # Attendance Functions
14
+ def mark_attendance(student_id, date, status, remarks=""):
15
+ conn = sqlite3.connect('school_data.db')
16
+ cursor = conn.cursor()
17
+
18
+ cursor.execute('''
19
+ INSERT OR REPLACE INTO attendance (student_id, date, status, remarks)
20
+ VALUES (?, ?, ?, ?)
21
+ ''', (student_id, date, status, remarks))
22
+
23
+ conn.commit()
24
+ conn.close()
25
+ return f"✅ उपस्थिती नोंदवली: {student_id} - {status}"
26
+
27
+ def get_attendance_summary(student_id, month, year):
28
+ conn = sqlite3.connect('school_data.db')
29
+
30
+ query = '''
31
+ SELECT status, COUNT(*) as count
32
+ FROM attendance
33
+ WHERE student_id = ? AND strftime('%m', date) = ? AND strftime('%Y', date) = ?
34
+ GROUP BY status
35
+ '''
36
+
37
+ df = pd.read_sql_query(query, conn, params=(student_id, f"{month:02d}", str(year)))
38
+ conn.close()
39
+
40
+ if df.empty:
41
+ return "❌ या महिन्यासाठी उपस्थिती नाही"
42
+
43
+ summary = "उपस्थिती सारांश:\n"
44
+ for _, row in df.iterrows():
45
+ summary += f"{row['status']}: {row['count']} दिवस\n"
46
+
47
+ return summary
48
+
49
+ # Marks Entry System
50
+ def enter_marks(student_id, subject, exam_type, marks, total_marks, grade):
51
+ conn = sqlite3.connect('school_data.db')
52
+ cursor = conn.cursor()
53
+
54
+ cursor.execute('''
55
+ INSERT INTO marks (student_id, subject, exam_type, marks, total_marks, grade, entered_on)
56
+ VALUES (?, ?, ?, ?, ?, ?, ?)
57
+ ''', (student_id, subject, exam_type, marks, total_marks, grade, datetime.now()))
58
+
59
+ conn.commit()
60
+ conn.close()
61
+ return f"✅ गुण नोंदवले: {student_id} - {subject} - {marks}/{total_marks}"
62
+
63
+ # Report Generation
64
+ def generate_udise_report():
65
+ return generate_udise_data()
66
+
67
+ def generate_sports_report():
68
+ return generate_sports_data()
69
+
70
+ # Login System
71
+ def login_user(username, password, user_type):
72
+ return authenticate_user(username, password, user_type)
73
+
74
+ # Main Application with Tabs
75
+ with gr.Blocks(theme=gr.themes.Soft(), title="संपूर्ण शाळा व्यवस्थापन प्रणाली") as app:
76
+
77
+ gr.Markdown("# 🏫 संपूर्ण शाळा व्यवस्थापन प्रणाली")
78
+
79
+ # Login Section
80
+ with gr.Tab("🔐 लॉगिन"):
81
+ with gr.Row():
82
+ with gr.Column():
83
+ gr.Markdown("### प्रवेश करा")
84
+ login_username = gr.Textbox(label="वापरकर्तानाव")
85
+ login_password = gr.Textbox(label="पासवर्ड", type="password")
86
+ user_type = gr.Radio(["विद्यार्थी", "पालक", "शिक्षक", "प्राचार्य"], label="तुमचा प्रकार")
87
+ login_btn = gr.Button("लॉगिन करा")
88
+ login_output = gr.Textbox(label="लॉगिन निकाल")
89
+
90
+ # Student Management
91
+ with gr.Tab("📚 विद्यार्थी व्यवस्थापन"):
92
+ with gr.Row():
93
+ with gr.Column():
94
+ gr.Markdown("### नवीन विद्यार्थी नोंदणी")
95
+ stu_name = gr.Textbox(label="पूर्ण नाव")
96
+ stu_grade = gr.Dropdown([f"{i}वी" for i in range(1, 13)], label="इयत्ता")
97
+ stu_rollno = gr.Number(label="रोल नंबर")
98
+ stu_parent_name = gr.Textbox(label="पालकाचे नाव")
99
+ stu_parent_phone = gr.Textbox(label="मोबाइल नंबर")
100
+ stu_address = gr.Textbox(label="पत्ता")
101
+ add_student_btn = gr.Button("विद्यार्थी नोंदवा")
102
+
103
+ with gr.Column():
104
+ student_output = gr.Textbox(label="निकाल")
105
+ gr.Markdown("### विद्यार्थी शोधा")
106
+ search_student_id = gr.Textbox(label="विद्यार्थी ID")
107
+ search_student_btn = gr.Button("शोधा")
108
+ student_search_output = gr.Textbox(label="माहिती")
109
+
110
+ # Attendance System
111
+ with gr.Tab("📅 उपस्थिती व्यवस्थापन"):
112
+ with gr.Row():
113
+ with gr.Column():
114
+ gr.Markdown("### दैनिक उपस्थिती")
115
+ att_student_id = gr.Textbox(label="विद्यार्थी ID")
116
+ att_date = gr.Textbox(label="तारीख (YYYY-MM-DD)", value=date.today().isoformat())
117
+ att_status = gr.Radio(["Present", "Absent", "Late", "Halfday"], label="स्थिती")
118
+ att_remarks = gr.Textbox(label="शेरा")
119
+ mark_attendance_btn = gr.Button("उपस्थिती नोंदवा")
120
+
121
+ with gr.Column():
122
+ attendance_output = gr.Textbox(label="निकाल")
123
+ gr.Markdown("### उपस्थिती अहवाल")
124
+ report_student_id = gr.Textbox(label="विद्यार्थी ID")
125
+ report_month = gr.Number(label="महिना (1-12)", value=datetime.now().month)
126
+ report_year = gr.Number(label="वर्ष", value=datetime.now().year)
127
+ get_attendance_report_btn = gr.Button("अहवाल मिळवा")
128
+ attendance_report_output = gr.Textbox(label="उपस्थिती अहवाल")
129
+
130
+ # Marks Management
131
+ with gr.Tab("📊 गुण व्यवस्थापन"):
132
+ with gr.Row():
133
+ with gr.Column():
134
+ gr.Markdown("### गुण नोंदणी")
135
+ marks_student_id = gr.Textbox(label="विद्यार्थी ID")
136
+ marks_subject = gr.Dropdown([
137
+ "मराठी", "हिंदी", "इंग्रजी", "गणित", "विज्ञान", "सामाजिक शास्त्र",
138
+ "इतिहास", "भूगोल", "शारीरिक शिक्षण", "कला", "संगीत"
139
+ ], label="विषय")
140
+ marks_exam_type = gr.Dropdown(["Unit Test", "Semester", "Final", "Practical"], label="परीक्षा प्रकार")
141
+ marks_obtained = gr.Number(label="मिळालेले गुण")
142
+ marks_total = gr.Number(label="कमाल गुण", value=100)
143
+ marks_grade = gr.Textbox(label="श्रेणी")
144
+ enter_marks_btn = gr.Button("गुण नोंदवा")
145
+
146
+ with gr.Column():
147
+ marks_output = gr.Textbox(label="निकाल")
148
+
149
+ # Reports Generation
150
+ with gr.Tab("📈 अहवाल तयार करा"):
151
+ with gr.Row():
152
+ with gr.Column():
153
+ gr.Markdown("### UDISE+ डेटा अहवाल")
154
+ udise_report_btn = gr.Button("UDISE+ अहवाल तयार करा")
155
+ udise_output = gr.Textbox(label="UDISE+ अहवाल")
156
+
157
+ with gr.Column():
158
+ gr.Markdown("### क्रीडा अहवाल")
159
+ sports_report_btn = gr.Button("क्रीडा अहवाल तयार करा")
160
+ sports_output = gr.Textbox(label="क्रीडा अहवाल")
161
+
162
+ with gr.Row():
163
+ with gr.Column():
164
+ gr.Markdown("### शैक्षणिक अहवाल")
165
+ academic_report_btn = gr.Button("शैक्षणिक अहवाल तयार करा")
166
+ academic_output = gr.Textbox(label="शैक्षणिक अहवाल")
167
+
168
+ # Data Export
169
+ with gr.Tab("💾 डेटा निर्यात करा"):
170
+ with gr.Row():
171
+ with gr.Column():
172
+ gr.Markdown("### Excel मध्ये सेव्ह करा")
173
+ export_students_btn = gr.Button("विद्यार्थी डेटा Excel मध्ये")
174
+ export_teachers_btn = gr.Button("शिक्षक डेटा Excel मध्ये")
175
+ export_output = gr.Textbox(label="निर्यात निकाल")
176
+
177
+ with gr.Column():
178
+ gr.Markdown("### PDF अहवाल")
179
+ pdf_report_btn = gr.Button("PDF अहवाल तयार करा")
180
+ pdf_output = gr.Textbox(label="PDF निकाल")
181
+
182
+ # Button Actions
183
+ add_student_btn.click(add_student, [
184
+ stu_name, stu_grade, stu_rollno, stu_parent_name, stu_parent_phone, stu_address
185
+ ], student_output)
186
+
187
+ mark_attendance_btn.click(mark_attendance, [
188
+ att_student_id, att_date, att_status, att_remarks
189
+ ], attendance_output)
190
+
191
+ get_attendance_report_btn.click(get_attendance_summary, [
192
+ report_student_id, report_month, report_year
193
+ ], attendance_report_output)
194
+
195
+ enter_marks_btn.click(enter_marks, [
196
+ marks_student_id, marks_subject, marks_exam_type, marks_obtained, marks_total, marks_grade
197
+ ], marks_output)
198
+
199
+ udise_report_btn.click(generate_udise_report, [], udise_output)
200
+ sports_report_btn.click(generate_sports_report, [], sports_output)
201
+
202
+ login_btn.click(login_user, [login_username, login_password, user_type], login_output)
203
+
204
+ if __name__ == "__main__":
205
+ app.launch(share=True)