Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { schools } from './domain/index'
import { MemosSummary } from './index'

function ResultNumbersSummary({ statisticsResult }) {
const { documentType, koppsApiBasePath } = statisticsResult
const { documentType, ladokApiBasePath } = statisticsResult
// labels are for headers and short texts
const {
translation: { statisticsLabels: labels },
Expand All @@ -30,7 +30,7 @@ function ResultNumbersSummary({ statisticsResult }) {
{texts.subPageDescription()}
<details>
<summary className="white">{summaryLabels.sourceOfData}</summary>
{texts.courseDataApiDescription(koppsApiBasePath)}
{texts.courseDataApiDescription(ladokApiBasePath)}
</details>
</article>
<article key="documents-and-courses-compilation">
Expand All @@ -44,7 +44,7 @@ ResultNumbersSummary.propTypes = {
statisticsResult: PropTypes.shape({
combinedMemosPerSchool: PropTypes.shape({}),
documentType: PropTypes.oneOf(documentTypes()),
koppsApiBasePath: PropTypes.string,
ladokApiBasePath: PropTypes.string,
documentsApiBasePath: PropTypes.string,
school: PropTypes.oneOf(schools.orderedSchoolsFormOptions()),
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ function _getDataRowsForCourseMemo(offeringsWithMemos, year, browserConfig, seme
institution,
courseCode: offering.courseCode,
linkedProgram: offering.connectedPrograms,
applicationCode:
offering.courseRoundApplications && offering.courseRoundApplications.length > 0
? offering.courseRoundApplications[0].course_round_application_code
: '',
applicationCode: offering.courseRoundApplicationCode ?? '',
period,
courseStart:
languageIndex === 0 && offering.startDate && offering.startDate !== ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ const memos2021 = {
totalNumberOfMemosPublishedBeforeDeadline: 36,
},
documentType: 'courseMemo',
koppsApiBasePath: 'https://api-r.referens.sys.kth.se/api/kopps/v2/',
ladokApiBasePath: 'https://ladok-mellanlagring-lab.azure-api.net',
documentsApiBasePath: 'http://localhost/api/kurs-pm-data',
school: 'allSchools',
periods: ['0', '1', '2', '3', '4', '5'],
Expand Down Expand Up @@ -129,7 +129,7 @@ const memos2020 = {
totalNumberOfMemosPublishedBeforeDeadline: 45,
},
documentType: 'courseMemo',
koppsApiBasePath: 'https://api-r.referens.sys.kth.se/api/kopps/v2/',
ladokApiBasePath: 'https://ladok-mellanlagring-lab.azure-api.net',
documentsApiBasePath: 'http://localhost/api/kurs-pm-data',
school: 'allSchools',
periods: ['0', '1', '2', '3', '4', '5'],
Expand Down
12 changes: 12 additions & 0 deletions server/apiCalls/ladokApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,21 @@ async function getPeriods() {
}
}

async function getAllCourseRounds(query, lang) {
try {
const courseRounds = await client.getAllCourseRounds(query, lang)

return courseRounds
} catch (error) {
log.error(error)
return undefined
}
}

module.exports = {
getCourseAndRounds,
getExaminationModules,
getLadokSyllabuses,
getPeriods,
getAllCourseRounds,
}
11 changes: 7 additions & 4 deletions server/apiCalls/transformers/memos.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ const { findMemosForApplicationCode } = require('./docs')
const _memosPerCourseOffering = async (parsedOfferings, memos) => {
const courseOfferings = []
await parsedOfferings.forEach(offering => {
const { courseCode, firstSemester, courseRoundApplications } = offering
const [courseRoundApplication] = courseRoundApplications
const { course_round_application_code: applicationCode } = courseRoundApplication
const { courseCode, firstSemester, courseRoundApplicationCode } = offering
let courseMemoInfo = {}
const memosForApplicationCode = findMemosForApplicationCode(memos, courseCode, firstSemester, applicationCode)
const memosForApplicationCode = findMemosForApplicationCode(
memos,
courseCode,
firstSemester,
courseRoundApplicationCode
)

if (memosForApplicationCode.length === 1) {
const [publishedMemo] = memosForApplicationCode
Expand Down
170 changes: 79 additions & 91 deletions server/apiCalls/transformers/memos.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,7 @@ const offering_SF1625_202121 = {
connectedPrograms: 'TTGTM-2',
courseCode: 'SF1625',
period: 'P1',
courseRoundApplications: [
{
course_round_application_code: '1',
},
],
courseRoundApplicationCode: '1',
}
const memo_SF1625_202121_base = (courseCode = 'SF1625') => ({
courseCode,
Expand All @@ -39,11 +35,7 @@ const offering_SF1625_202122 = {
connectedPrograms: '',
courseCode: 'SF1625',
period: 'P1',
courseRoundApplications: [
{
course_round_application_code: '2',
},
],
courseRoundApplicationCode: '2',
}
const memo_SF1625_202122_base = (courseCode = 'SF1625') => ({
courseCode,
Expand Down Expand Up @@ -119,28 +111,28 @@ describe('Memos functions to count memos for one school', () => {
const { combinedMemosPerSchool } = await memosPerSchool(offerings, memos)

expect(combinedMemosPerSchool).toMatchInlineSnapshot(`
{
"schools": {
"ABE": {
"numberOfCourses": 1,
"numberOfMemosPublishedBeforeDeadline": 1,
"numberOfMemosPublishedBeforeStart": 1,
"numberOfUniqPdfMemos": 0,
"numberOfUniqWebAndPdfMemos": 1,
"numberOfUniqWebMemos": 1,
"uniqueCourseCodeDates": [
"SF1625-2021-08-30-2021-10-29",
],
"uniqueCourseCodeDatesWithoutMemo": [],
},
},
"totalCourses": 1,
"totalNumberOfMemosPublishedBeforeDeadline": 1,
"totalNumberOfMemosPublishedBeforeStart": 1,
"totalNumberOfPdfMemos": 0,
"totalNumberOfWebMemos": 1,
}
`)
{
"schools": {
"ABE": {
"numberOfCourses": 1,
"numberOfMemosPublishedBeforeDeadline": 1,
"numberOfMemosPublishedBeforeStart": 1,
"numberOfUniqPdfMemos": 0,
"numberOfUniqWebAndPdfMemos": 1,
"numberOfUniqWebMemos": 1,
"uniqueCourseCodeDates": [
"SF1625-2021-08-30-2021-10-29",
],
"uniqueCourseCodeDatesWithoutMemo": [],
},
},
"totalCourses": 1,
"totalNumberOfMemosPublishedBeforeDeadline": 1,
"totalNumberOfMemosPublishedBeforeStart": 1,
"totalNumberOfPdfMemos": 0,
"totalNumberOfWebMemos": 1,
}
`)

expect(Object.keys(combinedMemosPerSchool.schools).length).toBe(1)
expect(combinedMemosPerSchool.schools.ABE.numberOfCourses).toBe(1)
Expand Down Expand Up @@ -191,67 +183,63 @@ describe('Memos functions to count memos for one school', () => {
const { combinedMemosPerSchool, offeringsWithMemos } = await memosPerSchool(offerings, memos)
expect(offeringsWithMemos.length).toBe(1)
expect(offeringsWithMemos).toMatchInlineSnapshot(`
[
{
"connectedPrograms": "TTGTM-2",
"courseCode": "SF1625",
"courseMemoInfo": {
"applicationCodes": [
"1",
],
"courseCode": "SF1625",
"isPdf": false,
"lastChangeDate": "Tue Aug 02 2021 10:19:17 GMT+0000 (Coordinated Universal Time)",
"memoCommonLangAbbr": "sv",
"memoEndPoint": "SF162520212-1",
"memoName": "SF1625CMEDT1 (Startdatum 2021-08-30, Svenska)",
"publishedData": {
"offeringStartTime": "2021-08-30",
"publishedBeforeDeadline": true,
"publishedBeforeStart": true,
"publishedTime": "2021-08-02",
},
"semester": "20212",
"version": 1,
},
"courseRoundApplications": [
{
"course_round_application_code": "1",
},
],
"departmentName": "ABE/Geoinformatik",
"endDate": "2021-10-29",
"firstSemester": "20212",
"period": "P1",
"schoolMainCode": "ABE",
"startDate": "2021-08-30",
},
]
`)
[
{
"connectedPrograms": "TTGTM-2",
"courseCode": "SF1625",
"courseMemoInfo": {
"applicationCodes": [
"1",
],
"courseCode": "SF1625",
"isPdf": false,
"lastChangeDate": "Tue Aug 02 2021 10:19:17 GMT+0000 (Coordinated Universal Time)",
"memoCommonLangAbbr": "sv",
"memoEndPoint": "SF162520212-1",
"memoName": "SF1625CMEDT1 (Startdatum 2021-08-30, Svenska)",
"publishedData": {
"offeringStartTime": "2021-08-30",
"publishedBeforeDeadline": true,
"publishedBeforeStart": true,
"publishedTime": "2021-08-02",
},
"semester": "20212",
"version": 1,
},
"courseRoundApplicationCode": "1",
"departmentName": "ABE/Geoinformatik",
"endDate": "2021-10-29",
"firstSemester": "20212",
"period": "P1",
"schoolMainCode": "ABE",
"startDate": "2021-08-30",
},
]
`)

expect(combinedMemosPerSchool).toMatchInlineSnapshot(`
{
"schools": {
"ABE": {
"numberOfCourses": 1,
"numberOfMemosPublishedBeforeDeadline": 1,
"numberOfMemosPublishedBeforeStart": 1,
"numberOfUniqPdfMemos": 0,
"numberOfUniqWebAndPdfMemos": 1,
"numberOfUniqWebMemos": 1,
"uniqueCourseCodeDates": [
"SF1625-2021-08-30-2021-10-29",
],
"uniqueCourseCodeDatesWithoutMemo": [],
},
},
"totalCourses": 1,
"totalNumberOfMemosPublishedBeforeDeadline": 1,
"totalNumberOfMemosPublishedBeforeStart": 1,
"totalNumberOfPdfMemos": 0,
"totalNumberOfWebMemos": 1,
}
`)
{
"schools": {
"ABE": {
"numberOfCourses": 1,
"numberOfMemosPublishedBeforeDeadline": 1,
"numberOfMemosPublishedBeforeStart": 1,
"numberOfUniqPdfMemos": 0,
"numberOfUniqWebAndPdfMemos": 1,
"numberOfUniqWebMemos": 1,
"uniqueCourseCodeDates": [
"SF1625-2021-08-30-2021-10-29",
],
"uniqueCourseCodeDatesWithoutMemo": [],
},
},
"totalCourses": 1,
"totalNumberOfMemosPublishedBeforeDeadline": 1,
"totalNumberOfMemosPublishedBeforeStart": 1,
"totalNumberOfPdfMemos": 0,
"totalNumberOfWebMemos": 1,
}
`)
})

test('One course (one offering) and this offering has a memo published after course start', async () => {
Expand Down
Loading
Loading