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

fix(KUI-1176): show empty syllabus data if no syllabus exists #350

Merged
merged 7 commits into from
Jun 5, 2024
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
1 change: 0 additions & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
module.exports = {
testEnvironment: 'jsdom',
prettierPath: '<rootDir>/node_modules/prettier-2/index.js',
}
2,220 changes: 1,073 additions & 1,147 deletions package-lock.json

Large diffs are not rendered by default.

65 changes: 32 additions & 33 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,77 +27,76 @@
},
"dependencies": {
"@kth/api-call": "^4.1.0",
"@kth/appinsights": "^0.3.1",
"@kth/appinsights": "^0.4.0",
"@kth/kth-node-response": "^1.0.7",
"@kth/kth-node-web-common": "^9.3.0",
"@kth/kth-node-web-common": "^9.3.1",
"@kth/log": "^4.0.7",
"@kth/monitor": "^4.2.1",
"@kth/monitor": "^4.3.1",
"@kth/server": "^4.1.0",
"@kth/session": "^3.0.9",
"@kth/style": "^0.18.6",
"@kth/ug-rest-api-helper": "^1.0.25",
"axios": "^1.6.7",
"@kth/style": "^0.18.12",
"@kth/ug-rest-api-helper": "^1.0.26",
"axios": "^1.7.2",
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"date-fns": "^2.30.0",
"date-fns-tz": "^2.0.1",
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3",
"dotenv": "^16.4.5",
"express": "^4.18.3",
"express": "^4.19.2",
"express-handlebars": "^7.1.2",
"http-proxy-middleware": "^2.0.6",
"kth-node-access-log": "^0.2.9",
"kth-node-configuration": "^2.1.0",
"kth-node-express-routing": "^2.2.0",
"kth-node-i18n": "^1.0.18",
"kth-node-redis": "^3.3.0",
"kth-style": "^10.3.0",
"react": "^18.2.0",
"kth-style": "^10.3.3",
"react": "^18.3.1",
"react-data-table-component": "^7.6.2",
"react-dom": "^18.2.0",
"react-icons": "^5.0.1",
"react-router-dom": "^6.22.3",
"react-dom": "^18.3.1",
"react-icons": "^5.2.1",
"react-router-dom": "^6.23.1",
"reactstrap": "^9.2.2",
"sanitize-html": "^2.12.1",
"victory": "^36.9.1",
"sanitize-html": "^2.13.0",
"victory": "^36.9.2",
"xlsx": "^0.18.5"
},
"devDependencies": {
"@babel/cli": "^7.23.9",
"@babel/core": "^7.24.0",
"@babel/eslint-parser": "^7.23.10",
"@babel/plugin-transform-runtime": "^7.24.0",
"@babel/preset-env": "^7.24.0",
"@babel/preset-react": "^7.23.3",
"@babel/cli": "^7.24.6",
"@babel/core": "^7.24.6",
"@babel/eslint-parser": "^7.24.6",
"@babel/plugin-transform-runtime": "^7.24.6",
"@babel/preset-env": "^7.24.6",
"@babel/preset-react": "^7.24.6",
"@faker-js/faker": "^8.4.1",
"@kth/eslint-config-kth": "^3.4.0",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^14.2.1",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/jest": "^29.5.12",
"babel-jest": "^29.7.0",
"babel-loader": "^9.1.3",
"concurrently": "^8.2.2",
"cross-env": "^7.0.3",
"css-loader": "^6.10.0",
"css-loader": "^7.1.2",
"eslint": "^8.57.0",
"eslint-plugin-prettier": "^5.1.3",
"file-loader": "^6.2.0",
"husky": "^9.0.11",
"jest": "^29.7.0",
"jest-environment-jsdom": "29.7.0",
"lint-staged": "^15.2.2",
"mini-css-extract-plugin": "^2.8.1",
"nodemon": "^3.1.0",
"lint-staged": "^15.2.5",
"mini-css-extract-plugin": "^2.9.0",
"nodemon": "^3.1.3",
"null-loader": "^4.0.1",
"path": "^0.12.7",
"prettier": "^3.2.5",
"prettier-2": "npm:prettier@^2",
"prettier": "^3.3.0",
"prettier-eslint-cli": "^8.0.1",
"react-error-boundary": "^4.0.13",
"sass": "^1.71.1",
"sass-loader": "^14.1.1",
"sass": "^1.77.4",
"sass-loader": "^14.2.1",
"terser-webpack-plugin": "^5.3.10",
"webpack": "^5.90.3",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
},
"engines": {
Expand Down
3 changes: 3 additions & 0 deletions public/js/app/hooks/useSemesterRoundState.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ const useSemesterRoundState = ({
return getValidSyllabusForSemester(syllabusList, selectedSemester)
}, [syllabusList, selectedSemester])

/**
* Is true if the course has a non-empty syllabus
*/
const hasSyllabus = useMemo(
() => syllabusList && syllabusList.length > 0 && activeSyllabus !== undefined,
[activeSyllabus, syllabusList]
Expand Down
8 changes: 4 additions & 4 deletions public/js/app/pages/CoursePage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function CoursePage() {
hasSyllabus,
} = semesterRoundState

const { courseInfo } = courseData
const { courseInfo, emptySyllabusData } = courseData
const { translation, languageShortname } = useLanguage()

const { isMissingInfoLabel } = useMissingInfo()
Expand Down Expand Up @@ -317,10 +317,10 @@ function CoursePage() {
{/* --- COURSE INFORMATION CONTAINER--- */}
<CourseSectionList
courseInfo={courseInfo}
syllabus={activeSyllabus}
hasSyllabus={hasSyllabus}
// if there is no syllabus, we still want to display empty syllabus data
syllabus={hasSyllabus ? activeSyllabus : emptySyllabusData}
partToShow="courseContentBlock"
syllabusName={hasSyllabus ? syllabusName : ''}
syllabusName={syllabusName}
/>

{/* ---IF RESEARCH LEVEL: SHOW "Postgraduate course" LINK-- */}
Expand Down
3 changes: 2 additions & 1 deletion server/apiCalls/getFilteredData.js
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ const getFilteredData = async ({ courseCode, language, memoList }) => {
const courseTitleData = _parseTitleData(courseDetails)

//* **** Get list of syllabuses and valid syllabus semesters *****//
const { syllabusList } = createSyllabusList(courseDetails, language)
const { syllabusList, emptySyllabusData } = createSyllabusList(courseDetails, language)

//* **** Get a list of rounds and a list of redis keys for using to get teachers and responsibles from UG Rest API *****//
const { roundsBySemester, activeSemesters, employees } = _parseRounds({
Expand All @@ -273,6 +273,7 @@ const getFilteredData = async ({ courseCode, language, memoList }) => {
roundsBySemester,
courseTitleData,
language,
emptySyllabusData,
}

return {
Expand Down
17 changes: 17 additions & 0 deletions server/controllers/__tests__/courseCtrl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,23 @@ describe('Discontinued course to test', () => {
"course_other_title": "Carbohydrate Technologies in Glycoscience",
"course_title": "Kolhydratteknik inom glykovetenskap",
},
"emptySyllabusData": {
"course_additional_regulations": "",
"course_content": "<i>Ingen information tillagd</i>",
"course_decision_to_discontinue": "",
"course_eligibility": "<i>Ingen information tillagd</i>",
"course_ethical": "",
"course_examination": "<i>Ingen information tillagd</i>",
"course_examination_comments": "",
"course_goals": "<i>Ingen information tillagd</i>",
"course_literature": "<i>Ingen information tillagd</i>",
"course_literature_comment": "<i>Ingen information tillagd</i>",
"course_required_equipment": "",
"course_requirments_for_final_grade": "",
"course_transitional_reg": "",
"course_valid_from": undefined,
"course_valid_to": undefined,
},
"language": "sv",
"roundsBySemester": {},
"syllabusList": [
Expand Down
3 changes: 3 additions & 0 deletions server/controllers/createSyllabusList.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ const _parseSyllabusData = (courseDetails, semesterIndex = 0, language) => {

const createSyllabusList = (courseDetails, lang) => {
const { publicSyllabusVersions } = courseDetails
const emptySyllabusData = _createEmptySyllabusData(lang)

if (publicSyllabusVersions.length === 0) {
return {
syllabusList: [],
emptySyllabusData,
}
}

Expand All @@ -123,6 +125,7 @@ const createSyllabusList = (courseDetails, lang) => {

return {
syllabusList,
emptySyllabusData,
}
}

Expand Down
Loading