Spaces:
Sleeping
Sleeping
File size: 3,488 Bytes
54547af 102fe5c 6f7fccc 102fe5c 6f7fccc 1860b85 6f7fccc d8514e5 6f7fccc 54547af 6f7fccc 54547af 6f7fccc 54547af 6f7fccc 54547af 6f7fccc 54547af | 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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 | import gradio as gr
import os
import json
from datetime import datetime
# Load domain descriptions
def load_domain_descriptions():
try:
with open('domain_descriptions.json', 'r') as f:
return json.load(f)
except FileNotFoundError:
return {}
# Load projects data
def load_projects():
try:
with open('projects.json', 'r') as f:
return json.load(f)
except FileNotFoundError:
return {}
# Load students data
def load_students():
try:
with open('students.json', 'r') as f:
return json.load(f)
except FileNotFoundError:
return []
def get_domain_stats():
projects = load_projects()
students = load_students()
domains = load_domain_descriptions()
total_projects = len(projects)
total_students = len(students)
total_domains = len(domains)
return f"""
### Project Management System Statistics
- **Total Domains:** {total_domains}
- **Total Projects:** {total_projects}
- **Total Students:** {total_students}
"""
def get_domain_list():
domains = load_domain_descriptions()
projects = load_projects()
domain_list = []
for domain_id, description in domains.items():
domain_projects = [p for p in projects.values() if p.get('domain') == domain_id]
project_count = len(domain_projects)
domain_list.append(f"""
### Domain {domain_id}
{description}
**Projects:** {project_count}
""")
return "\n".join(domain_list)
def get_project_list():
projects = load_projects()
students = load_students()
project_list = []
for project_id, project in projects.items():
assigned_students = [s for s in students if project_id in s.get('projects', [])]
student_names = ", ".join([s['name'] for s in assigned_students])
project_list.append(f"""
### {project['name']}
**Domain:** {project['domain']}
**Type:** {'Hardware' if project.get('type') == 'H' else 'Software'}
**Description:** {project.get('description', 'No description available')}
**Assigned Students:** {student_names if student_names else 'None'}
""")
return "\n".join(project_list)
def get_student_list():
students = load_students()
projects = load_projects()
student_list = []
for student in students:
student_projects = [projects.get(pid) for pid in student.get('projects', [])]
project_names = ", ".join([p['name'] for p in student_projects if p])
student_list.append(f"""
### {student['name']}
**ID:** {student['id']}
**Email:** {student['email']}
**Projects:** {project_names if project_names else 'None'}
""")
return "\n".join(student_list)
# Create Gradio interface
with gr.Blocks() as demo:
gr.Markdown("# Project Management System")
with gr.Tab("Home"):
gr.Markdown(get_domain_stats())
with gr.Tab("Domains"):
gr.Markdown(get_domain_list())
with gr.Tab("Projects"):
gr.Markdown(get_project_list())
with gr.Tab("Students"):
gr.Markdown(get_student_list())
# Launch the interface
if __name__ == "__main__":
demo.launch(server_name="0.0.0.0", server_port=7860) |