-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #368 from mbeps/development
Added Education page showing my education history
- Loading branch information
Showing
48 changed files
with
2,657 additions
and
493 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
actions/material/course/aggregate/aggregateRelatedMaterialsForCourses.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import UniversityModuleKeysEnum from "@/enums/DatabaseKeysEnums/UniversityModuleKeysEnum"; | ||
import UniversityCourseInterface from "@/interfaces/material/UniversityCourseInterface"; | ||
import UniversityModuleInterface from "@/interfaces/material/UniversityModuleInterface"; | ||
|
||
export default function aggregateRelatedMaterialsForCourses( | ||
coursesDatabase: Database<UniversityCourseInterface>, | ||
modulesDatabase: Database<UniversityModuleInterface> | ||
): Database<UniversityCourseInterface> { | ||
// Create a new object to store the updated courses with aggregated related materials | ||
const updatedCoursesDatabase: Database<UniversityCourseInterface> = {}; | ||
|
||
// Iterate over each course in the database | ||
Object.keys(coursesDatabase).forEach((courseKey) => { | ||
const course: UniversityCourseInterface = coursesDatabase[courseKey]; | ||
|
||
// Start with existing related materials in the course, if any | ||
let aggregatedMaterials: string[] = course.relatedMaterials | ||
? [...course.relatedMaterials] | ||
: []; | ||
|
||
// Iterate over each module key in the course | ||
course.modules.forEach((moduleKey: UniversityModuleKeysEnum) => { | ||
const moduleData: UniversityModuleInterface = modulesDatabase[moduleKey]; | ||
// Ensure the moduleData exists and has related materials | ||
if (moduleData && moduleData.relatedMaterials) { | ||
// Aggregate the related materials | ||
aggregatedMaterials = [ | ||
...aggregatedMaterials, | ||
...moduleData.relatedMaterials, | ||
]; | ||
} | ||
}); | ||
|
||
// Remove duplicate related materials if necessary | ||
aggregatedMaterials = Array.from(new Set(aggregatedMaterials)); | ||
|
||
// Update the course object with the aggregated related materials and add it to the updated database | ||
updatedCoursesDatabase[courseKey] = { | ||
...course, | ||
relatedMaterials: aggregatedMaterials, | ||
}; | ||
}); | ||
|
||
// Return the updated courses database with the aggregated related materials | ||
return updatedCoursesDatabase; | ||
} |
38 changes: 38 additions & 0 deletions
38
actions/material/course/aggregate/aggregateSkillsForCourse.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import SkillKeysEnum from "@/enums/DatabaseKeysEnums/SkillKeysEnum"; | ||
import UniversityCourseInterface from "@/interfaces/material/UniversityCourseInterface"; | ||
import UniversityModuleInterface from "@/interfaces/material/UniversityModuleInterface"; | ||
|
||
/** | ||
* Adds the skills a course's modules to the course's skills itself. | ||
* All the skills that are related to a module are also related to the course. | ||
* | ||
* @param coursesDatabase Courses to which the skills are to be added. | ||
* @param modulesDatabase All the modules to access the data related to the modules. | ||
* @returns The courses with the aggregated skills. | ||
*/ | ||
export default function aggregateSkillsForCourse( | ||
course: UniversityCourseInterface, | ||
modulesDatabase: Database<UniversityModuleInterface> | ||
): UniversityCourseInterface { | ||
// Start with existing skills in the course, if any | ||
let aggregatedSkills: SkillKeysEnum[] = [...course.skills]; | ||
|
||
// Iterate over each module key in the course | ||
course.modules.forEach((moduleKey) => { | ||
const moduleData: UniversityModuleInterface = modulesDatabase[moduleKey]; // Avoid using 'module' as a variable name | ||
// Ensure the moduleData exists and has skills | ||
if (moduleData && moduleData.skills) { | ||
// Aggregate the skills | ||
aggregatedSkills = [...aggregatedSkills, ...moduleData.skills]; | ||
} | ||
}); | ||
|
||
// Remove duplicate skills if necessary | ||
aggregatedSkills = Array.from(new Set(aggregatedSkills)); | ||
|
||
// Return the course object with the aggregated skills | ||
return { | ||
...course, | ||
skills: aggregatedSkills, | ||
}; | ||
} |
51 changes: 51 additions & 0 deletions
51
actions/material/course/aggregate/aggregateSkillsForCourses.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import SkillKeysEnum from "@/enums/DatabaseKeysEnums/SkillKeysEnum"; | ||
import UniversityModuleKeysEnum from "@/enums/DatabaseKeysEnums/UniversityModuleKeysEnum"; | ||
import UniversityCourseInterface from "@/interfaces/material/UniversityCourseInterface"; | ||
import UniversityModuleInterface from "@/interfaces/material/UniversityModuleInterface"; | ||
|
||
/** | ||
* Adds the skills from a course's modules to the course's skills itself. | ||
* This works multiple courses at once. | ||
* All the skills that are related to a module are also related to the course. | ||
* | ||
* @param coursesDatabase Courses to which the skills are to be added. | ||
* @param modulesDatabase All the modules to access the data related to the modules. | ||
* @returns The courses with the aggregated skills. | ||
*/ | ||
export default function aggregateSkillsForCourses( | ||
coursesDatabase: Database<UniversityCourseInterface>, | ||
modulesDatabase: Database<UniversityModuleInterface> | ||
): Database<UniversityCourseInterface> { | ||
// Create a new object to store the updated courses with aggregated skills | ||
const updatedCoursesDatabase: Database<UniversityCourseInterface> = {}; | ||
|
||
// Iterate over each course in the database | ||
Object.keys(coursesDatabase).forEach((courseKey) => { | ||
const course: UniversityCourseInterface = coursesDatabase[courseKey]; | ||
|
||
// Start with existing skills in the course, if any | ||
let aggregatedSkills: SkillKeysEnum[] = [...course.skills]; | ||
|
||
// Iterate over each module key in the course | ||
course.modules.forEach((moduleKey: UniversityModuleKeysEnum) => { | ||
const moduleData: UniversityModuleInterface = modulesDatabase[moduleKey]; | ||
// Ensure the moduleData exists and has skills | ||
if (moduleData && moduleData.skills) { | ||
// Aggregate the skills | ||
aggregatedSkills = [...aggregatedSkills, ...moduleData.skills]; | ||
} | ||
}); | ||
|
||
// Remove duplicate skills if necessary | ||
aggregatedSkills = Array.from(new Set(aggregatedSkills)); | ||
|
||
// Update the course object with the aggregated skills and add it to the updated database | ||
updatedCoursesDatabase[courseKey] = { | ||
...course, | ||
skills: aggregatedSkills, | ||
}; | ||
}); | ||
|
||
// Return the updated courses database with the aggregated skills | ||
return updatedCoursesDatabase; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import UniversityModuleKeysEnum from "@/enums/DatabaseKeysEnums/UniversityModuleKeysEnum"; | ||
import UniversityCourseInterface from "@/interfaces/material/UniversityCourseInterface"; | ||
|
||
export default function findCourseKeyForModule( | ||
moduleKey: UniversityModuleKeysEnum, | ||
coursesDatabase: Database<UniversityCourseInterface> | ||
): string | null { | ||
// Iterate through the courses to find the one related to the specified module | ||
for (const [courseKey, course] of Object.entries(coursesDatabase)) { | ||
if (course.modules.includes(moduleKey)) { | ||
return courseKey; // Return the key of the course related to the module | ||
} | ||
} | ||
return null; // Return null if no related course is found | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.