Skip to content
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

(KUI-1375): Fetch recommended prerequisites from 'Om Kursen' #362

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading