uniq-backendd / database /mock_data.py
salmafahmy's picture
update backend logic
0514a09
Raw History Blame Contribute Delete
11.5 kB
# =========================
# 📚 DATA LAYER (CLEAN VERSION)
# =========================
class DataService:
def __init__(self):
# =========================
# 📚 COURSES DATABASE
# =========================
self.courses_db_mock = {
# === University Obligatory (إجباري جامعة) ===
"English Language I": {
"code": "02-24-00101",
"credits": 2,
"prereq": [],
"course_type": "university_obligatory",
"department": "UR"
},
"Human Rights and Fighting Corruption": {
"code": "02-24-00102",
"credits": 2,
"prereq": [],
"course_type": "university_obligatory",
"department": "UR"
},
# === University Elective (اختياري جامعة) ===
"Entrepreneurship and Innovation": {
"code": "02-24-00103",
"credits": 2,
"prereq": [],
"course_type": "university_elective",
"department": "UR"
},
"Critical Thinking Skills": {
"code": "02-24-00104",
"credits": 2,
"prereq": [],
"course_type": "university_elective",
"department": "UR"
},
# === Faculty Obligatory (إجباري كلية) ===
"Programming I": {
"code": "02-24-00105",
"credits": 3,
"prereq": [],
"course_type": "faculty_obligatory",
"department": "CS"
},
"Calculus": {
"code": "02-24-00102",
"credits": 3,
"prereq": [],
"course_type": "program_obligatory",
"department": "DS"
},
"Linear Algebra": {
"code": "02-24-00101",
"credits": 3,
"prereq": [],
"course_type": "faculty_obligatory",
"department": "BS"
},
"Introduction to Computer Systems": { # مادة مضافة لتجنب نقص المتطلبات السابقة
"code": "02-24-00103",
"credits": 3,
"prereq": [],
"course_type": "faculty_obligatory",
"department": "CS"
},
"Operating Systems": {
"code": "02-24-00203",
"credits": 3,
"prereq": ["Introduction to Computer Systems"],
"course_type": "faculty_obligatory",
"department": "CS"
},
# === Faculty Elective (اختياري كلية) ===
"Discrete Structures": {
"code": "02-24-00107",
"credits": 3,
"prereq": [],
"course_type": "faculty_elective",
"department": "CS"
},
"Introduction to Data Sciences": {
"code": "02-24-00104",
"credits": 3,
"prereq": [],
"course_type": "faculty_elective",
"department": "DS"
},
# === Program Obligatory (إجباري تخصص) ===
"Data Structures and Algorithms": {
"code": "02-24-00108",
"credits": 3,
"prereq": ["Programming I"],
"course_type": "program_obligatory",
"department": "CS"
},
"Probability and Statistics I": {
"code": "02-24-00106",
"credits": 3,
"prereq": [],
"course_type": "program_obligatory",
"department": "BS"
},
"Machine Learning": {
"code": "02-24-00205",
"credits": 3,
"prereq": ["Data Structures and Algorithms", "Linear Algebra"],
"course_type": "program_obligatory",
"department": "DS"
},
"Database Systems": {
"code": "02-24-00202",
"credits": 3,
"prereq": ["Data Structures and Algorithms"],
"course_type": "program_obligatory",
"department": "CS"
},
"Data Mining and Analytics": {
"code": "02-24-00206",
"credits": 3,
"prereq": ["Probability and Statistics I"],
"course_type": "program_obligatory",
"department": "DS"
},
"Computer Networks": { # مادة مضافة لتجنب نقص المتطلبات السابقة
"code": "02-24-00301",
"credits": 3,
"prereq": ["Introduction to Computer Systems"],
"course_type": "program_obligatory",
"department": "DS"
},
# === Program Elective (اختياري تخصص) ===
"Big Data Analytics": {
"code": "02-24-01401",
"credits": 3,
"prereq": ["Machine Learning", "Data Mining and Analytics"],
"course_type": "program_elective",
"department": "DS"
},
"Deep Learning": {
"code": "02-24-03403",
"credits": 3,
"prereq": ["Machine Learning"],
"course_type": "program_elective",
"department": "DS"
},
"Natural Language Understanding": {
"code": "02-24-03410",
"credits": 3,
"prereq": ["Deep Learning"],
"course_type": "program_elective",
"department": "DS"
},
"Social Networks Analytics": {
"code": "02-24-06414",
"credits": 3,
"prereq": ["Linear Algebra", "Probability and Statistics I", "Machine Learning"],
"course_type": "program_elective",
"department": "DS"
},
"Internet of Things": {
"code": "02-24-06415",
"credits": 3,
"prereq": ["Computer Networks"],
"course_type": "program_elective",
"department": "DS"
},
"Cloud Computing": {
"code": "02-24-00204",
"credits": 3,
"prereq": ["Data Structures and Algorithms"],
"course_type": "program_elective",
"department": "CS"
}
}
# =========================
# 👤 USERS MOCK DATABASE
# =========================
self.users_db_mock = {
# === طالب في قسم علوم البيانات (Data Science - DS) ===
"user_01": {
"name": "Ahmed",
"department": "DS",
"records": {
"Programming I": {"grade": "B+", "credit_hours": 3},
"Linear Algebra": {"grade": "C", "credit_hours": 3},
"Probability and Statistics I": {"grade": "B", "credit_hours": 3},
"Data Structures and Algorithms": {"grade": "B", "credit_hours": 3},
"Introduction to Data Sciences": {"grade": "A-", "credit_hours": 3}
},
"chat_history": []
},
# === طالبة في قسم علوم البيانات (Data Science - DS) - في البداية ===
"user_02": {
"name": "Salma",
"department": "CS",
"records": {
"Programming I": {"grade": "B+", "credit_hours": 3},
"Linear Algebra": {"grade": "C", "credit_hours": 3},
"Calculus": {"grade": "A", "credit_hours": 3},
"English Language I": {"grade": "A", "credit_hours": 2}
},
"chat_history": []
},
# === طالب من قسم علوم الحاسب (Computer Science - CS) - مستوى متقدم ===
"user_03": {
"name": "Omar",
"department": "CS",
"records": {
"Programming I": {"grade": "A", "credit_hours": 3},
"Introduction to Computer Systems": {"grade": "B", "credit_hours": 3},
"Data Structures and Algorithms": {"grade": "B+", "credit_hours": 3},
"Discrete Structures": {"grade": "A-", "credit_hours": 3},
"Operating Systems": {"grade": "B", "credit_hours": 3},
"Computer Networks": {"grade": "B+", "credit_hours": 3},
"Cloud Computing": {"grade": "A-", "credit_hours": 3},
"Human Rights and Fighting Corruption": {"grade": "A", "credit_hours": 2}
},
"chat_history": []
},
# === طالب من قسم علوم البيانات (Data Science - DS) - مستوى متقدم وخريج ===
"user_04": {
"name": "Mariam",
"department": "DS",
"records": {
"Programming I": {"grade": "A", "credit_hours": 3},
"Linear Algebra": {"grade": "A-", "credit_hours": 3},
"Probability and Statistics I": {"grade": "A", "credit_hours": 3},
"Data Structures and Algorithms": {"grade": "B+", "credit_hours": 3},
"Machine Learning": {"grade": "A", "credit_hours": 3},
"Introduction to Computer Systems": {"grade": "B+", "credit_hours": 3},
"Deep Learning": {"grade": "A-", "credit_hours": 3},
"Internet of Things": {"grade": "B", "credit_hours": 3},
"Natural Language Understanding": {"grade": "A", "credit_hours": 3},
"Entrepreneurship and Innovation": {"grade": "A", "credit_hours": 2},
"Big Data Analytics": {"grade": "A", "credit_hours": 2}
},
"chat_history": []
}
}
# =========================
# COURSES API
# =========================
def fetch_courses_catalog(self):
return self.courses_db_mock
# =========================
# STUDENT API
# =========================
def fetch_student_data(self, user_id):
student_info = self.users_db_mock.get(user_id)
if not student_info:
return {
"name": "Guest",
"department": None,
"records": {},
"chat_history": []
}
return {
"name": student_info.get("name", "Unknown"),
"department": student_info.get("department"), # 👈 IMPORTANT FIX
"records": student_info.get("records", {}),
"chat_history": student_info.get("chat_history", [])
}
# =========================
# COMPATIBILITY PROPS (to avoid breaking old code)
# =========================
@property
def COURSES_CATALOG(self):
return self.courses_db_mock