Skip to content

Commit

Permalink
Revert "Issues/KUI 1599 remove fields (#389)"
Browse files Browse the repository at this point in the history
This reverts commit 1fc43df.
  • Loading branch information
karlandindrakryggen committed Dec 4, 2024
1 parent 39d87b0 commit 46faa13
Show file tree
Hide file tree
Showing 16 changed files with 135 additions and 7 deletions.
6 changes: 6 additions & 0 deletions i18n/messages.en.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,13 @@ module.exports = {
course_valid_from: 'Valid from',
course_main_subject: 'Main field of study',
course_language: 'Language of instruction',
course_required_equipment: 'Equipment',
course_level_code: 'Education cycle',
course_decision_to_discontinue: 'Avvecklingsbeslut',
course_transitional_reg: 'Transitional regulations',
course_ethical: 'Ethical approach',
course_possibility_to_completions: 'Opportunity to complete the requirements via supplementary examination',
course_possibility_to_addition: 'Opportunity to raise an approved grade via renewed examination',
course_short_semester: {
1: 'Spring ',
2: 'Autumn ',
Expand All @@ -156,10 +159,12 @@ module.exports = {
RESEARCH: 'Third cycle',
},
course_department: 'Offered by',
course_contact_name: 'Contact ',
course_prerequisites: 'Recommended prerequisites',
course_prerequisites_description:
'Describes the knowledge and skills (in addition to the eligibility requirements) that you need to be able to take the course.',
course_prerequisites_menu_aria_label: 'Information about recommended prerequisites',
course_suggested_addon_studies: 'Add-on studies',
course_supplemental_information_url: 'Supplementary information link',
course_supplemental_information_url_text: 'Supplementary information link text',
course_supplemental_information: 'Supplementary information ',
Expand All @@ -168,6 +173,7 @@ module.exports = {
course_room_canvas: 'Course room in Canvas',
course_room_canvas_info:
'Registered students find further information about the implementation of the course in the course room in Canvas. A link to the course room can be found under the tab Studies in the Personal menu at the start of the course.',
course_application_info: 'Information for research students about course offerings',
},
courseRoundInformation: {
round_header: 'Information for',
Expand Down
6 changes: 6 additions & 0 deletions i18n/messages.se.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,13 @@ module.exports = {
course_valid_from: 'Giltig från',
course_main_subject: 'Huvudområde',
course_language: 'Undervisningsspråk',
course_required_equipment: 'Utrustning',
course_level_code: 'Utbildningsnivå',
course_decision_to_discontinue: 'Avvecklingsbeslut',
course_transitional_reg: 'Övergångsbestämmelser',
course_ethical: 'Etiskt förhållningssätt',
course_possibility_to_completions: 'Möjlighet till komplettering',
course_possibility_to_addition: 'Möjlighet till plussning',
course_short_semester: {
1: 'VT ',
2: 'HT ',
Expand All @@ -158,10 +161,12 @@ module.exports = {
RESEARCH: 'Forskarnivå',
},
course_department: 'Ges av',
course_contact_name: 'Kontaktperson',
course_prerequisites: 'Rekommenderade förkunskaper',
course_prerequisites_description:
'Beskriver vilka kunskaper och färdigheter (utöver behörighetskraven) som du behöver för att kunna ta till dig kursen.',
course_prerequisites_menu_aria_label: 'Information om rekommenderade förkunskaper',
course_suggested_addon_studies: 'Påbyggnad',
course_supplemental_information_url: 'Övrig information - länk',
course_supplemental_information_url_text: 'Övrig information - länk text',
course_supplemental_information: 'Övrig information',
Expand All @@ -170,6 +175,7 @@ module.exports = {
course_room_canvas: 'Kursrum i Canvas',
course_room_canvas_info:
'Registrerade studenter hittar information för genomförande av kursen i kursrummet i Canvas. En länk till kursrummet finns under fliken Studier i Personliga menyn vid kursstart.',
course_application_info: 'Information för forskarstuderande om när kursen ges',
},
courseRoundInformation: {
round_header: 'Information för',
Expand Down
19 changes: 19 additions & 0 deletions public/js/app/components/CourseSectionList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function CourseSectionList({ courseInfo = {}, partToShow, syllabus = {}, syllabu
literatureText = `${syllabus.course_literature_comment}`
}

const courseRequiredEquipment = !isMissingInfoLabel(courseInfo.course_required_equipment)
? courseInfo.course_required_equipment
: syllabus.course_required_equipment

const eligibility = getEligibility()

const during = [
Expand All @@ -66,6 +70,7 @@ function CourseSectionList({ courseInfo = {}, partToShow, syllabus = {}, syllabu
ariaLabel: translation.courseInformation.course_prerequisites_menu_aria_label,
},
},
{ header: translation.courseInformation.course_required_equipment, text: courseRequiredEquipment },
{ header: translation.courseInformation.course_literature, text: literatureText },
]

Expand Down Expand Up @@ -105,6 +110,14 @@ function CourseSectionList({ courseInfo = {}, partToShow, syllabus = {}, syllabu
syllabusMarker: true,
})
}
examination.push({
header: translation.courseInformation.course_possibility_to_completions,
text: courseInfo.course_possibility_to_completions,
})
examination.push({
header: translation.courseInformation.course_possibility_to_addition,
text: courseInfo.course_possibility_to_addition,
})
examination.push({ header: translation.courseInformation.course_examiners, text: courseInfo.course_examiners })
examination.push({
header: translation.courseInformation.course_ethical,
Expand Down Expand Up @@ -134,7 +147,13 @@ function CourseSectionList({ courseInfo = {}, partToShow, syllabus = {}, syllabu
text: translation.courseInformation.course_level_code_label[courseInfo.course_level_code],
syllabusMarker: true,
},
{
header: translation.courseInformation.course_suggested_addon_studies,
text: courseInfo.course_suggested_addon_studies,
},
]
if (!isMissingInfoLabel(courseInfo.course_contact_name))
prepare.push({ header: translation.courseInformation.course_contact_name, text: courseInfo.course_contact_name })
if (syllabus.course_transitional_reg !== '')
prepare.push({
header: translation.courseInformation.course_transitional_reg,
Expand Down
6 changes: 6 additions & 0 deletions public/js/app/components/MainCourseInformation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ const MainCourseInformation = ({ courseCode, courseData, semesterRoundState }) =
</Alert>
)}

{courseInfo.course_application_info.length > 0 && (
<Alert type="info" header={translation.courseInformation.course_application_info}>
<span dangerouslySetInnerHTML={{ __html: courseInfo.course_application_info }} />
</Alert>
)}

<CourseSectionList
courseInfo={courseInfo}
// if there is no syllabus, we still want to display empty syllabus data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { usePlannedModules } from '../../hooks/usePlannedModules'
import { RoundInformationInfoGrid } from './RoundInformationInfoGrid'
import { RoundInformationContacts } from './RoundInformationContacts'

function RoundInformation({ courseCode, courseRound, semesterRoundState }) {
function RoundInformation({ courseCode, courseData, courseRound, semesterRoundState }) {
const { translation } = useLanguage()

const { createRoundHeader } = useRoundUtils()
Expand Down Expand Up @@ -75,7 +75,7 @@ function RoundInformation({ courseCode, courseRound, semesterRoundState }) {
)}

<h3>{translation.courseLabels.header_contact}</h3>
<RoundInformationContacts courseRoundEmployees={courseRoundEmployees ?? {}} />
<RoundInformationContacts courseData={courseData} courseRoundEmployees={courseRoundEmployees ?? {}} />
</div>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react'
import { useLanguage } from '../../hooks/useLanguage'
import { useMissingInfo } from '../../hooks/useMissingInfo'

function RoundInformationContacts({ courseRoundEmployees }) {
function RoundInformationContacts({ courseData, courseRoundEmployees }) {
const { translation } = useLanguage()
const { missingInfoLabel } = useMissingInfo()

Expand All @@ -26,6 +26,15 @@ function RoundInformationContacts({ courseRoundEmployees }) {
<dt>{translation.courseRoundInformation.round_teacher}</dt>
<dd dangerouslySetInnerHTML={{ __html: courseRoundEmployees.teachers || missingInfoLabel }} />
</div>

{courseData.course_contact_name && courseData.course_contact_name !== missingInfoLabel && (
<div>
<dt>{translation.courseInformation.course_contact_name}</dt>
<dd>
<p>{courseData.course_contact_name}</p>
</dd>
</div>
)}
</div>
)
}
Expand Down
6 changes: 6 additions & 0 deletions public/js/app/components/__tests__/RoundInformation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ describe('Component <RoundInformation>', () => {
const propsWithStudyPace = {
memoStorageUri: '',
semesterRoundState: defaultSemesterRoundState,
courseData: {},
courseRound: {
round_course_term: ['2018', '1'],
round_study_pace: '25',
Expand All @@ -66,6 +67,7 @@ describe('Component <RoundInformation>', () => {
const propsWithEmployees = {
memoStorageUri: '',
semesterRoundState: defaultSemesterRoundState,
courseData: {},
courseCode: 'SF1624',
courseRound: mockCourseRound,
}
Expand Down Expand Up @@ -95,6 +97,7 @@ describe('Component <RoundInformation>', () => {
const propsWithEmptyEmployees = {
memoStorageUri: '',
semesterRoundState: defaultSemesterRoundState,
courseData: {},
courseCode: 'SF1624',
courseRound: mockCourseRound,
}
Expand All @@ -112,6 +115,7 @@ describe('Component <RoundInformation>', () => {
const propsWithoutEmployees = {
memoStorageUri: '',
semesterRoundState: defaultSemesterRoundState,
courseData: {},
courseCode: 'SF1624',
courseRound: mockCourseRound,
}
Expand Down Expand Up @@ -167,6 +171,7 @@ describe('Component <RoundInformation>', () => {
const propsWithoutSeatsNum = {
memoStorageUri: '',
semesterRoundState: defaultSemesterRoundState,
courseData: {},
courseRound: {
round_course_term: ['2018', '1'],
round_selection_criteria: '<p>English. Spicy jalapeno bacon ipsum</p>',
Expand Down Expand Up @@ -195,6 +200,7 @@ describe('Component <RoundInformation>', () => {
const propsWithEmptyCriteria = {
memoStorageUri: '',
semesterRoundState: defaultSemesterRoundState,
courseData: {},
courseRound: {
round_course_term: ['2018', '1'],
round_selection_criteria: '<p></p>',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const withinNextSibling = element => within(nextSibling(element))
describe('Component <RoundInformationContacts>', () => {
describe('examiners, responsibles and teachers', () => {
test('shoud show headers with "missing info" text when data is missing', () => {
render(<RoundInformationContacts courseRoundEmployees={{}} />)
render(<RoundInformationContacts courseData={{}} courseRoundEmployees={{}} />)
const examinerLabel = screen.getByText('Examiner')
expect(nextSibling(examinerLabel)).toHaveTextContent('No information inserted')

Expand All @@ -36,6 +36,7 @@ describe('Component <RoundInformationContacts>', () => {
test('shoud show headers with data inserted as html', () => {
render(
<RoundInformationContacts
courseData={{ courseInfo: { course_contact_name: undefined } }}
courseRoundEmployees={{
examiners: '<p class="person"><a href="/profile/testexaminers/">Test examiners</a></p>',
responsibles: '<p class="person"><a href="/profile/testresponsibles/">Test responsibles</a></p>',
Expand All @@ -59,4 +60,24 @@ describe('Component <RoundInformationContacts>', () => {
expect(teacherLink).toHaveAttribute('href', '/profile/testteachers/')
})
})

describe('cource contact', () => {
test('should show header and content for course contact name', () => {
render(
<RoundInformationContacts courseData={{ course_contact_name: 'Contact name' }} courseRoundEmployees={{}} />
)
const contactLabel = screen.getByText('Contact')
expect(contactLabel).toBeInTheDocument()
})
test.each([undefined, '<i>No information inserted</i>'])(
"shoud NOT show header if contact name is '%s'",
contactNameArg => {
render(
<RoundInformationContacts courseData={{ course_contact_name: contactNameArg }} courseRoundEmployees={{}} />
)
const contactLabel = screen.queryByText('Contact')
expect(contactLabel).not.toBeInTheDocument()
}
)
})
})
2 changes: 2 additions & 0 deletions public/js/app/hooks/__tests__/useSemesterRoundState.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ const syllabusList = [
semesterNumber: 2,
},
course_valid_to: [],
course_required_equipment: '<i>No information inserted</i>',
course_examination:
"<ul class='ul-no-padding' ><li>TEN1 - \n Examination,\n 7.5 credits, \n grading scale: A, B, C, D, E, FX, F \n </li></ul>",
course_examination_comments:
Expand Down Expand Up @@ -186,6 +187,7 @@ const syllabusList = [
year: 2019,
semesterNumber: 1,
},
course_required_equipment: '<i>No information inserted</i>',
course_examination:
"<ul class='ul-no-padding' ><li>TEN1 - \n Examination,\n 7.5 credits, \n grading scale: A, B, C, D, E, FX, F \n </li></ul>",
course_examination_comments:
Expand Down
19 changes: 17 additions & 2 deletions public/js/app/pages/CoursePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function CoursePage() {
browserConfig,
courseCode,
courseData = {
courseInfo: {},
courseInfo: { course_application_info: '' },
syllabusList: [],
},
isCancelledOrDeactivated,
Expand Down Expand Up @@ -59,6 +59,16 @@ function CoursePage() {
courseImage = `${browserConfig.imageStorageUri}${courseImage}`

const decisionToDiscontinue = hasSyllabus ? activeSyllabus.course_decision_to_discontinue : ''
const course_valid_from = hasSyllabus ? activeSyllabus.course_valid_from : ''

const courseInformationToRounds = {
course_code: courseCode,
course_examiners: courseInfo.course_examiners,
course_contact_name: courseInfo.course_contact_name,
course_main_subject: courseInfo.course_main_subject,
course_level_code: courseInfo.course_level_code,
course_valid_from,
}

useEffect(() => {
let isMounted = true
Expand Down Expand Up @@ -119,7 +129,12 @@ function CoursePage() {
<RoundSelector activeSemesters={activeSemesters} semesterRoundState={semesterRoundState} />

{showRoundData && (
<RoundInformation courseCode={courseCode} courseRound={activeRound} semesterRoundState={semesterRoundState} />
<RoundInformation
courseCode={courseCode}
courseData={courseInformationToRounds}
courseRound={activeRound}
semesterRoundState={semesterRoundState}
/>
)}

<MainCourseInformation
Expand Down
4 changes: 3 additions & 1 deletion public/js/app/pages/__tests__/CoursePage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,9 @@ describe('Component <CoursePage>', () => {
],
courseCode: 'MF1016',
courseData: {
courseInfo: {},
courseInfo: {
course_application_info: '',
},
courseTitleData: {
course_code: 'MF1016',
course_credits: 9,
Expand Down
14 changes: 14 additions & 0 deletions server/apiCalls/getFilteredData.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ const {
const koppsCourseData = require('./koppsCourseData')
const courseApi = require('./kursinfoApi')

function parceContactName(infoContactName, language) {
const courseContactName = parseOrSetEmpty(infoContactName, language)
if (courseContactName === INFORM_IF_IMPORTANT_INFO_IS_MISSING[language]) return courseContactName
const emailBracketsRexEx = /<|>/gi
const contact = courseContactName.replace(emailBracketsRexEx, '')
return contact
}

function _parseCourseDefaultInformation(courseDetails, language) {
const { course, formattedGradeScales, mainSubjects } = courseDetails
return {
course_application_info: parseOrSetEmpty(course.applicationInfo, language, true), // applicationInfo is info for research students (Label in Kopps: "Information for research students about course offerings")
course_code: parseOrSetEmpty(course.courseCode),
course_contact_name: parceContactName(course.infoContactName, language),
course_department: parseOrSetEmpty(course.department.name, language),
course_department_code: parseOrSetEmpty(course.department.code, language),
course_department_link: buildCourseDepartmentLink(course.department, language),
Expand All @@ -32,7 +42,11 @@ function _parseCourseDefaultInformation(courseDetails, language) {
mainSubjects && mainSubjects.length > 0
? mainSubjects.join(', ')
: 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_recruitment_text: parseOrSetEmpty(course.recruitmentText, language, true),
course_required_equipment: parseOrSetEmpty(course.requiredEquipment, language),
course_suggested_addon_studies: parseOrSetEmpty(course.addOn, language),
course_state: parseOrSetEmpty(course.state, language, true),
}
}
Expand Down
Loading

0 comments on commit 46faa13

Please sign in to comment.