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-1498: replace examinationSets (KOPPS) with modules (Ladok) #395

Open
wants to merge 10 commits into
base: upl-main
Choose a base branch
from
112 changes: 57 additions & 55 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 1 addition & 4 deletions public/js/app/pages/ChangePublished.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,7 @@ function ChangePublished(props) {
return (
<div className="kip-container">
<div id="scroll-here-if-alert">
<PageHeading
heading={pageTitles.published}
subHeading={course && combinedCourseName(courseCode, course, langAbbr)}
/>
<PageHeading heading={pageTitles.published} subHeading={course && combinedCourseName(courseCode, course)} />
</div>

<ProgressBar current={0} steps={pagesChangePublishedPm} />
Expand Down
4 changes: 2 additions & 2 deletions public/js/app/pages/CreateNewMemo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function CreateNewMemo(props) {
const continueToEditorUrl = `${SERVICE_URL.courseMemoAdmin}${courseCode}/${existingDraftEndPoint}`
window.location = continueToEditorUrl
} else if (sortedApplicationCodes.length > 0 && !existingDraftEndPoint) {
const courseTitle = combinedCourseName(courseCode, course, memoCommonLangAbbr)
const courseTitle = combinedCourseName(courseCode, course)
// Create new draft from chosen semester rounds
const body = {
courseCode,
Expand Down Expand Up @@ -261,7 +261,7 @@ function CreateNewMemo(props) {
return (
<div className="kip-container">
<Row id="scroll-here-if-alert">
<PageHeading heading={pageTitles.new} subHeading={course && combinedCourseName(courseCode, course, langAbbr)} />
<PageHeading heading={pageTitles.new} subHeading={course && combinedCourseName(courseCode, course)} />
</Row>

<ProgressBar current={0} steps={pagesCreateNewPm} />
Expand Down
11 changes: 5 additions & 6 deletions public/js/app/pages/MemoEditingContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,9 @@ function MemoContainer(props) {
}

const courseSubHeader = () => {
const { title, credits, creditUnitAbbr } = memoData
const { title, credits } = memoData

const creditsStandard = credits || ''
const courseTitle = `${courseCode} ${title} ${creditsStandard} ${userLangIndex === 1 ? creditUnitAbbr : 'credits'}`
const courseTitle = `${courseCode} ${title} ${credits.formattedWithUnit}`

// update course title in case if smth changed in kopps
store.setCourseTitle(courseTitle)
Expand Down Expand Up @@ -181,7 +180,7 @@ function MemoContainer(props) {

// eslint-disable-next-line consistent-return
const onSave = async (editorContent, alertTranslationId) => {
const { syllabusValid, memoCommonLangAbbr, credits, creditUnitAbbr, title, educationalTypeId } = memoData
const { syllabusValid, credits, creditUnitAbbr, title, educationalTypeId } = memoData
const eduTypeId = educationalTypeId ? { educationalTypeId } : {}
const { validFromTerm, validUntilTerm } = syllabusValid || {}
if (syllabusValid)
Expand All @@ -191,9 +190,9 @@ function MemoContainer(props) {
const course = {
credits,
creditUnitAbbr,
title: { [memoCommonLangAbbr]: title },
title,
}
const courseTitle = combinedCourseName(courseCode, course, memoCommonLangAbbr)
const courseTitle = combinedCourseName(courseCode, course)
const body = { courseCode, memoEndPoint, ...editorContent, syllabusValid, courseTitle, ...eduTypeId } // containt kopps old data, or it is empty first time
try {
const result = await store.updateDraft(body)
Expand Down
48 changes: 16 additions & 32 deletions public/js/app/util/__test__/helpers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,58 +5,42 @@ const coursesTypeOne = {
course_SV: {
courseCode: 'ML1616',
gradeScaleCode: 'AF',
title: { sv: 'Industriell projektledning och projektstyrning' },
credits: 7.5,
title: 'Industriell projektledning och projektstyrning',
credits: { formattedWithUnit: '7.5 hp' },
creditUnitLabel: 'Högskolepoäng',
creditUnitAbbr: 'hp',
courseLiterature: '<p>Meddelas vid kursstart.</p>',
},
course_EN: {
courseCode: 'DD1321',
gradeScaleCode: 'AF',
title: { en: 'Applied Programming and Computer Science' },
credits: 7.5,
title: 'Applied Programming and Computer Science',
credits: { formattedWithUnit: '7.5 credits' },
creditUnitLabel: 'Credits',
creditUnitAbbr: 'hp',
},
}
const courseTypeTwo = {
course: {
title: {
sv: 'Tillämpad programmering och datalogi',
en: 'Applied Programming and Computer Science',
},
credits: 9,
creditUnitLabel: {
sv: 'Högskolepoäng',
en: 'Credits',
},
creditUnitAbbr: {
sv: 'hp',
en: 'hp',
},
},
}

describe('combine course name', () => {
test('combine course name for an object from a detailed information endpoint in Swedish', () => {
const courseTitle = combinedCourseName('ML1616', coursesTypeOne.course_SV, 'sv')
expect(courseTitle).toBe('ML1616 Industriell projektledning och projektstyrning 7,5 hp')
const courseTitle = combinedCourseName('ML1616', coursesTypeOne.course_SV)
expect(courseTitle).toBe('ML1616 Industriell projektledning och projektstyrning 7.5 hp')
})

test('combine course name for an object from a detailed information endpoint in English', () => {
const courseTitle = combinedCourseName('ML1616', coursesTypeOne.course_EN, 'en')
const courseTitle = combinedCourseName('ML1616', coursesTypeOne.course_EN)
expect(courseTitle).toBe('ML1616 Applied Programming and Computer Science 7.5 credits')
})

test('combine course name for an object from a course rounds information endpoint in Swedish', () => {
const courseTitle = combinedCourseName('ALLLLL', courseTypeTwo.course, 'sv')
expect(courseTitle).toBe('ALLLLL Tillämpad programmering och datalogi 9.0 hp')
})
// test('combine course name for an object from a course rounds information endpoint in Swedish', () => {
// const courseTitle = combinedCourseName('ALLLLL', courseTypeTwo.course, 'sv')
// expect(courseTitle).toBe('ALLLLL Tillämpad programmering och datalogi 9.0 hp')
// })

test('combine course name for an object from a course rounds endpoint in English', () => {
const courseTitle = combinedCourseName('ALLLLL', courseTypeTwo.course, 'en')
expect(courseTitle).toBe('ALLLLL Applied Programming and Computer Science 9.0 credits')
})
// test('combine course name for an object from a course rounds endpoint in English', () => {
// const courseTitle = combinedCourseName('ALLLLL', courseTypeTwo.course, 'en')
// expect(courseTitle).toBe('ALLLLL Applied Programming and Computer Science 9.0 credits')
// })
})

describe('parse termin/semester into a season string', () => {
Expand Down
11 changes: 2 additions & 9 deletions public/js/app/util/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ import { seasonStr } from '../utils-shared/helpers'

const i18n = require('../../../../i18n')

export const combinedCourseName = (courseCode, course, langAbbr) => {
export const combinedCourseName = (courseCode, course) => {
if (!course) return ''
const { credits, title } = course
let { creditUnitAbbr = '' } = course
creditUnitAbbr = typeof creditUnitAbbr === 'object' ? creditUnitAbbr[langAbbr] : creditUnitAbbr
const creditsStandard = credits.toString().indexOf('.') < 0 ? credits + '.0' : credits
const localeCredits =
langAbbr === 'sv' ? creditsStandard.toLocaleString('sv-SE') : creditsStandard.toLocaleString('en-US')
const creditUnit = langAbbr === 'sv' ? creditUnitAbbr : 'credits'

const courseName = `${courseCode} ${title[langAbbr]} ${localeCredits} ${creditUnit}`
const courseName = `${courseCode} ${title} ${credits.formattedWithUnit}`
return courseName
}

Expand Down
Loading