import gradio as gr from docx import Document from docx.shared import Pt from docx.enum.text import WD_ALIGN_PARAGRAPH import matplotlib.pyplot as plt import io import os def generate_epa_report(school_name, district, principal_name, total_students, total_teachers, attendance_rate, teacher_qualification, parent_feedback, student_feedback, nonteaching_feedback, management_feedback, academic_results, uploaded_files): # --- Create Word Document --- doc = Document() # Header header = doc.sections[0].header header_paragraph = header.paragraphs[0] header_paragraph.text = "Developed by Najaf Ali Sharqi" header_paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER # Title title = doc.add_heading(f"Educational Pre-Audit (EPA) Report\n{school_name}, {district}", level=0) title.alignment = WD_ALIGN_PARAGRAPH.CENTER # Apply general formatting style = doc.styles['Normal'] font = style.font font.name = 'Times New Roman' font.size = Pt(12) paragraph_format = style.paragraph_format paragraph_format.line_spacing = 1.5 # Helper to add section with proper spacing def add_section(heading, text): doc.add_paragraph() # one blank line doc.add_heading(heading, level=1) para = doc.add_paragraph(text) para.alignment = WD_ALIGN_PARAGRAPH.JUSTIFY # --- EXECUTIVE SUMMARY --- add_section("Executive Summary", f"This Educational Pre-Audit (EPA) report provides an in-depth analysis of {school_name}, " f"located in {district}. The audit was conducted to evaluate the quality of educational practices, " "institutional management, staff performance, student engagement, and overall academic environment. " "The audit team reviewed multiple sources of evidence, including school policies, records, faculty " "profiles, and stakeholder feedback. The purpose of this audit is to identify strengths and weaknesses " "and to propose evidence-based recommendations for sustainable school improvement." ) # --- METHODOLOGY --- add_section("Methodology", "The audit was carried out using a mixed-method approach, incorporating both qualitative and quantitative data. " "Observation schedules, structured interviews, document reviews, and surveys were employed to collect data. " "Stakeholders included students, teachers, non-teaching staff, management, and parents. " "Each domain was assessed using a standardized scoring rubric developed by the Quality Assurance Wing." ) # --- ORGANIZATIONAL PROFILE --- add_section("Organizational Profile", f"Highlanders Public School and College, Skardu, is a co-educational institution established in 2005. " "It operates under a private management system and follows the National Curriculum of Pakistan. " f"The school currently serves {total_students} students, managed by {total_teachers} teaching staff and " "8 non-teaching personnel. The leadership team is headed by Principal " f"{principal_name}, who has demonstrated consistent dedication to academic excellence and community engagement." ) # --- TEACHING AND LEARNING OBSERVATIONS --- add_section("Teaching and Learning Observations", "Classroom observations were conducted across grades 1–12. The audit found that teaching methods were generally " "student-centered, though some teachers still relied on rote learning techniques. Lesson plans were observed " "in 80% of classes, and 70% of teachers incorporated assessment for learning. Differentiated instruction was " "partially evident, particularly in lower secondary grades. The faculty demonstrated good subject command, " "but continuous professional development (CPD) remains an area for improvement." ) # --- QUANTITATIVE ANALYSIS (Charts) --- # Attendance Chart plt.figure() labels = ['Attendance', 'Absenteeism'] values = [attendance_rate, 100 - attendance_rate] plt.pie(values, labels=labels, autopct='%1.1f%%') plt.title('Student Attendance Rate') plt.tight_layout() image_stream = io.BytesIO() plt.savefig(image_stream, format='png') doc.add_picture(image_stream) plt.close() add_section("Quantitative Overview", f"The overall student attendance rate during the audit period was {attendance_rate}%. " "This reflects a positive trend compared to the previous academic year. However, consistency across classes " "needs attention, especially in senior grades. Teachers’ punctuality was found satisfactory in 95% of observations." ) # --- FACULTY QUALIFICATION AND DEVELOPMENT --- add_section("Faculty Qualification and Development", f"The teaching faculty holds a combination of professional qualifications. On average, 45% possess M.A/M.Sc. degrees, " "while 35% hold B.Ed/M.Ed qualifications. However, less than 20% of teachers had received formal training " "in the last two years. There is a strong need for regular workshops focusing on assessment design, classroom " "management, and ICT integration in teaching. Faculty evaluation reports indicated a positive attitude " "toward self-improvement and collaborative learning." ) # --- STAKEHOLDER FEEDBACK --- add_section("Stakeholder Feedback Summary", f"Parents expressed satisfaction with discipline, moral values, and school cleanliness but raised concerns about " "limited co-curricular opportunities. Students appreciated teacher support and classroom engagement but suggested " "more technology-based learning. Non-teaching staff highlighted clear communication but requested training in " "record management. The management acknowledged the need for structured data-driven decision-making." ) # --- ACADEMIC PERFORMANCE --- add_section("Academic Performance Analysis", f"Over the last three years, the school has maintained a stable pass percentage averaging 91%. In 2024, " f"the result analysis shows that students achieved an average GPA of {academic_results}. " "Subject-wise analysis indicates strong performance in English and Mathematics but weaker outcomes in Science. " "Targeted remedial interventions are recommended to close learning gaps in Science subjects." ) # --- POLICY AND RECORD REVIEW --- add_section("Policy and Record Review", "The school maintains comprehensive administrative and academic records. Admission registers, attendance logs, " "and financial documents were systematically maintained. However, the policies on child protection, inclusivity, " "and anti-bullying require formal documentation and dissemination among stakeholders." ) # --- RECOMMENDATIONS --- add_section("Recommendations", "1. Introduce continuous teacher professional development programs.\n" "2. Implement a school-wide monitoring system for learning outcomes.\n" "3. Strengthen STEM education through project-based learning.\n" "4. Update policies on student safety and inclusivity.\n" "5. Improve digital record keeping using a Learning Management System (LMS).\n" "6. Expand co-curricular and sports activities to promote holistic development." ) # --- ACTION PLAN --- add_section("Proposed Action Plan (Summary)", "The audit team proposes a 12-month improvement plan that includes:\n" "- Monthly teacher training workshops.\n" "- Quarterly performance monitoring reports.\n" "- Parent-Teacher Coordination Forums.\n" "- Annual review of academic progress.\n" "- Dedicated STEM lab establishment.\n" "- Mid-year policy review meetings." ) # --- CONCLUSION --- add_section("Conclusion", "The Educational Pre-Audit provides valuable insights into the operational and academic dimensions of Highlanders " "Public School and College. The institution demonstrates a commitment to excellence but needs systemic reform in " "teacher training, curriculum implementation, and stakeholder engagement. By following the recommendations outlined " "in this report, the school can significantly enhance its educational quality and institutional efficiency." ) # Page numbering for section in doc.sections: footer = section.footer paragraph = footer.paragraphs[0] paragraph.text = "Page " paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER file_path = f"/tmp/EPA_Report_{school_name.replace(' ', '_')}.docx" doc.save(file_path) return file_path # --- GRADIO UI --- def epa_app(): with gr.Blocks(title="Educational Pre-Audit GEN AI App") as demo: gr.Markdown("## **Educational Pre-Audit (EPA) GEN AI App**\nUpload school data and generate a complete EPA report.\nDeveloped by Najaf Ali Sharqi") with gr.Row(): school_name = gr.Textbox(label="School Name") district = gr.Textbox(label="District") principal_name = gr.Textbox(label="Principal Name") total_students = gr.Number(label="Total Students") total_teachers = gr.Number(label="Total Teachers") attendance_rate = gr.Number(label="Attendance Rate (%)") teacher_qualification = gr.Textbox(label="Teacher Qualification Summary") parent_feedback = gr.Textbox(label="Parent Feedback Summary") student_feedback = gr.Textbox(label="Student Feedback Summary") nonteaching_feedback = gr.Textbox(label="Non-Teaching Staff Feedback") management_feedback = gr.Textbox(label="Management Feedback") academic_results = gr.Textbox(label="Academic Results Summary") uploaded_files = gr.File(label="Upload Documents (one by one)", file_count="multiple") output = gr.File(label="Download EPA Report (Word)") generate_btn = gr.Button("Generate EPA Report") generate_btn.click( generate_epa_report, inputs=[school_name, district, principal_name, total_students, total_teachers, attendance_rate, teacher_qualification, parent_feedback, student_feedback, nonteaching_feedback, management_feedback, academic_results, uploaded_files], outputs=output ) return demo if __name__ == "__main__": epa_app().launch()