Skip to content

Commit

Permalink
Merge pull request #362 from KTH/issues/KUI-1375-fetch-recommended-pr…
Browse files Browse the repository at this point in the history
…erequisites-from-om-kursen

(KUI-1375): Fetch recommended prerequisites from 'Om Kursen'
  • Loading branch information
axelbjo authored Oct 4, 2024
2 parents b2446d8 + d253ebf commit 7ffbfd5
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
10 changes: 9 additions & 1 deletion public/js/app/components/CourseSectionList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,17 @@ function CourseSectionList({ courseInfo = {}, partToShow, syllabus = {}, syllabu

const eligibility = getEligibility()

const recommendedPrerequisitesSection =
courseInfo.course_recommended_prerequisites != ''
? {
header: translation.courseInformation.course_prerequisites,
text: courseInfo.course_recommended_prerequisites,
}
: {}

const during = [
...eligibility,
{ header: translation.courseInformation.course_prerequisites, text: courseInfo.course_prerequisites },
recommendedPrerequisitesSection,
{ header: translation.courseInformation.course_required_equipment, text: courseRequiredEquipment },
{ header: translation.courseInformation.course_literature, text: literatureText },
]
Expand Down
5 changes: 3 additions & 2 deletions server/apiCalls/getFilteredData.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ function _parseCourseDefaultInformation(courseDetails, language) {
: INFORM_IF_IMPORTANT_INFO_IS_MISSING_ABOUT_MIN_FIELD_OF_STUDY[language],
course_possibility_to_addition: parseOrSetEmpty(course.possibilityToAddition, language),
course_possibility_to_completions: parseOrSetEmpty(course.possibilityToCompletion, language),
course_prerequisites: parseOrSetEmpty(course.prerequisites, language),
course_recruitment_text: parseOrSetEmpty(course.recruitmentText, language, true),
course_required_equipment: parseOrSetEmpty(course.requiredEquipment, language),
course_suggested_addon_studies: parseOrSetEmpty(course.addOn, language),
Expand Down Expand Up @@ -241,13 +240,15 @@ const getFilteredData = async ({ courseCode, language, memoList }) => {
//* **** Course information that is static on the course side *****//
const courseDefaultInformation = _parseCourseDefaultInformation(courseDetails, language)

const { sellingText, courseDisposition, supplementaryInfo, imageInfo } = await courseApi.getCourseInfo(courseCode)
const { sellingText, courseDisposition, recommendedPrerequisites, supplementaryInfo, imageInfo } =
await courseApi.getCourseInfo(courseCode)

const courseInfo = {
...courseDefaultInformation,
sellingText: resolveText(sellingText, language),
imageFromAdmin: imageInfo,
course_disposition: resolveText(courseDisposition, language),
course_recommended_prerequisites: resolveText(recommendedPrerequisites, language),
course_supplemental_information: resolveText(supplementaryInfo, language),
}

Expand Down
2 changes: 2 additions & 0 deletions server/apiCalls/kursinfoApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@ async function _getCourseInfo(courseCode) {
imageInfo: '',
supplementaryInfo: { sv: '', en: '' },
courseDisposition: { sv: '', en: '' },
recommendedPrerequisites: { sv: '', en: '' },
}

if (res.statusCode === 200 && res.body) {
const { body } = res
return {
sellingText: body.sellingText ?? defaultValues.sellingText,
courseDisposition: body.courseDisposition ?? defaultValues.courseDisposition,
recommendedPrerequisites: body.recommendedPrerequisites ?? defaultValues.recommendedPrerequisites,
supplementaryInfo: body.supplementaryInfo ?? defaultValues.supplementaryInfo,
imageInfo: body.imageInfo ?? defaultValues.imageInfo,
}
Expand Down
2 changes: 1 addition & 1 deletion server/controllers/__tests__/courseCtrl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ describe('Discontinued course to test', () => {
"course_main_subject": "Denna kurs tillhör inget huvudområde.",
"course_possibility_to_addition": "<i>Ingen information tillagd</i>",
"course_possibility_to_completions": "<i>Ingen information tillagd</i>",
"course_prerequisites": "<i>Ingen information tillagd</i>",
"course_recommended_prerequisites": "",
"course_recruitment_text": "<p>Teori och metoder inom glykovetenskap.</p>",
"course_required_equipment": "<i>Ingen information tillagd</i>",
"course_state": "ESTABLISHED",
Expand Down

0 comments on commit 7ffbfd5

Please sign in to comment.