-
-
Notifications
You must be signed in to change notification settings - Fork 148
feat(curriculum): Prototype drafted for Workshop – Smart Campus Directory #1161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,203 @@ | ||
| { | ||
| "Computer Science and Engineering": { | ||
| "Dept_code": "CSE", | ||
| "programs": [ | ||
| { | ||
| "id": "CSE101", | ||
| "name": "Database Management System", | ||
| "buildingCode": "CSE", | ||
| "room": "402", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS001", | ||
| "name": "Alejandro", | ||
| "email": "alejandro@edu.com", | ||
| "officeHours": "Sun-Tue 10AM-12PM" | ||
| }, | ||
| { | ||
| "id": "INS002", | ||
| "name": "Kenji", | ||
| "email": "kenji@edu.com", | ||
| "officeHours": null | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "CSE102", | ||
| "name": "Data Structures and Algorithms", | ||
| "buildingCode": "CSE", | ||
| "room": "205", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS003", | ||
| "name": "Fatima", | ||
| "email": "fatima@edu.com", | ||
| "officeHours": "Mon-Wed 2PM-4PM" | ||
| }, | ||
| { | ||
| "id": "INS004", | ||
| "name": "Mei", | ||
| "email": "mei@edu.com" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "CSE103", | ||
| "name": "Operating Systems", | ||
| "buildingCode": "CSE", | ||
| "room": null, | ||
| "instructors": [ | ||
| { | ||
| "id": "INS005", | ||
| "name": "Dmitri", | ||
| "email": "dmitri@edu.com", | ||
| "officeHours": "Thu 11AM-1PM" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "CSE104", | ||
| "name": "Computer Networks", | ||
| "buildingCode": "CSE", | ||
| "room": "510", | ||
| "instructors": [] | ||
| } | ||
| ] | ||
| }, | ||
| "Electrical and Electronic Engineering": { | ||
| "Dept_code": "EEE", | ||
| "programs": [ | ||
| { | ||
| "id": "EEE101", | ||
| "name": "Digital Logic Design", | ||
| "buildingCode": "EEE", | ||
| "room": "101", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS006", | ||
| "name": "Javier", | ||
| "email": "javier@edu.com", | ||
| "officeHours": "Sun 9AM-11AM" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "EEE102", | ||
| "name": "Electronic Devices and Circuits", | ||
| "buildingCode": "EEE", | ||
| "room": "303", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS007", | ||
| "name": "Isabella", | ||
| "email": "isabella@edu.com", | ||
| "officeHours": null | ||
| }, | ||
| { | ||
| "id": "INS008", | ||
| "name": "Omar", | ||
| "email": null, | ||
| "officeHours": "Tue 3PM-5PM" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "EEE103", | ||
| "name": "Power Systems", | ||
| "room": "404", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS009", | ||
| "name": "Yuki", | ||
| "email": "yuki@edu.com", | ||
| "officeHours": "Mon 10AM-12PM" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| }, | ||
| "Business Administration": { | ||
| "Dept_code": "BBA", | ||
| "programs": [ | ||
| { | ||
| "id": "BBA101", | ||
| "name": "Financial Accounting", | ||
| "buildingCode": "BBA", | ||
| "room": "201", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS010", | ||
| "name": "Sofia", | ||
| "email": "sofia@edu.com", | ||
| "officeHours": "Wed 1PM-3PM" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "BBA102", | ||
| "name": "Marketing Principles", | ||
| "buildingCode": "BBA", | ||
| "room": "305", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS011", | ||
| "name": "Mateo", | ||
| "email": "mateo@edu.com" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "BBA103", | ||
| "name": "Business Analytics", | ||
| "buildingCode": "BBA", | ||
| "room": null, | ||
| "instructors": [] | ||
| } | ||
| ] | ||
| }, | ||
| "Architecture": { | ||
| "Dept_code": "ARC", | ||
| "programs": [ | ||
| { | ||
| "id": "ARC101", | ||
| "name": "Urban Design", | ||
| "buildingCode": "ARC", | ||
| "room": "601", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS012", | ||
| "name": "Elena", | ||
| "email": "elena@edu.com", | ||
| "officeHours": "Thu 2PM-4PM" | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "ARC102", | ||
| "name": "Architectural Drawing", | ||
| "buildingCode": "ARC", | ||
| "room": "603", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS013", | ||
| "name": "Santiago", | ||
| "email": "santiago@edu.com", | ||
| "officeHours": null | ||
| } | ||
| ] | ||
| }, | ||
| { | ||
| "id": "ARC103", | ||
| "name": "Landscape Planning", | ||
| "buildingCode": "ARC", | ||
| "instructors": [ | ||
| { | ||
| "id": "INS014", | ||
| "name": "Aisha", | ||
| "email": "aisha@edu.com" | ||
| } | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,168 @@ | ||
| //this data will be fetched from CDN | ||
| const fs = require("fs"); | ||
| const data = fs.readFileSync("data.json", "utf8"); | ||
| const rawData = JSON.parse(data); | ||
| // console.log(rawData); | ||
|
Comment on lines
+1
to
+5
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please create a PR in the freecodecamp CDN repo, to add the data.json. If you have already created a PR and had it approved and merged in, then this will need to be updated to come from the CDN instead.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After confirming the draft these lines will be removed. |
||
|
|
||
| function normalizeDirectory(rawData) { | ||
| // Lookup tables | ||
| const departmentsById = {}; | ||
| const programsById = {}; | ||
| const instructorsById = {}; | ||
| const instructorsByEmail = {}; | ||
|
|
||
| // Convert object into iterable array | ||
| const departmentEntries = Object.entries(rawData); | ||
|
|
||
| departmentEntries.forEach(([departmentName, departmentData], index) => { | ||
| // Generate department ID | ||
| const departmentId = departmentData.Dept_code || `dept-${index + 1}`; | ||
|
|
||
| // Store department | ||
| departmentsById[departmentId] = { | ||
| id: departmentId, | ||
| name: departmentName, | ||
| programIds: [], | ||
| }; | ||
|
|
||
| // Loop through programs | ||
| departmentData.programs.forEach((program) => { | ||
| programsById[program.id] = { | ||
| ...program, | ||
| departmentId, | ||
| }; | ||
|
|
||
| departmentsById[departmentId].programIds.push(program.id); | ||
|
|
||
| // Normalize instructors | ||
| program.instructors.forEach((instructor) => { | ||
| instructorsById[instructor.id] = { | ||
| ...instructor, | ||
| programId: program.id, | ||
| departmentId, | ||
| }; | ||
|
|
||
| // Create fast email lookup | ||
| if (instructor.email) { | ||
| instructorsByEmail[instructor.email] = instructor.id; | ||
| } | ||
| }); | ||
| }); | ||
| }); | ||
|
|
||
| return { | ||
| departmentsById, | ||
| programsById, | ||
| instructorsById, | ||
| instructorsByEmail, | ||
| }; | ||
| } | ||
|
|
||
| const normalizedData = normalizeDirectory(rawData); | ||
| // console.log(normalizedData); | ||
|
|
||
|
|
||
|
|
||
| function getInstructorByEmail(email, normalizedData) { | ||
|
|
||
| const instructorId = | ||
| normalizedData.instructorsByEmail[email]; | ||
|
|
||
| if (!instructorId) { | ||
| return "Instructor not found"; | ||
| } | ||
|
|
||
| const instructor = | ||
| normalizedData.instructorsById[instructorId]; | ||
|
|
||
| const department = | ||
| normalizedData.departmentsById[ | ||
| instructor?.departmentId | ||
| ]; | ||
|
|
||
| return { | ||
| name: instructor?.name ?? "Unknown Instructor", | ||
|
|
||
| officeHours: | ||
| instructor?.officeHours ?? | ||
| "Not Available", | ||
|
|
||
| department: | ||
| department?.name ?? | ||
| "Unknown Department" | ||
| }; | ||
| } | ||
|
|
||
| // console.log( | ||
| // getInstructorByEmail( | ||
| // "dmitri@edu.com", | ||
| // normalizedData | ||
| // ) | ||
| // ); | ||
|
|
||
|
|
||
| function listRoomsByBuilding(buildingCode, normalizedData) { | ||
|
|
||
| return Object.values(normalizedData.programsById) | ||
|
|
||
| .filter(program => | ||
| program.buildingCode === buildingCode | ||
| ) | ||
|
|
||
| .map(program => program.room) | ||
|
|
||
| .filter(room => room != null) | ||
|
|
||
| .sort((a, b) => a.localeCompare(b, undefined, { | ||
| numeric: true | ||
| })); | ||
| } | ||
|
|
||
| // List rooms | ||
| // console.log( | ||
| // listRoomsByBuilding( | ||
| // "CSE", | ||
| // normalizedData | ||
| // ) | ||
| // ); | ||
|
|
||
|
|
||
| function renderDirectorySummary(normalizedData) { | ||
|
|
||
| const departments = | ||
| Object.keys(normalizedData.departmentsById).length; | ||
|
|
||
| const programs = | ||
| Object.keys(normalizedData.programsById).length; | ||
|
|
||
| const instructors = | ||
| Object.keys(normalizedData.instructorsById).length; | ||
|
|
||
| const missingOfficeHours = | ||
| Object.values(normalizedData.instructorsById) | ||
| .filter(instructor => | ||
| instructor.officeHours == null | ||
| ).length; | ||
|
|
||
| const programsWithoutRooms = | ||
| Object.values(normalizedData.programsById) | ||
| .filter(program => | ||
| program.room == null | ||
| ).length; | ||
|
|
||
| return ` | ||
| Campus Directory Summary | ||
| ------------------------ | ||
| Departments: ${departments} | ||
| Programs: ${programs} | ||
| Instructors: ${instructors} | ||
| Missing Office Hours: ${missingOfficeHours} | ||
| Programs Without Rooms: ${programsWithoutRooms} | ||
| `; | ||
| } | ||
|
|
||
| console.log( | ||
| renderDirectorySummary( | ||
| normalizedData | ||
| ) | ||
| ); | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a PR in the freecodecamp CDN repo, if you haven't already done so to add this data there.
If you have already created a PR and had it approved and merged in, then this file can be removed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's confirm the draft, then I'll would PR finalized data.json