mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-13 03:13:40 +03:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ed71a0ce3b | ||
|
|
f3c290a5ee | ||
|
|
7ab8236e14 | ||
|
|
a884069e77 | ||
|
|
1d8a06c477 | ||
|
|
88ba4af98c | ||
|
|
4ed75331ff | ||
|
|
63c2d9756f | ||
|
|
2592adfd18 | ||
|
|
d8976adb46 | ||
|
|
f47f4bca29 | ||
|
|
a5d824b927 | ||
|
|
e20e1137ae | ||
|
|
11792b0397 | ||
|
|
3cb2e370aa | ||
|
|
db5b0a29cd | ||
|
|
79f9a59116 | ||
|
|
fdba5dc6a6 | ||
|
|
d0e8a9632d | ||
|
|
16b7debbb5 | ||
|
|
6081bb3e78 | ||
|
|
de2823f3b5 | ||
|
|
07e2dabe3f | ||
|
|
1cccecc7f5 | ||
|
|
37a50731aa | ||
|
|
eba296f5fd | ||
|
|
fbe0b0af3a | ||
|
|
ea4d299f16 | ||
|
|
f2f9bdd9e8 | ||
|
|
4b86ed252f | ||
|
|
f535a5dbdb | ||
|
|
ffe6425999 | ||
|
|
256997633a | ||
|
|
1d3fef6c8d | ||
|
|
428e46084c | ||
|
|
09f4814f80 | ||
|
|
a220050a53 | ||
|
|
115674636f | ||
|
|
f901fec6a3 | ||
|
|
a77ba0e1e1 | ||
|
|
434183bac0 | ||
|
|
7993c2b45a | ||
|
|
8551a76fc9 | ||
|
|
b25f9ba55f | ||
|
|
f28276e086 | ||
|
|
6327ca7e2c | ||
|
|
625f2962eb | ||
|
|
f85e9f0a5d | ||
|
|
d4d67b239e | ||
|
|
83d17a3026 | ||
|
|
e3f8fdb4ae | ||
|
|
b7051ccd41 | ||
|
|
b0a0be7969 | ||
|
|
896cb46ad1 | ||
|
|
17f7289b1c | ||
|
|
a019dd9672 | ||
|
|
881aaf93b4 | ||
|
|
5c973d4f8c | ||
|
|
f9e8bf6d31 | ||
|
|
a2726d4894 | ||
|
|
11377da7bd | ||
|
|
8c4515b158 | ||
|
|
db3cd52d69 | ||
|
|
b4c8bf0f4a | ||
|
|
384afb1e5f | ||
|
|
090d327405 | ||
|
|
30117e60b3 | ||
|
|
9a4fec0974 | ||
|
|
37114c5570 | ||
|
|
63b7c5876d | ||
|
|
9790c829c6 | ||
|
|
082aaa4022 | ||
|
|
3906efbcca | ||
|
|
9d575d6c88 | ||
|
|
4d4a288719 | ||
|
|
a39f522501 | ||
|
|
32293eb050 | ||
|
|
ed56d32cce | ||
|
|
f4b04d3283 | ||
|
|
3a6e5132f3 | ||
|
|
694e537baa | ||
|
|
372ac53a46 | ||
|
|
5d9bbe368c | ||
|
|
3d552a5811 | ||
|
|
624a103f08 | ||
|
|
9f56554ed9 | ||
|
|
0d1bc3c519 | ||
|
|
aa1d21bc09 | ||
|
|
eaf5d7574e | ||
|
|
9db14a839f | ||
|
|
b55d649622 | ||
|
|
47c792e1f1 | ||
|
|
fffa3d3ee1 | ||
|
|
c9407ff4b0 | ||
|
|
1b43d4fc39 | ||
|
|
c0ce396d4d | ||
|
|
f15ffa95f5 | ||
|
|
765d2f771a | ||
|
|
e1271d7d1f | ||
|
|
7f632bde34 | ||
|
|
9dd47d002d | ||
|
|
16a07ace39 | ||
|
|
ac756cb35b | ||
|
|
b9059eb058 | ||
|
|
1f967a1f2c | ||
|
|
e8ef944a9d | ||
|
|
0e9ea20235 | ||
|
|
8d4f1c7794 | ||
|
|
6f3e4b8f64 | ||
|
|
316ed2af2f | ||
|
|
2f753d976b | ||
|
|
9b6aa96531 | ||
|
|
229a64aa45 | ||
|
|
6456b84777 | ||
|
|
9d34c34de7 | ||
|
|
2573976ea4 | ||
|
|
389b71cfbf | ||
|
|
c0ee74b7f8 | ||
|
|
e3fbf91b99 | ||
|
|
3d1f7cc655 | ||
|
|
069bd97729 | ||
|
|
96fded285b | ||
|
|
9c172c2f97 | ||
|
|
d37b037cc6 | ||
|
|
a55eef0f34 | ||
|
|
01ec83d909 | ||
|
|
81e8a0c77e | ||
|
|
7782f4f863 | ||
|
|
80f52355bb | ||
|
|
28cf6c855d | ||
|
|
6d446a1c05 | ||
|
|
d8214e7432 | ||
|
|
a8b04d56d6 | ||
|
|
0fc7bfda51 | ||
|
|
5614a6eb3f | ||
|
|
dfde4adf87 | ||
|
|
32a8c7c261 | ||
|
|
b7390912f4 | ||
|
|
6af7a1a5d0 | ||
|
|
e24b63da74 | ||
|
|
bb5bb8d04e | ||
|
|
a91fb5d7b7 | ||
|
|
5369e75b61 | ||
|
|
7a43433947 | ||
|
|
656870028e | ||
|
|
1315d7ca81 | ||
|
|
3b1f002ac8 | ||
|
|
00116544bf | ||
|
|
7bbccc9a81 | ||
|
|
c18187d094 | ||
|
|
7688a22c53 | ||
|
|
49df0a0d21 | ||
|
|
449e8976d9 | ||
|
|
6871502cb9 | ||
|
|
b72bedc49f | ||
|
|
9f300ccab0 | ||
|
|
cb8aa00f6f | ||
|
|
4a05f136cc | ||
|
|
50840a3fe2 | ||
|
|
ac440ff843 | ||
|
|
b6d28c6cff |
Binary file not shown.
|
Before Width: | Height: | Size: 106 KiB |
@@ -50,7 +50,11 @@ What different CLI options do:
|
||||
|
||||
### Architecture
|
||||
|
||||

|
||||

|
||||
|
||||
### Documentation
|
||||
|
||||
Folder `documentation` currently contains some notes on sis-db schema and is meant as a place for storing useful information on Oodikone to make life easier for future developers. Feel free to add anything relevant!
|
||||
|
||||
### Basics
|
||||
|
||||
|
||||
@@ -247,8 +247,8 @@ describe('Faculty overview', () => {
|
||||
cy.get('[data-cy="Graph-FacultyMastersProgress"]').should('be.visible')
|
||||
cy.get('[data-cy="Graph-FacultyBachelorsProgress"]').should('be.visible')
|
||||
})
|
||||
// Following two tests just test that nothig goes broken after toggling
|
||||
// No data for testing that the data actual changes as supposed
|
||||
// Following two tests just test that nothing goes broken after toggling
|
||||
// No data for testing that data actual change as supposed
|
||||
it('Graduations can be excluded', () => {
|
||||
cy.get('[data-cy="FacultyStudentStatsTable"]').should('be.visible')
|
||||
cy.get('[data-cy="StudentToggle"]').click()
|
||||
@@ -269,16 +269,16 @@ describe('Faculty overview', () => {
|
||||
})
|
||||
|
||||
it('Progress tables can be toggled', () => {
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-0"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Button-Show-FacultyBachelorsProgressTable-0"]').click()
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-0"]').should('be.visible')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-1"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-2"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-3"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-4"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-5"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Button-Hide-FacultyBachelorsProgressTable-0"]').click()
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-0"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-6"]').should('not.be.visible')
|
||||
cy.get('[data-cy="Button-Show-FacultyBachelorsProgressTable-6"]').click()
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-0"]').should('not.exist')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-1"]').should('not.exist')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-2"]').should('not.exist')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-3"]').should('not.exist')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-4"]').should('not.exist')
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-6"]').should('be.visible')
|
||||
cy.get('[data-cy="Button-Hide-FacultyBachelorsProgressTable-6"]').click()
|
||||
cy.get('[data-cy="Cell-FacultyBachelorsProgressTable-6"]').should('not.be.visible')
|
||||
})
|
||||
|
||||
it('Sudent statstable can be toggled', () => {
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable cypress/no-unnecessary-waiting */
|
||||
/// <reference types="Cypress" />
|
||||
|
||||
// const baseUrl = Cypress.config().baseUrl
|
||||
@@ -20,6 +21,7 @@ const clearSingleDropdownSelection = dataCyAttribute => {
|
||||
}
|
||||
|
||||
const testRangeFilter = (parentEl, min, max, expected) => {
|
||||
cy.clock(MOCKED_DATE, ['Date'])
|
||||
cy.cs(parentEl)
|
||||
.cs('range-selector-min')
|
||||
.find('input')
|
||||
@@ -49,8 +51,6 @@ const createRunTestStepWithPreAndPostPartsFunction = amountWithoutFiltering => {
|
||||
const card = cy.cs(`${filterName}-filter-card`)
|
||||
|
||||
card.invoke('attr', 'data-open').then(open => {
|
||||
console.log('open', open)
|
||||
|
||||
const getHeader = () => cy.cs(`${filterName}-header`)
|
||||
|
||||
if (open === 'false') {
|
||||
@@ -136,6 +136,7 @@ describe('Population Statistics', () => {
|
||||
runTestStepWithPreAndPostParts('CreditsEarned', () => {
|
||||
testRangeFilter('CreditsEarned-filter-card', 50, 150, 118)
|
||||
})
|
||||
cy.cs('reset-all-filters').click()
|
||||
})
|
||||
|
||||
it('Age filter works', () => {
|
||||
@@ -146,6 +147,7 @@ describe('Population Statistics', () => {
|
||||
})
|
||||
|
||||
it('Gender filter works', () => {
|
||||
cy.cs('reset-all-filters').click()
|
||||
runTestStepWithPreAndPostParts('Gender', () => {
|
||||
cy.cs('genderFilter-dropdown').selectFromDropdown(0)
|
||||
checkFilteringResult(42)
|
||||
@@ -260,8 +262,8 @@ describe('Course Statistics', () => {
|
||||
programmeDropdown.get('i.delete').click()
|
||||
})
|
||||
})
|
||||
|
||||
it('Age filter works', () => {
|
||||
// FIX THIS SOON!
|
||||
it.skip('Age filter works', () => {
|
||||
cy.clock(MOCKED_DATE, ['Date'])
|
||||
runTestStepWithPreAndPostParts('Age', () => {
|
||||
testRangeFilter('Age-filter-card', 20, 40, 33)
|
||||
@@ -269,6 +271,7 @@ describe('Course Statistics', () => {
|
||||
})
|
||||
|
||||
it('Gender filter works', () => {
|
||||
cy.cs('reset-all-filters').click()
|
||||
runTestStepWithPreAndPostParts('Gender', () => {
|
||||
cy.cs('genderFilter-dropdown').selectFromDropdown(0)
|
||||
checkFilteringResult(27)
|
||||
@@ -325,6 +328,7 @@ describe('Custom Population Statistics', () => {
|
||||
runTestStepWithPreAndPostParts('Age', () => {
|
||||
testRangeFilter('Age-filter-card', 20, 30, 1)
|
||||
})
|
||||
cy.cs('reset-all-filters').click()
|
||||
})
|
||||
|
||||
it('Programme defaults to "Active Study Right" mode', () => {
|
||||
|
||||
@@ -217,8 +217,8 @@ describe('Population Statistics tests', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// Fails in CI, not worth the effort to fix
|
||||
/* describe('when using IAM user', () => {
|
||||
/*
|
||||
describe('when using IAM user', () => {
|
||||
beforeEach(() => {
|
||||
cy.init(pathToCSBach2017, 'onlyiamrights')
|
||||
})
|
||||
@@ -242,5 +242,6 @@ describe('Population Statistics tests', () => {
|
||||
cy.contains('Students (170)').should('not.exist')
|
||||
// TODO: somehow check that obfuscation works
|
||||
})
|
||||
}) */
|
||||
})
|
||||
*/
|
||||
})
|
||||
|
||||
@@ -236,6 +236,8 @@ describe('Studyprogramme overview', () => {
|
||||
describe('Studytrack overview works for basic user', () => {
|
||||
beforeEach(() => {
|
||||
cy.init('/study-programme')
|
||||
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
||||
cy.wait(10000)
|
||||
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
|
||||
cy.get('.attached').contains('Studytracks and class statistics').click()
|
||||
})
|
||||
@@ -298,6 +300,8 @@ describe('Studyprogramme overview', () => {
|
||||
describe('Programme courses works for basic user', () => {
|
||||
beforeEach(() => {
|
||||
cy.init('/study-programme')
|
||||
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
||||
cy.wait(10000)
|
||||
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
|
||||
cy.get('.attached').contains('Programme courses').click()
|
||||
})
|
||||
@@ -365,7 +369,7 @@ describe('Studyprogramme overview', () => {
|
||||
cy.get('[data-cy=creditsStudentsToggle]').first().click()
|
||||
|
||||
cy.get('[data-cy=CoursesSortableTable]').within(() => {
|
||||
cy.get('tr').eq(1).contains('267')
|
||||
cy.get('tr').eq(2).contains('267')
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -374,6 +378,8 @@ describe('Studyprogramme overview', () => {
|
||||
describe('Basic information -view works for basic user', () => {
|
||||
beforeEach(() => {
|
||||
cy.init('/study-programme')
|
||||
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
||||
cy.wait(10000)
|
||||
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
|
||||
cy.get('.attached').contains('Tags').click()
|
||||
})
|
||||
@@ -434,8 +440,8 @@ describe('Studyprogramme overview', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// Fails in CI and not worth the effor to fix
|
||||
/* describe('IAM user', () => {
|
||||
/*
|
||||
describe('IAM user', () => {
|
||||
beforeEach(() => {
|
||||
cy.init('/study-programme', 'onlyiamrights')
|
||||
|
||||
@@ -469,5 +475,6 @@ describe('Studyprogramme overview', () => {
|
||||
cy.get('[data-cy=Section-StudytrackProgress]')
|
||||
cy.get('[data-cy=Section-AverageGraduationTimesStudytracks]')
|
||||
})
|
||||
}) */
|
||||
})
|
||||
*/
|
||||
})
|
||||
|
||||
+15
-1
@@ -66,12 +66,26 @@ services:
|
||||
<<: *defaults
|
||||
image: toska/jami
|
||||
environment:
|
||||
- NODE_ENV=production
|
||||
- PORT=3003
|
||||
- NODE_ENV=production
|
||||
- POSTGRES_HOST=jami-db
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DATABASE=postgres
|
||||
ports:
|
||||
- 3003:3003
|
||||
container_name: jami
|
||||
|
||||
jami-db:
|
||||
<<: *defaults
|
||||
image: postgres:13.2
|
||||
environment:
|
||||
- PGDATA=/data
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
container_name: jami-db
|
||||
ports:
|
||||
- 5433:5432
|
||||
|
||||
nginx:
|
||||
image: nginx:latest
|
||||
container_name: nginx
|
||||
|
||||
+18
-1
@@ -172,12 +172,28 @@ services:
|
||||
<<: *defaults
|
||||
image: toska/jami
|
||||
environment:
|
||||
- NODE_ENV=development
|
||||
- PORT=3003
|
||||
- NODE_ENV=dev
|
||||
- POSTGRES_HOST=jami-db
|
||||
- POSTGRES_USER=postgres
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
- POSTGRES_DATABASE=postgres
|
||||
ports:
|
||||
- 3003:3003
|
||||
container_name: jami
|
||||
|
||||
jami-db:
|
||||
<<: *defaults
|
||||
image: postgres:13.2
|
||||
environment:
|
||||
- PGDATA=/data
|
||||
- POSTGRES_PASSWORD=postgres
|
||||
container_name: jami-db
|
||||
ports:
|
||||
- 5433:5432
|
||||
volumes:
|
||||
- jami-data:/data
|
||||
|
||||
volumes:
|
||||
backend-nodemod:
|
||||
frontend-nodemod:
|
||||
@@ -188,3 +204,4 @@ volumes:
|
||||
sis-updater-scheduler-nodemod:
|
||||
sis-updater-worker-nodemod:
|
||||
user-db-data:
|
||||
jami-data:
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 106 KiB |
File diff suppressed because one or more lines are too long
|
After Width: | Height: | Size: 72 KiB |
@@ -0,0 +1,48 @@
|
||||
# Mystery numbers
|
||||
|
||||
Sis data uses some numeric classifiers that are not self-explanatory and (most) previously needed to be deciphered from existing code.
|
||||
Some mystery numbers are gathered here for convenience. Feel free to add anything that could be useful. Remember to use the spelling used in code to enable project wide search.
|
||||
|
||||
## extentcode
|
||||
|
||||
(from **studyright**)
|
||||
|
||||
These are actually defined in db table studyright_extents. Tells studyright level or type, eg. bachelor's degree or non-degree studies.
|
||||
|
||||
## prioritycode
|
||||
|
||||
(from **studyright**)
|
||||
|
||||
1: Primary
|
||||
|
||||
2: Secondary
|
||||
|
||||
5: Rescinded (Seemingly not in use anymore)
|
||||
|
||||
6: Option
|
||||
|
||||
30: Graduated
|
||||
|
||||
## type
|
||||
|
||||
(from **element_details**)
|
||||
|
||||
20: A study programme
|
||||
|
||||
30: Module/Studytrack/kokonaisuus? Eg. Neurology
|
||||
|
||||
## enrollmenttype
|
||||
|
||||
(from **semester_enrollments**)
|
||||
|
||||
1: Present
|
||||
|
||||
2: Absent
|
||||
|
||||
3: Inactive (neither 1 or 2 has been declared)
|
||||
|
||||
## credittypecode
|
||||
|
||||
(from **credit**)
|
||||
|
||||
Defined in credit_types db table. Completed/Improved/Transferred/Failed
|
||||
Generated
+533
-882
File diff suppressed because it is too large
Load Diff
+10
-10
@@ -29,28 +29,28 @@
|
||||
},
|
||||
"homepage": "https://github.com/UniversityOfHelsinkiCS/oodikone#readme",
|
||||
"devDependencies": {
|
||||
"@babel/core": "^7.20.12",
|
||||
"@babel/core": "^7.19.3",
|
||||
"@babel/eslint-parser": "^7.19.1",
|
||||
"@babel/plugin-syntax-jsx": "^7.16.7",
|
||||
"concurrently": "^7.6.0",
|
||||
"concurrently": "^7.4.0",
|
||||
"cypress": "^10.9.0",
|
||||
"eslint": "^8.31.0",
|
||||
"eslint": "^8.25.0",
|
||||
"eslint-config-airbnb": "^19.0.4",
|
||||
"eslint-config-prettier": "^8.6.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-plugin-babel": "^5.3.1",
|
||||
"eslint-plugin-cypress": "^2.12.1",
|
||||
"eslint-plugin-import": "^2.25.4",
|
||||
"eslint-plugin-jsx-a11y": "^6.5.1",
|
||||
"eslint-plugin-prefer-object-spread": "^1.2.1",
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-react": "^7.31.11",
|
||||
"eslint-plugin-react": "^7.31.9",
|
||||
"eslint-plugin-react-hooks": "^4.3.0",
|
||||
"husky": "^8.0.3",
|
||||
"lint-staged": "^13.1.0",
|
||||
"husky": "^8.0.1",
|
||||
"lint-staged": "^13.0.3",
|
||||
"node-actionlint": "^1.2.2",
|
||||
"prettier": "^2.8.2",
|
||||
"stylelint": "^14.16.1",
|
||||
"stylelint-config-prettier": "^9.0.4",
|
||||
"prettier": "^2.5.1",
|
||||
"stylelint": "^14.13.0",
|
||||
"stylelint-config-prettier": "^9.0.3",
|
||||
"stylelint-config-standard": "^26.0.0",
|
||||
"stylelint-prettier": "^2.0.0"
|
||||
},
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
PROJECT_ROOT="$(git rev-parse --show-toplevel)"
|
||||
DUMP_DIR="$PROJECT_ROOT/.databasedumps"
|
||||
USER_DATA_FILE="$DUMP_DIR/hyuserdata"
|
||||
DOCKER_COMPOSE=$PROJECT_ROOT/docker-compose.yml
|
||||
|
||||
## Following the naming convention in docker-compose, these are names for database
|
||||
## services. The real data databases inside service will have names suffixed by "-real".
|
||||
@@ -100,6 +101,28 @@ reset_databases() {
|
||||
successmsg "Database setup finished"
|
||||
}
|
||||
|
||||
reset_jami_data() {
|
||||
local database="jami-db"
|
||||
local pannu_url="svm-85.cs.helsinki.fi:/home/toska_user/most_recent_backup_store/jami.sql.gz"
|
||||
local dump_destination="$DUMP_DIR/$database.sqz"
|
||||
|
||||
infomsg "Downloading Jami data"
|
||||
scp -r -o ProxyCommand="ssh -l $username -W %h:%p melkki.cs.helsinki.fi" "$username@$pannu_url" "$dump_destination"
|
||||
|
||||
infomsg "Removing database and related volume"
|
||||
docker volume rm oodikone_jami-data || warningmsg "This is okay, continuing"
|
||||
docker-compose -f "$DOCKER_COMPOSE" down "$database" || warningmsg "This is okay, continuing"
|
||||
|
||||
infomsg "Starting postgres in the background"
|
||||
docker-compose -f "$DOCKER_COMPOSE" up -d "$database"
|
||||
retry docker-compose -f "$DOCKER_COMPOSE" exec "$database" pg_isready --dbname="postgres"
|
||||
|
||||
infomsg "Populating Jami"
|
||||
docker exec -i "$database" /bin/bash -c "gunzip | psql -U postgres" < "$dump_destination"
|
||||
docker-compose stop "$database"
|
||||
msg ""
|
||||
}
|
||||
|
||||
reset_all_real_data() {
|
||||
infomsg "Downloading real data dumps, asking for pannu password when needed"
|
||||
for i in ${!DATABASES[*]}; do
|
||||
@@ -108,6 +131,7 @@ reset_all_real_data() {
|
||||
download_real_dump "$database" "$url"
|
||||
done
|
||||
reset_databases "${DATABASES[@]}"
|
||||
reset_jami_data
|
||||
}
|
||||
|
||||
reset_single_database() {
|
||||
@@ -119,6 +143,7 @@ reset_single_database() {
|
||||
"sis-db"
|
||||
"sis-importer-db"
|
||||
"user-db"
|
||||
"jami-db"
|
||||
"Return to main menu."
|
||||
)
|
||||
|
||||
@@ -144,6 +169,9 @@ reset_single_database() {
|
||||
local database=$USER_DB_NAME
|
||||
local url=$USER_DB_REAL_DUMP_URL
|
||||
break 2;;
|
||||
"jami-db")
|
||||
reset_jami_data
|
||||
break 2;;
|
||||
"Return to main menu.")
|
||||
break 2;;
|
||||
*) msg "${RED}Invalid option:${NOFORMAT} $REPLY
|
||||
|
||||
@@ -125,7 +125,7 @@ const codes = {
|
||||
T922106: 'foodhealth',
|
||||
T923101: 'papu',
|
||||
T923102: 'geodoc',
|
||||
T923103: 'atm',
|
||||
T923103: 'atm-dp',
|
||||
T923104: 'chems',
|
||||
T923105: 'domast',
|
||||
T923106: 'matrena',
|
||||
|
||||
Generated
+29
-29
@@ -9,7 +9,7 @@
|
||||
"@sentry/node": "^5.30.0",
|
||||
"@sentry/tracing": "^6.18.2",
|
||||
"async": "^3.2.3",
|
||||
"async-lock": "^1.4.0",
|
||||
"async-lock": "^1.3.1",
|
||||
"axios": "^0.21.4",
|
||||
"bluebird": "^3.7.2",
|
||||
"cors": "^2.8.5",
|
||||
@@ -19,11 +19,11 @@
|
||||
"lodash": "^4.17.21",
|
||||
"lru-cache": "^5.1.1",
|
||||
"moment": "^2.29.1",
|
||||
"moment-timezone": "^0.5.40",
|
||||
"moment-timezone": "^0.5.37",
|
||||
"morgan": "^1.10.0",
|
||||
"pg": "^8.8.0",
|
||||
"redis": "^3.1.2",
|
||||
"sequelize": "^6.28.0",
|
||||
"sequelize": "^6.24.0",
|
||||
"umzug": "^2.3.0",
|
||||
"unfuck-utf8-headers-middleware": "^1.0.1",
|
||||
"uuid": "^3.4.0",
|
||||
@@ -394,9 +394,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/async-lock": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/async-lock/-/async-lock-1.4.0.tgz",
|
||||
"integrity": "sha512-coglx5yIWuetakm3/1dsX9hxCNox22h7+V80RQOu2XUUMidtArxKoZoOtHUPuR84SycKTXzgGzAUR5hJxujyJQ=="
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/async-lock/-/async-lock-1.3.2.tgz",
|
||||
"integrity": "sha512-phnXdS3RP7PPcmP6NWWzWMU0sLTeyvtZCxBPpZdkYE3seGLKSQZs9FrmVO/qwypq98FUtWWUEYxziLkdGk5nnA=="
|
||||
},
|
||||
"node_modules/atob": {
|
||||
"version": "2.1.2",
|
||||
@@ -2209,9 +2209,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/moment-timezone": {
|
||||
"version": "0.5.40",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.40.tgz",
|
||||
"integrity": "sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg==",
|
||||
"version": "0.5.37",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.37.tgz",
|
||||
"integrity": "sha512-uEDzDNFhfaywRl+vwXxffjjq1q0Vzr+fcQpQ1bU0kbzorfS7zVtZnCnGc8mhWmF39d4g4YriF6kwA75mJKE/Zg==",
|
||||
"dependencies": {
|
||||
"moment": ">= 2.9.0"
|
||||
},
|
||||
@@ -3013,9 +3013,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/retry-as-promised": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.3.tgz",
|
||||
"integrity": "sha512-SEvMa4khHvpU/o6zgh7sK24qm6rxVgKnrSyzb5POeDvZx5N9Bf0s5sQsQ4Fl+HjRp0X+w2UzACGfUnXtx6cJ9Q=="
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-6.1.0.tgz",
|
||||
"integrity": "sha512-Hj/jY+wFC+SB9SDlIIFWiGOHnNG0swYbGYsOj2BJ8u2HKUaobNKab0OIC0zOLYzDy0mb7A4xA5BMo4LMz5YtEA=="
|
||||
},
|
||||
"node_modules/safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
@@ -3108,9 +3108,9 @@
|
||||
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA=="
|
||||
},
|
||||
"node_modules/sequelize": {
|
||||
"version": "6.28.0",
|
||||
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.28.0.tgz",
|
||||
"integrity": "sha512-+WHqvUQgTp19GLkt+gyQ+F6qg+FIEO2O5F9C0TOYV/PjZ2a/XwWvVkL1NCkS4VSIjVVvAUutiW6Wv9ofveGaVw==",
|
||||
"version": "6.24.0",
|
||||
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.24.0.tgz",
|
||||
"integrity": "sha512-mPo7Q7gWkrsstjR2aw8ahkrj8RUJCozz3kedAz2B5ZIdLoQEH1z2tvaeJONI8R6RqeuyRQosx9Yn3s9yQyo6lQ==",
|
||||
"funding": [
|
||||
{
|
||||
"type": "opencollective",
|
||||
@@ -3127,7 +3127,7 @@
|
||||
"moment": "^2.29.1",
|
||||
"moment-timezone": "^0.5.34",
|
||||
"pg-connection-string": "^2.5.0",
|
||||
"retry-as-promised": "^7.0.3",
|
||||
"retry-as-promised": "^6.1.0",
|
||||
"semver": "^7.3.5",
|
||||
"sequelize-pool": "^7.1.0",
|
||||
"toposort-class": "^1.0.1",
|
||||
@@ -4443,9 +4443,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"async-lock": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/async-lock/-/async-lock-1.4.0.tgz",
|
||||
"integrity": "sha512-coglx5yIWuetakm3/1dsX9hxCNox22h7+V80RQOu2XUUMidtArxKoZoOtHUPuR84SycKTXzgGzAUR5hJxujyJQ=="
|
||||
"version": "1.3.2",
|
||||
"resolved": "https://registry.npmjs.org/async-lock/-/async-lock-1.3.2.tgz",
|
||||
"integrity": "sha512-phnXdS3RP7PPcmP6NWWzWMU0sLTeyvtZCxBPpZdkYE3seGLKSQZs9FrmVO/qwypq98FUtWWUEYxziLkdGk5nnA=="
|
||||
},
|
||||
"atob": {
|
||||
"version": "2.1.2",
|
||||
@@ -5888,9 +5888,9 @@
|
||||
"integrity": "sha512-5LC9SOxjSc2HF6vO2CyuTDNivEdoz2IvyJJGj6X8DJ0eFyfszE0QiEd+iXmBvUP3WHxSjFH/vIsA0EN00cgr8w=="
|
||||
},
|
||||
"moment-timezone": {
|
||||
"version": "0.5.40",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.40.tgz",
|
||||
"integrity": "sha512-tWfmNkRYmBkPJz5mr9GVDn9vRlVZOTe6yqY92rFxiOdWXbjaR0+9LwQnZGGuNR63X456NqmEkbskte8tWL5ePg==",
|
||||
"version": "0.5.37",
|
||||
"resolved": "https://registry.npmjs.org/moment-timezone/-/moment-timezone-0.5.37.tgz",
|
||||
"integrity": "sha512-uEDzDNFhfaywRl+vwXxffjjq1q0Vzr+fcQpQ1bU0kbzorfS7zVtZnCnGc8mhWmF39d4g4YriF6kwA75mJKE/Zg==",
|
||||
"requires": {
|
||||
"moment": ">= 2.9.0"
|
||||
}
|
||||
@@ -6513,9 +6513,9 @@
|
||||
"dev": true
|
||||
},
|
||||
"retry-as-promised": {
|
||||
"version": "7.0.3",
|
||||
"resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-7.0.3.tgz",
|
||||
"integrity": "sha512-SEvMa4khHvpU/o6zgh7sK24qm6rxVgKnrSyzb5POeDvZx5N9Bf0s5sQsQ4Fl+HjRp0X+w2UzACGfUnXtx6cJ9Q=="
|
||||
"version": "6.1.0",
|
||||
"resolved": "https://registry.npmjs.org/retry-as-promised/-/retry-as-promised-6.1.0.tgz",
|
||||
"integrity": "sha512-Hj/jY+wFC+SB9SDlIIFWiGOHnNG0swYbGYsOj2BJ8u2HKUaobNKab0OIC0zOLYzDy0mb7A4xA5BMo4LMz5YtEA=="
|
||||
},
|
||||
"safe-buffer": {
|
||||
"version": "5.2.1",
|
||||
@@ -6584,9 +6584,9 @@
|
||||
}
|
||||
},
|
||||
"sequelize": {
|
||||
"version": "6.28.0",
|
||||
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.28.0.tgz",
|
||||
"integrity": "sha512-+WHqvUQgTp19GLkt+gyQ+F6qg+FIEO2O5F9C0TOYV/PjZ2a/XwWvVkL1NCkS4VSIjVVvAUutiW6Wv9ofveGaVw==",
|
||||
"version": "6.24.0",
|
||||
"resolved": "https://registry.npmjs.org/sequelize/-/sequelize-6.24.0.tgz",
|
||||
"integrity": "sha512-mPo7Q7gWkrsstjR2aw8ahkrj8RUJCozz3kedAz2B5ZIdLoQEH1z2tvaeJONI8R6RqeuyRQosx9Yn3s9yQyo6lQ==",
|
||||
"requires": {
|
||||
"@types/debug": "^4.1.7",
|
||||
"@types/validator": "^13.7.1",
|
||||
@@ -6597,7 +6597,7 @@
|
||||
"moment": "^2.29.1",
|
||||
"moment-timezone": "^0.5.34",
|
||||
"pg-connection-string": "^2.5.0",
|
||||
"retry-as-promised": "^7.0.3",
|
||||
"retry-as-promised": "^6.1.0",
|
||||
"semver": "^7.3.5",
|
||||
"sequelize-pool": "^7.1.0",
|
||||
"toposort-class": "^1.0.1",
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
"@sentry/node": "^5.30.0",
|
||||
"@sentry/tracing": "^6.18.2",
|
||||
"async": "^3.2.3",
|
||||
"async-lock": "^1.4.0",
|
||||
"async-lock": "^1.3.1",
|
||||
"axios": "^0.21.4",
|
||||
"bluebird": "^3.7.2",
|
||||
"cors": "^2.8.5",
|
||||
@@ -20,11 +20,11 @@
|
||||
"lodash": "^4.17.21",
|
||||
"lru-cache": "^5.1.1",
|
||||
"moment": "^2.29.1",
|
||||
"moment-timezone": "^0.5.40",
|
||||
"moment-timezone": "^0.5.37",
|
||||
"morgan": "^1.10.0",
|
||||
"pg": "^8.8.0",
|
||||
"redis": "^3.1.2",
|
||||
"sequelize": "^6.28.0",
|
||||
"sequelize": "^6.24.0",
|
||||
"umzug": "^2.3.0",
|
||||
"unfuck-utf8-headers-middleware": "^1.0.1",
|
||||
"uuid": "^3.4.0",
|
||||
|
||||
+33
@@ -0,0 +1,33 @@
|
||||
const { INTEGER, STRING, ARRAY, DATE } = require('sequelize')
|
||||
|
||||
module.exports = {
|
||||
up: async queryInterface => {
|
||||
await queryInterface.createTable('progress_criteria', {
|
||||
code: {
|
||||
type: STRING,
|
||||
primaryKey: true,
|
||||
},
|
||||
courses_year_one: {
|
||||
type: ARRAY(STRING),
|
||||
},
|
||||
courses_year_two: {
|
||||
type: ARRAY(STRING),
|
||||
},
|
||||
courses_year_three: {
|
||||
type: ARRAY(STRING),
|
||||
},
|
||||
credits_year_one: {
|
||||
type: INTEGER,
|
||||
},
|
||||
credits_year_two: {
|
||||
type: INTEGER,
|
||||
},
|
||||
credits_year_three: {
|
||||
type: INTEGER,
|
||||
},
|
||||
created_at: DATE,
|
||||
updated_at: DATE,
|
||||
})
|
||||
},
|
||||
down: () => {},
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
await queryInterface.addColumn('progress_criteria', 'courses_year_four', {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
})
|
||||
await queryInterface.addColumn('progress_criteria', 'courses_year_five', {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
})
|
||||
await queryInterface.addColumn('progress_criteria', 'courses_year_six', {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
})
|
||||
await queryInterface.addColumn('progress_criteria', 'credits_year_four', {
|
||||
type: Sequelize.INTEGER,
|
||||
})
|
||||
await queryInterface.addColumn('progress_criteria', 'credits_year_five', {
|
||||
type: Sequelize.INTEGER,
|
||||
})
|
||||
await queryInterface.addColumn('progress_criteria', 'credits_year_six', {
|
||||
type: Sequelize.INTEGER,
|
||||
})
|
||||
},
|
||||
down: async () => {},
|
||||
}
|
||||
@@ -28,7 +28,8 @@ const currentUserMiddleware = async (req, _res, next) => {
|
||||
}
|
||||
|
||||
const iamGroups = parseIamGroups(hygroupcn)
|
||||
const iamRights = Object.keys(await getOrganizationAccess({ iamGroups }))
|
||||
const { access = {}, specialGroup = {} } = await getOrganizationAccess({ iamGroups })
|
||||
const iamRights = Object.keys(access)
|
||||
|
||||
if (!hasRequiredIamGroup(iamGroups, iamRights)) {
|
||||
logger.error({ message: 'User does not have required iam group', meta: { iamGroups, iamRights } })
|
||||
@@ -41,6 +42,7 @@ const currentUserMiddleware = async (req, _res, next) => {
|
||||
email,
|
||||
iamGroups,
|
||||
iamRights,
|
||||
specialGroup,
|
||||
sisId,
|
||||
})
|
||||
|
||||
|
||||
@@ -67,6 +67,9 @@ Studyright.belongsTo(Organization, { foreignKey: 'facultyCode', targetKey: 'code
|
||||
Studyplan.belongsTo(Student, { foreignKey: 'studentnumber', targetKey: 'studentnumber' })
|
||||
Student.hasMany(Studyplan, { foreignKey: 'studentnumber', sourceKey: 'studentnumber' })
|
||||
|
||||
Studyplan.belongsTo(Studyright, { foreignKey: 'studyrightid', targetKey: 'studyrightid' })
|
||||
Studyright.hasMany(Studyplan, { foreignKey: 'studyrightid', sourceKey: 'studyrightid' })
|
||||
|
||||
Studyright.belongsTo(Student, { foreignKey: 'studentStudentnumber', targetKey: 'studentnumber' })
|
||||
Student.hasMany(Studyright, { foreignKey: 'studentStudentnumber', sourceKey: 'studentnumber' })
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
const { STRING } = require('sequelize')
|
||||
const Sequelize = require('sequelize')
|
||||
const { sequelizeKone } = require('../database/connection')
|
||||
|
||||
@@ -143,6 +144,53 @@ const OpenUniPopulationSearch = sequelizeKone.define(
|
||||
{ underscored: true, timestamps: true }
|
||||
)
|
||||
|
||||
const ProgressCriteria = sequelizeKone.define(
|
||||
'progress_criteria',
|
||||
{
|
||||
code: {
|
||||
primaryKey: true,
|
||||
type: STRING,
|
||||
},
|
||||
coursesYearOne: {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
},
|
||||
coursesYearTwo: {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
},
|
||||
coursesYearThree: {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
},
|
||||
coursesYearFour: {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
},
|
||||
coursesYearFive: {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
},
|
||||
coursesYearSix: {
|
||||
type: Sequelize.ARRAY(Sequelize.STRING),
|
||||
},
|
||||
creditsYearOne: {
|
||||
type: Sequelize.INTEGER,
|
||||
},
|
||||
creditsYearTwo: {
|
||||
type: Sequelize.INTEGER,
|
||||
},
|
||||
creditsYearThree: {
|
||||
type: Sequelize.INTEGER,
|
||||
},
|
||||
creditsYearFour: {
|
||||
type: Sequelize.INTEGER,
|
||||
},
|
||||
creditsYearFive: {
|
||||
type: Sequelize.INTEGER,
|
||||
},
|
||||
creditsYearSix: {
|
||||
type: Sequelize.INTEGER,
|
||||
},
|
||||
},
|
||||
{ underscored: true, timestamps: true }
|
||||
)
|
||||
|
||||
const StudyGuidanceGroupTag = sequelizeKone.define(
|
||||
'study_guidance_group_tags',
|
||||
{
|
||||
@@ -188,4 +236,5 @@ module.exports = {
|
||||
sequelizeKone,
|
||||
ExcludedCourse,
|
||||
StudyGuidanceGroupTag,
|
||||
ProgressCriteria,
|
||||
}
|
||||
|
||||
@@ -20,6 +20,16 @@ Studyplan.init(
|
||||
onDelete: 'cascade',
|
||||
allowNull: false,
|
||||
},
|
||||
studyrightid: {
|
||||
type: STRING,
|
||||
references: {
|
||||
model: 'studyright',
|
||||
key: 'studyrightid',
|
||||
},
|
||||
onUpdate: 'cascade',
|
||||
onDelete: 'cascade',
|
||||
allowNull: false,
|
||||
},
|
||||
programme_code: {
|
||||
type: STRING,
|
||||
allowNull: false,
|
||||
@@ -30,6 +40,9 @@ Studyplan.init(
|
||||
completed_credits: {
|
||||
type: INTEGER,
|
||||
},
|
||||
sisu_id: {
|
||||
type: STRING,
|
||||
},
|
||||
createdAt: {
|
||||
type: DATE,
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
const { Model, STRING, DATE, INTEGER } = require('sequelize')
|
||||
const { Model, STRING, DATE, INTEGER, BOOLEAN } = require('sequelize')
|
||||
const { dbConnections } = require('../database/connection')
|
||||
|
||||
class Studyright extends Model {}
|
||||
@@ -27,7 +27,9 @@ Studyright.init(
|
||||
active: {
|
||||
type: INTEGER,
|
||||
},
|
||||
// irtisanomisperuste
|
||||
cancelled: {
|
||||
type: BOOLEAN,
|
||||
},
|
||||
studentStudentnumber: {
|
||||
type: STRING,
|
||||
references: {
|
||||
|
||||
@@ -31,8 +31,9 @@ const programmeModules = require('./routes/programmeModules')
|
||||
const studyGuidanceGroups = require('./routes/studyGuidanceGroups')
|
||||
const studyProgramme = require('./routes/studyProgramme')
|
||||
const customOpenUniSearch = require('./routes/customOpenUniSearch')
|
||||
const studyProgrammeCriteria = require('./routes/studyProgrammeCriteria')
|
||||
const initializeSentry = require('./util/sentry')
|
||||
|
||||
const prerequisiteSearch = require('./routes/prerequisitesSearch')
|
||||
const errorMiddleware = require('./middleware/errorMiddleware')
|
||||
|
||||
module.exports = (app, url) => {
|
||||
@@ -58,7 +59,9 @@ module.exports = (app, url) => {
|
||||
app.use(url, tags)
|
||||
app.use(url, programmeModules)
|
||||
app.use(url, studyProgramme)
|
||||
app.use(`${url}/programmecriteria`, studyProgrammeCriteria)
|
||||
app.use(`${url}/openunisearch`, auth.roles(['openUniSearch']), customOpenUniSearch)
|
||||
app.use(`${url}/prerequisitesearch`, auth.roles(['studyGuidanceGroups']), prerequisiteSearch)
|
||||
app.use(`${url}/faculties`, auth.roles(['facultyStatistics']), faculties)
|
||||
app.use(`${url}/updater`, auth.roles(['admin']), updater)
|
||||
app.use(`${url}/teachers`, auth.roles(['teachers']), teachers)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const router = require('express').Router()
|
||||
var moment = require('moment-timezone')
|
||||
const moment = require('moment-timezone')
|
||||
const { getCustomOpenUniCourses } = require('../services/openUni/openUniStats')
|
||||
const {
|
||||
getOpenUniSearches,
|
||||
|
||||
@@ -84,11 +84,10 @@ router.get('/:id/basicstats', async (req, res) => {
|
||||
router.get('/:id/creditstats', async (req, res) => {
|
||||
const code = req.params.id
|
||||
const yearType = req.query?.year_type
|
||||
const specialGroups = req.query?.special_groups
|
||||
const programmeFilter = req.query?.programme_filter
|
||||
|
||||
if (!code) return res.status(422).end()
|
||||
const data = await getCreditStats(code, yearType, programmeFilter, specialGroups)
|
||||
const data = await getCreditStats(code, yearType, programmeFilter)
|
||||
if (data) return res.json(data)
|
||||
|
||||
const programmes = await getProgrammes(code, programmeFilter)
|
||||
@@ -97,9 +96,9 @@ router.get('/:id/creditstats', async (req, res) => {
|
||||
// list of all programmes is also needed in classification of credits
|
||||
const allProgrammes = programmeFilter === 'ALL_PROGRAMMES' ? programmes : await getProgrammes(code, 'ALL_PROGRAMMES')
|
||||
|
||||
let updatedStats = await combineFacultyCredits(code, programmes.data, allProgrammes.data, yearType, specialGroups)
|
||||
let updatedStats = await combineFacultyCredits(code, programmes.data, allProgrammes.data, yearType)
|
||||
if (updatedStats) {
|
||||
updatedStats = await setCreditStats(updatedStats, yearType, programmeFilter, specialGroups)
|
||||
updatedStats = await setCreditStats(updatedStats, yearType, programmeFilter)
|
||||
}
|
||||
|
||||
return res.json(updatedStats)
|
||||
|
||||
@@ -82,20 +82,6 @@ router.post('/v2/populationstatistics/courses', async (req, res) => {
|
||||
return
|
||||
}
|
||||
|
||||
//These cause problems in front (where they were originally calculated)
|
||||
// Do them here for the moment
|
||||
for (const course of result.coursestatistics) {
|
||||
// course.students.notParticipated = {}
|
||||
course.students.didNotPass = {}
|
||||
|
||||
for (const student of Object.keys(course.students.all)) {
|
||||
if (
|
||||
!Object.keys(course.students.passed).includes(student) &&
|
||||
!Object.keys(course.students.retryPassed).includes(student)
|
||||
)
|
||||
course.students.didNotPass[student] = true
|
||||
}
|
||||
}
|
||||
res.json(result)
|
||||
}
|
||||
})
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
const router = require('express').Router()
|
||||
const { getCompletedCourses } = require('../services/prerequisiteSearch')
|
||||
const _ = require('lodash')
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
const studentNumbers = JSON.parse(req.query?.studentlist) || []
|
||||
const courseCodes = JSON.parse(req.query?.courselist) || []
|
||||
const {
|
||||
user: { isAdmin, studentsUserCanAccess },
|
||||
} = req
|
||||
if (!Array.isArray(studentNumbers)) return res.status(400).json({ error: 'Student numbers must be of type array' })
|
||||
if (!Array.isArray(courseCodes)) return res.status(400).json({ error: 'Courses must be of type array' })
|
||||
|
||||
const filteredStudentNumbers = isAdmin ? studentNumbers : _.intersection(studentNumbers, studentsUserCanAccess)
|
||||
const completedCourses = await getCompletedCourses(filteredStudentNumbers, courseCodes)
|
||||
return res.json(completedCourses)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -15,6 +15,7 @@ const {
|
||||
setStudytrackStats,
|
||||
} = require('../services/analyticsService')
|
||||
const { updateBasicView, updateStudytrackView } = require('../services/studyprogrammeUpdates')
|
||||
const { getProgrammeName } = require('../services/studyprogramme')
|
||||
const logger = require('../util/logger')
|
||||
|
||||
router.get('/v2/studyprogrammes/:id/basicstats', async (req, res) => {
|
||||
@@ -143,4 +144,73 @@ router.get('/v2/studyprogrammes/:id/update_studytrackview', async (req, res) =>
|
||||
}
|
||||
})
|
||||
|
||||
router.get('/v2/studyprogrammes/:id/evaluationstats', async (req, res) => {
|
||||
const code = req.params.id
|
||||
const yearType = req.query?.year_type
|
||||
const specialGroups = req.query?.special_groups
|
||||
const graduated = req.query?.graduated
|
||||
|
||||
if (!code) return res.status(422).end()
|
||||
|
||||
// Statistics for Tilannekuvalomake view
|
||||
|
||||
let gradData = await getGraduationStats(code, yearType, specialGroups)
|
||||
if (!gradData) {
|
||||
const updatedStats = await getGraduationStatsForStudytrack({
|
||||
studyprogramme: req.params.id,
|
||||
settings: {
|
||||
isAcademicYear: yearType === 'ACADEMIC_YEAR',
|
||||
includeAllSpecials: specialGroups === 'SPECIAL_INCLUDED',
|
||||
},
|
||||
})
|
||||
if (updatedStats) {
|
||||
await setGraduationStats(updatedStats, yearType, specialGroups)
|
||||
gradData = updatedStats
|
||||
}
|
||||
}
|
||||
|
||||
let progressData = await getStudytrackStats(code, graduated, specialGroups)
|
||||
if (!progressData) {
|
||||
const updated = await getStudytrackStatsForStudyprogramme({
|
||||
studyprogramme: code,
|
||||
settings: {
|
||||
graduated: graduated === 'GRADUATED_INCLUDED',
|
||||
specialGroups: specialGroups === 'SPECIAL_INCLUDED',
|
||||
},
|
||||
})
|
||||
if (updated) {
|
||||
await setStudytrackStats(updated, graduated, specialGroups)
|
||||
progressData = updated
|
||||
}
|
||||
}
|
||||
|
||||
const programmeName = await getProgrammeName(code)
|
||||
|
||||
delete gradData.tableStats
|
||||
delete gradData.graphStats
|
||||
delete gradData.titles
|
||||
|
||||
const data = {
|
||||
id: code,
|
||||
programmeName: programmeName?.name,
|
||||
status: gradData?.status,
|
||||
lastUpdated: gradData.lastUpdated,
|
||||
graduations: gradData,
|
||||
progress: {
|
||||
creditTableStats: {},
|
||||
creditTableTitles: progressData?.creditTableTitles,
|
||||
graphData: {
|
||||
creditGraphStats: {},
|
||||
id: progressData?.id,
|
||||
years: progressData?.years,
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
data.progress.creditTableStats[code] = progressData?.creditTableStats[code]
|
||||
data.progress.graphData.creditGraphStats[code] = progressData?.creditGraphStats[code]
|
||||
|
||||
return res.json(data)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
const {
|
||||
getCriteria,
|
||||
saveYearlyCourseCriteria,
|
||||
saveYearlyCreditCriteria,
|
||||
} = require('../services/studyProgrammeCriteria')
|
||||
|
||||
const router = require('express').Router()
|
||||
|
||||
router.get('/', async (req, res) => {
|
||||
const studyProgramme = req.query?.programmecode
|
||||
if (!studyProgramme) return res.status(422).end()
|
||||
const studyProgrammeCriteria = await getCriteria(studyProgramme)
|
||||
return res.json(studyProgrammeCriteria)
|
||||
})
|
||||
|
||||
router.post('/courses', async (req, res) => {
|
||||
const { code, courses, year } = req.body
|
||||
if (!code || !courses || !year) return res.status(400).end()
|
||||
const studyProgrammeCriteria = await saveYearlyCourseCriteria(code, courses, year)
|
||||
return res.json(studyProgrammeCriteria)
|
||||
})
|
||||
|
||||
router.post('/credits', async (req, res) => {
|
||||
const { code, credits } = req.body
|
||||
if (!code || !credits) return res.status(400).end()
|
||||
const studyProgrammeCriteria = await saveYearlyCreditCriteria(code, credits)
|
||||
return res.json(studyProgrammeCriteria)
|
||||
})
|
||||
|
||||
module.exports = router
|
||||
@@ -26,7 +26,9 @@ class CourseStatsCounter {
|
||||
failedMany: {},
|
||||
improvedPassedGrade: {},
|
||||
markedToSemester: {},
|
||||
enrolledNoGrade: {},
|
||||
}
|
||||
|
||||
this.stats = {
|
||||
students: 0,
|
||||
passed: 0,
|
||||
@@ -38,10 +40,10 @@ class CourseStatsCounter {
|
||||
percentage: undefined,
|
||||
passedOfPopulation: undefined,
|
||||
triedOfPopulation: undefined,
|
||||
perStudent: undefined,
|
||||
passingSemesters: this.initializePassingSemesters(),
|
||||
}
|
||||
this.enrollments = {
|
||||
enrolledNoGrade: new Set(),
|
||||
semesters: this.initializePassingSemesters({}),
|
||||
}
|
||||
this.grades = {}
|
||||
@@ -184,11 +186,20 @@ class CourseStatsCounter {
|
||||
getFinalStats() {
|
||||
const stats = this.stats
|
||||
const students = this.students
|
||||
const allStudents = Object.keys(students.all)
|
||||
const totalEnrolledNoGrade = [...(this.enrollments.ENROLLED || [])].filter(
|
||||
student => !allStudents.includes(student)
|
||||
).length
|
||||
const studs = this.enrollments
|
||||
? Object.keys(this.enrollments)
|
||||
.filter(key => key !== 'ENROLLED' && key !== 'semesters')
|
||||
.reduce((acc, key) => [...acc, ...[...this.enrollments[key]].map(studentnumber => studentnumber)], [])
|
||||
: []
|
||||
const allStudents = Object.keys(students.all).map(student => student)
|
||||
const fileredEnrolledNoGrade = this.enrollments['ENROLLED']
|
||||
? [...this.enrollments['ENROLLED']]
|
||||
.filter(student => !studs.includes(student) && !allStudents.includes(student))
|
||||
.reduce((acc, student) => ({ ...acc, [student]: true }), {})
|
||||
: {}
|
||||
|
||||
students.all = { ...students.all, ...fileredEnrolledNoGrade }
|
||||
students.enrolledNoGrade = fileredEnrolledNoGrade
|
||||
stats.students = lengthOf(students.all)
|
||||
stats.passed = lengthOf(students.passed)
|
||||
stats.failed = lengthOf(students.failed)
|
||||
@@ -200,8 +211,8 @@ class CourseStatsCounter {
|
||||
stats.triedOfPopulation = percentageOf(stats.students, this.studentsInTotal)
|
||||
stats.perStudent = stats.attempts / (stats.passed + stats.failed)
|
||||
stats.passingSemestersCumulative = this.getPassingSemestersCumulative()
|
||||
stats.totalStudents = stats.students + totalEnrolledNoGrade
|
||||
stats.totalEnrolledNoGrade = totalEnrolledNoGrade
|
||||
stats.totalStudents = stats.students
|
||||
stats.totalEnrolledNoGrade = lengthOf(fileredEnrolledNoGrade)
|
||||
stats.percentageWithEnrollments = percentageOf(stats.passed, stats.totalStudents)
|
||||
|
||||
return {
|
||||
|
||||
@@ -111,7 +111,7 @@ const getFacultyStarters = async (
|
||||
}
|
||||
})
|
||||
|
||||
allBasics.studentInfo.graphStats.push({ name: 'Started studying', data: startedGraphStats })
|
||||
allBasics.studentInfo.graphStats.push({ name: 'Started studying (new in faculty)', data: startedGraphStats })
|
||||
programmeData['started'] = programmeTableStats
|
||||
|
||||
Object.keys(startedTableStats).forEach(year => {
|
||||
@@ -155,6 +155,7 @@ const getFacultyGraduates = async (
|
||||
if (keys.includes(programme)) {
|
||||
programmeId = codes[programme].toUpperCase()
|
||||
}
|
||||
|
||||
if (programmeFilter === 'ALL_PROGRAMMES' || isNewProgramme(programme)) {
|
||||
const endYear = defineYear(enddate, isAcademicYear)
|
||||
graduatedGraphStats[0][indexOf(yearsArray, endYear)] += 1
|
||||
|
||||
@@ -7,14 +7,8 @@ const {
|
||||
isNonMajorCredit,
|
||||
getYearsArray,
|
||||
getStartDate,
|
||||
isSpecialGroupCredit,
|
||||
} = require('../studyprogrammeHelpers')
|
||||
const {
|
||||
getStudyRights,
|
||||
getCreditsForStudyProgramme,
|
||||
allTransfers,
|
||||
getCourseCodesForStudyProgramme,
|
||||
} = require('../studyprogramme')
|
||||
const { getStudyRights, getCreditsForStudyProgramme, getCourseCodesForStudyProgramme } = require('../studyprogramme')
|
||||
|
||||
const isFacultyNonMajorCredit = (studyrights, attainment_date, facultyProgrammes) => {
|
||||
let right = ''
|
||||
@@ -42,25 +36,14 @@ const isFacultyNonMajorCredit = (studyrights, attainment_date, facultyProgrammes
|
||||
// Fetches all the credits for the studyprogramme and divides them into major-students, non-major faculty students,
|
||||
// non-major other faculty students adn non-degree student credits
|
||||
// Division is done on the basis that whether the student had a primary studyright to the programme on the attainment_date
|
||||
const getFacultyRegularCreditStats = async ({
|
||||
studyprogramme,
|
||||
since,
|
||||
years,
|
||||
isAcademicYear,
|
||||
includeAllSpecials,
|
||||
facultyProgrammes,
|
||||
}) => {
|
||||
const getFacultyRegularCreditStats = async ({ studyprogramme, since, years, isAcademicYear, facultyProgrammes }) => {
|
||||
const providercode = mapToProviders([studyprogramme])[0]
|
||||
const courses = await getCourseCodesForStudyProgramme(providercode)
|
||||
// console.log(JSON.stringify(courses))
|
||||
const credits = await getCreditsForStudyProgramme(courses, since)
|
||||
const students = [...new Set(credits.map(({ student_studentnumber }) => student_studentnumber))]
|
||||
|
||||
let studyrights = await getStudyRights(students)
|
||||
const transfers = (await allTransfers(studyprogramme, since)).map(t => t.studyrightid).filter(s => s !== 'undefined')
|
||||
if (!includeAllSpecials) {
|
||||
studyrights = studyrights.filter(s => !transfers.includes(s.studyrightid))
|
||||
}
|
||||
|
||||
let majors = getStatsBasis(years)
|
||||
let allNonMajors = getStatsBasis(years)
|
||||
let facultyNonMajors = getStatsBasis(years)
|
||||
@@ -71,10 +54,6 @@ const getFacultyRegularCreditStats = async ({
|
||||
const studentStudyrights = studyrights.filter(studyright => studyright.studentnumber === student_studentnumber)
|
||||
const attainmentYear = defineYear(attainment_date, isAcademicYear)
|
||||
|
||||
if (!includeAllSpecials && isSpecialGroupCredit(studentStudyrights, attainment_date, transfers)) {
|
||||
return
|
||||
}
|
||||
|
||||
if (isMajorStudentCredit(studentStudyrights, attainment_date, studyprogramme)) {
|
||||
majors.graphStats[indexOf(years, attainmentYear)] += credits || 0
|
||||
majors.tableStats[attainmentYear] += credits || 0
|
||||
@@ -116,12 +95,11 @@ const getFacultyRegularCreditStats = async ({
|
||||
// Fetches all credits for the studytrack and combines them into statistics
|
||||
// These are for the faculty view which differs from study programme overview
|
||||
// (no transfers, non majors split to in- and outside-faculty)
|
||||
const getFacultyCreditStatsForStudytrack = async ({ studyprogramme, facultyProgrammes, settings }) => {
|
||||
const { isAcademicYear, includeAllSpecials } = settings
|
||||
const getFacultyCreditStatsForStudytrack = async ({ studyprogramme, facultyProgrammes, isAcademicYear }) => {
|
||||
const since = getStartDate(studyprogramme, isAcademicYear)
|
||||
const years = getYearsArray(since.getFullYear(), isAcademicYear)
|
||||
|
||||
const queryParameters = { studyprogramme, since, years, isAcademicYear, includeAllSpecials, facultyProgrammes }
|
||||
const queryParameters = { studyprogramme, since, years, isAcademicYear, facultyProgrammes }
|
||||
const { majors, facultyNonMajors, otherNonMajors, nonDegree } = await getFacultyRegularCreditStats(queryParameters)
|
||||
|
||||
const reversedYears = getYearsArray(since.getFullYear(), isAcademicYear).reverse()
|
||||
@@ -129,47 +107,36 @@ const getFacultyCreditStatsForStudytrack = async ({ studyprogramme, facultyProgr
|
||||
|
||||
if (!dataFound) return null
|
||||
|
||||
const tableStats = reversedYears.map(year =>
|
||||
includeAllSpecials
|
||||
? [
|
||||
year,
|
||||
majors.tableStats[year] +
|
||||
facultyNonMajors.tableStats[year] +
|
||||
otherNonMajors.tableStats[year] +
|
||||
nonDegree.tableStats[year],
|
||||
majors.tableStats[year],
|
||||
facultyNonMajors.tableStats[year],
|
||||
otherNonMajors.tableStats[year],
|
||||
nonDegree.tableStats[year],
|
||||
]
|
||||
: [year, majors.tableStats[year], majors.tableStats[year]]
|
||||
)
|
||||
const tableStats = reversedYears.map(year => [
|
||||
year,
|
||||
majors.tableStats[year] +
|
||||
facultyNonMajors.tableStats[year] +
|
||||
otherNonMajors.tableStats[year] +
|
||||
nonDegree.tableStats[year],
|
||||
majors.tableStats[year],
|
||||
facultyNonMajors.tableStats[year],
|
||||
otherNonMajors.tableStats[year],
|
||||
nonDegree.tableStats[year],
|
||||
])
|
||||
|
||||
const graphStats = includeAllSpecials
|
||||
? [
|
||||
{
|
||||
name: 'Major students credits',
|
||||
data: majors.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Non-major faculty students credits',
|
||||
data: facultyNonMajors.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Non-major other faculty students credits 2',
|
||||
data: otherNonMajors.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Non-degree credits',
|
||||
data: nonDegree.graphStats,
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
name: 'Major students credits',
|
||||
data: majors.graphStats,
|
||||
},
|
||||
]
|
||||
const graphStats = [
|
||||
{
|
||||
name: 'Major students credits',
|
||||
data: majors.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Non-major faculty students credits',
|
||||
data: facultyNonMajors.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Non-major other faculty students credits 2',
|
||||
data: otherNonMajors.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Non-degree credits',
|
||||
data: nonDegree.graphStats,
|
||||
},
|
||||
]
|
||||
|
||||
return {
|
||||
id: studyprogramme,
|
||||
@@ -179,33 +146,27 @@ const getFacultyCreditStatsForStudytrack = async ({ studyprogramme, facultyProgr
|
||||
}
|
||||
}
|
||||
|
||||
const getProgrammeCredits = async (code, yearType, specialGroups, facultyProgrammes) => {
|
||||
const getProgrammeCredits = async (code, yearType, facultyProgrammes) => {
|
||||
const updatedStats = await getFacultyCreditStatsForStudytrack({
|
||||
studyprogramme: code,
|
||||
facultyProgrammes,
|
||||
settings: {
|
||||
isAcademicYear: yearType === 'ACADEMIC_YEAR',
|
||||
includeAllSpecials: specialGroups === 'SPECIAL_INCLUDED',
|
||||
},
|
||||
isAcademicYear: yearType === 'ACADEMIC_YEAR',
|
||||
})
|
||||
|
||||
return updatedStats
|
||||
}
|
||||
|
||||
const combineFacultyCredits = async (faculty, programmes, allProgrammes, yearType, specialGroups) => {
|
||||
const combineFacultyCredits = async (faculty, programmes, allProgrammes, yearType) => {
|
||||
let counts = {}
|
||||
let years = []
|
||||
const titles =
|
||||
specialGroups === 'SPECIAL_INCLUDED'
|
||||
? [
|
||||
'',
|
||||
'Total',
|
||||
'Major students credits',
|
||||
'Non-major faculty students credits',
|
||||
'Non-major other faculty students credits',
|
||||
'Non-degree student credits',
|
||||
]
|
||||
: ['', 'Total', 'Major students credits']
|
||||
const titles = [
|
||||
'',
|
||||
'Total',
|
||||
'Major students credits',
|
||||
'Non-major faculty students credits',
|
||||
'Non-major other faculty students credits',
|
||||
'Non-degree student credits',
|
||||
]
|
||||
|
||||
let allCredits = {
|
||||
id: faculty,
|
||||
@@ -220,7 +181,7 @@ const combineFacultyCredits = async (faculty, programmes, allProgrammes, yearTyp
|
||||
const progCodes = allProgrammes.map(p => p.code)
|
||||
for (const prog of programmes) {
|
||||
if (prog.code === 'MH70_008_2') continue
|
||||
const data = await getProgrammeCredits(prog.code, yearType, specialGroups, progCodes)
|
||||
const data = await getProgrammeCredits(prog.code, yearType, progCodes)
|
||||
if (data) {
|
||||
allCredits.programmeNames[prog.progId] = { code: prog.code, ...prog.name }
|
||||
allCredits.programmeTableStats[prog.progId] = data.tableStats
|
||||
@@ -260,16 +221,12 @@ const combineFacultyCredits = async (faculty, programmes, allProgrammes, yearTyp
|
||||
nonDegree.push(counts[year][4])
|
||||
})
|
||||
|
||||
allCredits.graphStats =
|
||||
specialGroups === 'SPECIAL_INCLUDED'
|
||||
? [
|
||||
{ name: 'Major students credits', data: majors },
|
||||
{ name: 'Non-major faculty students credits', data: facultyNonMajor },
|
||||
{ name: 'Non-major other faculty students credits', data: otherNonMajor },
|
||||
{ name: 'Non-degree credits', data: nonDegree },
|
||||
]
|
||||
: [{ name: 'Major students credits', data: majors }]
|
||||
|
||||
allCredits.graphStats = [
|
||||
{ name: 'Major students credits', data: majors },
|
||||
{ name: 'Non-major faculty students credits', data: facultyNonMajor },
|
||||
{ name: 'Non-major other faculty students credits', data: otherNonMajor },
|
||||
{ name: 'Non-degree credits', data: nonDegree },
|
||||
]
|
||||
return allCredits
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,8 @@ const getSortedProgIds = progs => {
|
||||
|
||||
for (const prog of progs) {
|
||||
if (Object.keys(codes).includes(prog)) {
|
||||
programmes = [...programmes, { name: codes[prog].toUpperCase(), code: prog }]
|
||||
const name = prog === 'T923103' ? codes[prog].toUpperCase() + '-DP' : codes[prog].toUpperCase()
|
||||
programmes = [...programmes, { name: name, code: prog }]
|
||||
} else {
|
||||
programmes = [...programmes, { name: prog, code: prog }]
|
||||
}
|
||||
|
||||
@@ -135,6 +135,9 @@ const mapCodesToIds = data => {
|
||||
for (const prog of data) {
|
||||
if (keys.includes(prog.code)) {
|
||||
prog.progId = codes[prog.code].toUpperCase()
|
||||
if (prog.code === 'T923103') {
|
||||
prog.progId = prog.progId + '-DP'
|
||||
}
|
||||
} else {
|
||||
prog.progId = prog.code
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ const getBasicStats = async (id, yearType, programmeFilter, specialGroups) => {
|
||||
return JSON.parse(dataFromRedis)
|
||||
}
|
||||
|
||||
const setCreditStats = async (data, yearType, programmeFilter, specialGroups) => {
|
||||
const setCreditStats = async (data, yearType, programmeFilter) => {
|
||||
const { id } = data
|
||||
const redisKey = createRedisKeyForCreditStats(id, yearType, programmeFilter, specialGroups)
|
||||
const redisKey = createRedisKeyForCreditStats(id, yearType, programmeFilter)
|
||||
const dataToRedis = {
|
||||
...data,
|
||||
status: 'DONE',
|
||||
|
||||
@@ -10,35 +10,21 @@ const {
|
||||
getYearsArray,
|
||||
tableTitles,
|
||||
getOnlyMasterCreditGraphStats,
|
||||
getOnlyMasterThresholds,
|
||||
getBcMsThresholds,
|
||||
getVetenaryCreditGraphStats,
|
||||
} = require('../studyprogrammeHelpers')
|
||||
const { studytrackStudents } = require('../studyprogramme')
|
||||
const { getStudyRightsByExtent, getTransferredInside, getTransferredToAndAway } = require('./faculty')
|
||||
const { checkTransfers } = require('./facultyHelpers')
|
||||
|
||||
const getStudentData = (
|
||||
startDate,
|
||||
students,
|
||||
thresholdKeys,
|
||||
thresholdAmounts,
|
||||
limits,
|
||||
limitKeys,
|
||||
prog,
|
||||
earlyStudyRights = []
|
||||
) => {
|
||||
const getStudentData = (startDate, students, thresholdKeys, thresholdAmounts, limits = [], limitKeys = [], prog) => {
|
||||
let data = {}
|
||||
let programmeData = {}
|
||||
let start = startDate
|
||||
thresholdKeys.forEach(t => (data[t] = 0))
|
||||
limitKeys.forEach(t => (programmeData[t] = 0))
|
||||
students.forEach(({ studentnumber, credits }) => {
|
||||
if (earlyStudyRights.length > 0) {
|
||||
const bcStudyright = earlyStudyRights.filter(sr => sr.studentnumber === studentnumber)
|
||||
start = bcStudyright.length > 0 ? bcStudyright[0].startdate : startDate
|
||||
}
|
||||
students.forEach(({ credits }) => {
|
||||
const creditcount = credits
|
||||
.filter(credit => moment(credit.attainment_date).isSameOrAfter(start))
|
||||
.filter(credit => moment(credit.attainment_date).isSameOrAfter(startDate))
|
||||
.reduce((prev, curr) => prev + curr.credits, 0)
|
||||
data[thresholdKeys[0]] += creditcount < thresholdAmounts[0] ? 1 : 0
|
||||
data[thresholdKeys[1]] += creditcount >= thresholdAmounts[0] && creditcount < thresholdAmounts[1] ? 1 : 0
|
||||
@@ -130,19 +116,17 @@ const combineFacultyStudentProgress = async (faculty, programmes, allProgrammeCo
|
||||
doctoralTableStats: new Array(yearsArray.length),
|
||||
bachelorsGraphStats: getBachelorCreditGraphStats(yearsArray),
|
||||
bcMsGraphStats: faculty === 'H90' ? getVetenaryCreditGraphStats(yearsArray) : getMasterCreditGraphStats(yearsArray),
|
||||
mastersGraphStats: getOnlyMasterCreditGraphStats(yearsArray),
|
||||
mastersGraphStats:
|
||||
faculty === 'H90' ? getBachelorCreditGraphStats(yearsArray) : getOnlyMasterCreditGraphStats(yearsArray),
|
||||
doctoralGraphStats: getDoctoralCreditGraphStats(yearsArray),
|
||||
bachelorTitles: tableTitles.creditProgress.bachelor,
|
||||
bcMsTitles: faculty === 'H90' ? titlesVet : tableTitles.creditProgress.master,
|
||||
mastersTitles: tableTitles.creditProgress.masterOnly,
|
||||
mastersTitles: faculty === 'H90' ? tableTitles.creditProgress.bachelor : tableTitles.creditProgress.masterOnly,
|
||||
doctoralTitles: tableTitles.creditProgress.doctoral,
|
||||
yearlyBachelorTitles: [],
|
||||
yearlyBcMsTitles: [],
|
||||
yearlyMasterTitles: [],
|
||||
programmeNames: programmes.reduce(
|
||||
(obj, dataItem) => ({ ...obj, [dataItem.progId]: { code: dataItem.code, ...dataItem.name } }),
|
||||
{}
|
||||
),
|
||||
programmeNames: {},
|
||||
bachelorsProgStats: {},
|
||||
bcMsProgStats: {},
|
||||
mastersProgStats: {},
|
||||
@@ -156,16 +140,20 @@ const combineFacultyStudentProgress = async (faculty, programmes, allProgrammeCo
|
||||
progressStats.mastersTableStats[indexOf(reversedYears, year)] = [year, 0, 0, 0, 0, 0, 0, 0]
|
||||
progressStats.doctoralTableStats[indexOf(reversedYears, year)] = [year, 0, 0, 0, 0, 0, 0]
|
||||
})
|
||||
|
||||
const limitKeys = ['zero', 't5', 't4', 't3', 't2', 't1']
|
||||
let bachelorlimits = []
|
||||
let masterlimits = []
|
||||
let bcmslimits = []
|
||||
const bachelorProgress = {}
|
||||
const masterProgress = {}
|
||||
const bcmsProgress = {}
|
||||
const doctoralProgress = {}
|
||||
for (const year of reversedYears) {
|
||||
if (year === 'Total') continue
|
||||
const { startDate, endDate } = getAcademicYearDates(year, since)
|
||||
const lastDayOfMonth = moment().endOf('month')
|
||||
let months = Math.round(moment.duration(moment(lastDayOfMonth).diff(moment(startDate))).asMonths())
|
||||
|
||||
if (months >= 36) {
|
||||
bachelorlimits = createLimits(36, 0)
|
||||
} else {
|
||||
@@ -177,18 +165,22 @@ const combineFacultyStudentProgress = async (faculty, programmes, allProgrammeCo
|
||||
masterlimits = createLimits(months, 0)
|
||||
}
|
||||
if (months >= 72 && faculty === 'H90') {
|
||||
bcmslimits = createLimits(72, 180)
|
||||
bcmslimits = createLimits(72, 0)
|
||||
} else if (months >= 60) {
|
||||
bcmslimits = createLimits(60, 180)
|
||||
bcmslimits = createLimits(60, 0)
|
||||
} else {
|
||||
bcmslimits = createLimits(months, 180)
|
||||
bcmslimits = createLimits(months, 0)
|
||||
}
|
||||
progressStats.yearlyBachelorTitles = [...progressStats.yearlyBachelorTitles, createYearlyTitles(0, bachelorlimits)]
|
||||
progressStats.yearlyMasterTitles = [...progressStats.yearlyMasterTitles, createYearlyTitles(0, masterlimits)]
|
||||
progressStats.yearlyBcMsTitles = [...progressStats.yearlyBcMsTitles, createYearlyTitles(180, bcmslimits)]
|
||||
progressStats.yearlyBcMsTitles = [...progressStats.yearlyBcMsTitles, createYearlyTitles(0, bcmslimits)]
|
||||
const programmeCodes = programmes.map(prog => prog.code)
|
||||
|
||||
for (const { progId, code } of programmes) {
|
||||
for (const { progId, code, name } of programmes) {
|
||||
let extentcodes = [1, 2, 3, 4]
|
||||
if (includeAllSpecials) {
|
||||
extentcodes = [...extentcodes, ...[7, 9, 34, 22, 99, 14, 13]]
|
||||
}
|
||||
const startDateWhere = {
|
||||
startdate: {
|
||||
[Op.and]: {
|
||||
@@ -197,23 +189,18 @@ const combineFacultyStudentProgress = async (faculty, programmes, allProgrammeCo
|
||||
},
|
||||
},
|
||||
}
|
||||
let extentcodes = []
|
||||
if (includeAllSpecials) {
|
||||
extentcodes = [7, 9, 34, 22, 99, 14, 13]
|
||||
let studyrights = await getStudyRightsByExtent(faculty, {}, startDateWhere, code, extentcodes, graduationStatus)
|
||||
let { creditThresholdKeys, creditThresholdAmounts } = getCreditThresholds(code, true)
|
||||
if (!creditThresholdKeys) continue
|
||||
if (!(progId in progressStats.programmeNames)) {
|
||||
progressStats.programmeNames[progId] = { code: code, ...name }
|
||||
}
|
||||
if (!includeAllSpecials) {
|
||||
studyrights = await filterOutTransfers(studyrights, programmeCodes, allProgrammeCodes, since)
|
||||
}
|
||||
let { creditThresholdKeys, creditThresholdAmounts } = getCreditThresholds(code)
|
||||
if (!creditThresholdKeys) return
|
||||
|
||||
if (code.includes('KH')) {
|
||||
extentcodes.push(1)
|
||||
let studyrights = await getStudyRightsByExtent(faculty, {}, startDateWhere, code, extentcodes, graduationStatus)
|
||||
if (!includeAllSpecials) {
|
||||
studyrights = await filterOutTransfers(studyrights, programmeCodes, allProgrammeCodes, since)
|
||||
}
|
||||
const all = studyrights
|
||||
.filter(sr => sr.studyrightElements.some(element => element.code === code))
|
||||
.map(sr => sr.studentnumber)
|
||||
const students = await studytrackStudents(all)
|
||||
const allBachelors = studyrights.filter(sr => sr.extentcode === 1).map(sr => sr.studentnumber)
|
||||
const students = await studytrackStudents(allBachelors)
|
||||
const { data: studentData, progData } = getStudentData(
|
||||
startDate,
|
||||
students,
|
||||
@@ -224,12 +211,12 @@ const combineFacultyStudentProgress = async (faculty, programmes, allProgrammeCo
|
||||
'KH'
|
||||
)
|
||||
|
||||
if (!(progId in progressStats.bachelorsProgStats)) {
|
||||
progressStats.bachelorsProgStats[progId] = new Array(reversedYears.length - 1)
|
||||
if (!(progId in bachelorProgress)) {
|
||||
bachelorProgress[progId] = new Array(reversedYears.length - 1)
|
||||
}
|
||||
progressStats.bachelorsTableStats[indexOf(reversedYears, year)][1] += students.length || 0
|
||||
progressStats.bachelorsTableStats[indexOf(reversedYears, 'Total')][1] += students.length || 0
|
||||
progressStats.bachelorsProgStats[progId][indexOf(reversedYears, year)] = limitKeys.map(key => progData[key])
|
||||
bachelorProgress[progId][indexOf(reversedYears, year)] = limitKeys.map(key => progData[key])
|
||||
for (const key of Object.keys(studentData)) {
|
||||
progressStats.bachelorsTableStats[indexOf(reversedYears, year)][indexOf(creditThresholdKeys, key) + 2] +=
|
||||
studentData[key] || 0
|
||||
@@ -239,16 +226,12 @@ const combineFacultyStudentProgress = async (faculty, programmes, allProgrammeCo
|
||||
progressStats.bachelorsGraphStats[key].data[indexOf(yearsArray, 'Total')] += studentData[key] || 0
|
||||
}
|
||||
} else if (code.includes('MH')) {
|
||||
extentcodes.push(2)
|
||||
let all = await getStudyRightsByExtent(faculty, startDateWhere, {}, code, extentcodes, graduationStatus)
|
||||
if (!includeAllSpecials) {
|
||||
all = await filterOutTransfers(all, programmeCodes, allProgrammeCodes, since)
|
||||
}
|
||||
const allMsStudents = all.filter(sr => sr.studyrightid.slice(-2) !== '-2').map(sr => sr.studentnumber)
|
||||
const allBcMsStudents = all.filter(sr => sr.studyrightid.slice(-2) === '-2').map(sr => sr.studentnumber)
|
||||
const studentsWithBachelor = all
|
||||
.filter(sr => sr.studyrightid.slice(-2) === '-2')
|
||||
.map(sr => ({ studentnumber: sr.studentnumber, startdate: sr.startdate }))
|
||||
const allMsStudents = studyrights
|
||||
.filter(sr => sr.extentcode === 2 && sr.studyrightid.slice(-2) !== '-2')
|
||||
.map(sr => sr.studentnumber)
|
||||
const allBcMsStudents = studyrights
|
||||
.filter(sr => sr.extentcode === 2 && sr.studyrightid.slice(-2) === '-2')
|
||||
.map(sr => sr.studentnumber)
|
||||
const bcMsStudents = await studytrackStudents(allBcMsStudents)
|
||||
const msStudents = await studytrackStudents(allMsStudents)
|
||||
|
||||
@@ -256,85 +239,84 @@ const combineFacultyStudentProgress = async (faculty, programmes, allProgrammeCo
|
||||
progressStats.mastersTableStats[indexOf(reversedYears, 'Total')][1] += msStudents.length || 0
|
||||
progressStats.bcMsTableStats[indexOf(reversedYears, year)][1] += bcMsStudents.length || 0
|
||||
progressStats.bcMsTableStats[indexOf(reversedYears, 'Total')][1] += bcMsStudents.length || 0
|
||||
const { creditThresholdKeysBcMs, creditThresholdAmountsBcMs } = getBcMsThresholds(code)
|
||||
const { data: bcMsStudentdata, progData: bcMsProgdata } = getStudentData(
|
||||
startDate,
|
||||
bcMsStudents,
|
||||
creditThresholdKeys,
|
||||
creditThresholdAmounts,
|
||||
creditThresholdKeysBcMs,
|
||||
creditThresholdAmountsBcMs,
|
||||
bcmslimits,
|
||||
limitKeys,
|
||||
'MH',
|
||||
studentsWithBachelor
|
||||
'MH'
|
||||
)
|
||||
const { msOnlyCreditThresholdKeys, msOnlyCreditThresholdAmount } = getOnlyMasterThresholds()
|
||||
|
||||
const { data: msStudentdata, progData: msProgdata } = getStudentData(
|
||||
startDate,
|
||||
msStudents,
|
||||
msOnlyCreditThresholdKeys,
|
||||
msOnlyCreditThresholdAmount,
|
||||
creditThresholdKeys,
|
||||
creditThresholdAmounts,
|
||||
masterlimits,
|
||||
limitKeys,
|
||||
'MH'
|
||||
)
|
||||
if (!(progId in progressStats.mastersProgStats)) {
|
||||
progressStats.mastersProgStats[progId] = new Array(reversedYears.length - 1)
|
||||
if (!(progId in masterProgress)) {
|
||||
masterProgress[progId] = new Array(reversedYears.length - 1)
|
||||
bcmsProgress[progId] = new Array(reversedYears.length - 1)
|
||||
}
|
||||
if (!(progId in progressStats.bcMsProgStats)) {
|
||||
progressStats.bcMsProgStats[progId] = new Array(reversedYears.length - 1)
|
||||
}
|
||||
progressStats.mastersProgStats[progId][indexOf(reversedYears, year)] = limitKeys.map(key => msProgdata[key])
|
||||
progressStats.bcMsProgStats[progId][indexOf(reversedYears, year)] = limitKeys.map(key => bcMsProgdata[key])
|
||||
|
||||
masterProgress[progId][indexOf(reversedYears, year)] = limitKeys.map(key => msProgdata[key])
|
||||
bcmsProgress[progId][indexOf(reversedYears, year)] = limitKeys.map(key => bcMsProgdata[key])
|
||||
for (const key of Object.keys(msStudentdata)) {
|
||||
progressStats.mastersTableStats[indexOf(reversedYears, year)][indexOf(msOnlyCreditThresholdKeys, key) + 2] +=
|
||||
progressStats.mastersTableStats[indexOf(reversedYears, year)][indexOf(creditThresholdKeys, key) + 2] +=
|
||||
msStudentdata[key] || 0
|
||||
progressStats.mastersTableStats[indexOf(reversedYears, 'Total')][indexOf(creditThresholdKeys, key) + 2] +=
|
||||
msStudentdata[key] || 0
|
||||
progressStats.mastersTableStats[indexOf(reversedYears, 'Total')][
|
||||
indexOf(msOnlyCreditThresholdKeys, key) + 2
|
||||
] += msStudentdata[key] || 0
|
||||
progressStats.mastersGraphStats[key].data[indexOf(yearsArray, year)] += msStudentdata[key] || 0
|
||||
progressStats.mastersGraphStats[key].data[indexOf(yearsArray, 'Total')] += msStudentdata[key] || 0
|
||||
}
|
||||
for (const key of Object.keys(bcMsStudentdata)) {
|
||||
progressStats.bcMsTableStats[indexOf(reversedYears, year)][indexOf(creditThresholdKeys, key) + 2] +=
|
||||
progressStats.bcMsTableStats[indexOf(reversedYears, year)][indexOf(creditThresholdKeysBcMs, key) + 2] +=
|
||||
bcMsStudentdata[key] || 0
|
||||
progressStats.bcMsTableStats[indexOf(reversedYears, 'Total')][indexOf(creditThresholdKeysBcMs, key) + 2] +=
|
||||
bcMsStudentdata[key] || 0
|
||||
progressStats.bcMsGraphStats[key].data[indexOf(yearsArray, year)] += bcMsStudentdata[key] || 0
|
||||
progressStats.bcMsTableStats[indexOf(reversedYears, 'Total')][indexOf(creditThresholdKeys, key) + 2] +=
|
||||
bcMsStudentdata[key] || 0
|
||||
progressStats.bcMsGraphStats[key].data[indexOf(yearsArray, 'Total')] += bcMsStudentdata[key] || 0
|
||||
}
|
||||
} else {
|
||||
extentcodes.push(4)
|
||||
let studyrights = await getStudyRightsByExtent(faculty, {}, startDateWhere, code, extentcodes, graduationStatus)
|
||||
if (!includeAllSpecials) {
|
||||
studyrights = await filterOutTransfers(studyrights, programmeCodes, allProgrammeCodes, since)
|
||||
}
|
||||
const all = studyrights
|
||||
.filter(sr => sr.studyrightElements.some(element => element.code === code))
|
||||
.map(sr => sr.studentnumber)
|
||||
const students = await studytrackStudents(all)
|
||||
const { data } = getStudentData(startDate, students, creditThresholdKeys, creditThresholdAmounts, [], [], 'T')
|
||||
const all = studyrights.filter(sr => sr.extentcode === 4 || sr.extentcode === 3).map(sr => sr.studentnumber)
|
||||
const doctoralStudents = await studytrackStudents(all)
|
||||
const { data } = getStudentData(startDate, doctoralStudents, creditThresholdKeys, creditThresholdAmounts, 'T')
|
||||
|
||||
progressStats.doctoralTableStats[indexOf(reversedYears, year)][1] += students.length || 0
|
||||
progressStats.doctoralTableStats[indexOf(reversedYears, 'Total')][1] += students.length || 0
|
||||
if (!(progId in progressStats.doctoralProgStats)) {
|
||||
progressStats.doctoralProgStats[progId] = new Array(reversedYears.length - 1)
|
||||
progressStats.doctoralTableStats[indexOf(reversedYears, year)][1] += doctoralStudents.length || 0
|
||||
progressStats.doctoralTableStats[indexOf(reversedYears, 'Total')][1] += doctoralStudents.length || 0
|
||||
if (!(progId in doctoralProgress)) {
|
||||
doctoralProgress[progId] = new Array(reversedYears.length - 1)
|
||||
}
|
||||
progressStats.doctoralProgStats[progId][indexOf(reversedYears, year)] = creditThresholdKeys.map(
|
||||
key => data[key]
|
||||
)
|
||||
doctoralProgress[progId][indexOf(reversedYears, year)] = creditThresholdKeys.map(key => data[key])
|
||||
|
||||
for (const key of Object.keys(data)) {
|
||||
progressStats.doctoralTableStats[indexOf(reversedYears, year)][indexOf(creditThresholdKeys, key) + 2] +=
|
||||
data[key] || 0
|
||||
progressStats.doctoralGraphStats[key].data[indexOf(yearsArray, year)] += data[key] || 0
|
||||
progressStats.doctoralTableStats[indexOf(reversedYears, 'Total')][indexOf(creditThresholdKeys, key) + 2] +=
|
||||
data[key] || 0
|
||||
progressStats.doctoralGraphStats[key].data[indexOf(yearsArray, year)] += data[key] || 0
|
||||
progressStats.doctoralGraphStats[key].data[indexOf(yearsArray, 'Total')] += data[key] || 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
progressStats.bachelorsProgStats = Object.keys(bachelorProgress)
|
||||
.filter(prog => !bachelorProgress[prog].every(year => year.every(value => value === 0)))
|
||||
.reduce((result, prog) => ({ ...result, [prog]: bachelorProgress[prog] }), {})
|
||||
progressStats.mastersProgStats = Object.keys(masterProgress)
|
||||
.filter(prog => !masterProgress[prog].every(year => year.every(value => value === 0)))
|
||||
.reduce((result, prog) => ({ ...result, [prog]: masterProgress[prog] }), {})
|
||||
progressStats.bcMsProgStats = Object.keys(bcmsProgress)
|
||||
.filter(prog => !bcmsProgress[prog].every(year => year.every(value => value === 0)))
|
||||
.reduce((result, prog) => ({ ...result, [prog]: bcmsProgress[prog] }), {})
|
||||
progressStats.doctoralProgStats = Object.keys(doctoralProgress)
|
||||
.filter(prog => !doctoralProgress[prog].every(year => year.every(value => value === 0)))
|
||||
.reduce((result, prog) => ({ ...result, [prog]: doctoralProgress[prog] }), {})
|
||||
return progressStats
|
||||
}
|
||||
module.exports = { combineFacultyStudentProgress }
|
||||
|
||||
@@ -88,6 +88,7 @@ const getFacultyDataForYear = async ({
|
||||
facultyExtra,
|
||||
allTotals,
|
||||
progTotals,
|
||||
programmeNames,
|
||||
}) => {
|
||||
const { includeAllSpecials, includeGraduated } = settings
|
||||
const { startDate, endDate } = getAcademicYearDates(year, since)
|
||||
@@ -102,7 +103,7 @@ const getFacultyDataForYear = async ({
|
||||
}
|
||||
const totals = emptyTotals()
|
||||
|
||||
for (const { progId, code } of programmes) {
|
||||
for (const { progId, code, name } of programmes) {
|
||||
let elementStart = {}
|
||||
let studyrightStart = {}
|
||||
const start = moment(`${year.slice(0, 4)}-08-01`, 'YYYY-MM-DD')
|
||||
@@ -156,11 +157,18 @@ const getFacultyDataForYear = async ({
|
||||
s.semesters.filter(semester => semester.semestercode === currentSemester.semestercode)[0]?.enrollmenttype === 1
|
||||
)
|
||||
// Count stats for the programme
|
||||
if (students.length === 0) continue
|
||||
if (!(progId in programmeTableStats)) {
|
||||
programmeTableStats[progId] = years.reduce((resultObj, yearKey) => {
|
||||
return { ...resultObj, [yearKey]: [] }
|
||||
}, {})
|
||||
progTotals[progId] = emptyTotals()
|
||||
}
|
||||
if (!(progId in programmeNames)) {
|
||||
programmeNames[progId] = { code: code, ...name }
|
||||
progTotals[progId] = emptyTotals()
|
||||
}
|
||||
|
||||
const yearTotals = {
|
||||
total: students.length,
|
||||
allStarted: started.length,
|
||||
@@ -226,8 +234,9 @@ const combineFacultyStudents = async (code, programmes, allProgrammeCodes, speci
|
||||
const facultyTableStats = getYearsObject({ years, emptyArrays: true })
|
||||
const programmeTableStats = {}
|
||||
const facultyExtra = years.reduce((acc, year) => ({ ...acc, [year]: {} }), {})
|
||||
const progTotals = programmes.reduce((acc, row) => ({ ...acc, [row.progId]: emptyTotals() }), {})
|
||||
const progTotals = {}
|
||||
const allTotals = emptyTotals()
|
||||
const programmeNames = {}
|
||||
for (const year of years.reverse()) {
|
||||
if (year === 'Total') continue
|
||||
const queryParams = {
|
||||
@@ -242,6 +251,7 @@ const combineFacultyStudents = async (code, programmes, allProgrammeCodes, speci
|
||||
facultyExtra,
|
||||
allTotals,
|
||||
progTotals,
|
||||
programmeNames,
|
||||
}
|
||||
const totals = await getFacultyDataForYear(queryParams)
|
||||
if (totals.total !== 0) {
|
||||
@@ -253,6 +263,7 @@ const combineFacultyStudents = async (code, programmes, allProgrammeCodes, speci
|
||||
Object.keys(progTotals).forEach(programme =>
|
||||
addTotalsProgramme(programmeTableStats, programme, 'Total', progTotals[programme])
|
||||
)
|
||||
|
||||
const studentsData = {
|
||||
id: code,
|
||||
years: years,
|
||||
@@ -260,10 +271,7 @@ const combineFacultyStudents = async (code, programmes, allProgrammeCodes, speci
|
||||
facultyTableStatsExtra: facultyExtra,
|
||||
programmeStats: programmeTableStats,
|
||||
titles: tableTitles['programmes'],
|
||||
programmeNames: programmes.reduce(
|
||||
(obj, dataItem) => ({ ...obj, [dataItem.progId]: { code: dataItem.code, ...dataItem.name } }),
|
||||
{}
|
||||
),
|
||||
programmeNames: programmeNames,
|
||||
}
|
||||
return studentsData
|
||||
}
|
||||
|
||||
@@ -11,22 +11,15 @@ const {
|
||||
} = require('../studyprogrammeHelpers')
|
||||
|
||||
const getFacultyThesisWriters = async ({ since, years, isAcademicYear, facultyProgrammes, includeAllSpecials }) => {
|
||||
const thesisTypes = [
|
||||
'urn:code:course-unit-type:bachelors-thesis',
|
||||
'urn:code:course-unit-type:masters-thesis',
|
||||
'urn:code:course-unit-type:doctors-thesis',
|
||||
'urn:code:course-unit-type:licentiate-thesis',
|
||||
]
|
||||
const thesisTypes = ['urn:code:course-unit-type:bachelors-thesis', 'urn:code:course-unit-type:masters-thesis']
|
||||
|
||||
let bachelors = getStatsBasis(years)
|
||||
let masters = getStatsBasis(years)
|
||||
let doctors = getStatsBasis(years)
|
||||
let licentiates = getStatsBasis(years)
|
||||
let programmeCounts = {}
|
||||
let programmeNames = {}
|
||||
|
||||
for (const { progId, code, name } of facultyProgrammes) {
|
||||
if (code === 'MH70_008_2') continue
|
||||
if (code === 'MH70_008_2' || code.startsWith('LIS') || code.startsWith('T')) continue
|
||||
const provider = mapToProviders([code])[0]
|
||||
const students = await getCorrectStudentnumbers({
|
||||
codes: [code],
|
||||
@@ -42,7 +35,7 @@ const getFacultyThesisWriters = async ({ since, years, isAcademicYear, facultyPr
|
||||
if (!(progId in programmeCounts)) {
|
||||
programmeCounts[progId] = {}
|
||||
|
||||
Object.keys(bachelors.tableStats).forEach(year => (programmeCounts[progId][year] = [0, 0, 0, 0, 0]))
|
||||
Object.keys(bachelors.tableStats).forEach(year => (programmeCounts[progId][year] = [0, 0, 0]))
|
||||
programmeNames[progId] = { ...name, code: code }
|
||||
}
|
||||
programmeCounts[progId][thesisYear][0] += 1
|
||||
@@ -55,19 +48,11 @@ const getFacultyThesisWriters = async ({ since, years, isAcademicYear, facultyPr
|
||||
masters.graphStats[indexOf(years, thesisYear)] += 1
|
||||
masters.tableStats[thesisYear] += 1
|
||||
programmeCounts[progId][thesisYear][2] += 1
|
||||
} else if (courseUnitType === thesisTypes[2]) {
|
||||
doctors.graphStats[indexOf(years, thesisYear)] += 1
|
||||
doctors.tableStats[thesisYear] += 1
|
||||
programmeCounts[progId][thesisYear][3] += 1
|
||||
} else if (courseUnitType === thesisTypes[3]) {
|
||||
licentiates.graphStats[indexOf(years, thesisYear)] += 1
|
||||
licentiates.tableStats[thesisYear] += 1
|
||||
programmeCounts[progId][thesisYear][4] += 1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return { bachelors, masters, doctors, licentiates, programmeCounts, programmeNames }
|
||||
return { bachelors, masters, programmeCounts, programmeNames }
|
||||
}
|
||||
|
||||
const getFacultyThesisWritersForProgrammes = async (
|
||||
@@ -79,24 +64,18 @@ const getFacultyThesisWritersForProgrammes = async (
|
||||
const since = isAcademicYear ? new Date('2017-08-01') : new Date('2017-01-01')
|
||||
const years = getYearsArray(since.getFullYear(), isAcademicYear)
|
||||
const queryParameters = { since, years, isAcademicYear, facultyProgrammes, includeAllSpecials }
|
||||
const { bachelors, masters, doctors, licentiates, programmeCounts, programmeNames } = await getFacultyThesisWriters(
|
||||
queryParameters
|
||||
)
|
||||
const { bachelors, masters, programmeCounts, programmeNames } = await getFacultyThesisWriters(queryParameters)
|
||||
|
||||
allThesisWriters.years = years.map(year => year.toString())
|
||||
const reversedYears = years.reverse()
|
||||
allThesisWriters.tableStats = reversedYears.map(year => [
|
||||
year,
|
||||
bachelors.tableStats[year] + masters.tableStats[year] + doctors.tableStats[year] + licentiates.tableStats[year],
|
||||
bachelors.tableStats[year] + masters.tableStats[year],
|
||||
bachelors.tableStats[year],
|
||||
masters.tableStats[year],
|
||||
doctors.tableStats[year],
|
||||
licentiates.tableStats[year],
|
||||
])
|
||||
allThesisWriters.graphStats.push({ name: 'Bachelors', data: bachelors.graphStats })
|
||||
allThesisWriters.graphStats.push({ name: 'Masters', data: masters.graphStats })
|
||||
allThesisWriters.graphStats.push({ name: 'Doctors', data: doctors.graphStats })
|
||||
allThesisWriters.graphStats.push({ name: 'Licentiates', data: licentiates.graphStats })
|
||||
|
||||
const programmes = programmeNames ? Object.keys(programmeNames) : facultyProgrammes.map(programme => programme.code)
|
||||
programmes.forEach(programmeId => {
|
||||
@@ -120,7 +99,7 @@ const combineFacultyThesisWriters = async (faculty, facultyProgrammes, yearType,
|
||||
tableStats: [],
|
||||
graphStats: [],
|
||||
programmeTableStats: {},
|
||||
titles: ['', 'All', 'Bachelors', 'Masters', 'Doctors', 'Licentiates'],
|
||||
titles: ['', 'All', 'Bachelors', 'Masters'],
|
||||
programmeNames: {},
|
||||
status: 'Done',
|
||||
lastUpdated: '',
|
||||
|
||||
@@ -100,13 +100,12 @@ const updateFacultyOverview = async (faculty, statsType) => {
|
||||
)
|
||||
await setBasicStats(updatedStudentInfo, option.yearType, option.programmeFilter, option.specialGroups)
|
||||
}
|
||||
if (statsType === 'ALL' || statsType === 'CREDITS') {
|
||||
if ((statsType === 'ALL' || statsType === 'CREDITS') && specialGroups !== 'SPECIAL_EXCLUDED') {
|
||||
const updatedCredits = await combineFacultyCredits(
|
||||
faculty,
|
||||
programmeFilter === 'ALL_PROGRAMMES' ? allProgrammes.data : newProgrammes.data,
|
||||
allProgrammes.data,
|
||||
yearType,
|
||||
specialGroups
|
||||
yearType
|
||||
)
|
||||
await setCreditStats(updatedCredits, yearType, programmeFilter, specialGroups)
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ const {
|
||||
} = require('./openUniHelpers')
|
||||
const { Op } = require('sequelize')
|
||||
|
||||
// 1. iteration: time is hardcoded. Check hyväksytty grades
|
||||
const getCredits = async (courseCodes, startdate) =>
|
||||
(
|
||||
await Credit.findAll({
|
||||
|
||||
@@ -25,6 +25,7 @@ const { CourseStatsCounter } = require('./course_stats_counter')
|
||||
const { getPassingSemester, semesterEnd, semesterStart } = require('../util/semester')
|
||||
const { getAllProgrammes } = require('./studyrights')
|
||||
const { encrypt } = require('../services/encrypt')
|
||||
const { getCriteria } = require('./studyProgrammeCriteria')
|
||||
|
||||
const enrolmentDates = () => {
|
||||
const query = 'SELECT DISTINCT s.dateOfUniversityEnrollment as date FROM Student s'
|
||||
@@ -38,7 +39,56 @@ const universityEnrolmentDates = async () => {
|
||||
.filter(d => d)
|
||||
.sort()
|
||||
}
|
||||
// Progress tab related helper functions.
|
||||
const createEmptyCriteriaYear = (criteria, year) => {
|
||||
return {
|
||||
credits: false,
|
||||
totalSatisfied: 0,
|
||||
coursesSatisfied:
|
||||
criteria?.courses && criteria?.courses[year]
|
||||
? criteria.courses[year].reduce((acc, course) => {
|
||||
acc[course] = null
|
||||
return acc
|
||||
}, {})
|
||||
: {},
|
||||
}
|
||||
}
|
||||
|
||||
const getCreditAmount = (courseDate, credits, startDate, addition) => {
|
||||
return moment(courseDate).isBetween(moment(startDate), moment(startDate).add(addition, 'year')) ? credits : 0
|
||||
}
|
||||
|
||||
const updateCourseByYear = (criteria, criteriaYear, course, criteriaChecked, yearToAdd, correctCode) => {
|
||||
if (
|
||||
criteria?.courses &&
|
||||
criteria?.courses[criteriaYear] &&
|
||||
(criteria.courses[criteriaYear].includes(course.course_code) ||
|
||||
criteria.courses[criteriaYear].some(
|
||||
c => criteria.allCourses[c] && criteria.allCourses[c].includes(course.course_code)
|
||||
))
|
||||
) {
|
||||
if (
|
||||
!criteriaChecked[yearToAdd].coursesSatisfied[correctCode] ||
|
||||
new Date(criteriaChecked[yearToAdd].coursesSatisfied[correctCode]) > new Date(course.date)
|
||||
) {
|
||||
criteriaChecked[yearToAdd].coursesSatisfied[correctCode] = course.date
|
||||
}
|
||||
}
|
||||
}
|
||||
const updateCreditcriteriaInfo = (criteria, criteriaYear, criteriaChecked, yearToAdd, academicYears, academicYear) => {
|
||||
if (criteria.courses) {
|
||||
if (criteriaChecked?.[yearToAdd]) {
|
||||
criteriaChecked[yearToAdd].totalSatisfied +=
|
||||
Object.keys(criteriaChecked?.[yearToAdd].coursesSatisfied).filter(
|
||||
course => criteriaChecked?.[yearToAdd].coursesSatisfied[course] !== null
|
||||
).length || 0
|
||||
}
|
||||
if (academicYears[academicYear] >= criteria?.credits[criteriaYear]) {
|
||||
criteriaChecked[yearToAdd].credits = true
|
||||
criteriaChecked[yearToAdd].totalSatisfied += 1
|
||||
}
|
||||
}
|
||||
}
|
||||
const formatStudentForPopulationStatistics = (
|
||||
{
|
||||
firstnames,
|
||||
@@ -48,6 +98,7 @@ const formatStudentForPopulationStatistics = (
|
||||
creditcount,
|
||||
abbreviatedname,
|
||||
email,
|
||||
secondary_email,
|
||||
phone_number,
|
||||
studyrights,
|
||||
studyplans,
|
||||
@@ -68,7 +119,8 @@ const formatStudentForPopulationStatistics = (
|
||||
credits,
|
||||
startDate,
|
||||
startDateMoment,
|
||||
endDateMoment
|
||||
endDateMoment,
|
||||
criteria
|
||||
) => {
|
||||
const toCourse = ({ grade, attainment_date, credits, course_code, credittypecode, isStudyModule, language }) => {
|
||||
const attainment_date_normailized =
|
||||
@@ -86,9 +138,56 @@ const formatStudentForPopulationStatistics = (
|
||||
language,
|
||||
}
|
||||
}
|
||||
const criteriaCoursesBySubstitutions = criteria?.allCourses
|
||||
? Object.keys(criteria.allCourses).reduce((acc, code) => {
|
||||
acc[code] = code
|
||||
criteria.allCourses[code].map(subst => (acc[subst] = code))
|
||||
return acc
|
||||
}, {})
|
||||
: {}
|
||||
|
||||
const toProgressCriteria = () => {
|
||||
const criteriaChecked = {
|
||||
year1: createEmptyCriteriaYear(criteria, 'yearOne'),
|
||||
year2: createEmptyCriteriaYear(criteria, 'yearTwo'),
|
||||
year3: createEmptyCriteriaYear(criteria, 'yearThree'),
|
||||
year4: createEmptyCriteriaYear(criteria, 'yearFour'),
|
||||
year5: createEmptyCriteriaYear(criteria, 'yearFive'),
|
||||
year6: createEmptyCriteriaYear(criteria, 'yearSix'),
|
||||
}
|
||||
|
||||
const academicYears = { first: 0, second: 0, third: 0, fourth: 0, fifth: 0, sixth: 0 }
|
||||
if (criteria.courses || criteria.credits) {
|
||||
const courses = credits[studentnumber] ? credits[studentnumber].map(toCourse) : []
|
||||
courses.forEach(course => {
|
||||
if (course.passed) {
|
||||
const correctCode = criteriaCoursesBySubstitutions[course.course_code]
|
||||
updateCourseByYear(criteria, 'yearOne', course, criteriaChecked, 'year1', correctCode)
|
||||
updateCourseByYear(criteria, 'yearTwo', course, criteriaChecked, 'year2', correctCode)
|
||||
updateCourseByYear(criteria, 'yearThree', course, criteriaChecked, 'year3', correctCode)
|
||||
updateCourseByYear(criteria, 'yearFour', course, criteriaChecked, 'year4', correctCode)
|
||||
updateCourseByYear(criteria, 'yearFive', course, criteriaChecked, 'year5', correctCode)
|
||||
updateCourseByYear(criteria, 'yearSix', course, criteriaChecked, 'year6', correctCode)
|
||||
academicYears.first += getCreditAmount(course.date, course.credits, startDate, 1)
|
||||
academicYears.second += getCreditAmount(course.date, course.credits, startDate, 2)
|
||||
academicYears.third += getCreditAmount(course.date, course.credits, startDate, 3)
|
||||
academicYears.fourth += getCreditAmount(course.date, course.credits, startDate, 4)
|
||||
academicYears.fifth += getCreditAmount(course.date, course.credits, startDate, 5)
|
||||
academicYears.sixth += getCreditAmount(course.date, course.credits, startDate, 6)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
updateCreditcriteriaInfo(criteria, 'yearOne', criteriaChecked, 'year1', academicYears, 'first')
|
||||
updateCreditcriteriaInfo(criteria, 'yearTwo', criteriaChecked, 'year2', academicYears, 'second')
|
||||
updateCreditcriteriaInfo(criteria, 'yearThree', criteriaChecked, 'year3', academicYears, 'third')
|
||||
updateCreditcriteriaInfo(criteria, 'yearFour', criteriaChecked, 'year4', academicYears, 'fourth')
|
||||
updateCreditcriteriaInfo(criteria, 'yearFive', criteriaChecked, 'year5', academicYears, 'fifth')
|
||||
updateCreditcriteriaInfo(criteria, 'yearSix', criteriaChecked, 'year6', academicYears, 'sixth')
|
||||
return criteriaChecked
|
||||
}
|
||||
|
||||
studyrights = studyrights || []
|
||||
|
||||
const started = dateofuniversityenrollment
|
||||
return {
|
||||
firstnames,
|
||||
@@ -104,6 +203,7 @@ const formatStudentForPopulationStatistics = (
|
||||
gender_code,
|
||||
gender: { gender_en, gender_fi, gender_sv },
|
||||
email,
|
||||
secondaryEmail: secondary_email,
|
||||
phoneNumber: phone_number,
|
||||
semesterenrollments: semester_enrollments || [],
|
||||
updatedAt: updatedAt || createdAt,
|
||||
@@ -114,6 +214,7 @@ const formatStudentForPopulationStatistics = (
|
||||
birthdate,
|
||||
studyplans,
|
||||
sis_person_id,
|
||||
criteriaProgress: toProgressCriteria(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,6 +334,7 @@ const getStudentsIncludeCoursesBetween = async (studentnumbers, startDate, endDa
|
||||
'creditcount',
|
||||
'abbreviatedname',
|
||||
'email',
|
||||
'secondary_email',
|
||||
'phone_number',
|
||||
'updatedAt',
|
||||
'gender_code',
|
||||
@@ -261,6 +363,7 @@ const getStudentsIncludeCoursesBetween = async (studentnumbers, startDate, endDa
|
||||
'faculty_code',
|
||||
'studystartdate',
|
||||
'admission_type',
|
||||
'cancelled',
|
||||
],
|
||||
separate: true,
|
||||
include: [
|
||||
@@ -291,7 +394,7 @@ const getStudentsIncludeCoursesBetween = async (studentnumbers, startDate, endDa
|
||||
},
|
||||
{
|
||||
model: Studyplan,
|
||||
attributes: ['included_courses', 'programme_code', 'completed_credits'],
|
||||
attributes: ['included_courses', 'programme_code', 'completed_credits', 'studyrightid'],
|
||||
separate: true,
|
||||
},
|
||||
],
|
||||
@@ -749,7 +852,8 @@ const formatStudentsForApi = async (
|
||||
startDate,
|
||||
endDate,
|
||||
{ studyRights },
|
||||
optionData
|
||||
optionData,
|
||||
criteria
|
||||
) => {
|
||||
const startDateMoment = moment(startDate)
|
||||
const endDateMoment = moment(endDate)
|
||||
@@ -783,8 +887,17 @@ const formatStudentsForApi = async (
|
||||
})
|
||||
if (student.studentnumber in optionData) student.option = optionData[student.studentnumber]
|
||||
else student.option = null
|
||||
|
||||
stats.students.push(
|
||||
formatStudentForPopulationStatistics(student, enrollments, credits, startDate, startDateMoment, endDateMoment)
|
||||
formatStudentForPopulationStatistics(
|
||||
student,
|
||||
enrollments,
|
||||
credits,
|
||||
startDate,
|
||||
startDateMoment,
|
||||
endDateMoment,
|
||||
criteria
|
||||
)
|
||||
)
|
||||
return stats
|
||||
},
|
||||
@@ -868,16 +981,17 @@ const optimizedStatisticsOf = async (query, studentnumberlist) => {
|
||||
nondegreeStudents,
|
||||
transferredStudents
|
||||
)
|
||||
// wtf
|
||||
// plz
|
||||
const code = studyRights[0] || ''
|
||||
let optionData = {}
|
||||
let criteria = {}
|
||||
if (code.includes('MH')) {
|
||||
optionData = await getOptionsForStudents(studentnumbers, code, 'MSC')
|
||||
} else if (code.includes('KH')) {
|
||||
optionData = await getOptionsForStudents(studentnumbers, code, 'BSC')
|
||||
}
|
||||
|
||||
if (code.includes('KH') || ['MH30_001', 'MH30_003'].includes(code)) {
|
||||
criteria = await getCriteria(code)
|
||||
}
|
||||
const { students, enrollments, credits, extents, semesters, elementdetails, courses } =
|
||||
await getStudentsIncludeCoursesBetween(
|
||||
studentnumbers,
|
||||
@@ -892,7 +1006,8 @@ const optimizedStatisticsOf = async (query, studentnumberlist) => {
|
||||
startDate,
|
||||
endDate,
|
||||
formattedQueryParams,
|
||||
optionData
|
||||
optionData,
|
||||
criteria
|
||||
)
|
||||
|
||||
return formattedStudents
|
||||
@@ -902,10 +1017,52 @@ const getSubstitutions = async codes => {
|
||||
const courses = await Course.findAll({ where: { code: codes }, attributes: ['code', 'substitutions'], raw: true })
|
||||
return [...new Set(courses.map(({ code, substitutions }) => [code, ...substitutions]).flat())]
|
||||
}
|
||||
|
||||
// This duplicate code is added here to ensure that we get the enrollments in cases no credits found for the selected students.
|
||||
const findCourseEnrollments = async (studentnumbers, beforeDate, courses = [], studentCountLimit = 0) => {
|
||||
const courseCodes = courses.length > 0 ? await getSubstitutions(courses) : ['DUMMY']
|
||||
const res = await sequelize.query(
|
||||
`
|
||||
SELECT DISTINCT ON (course.id)
|
||||
course.code,
|
||||
course.name,
|
||||
course.coursetypecode,
|
||||
course.substitutions,
|
||||
course.main_course_code,
|
||||
course_types.name AS course_type,
|
||||
enrollment.data AS enrollments
|
||||
FROM course
|
||||
INNER JOIN course_types ON course_types.coursetypecode = course.coursetypecode
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
course_id,
|
||||
ARRAY_AGG(JSON_BUILD_OBJECT(
|
||||
'studentnumber', studentnumber,
|
||||
'state', state,
|
||||
'enrollment_date_time', enrollment_date_time
|
||||
)) AS data
|
||||
FROM enrollment
|
||||
WHERE enrollment.studentnumber IN (:studentnumbers) AND enrollment.enrollment_date_time < :beforeDate
|
||||
GROUP BY enrollment.course_id
|
||||
HAVING COUNT(DISTINCT enrollment.studentnumber) >= :studentCountLimit
|
||||
) enrollment ON enrollment.course_id = course.id
|
||||
WHERE :skipCourseCodeFilter OR course.code IN (:courseCodes)
|
||||
-- GROUP BY 1, 2, 3, 4, 5, 6
|
||||
`,
|
||||
{
|
||||
replacements: {
|
||||
studentnumbers: studentnumbers.length > 0 ? studentnumbers : ['DUMMY'],
|
||||
beforeDate,
|
||||
studentCountLimit,
|
||||
courseCodes,
|
||||
skipCourseCodeFilter: courses.length === 0,
|
||||
},
|
||||
type: sequelize.QueryTypes.SELECT,
|
||||
}
|
||||
)
|
||||
return res
|
||||
}
|
||||
const findCourses = async (studentnumbers, beforeDate, courses = [], studentCountLimit = 0) => {
|
||||
const courseCodes = courses.length > 0 ? await getSubstitutions(courses) : ['DUMMY']
|
||||
|
||||
const res = await sequelize.query(
|
||||
`
|
||||
SELECT DISTINCT ON (course.id)
|
||||
@@ -1030,14 +1187,22 @@ const bottlenecksOf = async (query, studentnumberlist, encryptdata = false) => {
|
||||
numbers[num] = true
|
||||
return numbers
|
||||
}, {})
|
||||
|
||||
const courses = await findCourses(
|
||||
studentnumbers,
|
||||
dateMonthsFromNow(startDate, months),
|
||||
courseCodes,
|
||||
query.studentCountLimit
|
||||
)
|
||||
return [allstudents, courses]
|
||||
const foundCourseCodes = Object.keys(keyBy(courses, 'code'))
|
||||
const filteredCourseCodes = courseCodes?.filter(code => !foundCourseCodes.includes(code))
|
||||
|
||||
const courseEnrollements = await findCourseEnrollments(
|
||||
studentnumbers,
|
||||
dateMonthsFromNow(startDate, months),
|
||||
filteredCourseCodes,
|
||||
query.studentCountLimit
|
||||
)
|
||||
return [allstudents, courses, courseEnrollements]
|
||||
} else {
|
||||
const { months, startDate } = params
|
||||
const beforeDate = months && startDate ? dateMonthsFromNow(startDate, months) : new Date()
|
||||
@@ -1047,7 +1212,16 @@ const bottlenecksOf = async (query, studentnumberlist, encryptdata = false) => {
|
||||
return numbers
|
||||
}, {})
|
||||
const courses = await findCourses(studentnumberlist, beforeDate, courseCodes, query.studentCountLimit)
|
||||
return [allstudents, courses]
|
||||
const foundCourseCodes = Object.keys(keyBy(courses, 'code'))
|
||||
const filteredCourseCodes = courseCodes?.filter(code => !foundCourseCodes.includes(code))
|
||||
|
||||
const courseEnrollements = await findCourseEnrollments(
|
||||
studentnumberlist,
|
||||
dateMonthsFromNow(startDate, months),
|
||||
filteredCourseCodes,
|
||||
query.studentCountLimit
|
||||
)
|
||||
return [allstudents, courses, courseEnrollements]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1067,24 +1241,52 @@ const bottlenecksOf = async (query, studentnumberlist, encryptdata = false) => {
|
||||
}
|
||||
|
||||
const params = parseQueryParams(query)
|
||||
const [[allstudents, courses], error] = await Promise.all([
|
||||
const allStudentsByYears = query?.selectedStudentsByYear
|
||||
? Object.keys(query.selectedStudentsByYear).reduce(
|
||||
(res, year) => [...res, ...query.selectedStudentsByYear[year]],
|
||||
[]
|
||||
)
|
||||
: []
|
||||
// To fix failed and enrolled, no grade filter options some not so clean and nice solutions were added
|
||||
// Get the data with actual 1. courses and filtered students. 2. all students by year, if provided.
|
||||
const [[allstudents, courses, courseEnrollements], [, allCourses], error] = await Promise.all([
|
||||
getStudentsAndCourses(query.selectedStudents, studentnumberlist, query.courses),
|
||||
getStudentsAndCourses(allStudentsByYears, null, query.courses),
|
||||
isValidRequest(query, params),
|
||||
])
|
||||
if (error) return error
|
||||
|
||||
if (error) return error
|
||||
// Get the substitution codes for the fetch data by selscted students
|
||||
const substitutionCodes = Object.entries(courses).reduce(
|
||||
(res, [, obj]) => [...res, ...(obj?.substitutions || [])],
|
||||
[]
|
||||
)
|
||||
const codes = Object.keys(keyBy(courses, 'code')).map(code => code)
|
||||
// Filter substitution courses for fetched courses -> this avoid the situation in which there is only
|
||||
// courses with old course codes. Frontend NEEDS in most cases the current course.
|
||||
const substitutionCourses = allCourses.filter(
|
||||
obj => substitutionCodes.includes(obj.code) && !codes.includes(obj.code)
|
||||
)
|
||||
const bottlenecks = {
|
||||
disciplines: {},
|
||||
coursetypes: {},
|
||||
}
|
||||
|
||||
const stats = {}
|
||||
|
||||
const startYear = parseInt(query.year, 10)
|
||||
const allstudentslength = Object.keys(allstudents).length
|
||||
const coursesByCode = keyBy(courses, 'code')
|
||||
let coursesToLoop = courses.concat(substitutionCourses)
|
||||
const codesList = coursesToLoop.map(course => course.code)
|
||||
// This fix problem when Enrolled no grade is chosen. The sql query for fetching
|
||||
// credits do not fetch enrollments if no credits found for selected students.
|
||||
// This and other sql query ensures that enrollments are added.
|
||||
const coursesOnlyWithEnrollments = courseEnrollements.filter(
|
||||
course => !codesList.includes(course.code) && course.enrollments
|
||||
)
|
||||
coursesToLoop = coursesToLoop.concat(coursesOnlyWithEnrollments)
|
||||
|
||||
for (const course of courses) {
|
||||
const coursesByCode = keyBy(coursesToLoop, 'code')
|
||||
for (const course of coursesToLoop) {
|
||||
let { course_type } = course
|
||||
let maincourse = course
|
||||
|
||||
@@ -1101,28 +1303,32 @@ const bottlenecksOf = async (query, studentnumberlist, encryptdata = false) => {
|
||||
}
|
||||
|
||||
const coursestats = stats[maincourse.code]
|
||||
|
||||
coursestats.addCourseType(course_type.coursetypecode, course_type.name)
|
||||
coursestats.addCourseSubstitutions(course.substitutions)
|
||||
bottlenecks.coursetypes[course_type.coursetypecode] = course_type.name
|
||||
|
||||
course.credits.forEach(credit => {
|
||||
const { studentnumber, passingGrade, improvedGrade, failingGrade, grade, date } = parseCreditInfo(credit)
|
||||
const semester = getPassingSemester(startYear, date)
|
||||
coursestats.markCredit(studentnumber, grade, passingGrade, failingGrade, improvedGrade, semester)
|
||||
})
|
||||
|
||||
if (course.enrollments) {
|
||||
course.enrollments.forEach(({ studentnumber, state, enrollment_date_time }) => {
|
||||
const semester = getPassingSemester(startYear, enrollment_date_time)
|
||||
coursestats.markEnrollment(studentnumber, state, semester)
|
||||
if ((query?.selectedStudents && query?.selectedStudents.includes(studentnumber)) || !query?.selectedStudents) {
|
||||
const semester = getPassingSemester(startYear, enrollment_date_time)
|
||||
coursestats.markEnrollment(studentnumber, state, semester, enrollment_date_time)
|
||||
}
|
||||
})
|
||||
}
|
||||
if (course.credits) {
|
||||
course.credits.forEach(credit => {
|
||||
const { studentnumber, passingGrade, improvedGrade, failingGrade, grade, date } = parseCreditInfo(credit)
|
||||
if ((query?.selectedStudents && query?.selectedStudents.includes(studentnumber)) || !query?.selectedStudents) {
|
||||
const semester = getPassingSemester(startYear, date)
|
||||
coursestats.markCredit(studentnumber, grade, passingGrade, failingGrade, improvedGrade, semester)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
stats[maincourse.code] = coursestats
|
||||
}
|
||||
|
||||
bottlenecks.coursestatistics = Object.values(stats).map(coursestatistics => coursestatistics.getFinalStats())
|
||||
const allStats = Object.values(stats).map(coursestatistics => coursestatistics.getFinalStats())
|
||||
bottlenecks.coursestatistics = allStats.filter(course => course.stats.students > 0)
|
||||
bottlenecks.allStudents = allstudentslength
|
||||
|
||||
if (encryptdata) encryptStudentnumbers(bottlenecks)
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
const { Credit, Enrollment } = require('../models')
|
||||
const { Op } = require('sequelize')
|
||||
const _ = require('lodash')
|
||||
|
||||
const getCompletedCourses = async (studentNumbers, courseCodes) => {
|
||||
let credits = await Credit.findAll({
|
||||
attributes: ['course_code', 'student_studentnumber', 'credittypecode'],
|
||||
where: {
|
||||
course_code: {
|
||||
[Op.in]: courseCodes,
|
||||
},
|
||||
student_studentnumber: {
|
||||
[Op.in]: studentNumbers,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
let enrollments = await Enrollment.findAll({
|
||||
attributes: ['course_code', 'enrollment_date_time', 'studentnumber'],
|
||||
where: {
|
||||
course_code: {
|
||||
[Op.in]: courseCodes,
|
||||
},
|
||||
studentnumber: {
|
||||
[Op.in]: studentNumbers,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
credits = credits.map(credit => {
|
||||
const { course_code, student_studentnumber, credittypecode } = credit
|
||||
return { courseCode: course_code, studentNumber: student_studentnumber, creditType: credittypecode }
|
||||
})
|
||||
|
||||
enrollments = enrollments.map(enrollment => {
|
||||
return {
|
||||
courseCode: enrollment.course_code,
|
||||
studentNumber: enrollment.studentnumber,
|
||||
date: enrollment.enrollment_date_time,
|
||||
}
|
||||
})
|
||||
|
||||
const createFieldsIfNeeded = student => {
|
||||
if (!studentCredits[student]) {
|
||||
studentCredits[student] = { credits: [], enrollments: [] }
|
||||
}
|
||||
}
|
||||
|
||||
const studentCredits = {}
|
||||
|
||||
credits.forEach(credit => {
|
||||
createFieldsIfNeeded(credit.studentNumber)
|
||||
studentCredits[credit.studentNumber].credits.push({
|
||||
courseCode: credit.courseCode,
|
||||
creditType: credit.creditType,
|
||||
})
|
||||
})
|
||||
|
||||
enrollments.forEach(enrollment => {
|
||||
createFieldsIfNeeded(enrollment.studentNumber)
|
||||
if (credits.find(credit => credit.courseCode === enrollment.courseCode)) {
|
||||
return
|
||||
}
|
||||
if (enrollment.date === null) {
|
||||
return
|
||||
}
|
||||
studentCredits[enrollment.studentNumber].enrollments.push({
|
||||
date: enrollment.date,
|
||||
courseCode: enrollment.courseCode,
|
||||
})
|
||||
})
|
||||
|
||||
const students = Object.keys(studentCredits).reduce(
|
||||
(acc, student) => [
|
||||
...acc,
|
||||
{
|
||||
studentNumber: student,
|
||||
credits: studentCredits[student].credits,
|
||||
enrollments: studentCredits[student].enrollments,
|
||||
},
|
||||
],
|
||||
[]
|
||||
)
|
||||
|
||||
courseCodes = [...new Set(courseCodes)]
|
||||
|
||||
// Choose the latest enrollment and throw others out
|
||||
students.forEach(student => {
|
||||
courseCodes.forEach(courseCode => {
|
||||
let [hits, rest] = _.partition(student.enrollments, e => e.courseCode === courseCode)
|
||||
if (hits?.length === 0) return
|
||||
let latest = hits[0]
|
||||
for (let hit of hits) {
|
||||
if (hit > latest) {
|
||||
latest = hit
|
||||
}
|
||||
}
|
||||
student.enrollments = [latest, ...rest]
|
||||
})
|
||||
})
|
||||
|
||||
return { students, courseCodes }
|
||||
}
|
||||
|
||||
module.exports = { getCompletedCourses }
|
||||
@@ -13,6 +13,7 @@ const {
|
||||
SemesterEnrollment,
|
||||
Semester,
|
||||
Studyplan,
|
||||
Transfer,
|
||||
} = require('../models')
|
||||
const { TagStudent, Tag } = require('../models/models_kone')
|
||||
const Op = Sequelize.Op
|
||||
@@ -60,7 +61,10 @@ const byId = async id => {
|
||||
},
|
||||
{
|
||||
model: Studyplan,
|
||||
attributes: ['included_courses', 'programme_code', 'completed_credits'],
|
||||
attributes: ['included_courses', 'programme_code', 'completed_credits', 'studyrightid'],
|
||||
},
|
||||
{
|
||||
model: Transfer,
|
||||
},
|
||||
],
|
||||
}),
|
||||
@@ -347,6 +351,20 @@ const studentnumberLike = terms => {
|
||||
const bySearchTerm = async searchterm => {
|
||||
const terms = splitByEmptySpace(searchterm)
|
||||
const matches = await Student.findAll({
|
||||
include: {
|
||||
model: Studyright,
|
||||
include: {
|
||||
model: StudyrightElement,
|
||||
include: {
|
||||
model: ElementDetail,
|
||||
where: {
|
||||
type: {
|
||||
[Op.in]: [10, 20, 30],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
where: {
|
||||
[Op.or]: [nameLike(terms), studentnumberLike(terms)],
|
||||
},
|
||||
@@ -357,6 +375,20 @@ const bySearchTerm = async searchterm => {
|
||||
const bySearchTermAndStudentNumbers = async (searchterm, studentnumbers) => {
|
||||
const terms = splitByEmptySpace(searchterm)
|
||||
const matches = await Student.findAll({
|
||||
include: {
|
||||
model: Studyright,
|
||||
include: {
|
||||
model: StudyrightElement,
|
||||
include: {
|
||||
model: ElementDetail,
|
||||
where: {
|
||||
type: {
|
||||
[Op.in]: [10, 20, 30],
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
where: {
|
||||
[Op.and]: {
|
||||
[Op.or]: [nameLike(terms), studentnumberLike(terms)],
|
||||
|
||||
@@ -0,0 +1,147 @@
|
||||
const { ProgressCriteria } = require('../models/models_kone')
|
||||
const { Course } = require('../models')
|
||||
const logger = require('../util/logger')
|
||||
|
||||
const getCriteriaByStudyProgramme = code =>
|
||||
ProgressCriteria.findOne({
|
||||
where: {
|
||||
code: code,
|
||||
},
|
||||
})
|
||||
|
||||
const getSubstitutions = async codes => {
|
||||
if (codes === []) return []
|
||||
const courses = await Course.findAll({ where: { code: codes }, attributes: ['code', 'substitutions'], raw: true })
|
||||
return courses.reduce((acc, { code, substitutions }) => ({ ...acc, [code]: substitutions }), {})
|
||||
}
|
||||
|
||||
const formattedData = async data => {
|
||||
const yearOne = data.coursesYearOne ? data.coursesYearOne : []
|
||||
const yearTwo = data.coursesYearTwo ? data.coursesYearTwo : []
|
||||
const yearThree = data.coursesYearThree ? data.coursesYearThree : []
|
||||
const yearFour = data.coursesYearFour ? data.coursesYearFour : []
|
||||
const yearFive = data.coursesYearFive ? data.coursesYearFive : []
|
||||
const yearSix = data.coursesYearSix ? data.coursesYearSix : []
|
||||
const courseCodes = [...yearOne, ...yearTwo, ...yearThree, ...yearFour, ...yearFive, ...yearSix]
|
||||
const allCourses = await getSubstitutions(courseCodes)
|
||||
|
||||
const criteria = {
|
||||
courses: { yearOne, yearTwo, yearThree, yearFour, yearFive, yearSix },
|
||||
allCourses,
|
||||
credits: {
|
||||
yearOne: data.creditsYearOne ? data.creditsYearOne : 0,
|
||||
yearTwo: data.creditsYearTwo ? data.creditsYearTwo : 0,
|
||||
yearThree: data.creditsYearThree ? data.creditsYearThree : 0,
|
||||
yearFour: data.creditsYearFour ? data.creditsYearFour : 0,
|
||||
yearFive: data.creditsYearFive ? data.creditsYearFive : 0,
|
||||
yearSix: data.creditsYearSix ? data.creditsYearSix : 0,
|
||||
},
|
||||
}
|
||||
return criteria
|
||||
}
|
||||
|
||||
const createCriteria = async (studyProgramme, courseObj, creditsObj) => {
|
||||
const newProgrammeCriteria = {
|
||||
code: studyProgramme,
|
||||
coursesYearOne: courseObj.year1,
|
||||
coursesYearTwo: courseObj.year2,
|
||||
coursesYearThree: courseObj.year3,
|
||||
coursesYearFour: courseObj.year4,
|
||||
coursesYearFive: courseObj.year5,
|
||||
coursesYearSix: courseObj.year6,
|
||||
creditsYearOne: creditsObj.year1,
|
||||
creditsYearTwo: creditsObj.year2,
|
||||
creditsYearThree: creditsObj.year3,
|
||||
creditsYearFour: creditsObj.year4,
|
||||
creditsYearFive: creditsObj.year5,
|
||||
creditsYearSix: creditsObj.year6,
|
||||
}
|
||||
try {
|
||||
const createdData = await ProgressCriteria.create(newProgrammeCriteria)
|
||||
return await formattedData(createdData)
|
||||
} catch (error) {
|
||||
logger.error(`Create criteria failed: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
const saveYearlyCreditCriteria = async (studyProgramme, credits) => {
|
||||
const studyProgrammeToUpdate = await getCriteriaByStudyProgramme(studyProgramme)
|
||||
if (!studyProgrammeToUpdate) {
|
||||
const courseObj = { year1: [], year2: [], year3: [], year4: [], year5: [], year6: [] }
|
||||
const creditsObj = {
|
||||
year1: parseInt(credits.year1),
|
||||
year2: parseInt(credits.year2),
|
||||
year3: parseInt(credits.year3),
|
||||
year4: parseInt(credits.year4),
|
||||
year5: parseInt(credits.year5),
|
||||
year6: parseInt(credits.year6),
|
||||
}
|
||||
return await createCriteria(studyProgramme, courseObj, creditsObj)
|
||||
}
|
||||
const yearlyCredits = {
|
||||
creditsYearOne: parseInt(credits.year1),
|
||||
creditsYearTwo: parseInt(credits.year2),
|
||||
creditsYearThree: parseInt(credits.year3),
|
||||
creditsYearFour: parseInt(credits.year4),
|
||||
creditsYearFive: parseInt(credits.year5),
|
||||
creditsYearSix: parseInt(credits.year6),
|
||||
}
|
||||
try {
|
||||
const updatedData = await studyProgrammeToUpdate.update({ ...yearlyCredits })
|
||||
return await formattedData(updatedData)
|
||||
} catch (error) {
|
||||
logger.error(`Update yearly credit criteria failed: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
const saveYearlyCourseCriteria = async (studyProgramme, courses, year) => {
|
||||
const studyProgrammeToUpdate = await getCriteriaByStudyProgramme(studyProgramme)
|
||||
if (!studyProgrammeToUpdate) {
|
||||
const courseObj = { year1: [], year2: [], year3: [], year4: [], year5: [], year6: [] }
|
||||
const creditObj = { year1: 0, year2: 0, year3: 0, year4: 0, year5: 0, year6: 0 }
|
||||
if (year === 1) {
|
||||
courseObj.year1 = courses
|
||||
} else if (year === 2) {
|
||||
courseObj.year2 = courses
|
||||
} else if (year === 3) {
|
||||
courseObj.year3 = courses
|
||||
} else if (year === 4) {
|
||||
courseObj.year4 = courses
|
||||
} else if (year === 5) {
|
||||
courseObj.year5 = courses
|
||||
} else {
|
||||
courseObj.year6 = courses
|
||||
}
|
||||
return await createCriteria(studyProgramme, courseObj, creditObj)
|
||||
}
|
||||
|
||||
try {
|
||||
let updatedData = {}
|
||||
if (year === 1) updatedData = await studyProgrammeToUpdate.update({ coursesYearOne: courses })
|
||||
if (year === 2) updatedData = await studyProgrammeToUpdate.update({ coursesYearTwo: courses })
|
||||
if (year === 3) updatedData = await studyProgrammeToUpdate.update({ coursesYearThree: courses })
|
||||
if (year === 4) updatedData = await studyProgrammeToUpdate.update({ coursesYearFour: courses })
|
||||
if (year === 5) updatedData = await studyProgrammeToUpdate.update({ coursesYearFive: courses })
|
||||
if (year === 6) updatedData = await studyProgrammeToUpdate.update({ coursesYearSix: courses })
|
||||
const criteria = formattedData(updatedData)
|
||||
return criteria
|
||||
} catch (error) {
|
||||
logger.error(`Update yearly credit criteria failed: ${error}`)
|
||||
}
|
||||
}
|
||||
|
||||
const getCriteria = async studyProgramme => {
|
||||
const studyProgrammeCriteria = await getCriteriaByStudyProgramme(studyProgramme)
|
||||
const criteria = {
|
||||
courses: { yearOne: [], yearTwo: [], yearThree: [], yearFour: [], yearFive: [], yearSix: [] },
|
||||
allCourses: [],
|
||||
credits: { yearOne: 0, yearTwo: 0, yearThree: 0, yearFour: 0, yearFive: 0, yearSix: 0 },
|
||||
}
|
||||
return studyProgrammeCriteria ? formattedData(studyProgrammeCriteria) : criteria
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getCriteria,
|
||||
saveYearlyCourseCriteria,
|
||||
saveYearlyCreditCriteria,
|
||||
}
|
||||
@@ -12,13 +12,16 @@ const {
|
||||
Studyright,
|
||||
StudyrightElement,
|
||||
ElementDetail,
|
||||
ProgrammeModule,
|
||||
Transfer,
|
||||
Student,
|
||||
SemesterEnrollment,
|
||||
Semester,
|
||||
Enrollment,
|
||||
} = require('../models')
|
||||
const { formatStudyright, formatStudent, formatTransfer } = require('./studyprogrammeHelpers')
|
||||
const { getCurrentSemester } = require('./semesters')
|
||||
const logger = require('../util/logger')
|
||||
|
||||
const whereStudents = studentnumbers => {
|
||||
return studentnumbers ? studentnumbers : { [Op.not]: null }
|
||||
@@ -356,7 +359,7 @@ const allTransfers = async (studytrack, since) => {
|
||||
const getProgrammesStudyrights = async studyprogramme =>
|
||||
(
|
||||
await Studyright.findAll({
|
||||
attributes: ['studyrightid', 'studystartdate', 'enddate', 'graduated', 'prioritycode', 'extentcode'],
|
||||
attributes: ['studyrightid', 'studystartdate', 'enddate', 'graduated', 'prioritycode', 'extentcode', 'cancelled'],
|
||||
include: [
|
||||
{
|
||||
model: StudyrightElement,
|
||||
@@ -379,7 +382,16 @@ const getProgrammesStudyrights = async studyprogramme =>
|
||||
const getStudyRights = async students =>
|
||||
(
|
||||
await Studyright.findAll({
|
||||
attributes: ['studyrightid', 'studystartdate', 'enddate', 'graduated', 'prioritycode', 'extentcode'],
|
||||
attributes: [
|
||||
'studyrightid',
|
||||
'startdate',
|
||||
'studystartdate',
|
||||
'enddate',
|
||||
'graduated',
|
||||
'prioritycode',
|
||||
'extentcode',
|
||||
'cancelled',
|
||||
],
|
||||
where: {
|
||||
studentStudentnumber: students,
|
||||
},
|
||||
@@ -415,9 +427,7 @@ const getCreditsForStudyProgramme = async (codes, since) => {
|
||||
},
|
||||
},
|
||||
where: {
|
||||
credittypecode: {
|
||||
[Op.notIn]: [10, 9, 7],
|
||||
},
|
||||
credittypecode: 4,
|
||||
isStudyModule: {
|
||||
[Op.not]: true,
|
||||
},
|
||||
@@ -498,16 +508,110 @@ const getStudentsForProgrammeCourses = async (from, to, programmeCourses) => {
|
||||
code: course.code,
|
||||
name: course.course_name,
|
||||
year: course.year,
|
||||
totalAllStudents: parseInt(course.total_students),
|
||||
totalPassed: parseInt(course.total_students),
|
||||
totalAllcredits: parseInt(course.total_credits),
|
||||
type: 'total',
|
||||
type: 'passed',
|
||||
}))
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log(e)
|
||||
logger.log(e)
|
||||
}
|
||||
}
|
||||
const getNotCompletedForProgrammeCourses = async (from, to, programmeCourses) => {
|
||||
try {
|
||||
const enrollmentsCourses = await Enrollment.findAll({
|
||||
attributes: ['studentnumber', 'course_code'],
|
||||
where: {
|
||||
course_code: {
|
||||
[Op.in]: programmeCourses,
|
||||
},
|
||||
studentnumber: {
|
||||
[Op.ne]: null,
|
||||
},
|
||||
enrollment_date_time: {
|
||||
[Op.between]: [from, to],
|
||||
},
|
||||
state: 'ENROLLED',
|
||||
},
|
||||
})
|
||||
const allEnrollments = {}
|
||||
for (const { studentnumber, course_code } of enrollmentsCourses) {
|
||||
if (!(course_code in allEnrollments)) {
|
||||
allEnrollments[course_code] = []
|
||||
}
|
||||
allEnrollments[course_code].push(studentnumber)
|
||||
}
|
||||
|
||||
const credits = await Credit.findAll({
|
||||
attributes: ['id', 'course_code', 'student_studentnumber', 'credittypecode', 'attainment_date'],
|
||||
include: {
|
||||
model: Course,
|
||||
attributes: ['code', 'name'],
|
||||
required: true,
|
||||
where: {
|
||||
is_study_module: false,
|
||||
code: programmeCourses,
|
||||
},
|
||||
},
|
||||
where: {
|
||||
credittypecode: [4, 7, 10],
|
||||
isStudyModule: {
|
||||
[Op.not]: true,
|
||||
},
|
||||
attainment_date: {
|
||||
[Op.between]: [from, to],
|
||||
},
|
||||
},
|
||||
})
|
||||
const creditsObj = credits.map(credit => {
|
||||
return {
|
||||
code: credit.course_code,
|
||||
studentnumber: credit.student_studentnumber,
|
||||
credittype: credit.credittypecode,
|
||||
courseName: credit.course.name,
|
||||
year: moment(credit.attainment_date).year(),
|
||||
}
|
||||
})
|
||||
|
||||
const passedByCourseCodes = {}
|
||||
const notCompletedByCourseCodes = {}
|
||||
const courses = {}
|
||||
for (const course of creditsObj) {
|
||||
if (!(course.code in courses)) {
|
||||
courses[course.code] = {
|
||||
code: course.code,
|
||||
name: course.courseName,
|
||||
year: course.year,
|
||||
}
|
||||
|
||||
passedByCourseCodes[course.code] = []
|
||||
notCompletedByCourseCodes[course.code] = []
|
||||
}
|
||||
if ([4, 7].includes(course.credittype)) {
|
||||
passedByCourseCodes[course.code].push(course.studentnumber)
|
||||
}
|
||||
if (
|
||||
(allEnrollments[course.code]?.includes(course.studentnumber) || course.credittype === 10) &&
|
||||
!passedByCourseCodes[course.code].includes(course.studentnumber)
|
||||
) {
|
||||
notCompletedByCourseCodes[course.code].push(course.studentnumber)
|
||||
}
|
||||
}
|
||||
|
||||
return Object.keys(courses)
|
||||
.reduce((acc, val) => [...acc, { ...courses[val] }], [])
|
||||
.map(course => ({
|
||||
code: course.code,
|
||||
name: course.name,
|
||||
year: course.year,
|
||||
totalNotCompleted: [...new Set(notCompletedByCourseCodes[course.code])].length,
|
||||
type: 'notCompleted',
|
||||
}))
|
||||
} catch (e) {
|
||||
// eslint-disable-next-line no-console
|
||||
logger.log(e)
|
||||
}
|
||||
}
|
||||
const getOwnStudentsForProgrammeCourses = async (from, to, programmeCourses, studyprogramme) => {
|
||||
const res = await sequelize.query(
|
||||
`
|
||||
@@ -534,7 +638,6 @@ const getOwnStudentsForProgrammeCourses = async (from, to, programmeCourses, stu
|
||||
}
|
||||
)
|
||||
return res.map(course => {
|
||||
// console.log('course: ', course)
|
||||
const res = {
|
||||
code: course.code,
|
||||
name: course.course_name,
|
||||
@@ -732,6 +835,15 @@ const getCurrentStudyYearStartDate = _.memoize(
|
||||
)
|
||||
)
|
||||
|
||||
const getProgrammeName = async code => {
|
||||
return ProgrammeModule.findOne({
|
||||
attributes: ['name'],
|
||||
where: {
|
||||
code,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
studytrackStudents,
|
||||
enrolledStudents,
|
||||
@@ -758,4 +870,6 @@ module.exports = {
|
||||
getStudyRights,
|
||||
getCourseCodesForStudyProgramme,
|
||||
getTransferStudentsForProgrammeCourses,
|
||||
getProgrammeName,
|
||||
getNotCompletedForProgrammeCourses,
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ const {
|
||||
getStudentsForProgrammeCourses,
|
||||
getCurrentStudyYearStartDate,
|
||||
getOwnStudentsForProgrammeCourses,
|
||||
getNotCompletedForProgrammeCourses,
|
||||
getStudentsWithoutStudyrightForProgrammeCourses,
|
||||
getTransferStudentsForProgrammeCourses,
|
||||
getOtherStudentsForProgrammeCourses,
|
||||
@@ -39,9 +40,12 @@ const makeYearlyPromises = (years, academicYear, type, programmeCourses, studypr
|
||||
let result = null
|
||||
|
||||
switch (type) {
|
||||
case 'allStudents':
|
||||
case 'passed':
|
||||
result = await getStudentsForProgrammeCourses(from, to, programmeCourses)
|
||||
break
|
||||
case 'notCompleted':
|
||||
result = await getNotCompletedForProgrammeCourses(from, to, programmeCourses)
|
||||
break
|
||||
case 'ownStudents':
|
||||
result = await getOwnStudentsForProgrammeCourses(from, to, programmeCourses, studyprogramme)
|
||||
break
|
||||
@@ -74,7 +78,13 @@ const getStudyprogrammeCoursesForStudytrack = async (unixMillis, studyprogramme,
|
||||
const yearRange = _.range(2017, startYear + 1)
|
||||
const programmeCourses = await getAllStudyprogrammeCourses(studyprogramme)
|
||||
|
||||
const yearlyStudentByCoursePromises = makeYearlyPromises(yearRange, academicYear, 'allStudents', programmeCourses)
|
||||
const yearlyPassedStudentByCoursePromises = makeYearlyPromises(yearRange, academicYear, 'passed', programmeCourses)
|
||||
const yearlyNotCompletedStudentByCoursePromises = makeYearlyPromises(
|
||||
yearRange,
|
||||
academicYear,
|
||||
'notCompleted',
|
||||
programmeCourses
|
||||
)
|
||||
const yearlyProgrammeStudentsPromises = makeYearlyPromises(
|
||||
yearRange,
|
||||
academicYear,
|
||||
@@ -105,22 +115,24 @@ const getStudyprogrammeCoursesForStudytrack = async (unixMillis, studyprogramme,
|
||||
)
|
||||
|
||||
const [
|
||||
yearlyStudentByCourse,
|
||||
yearlyPassedStudentByCourse,
|
||||
yearlyNotCompletedStudentByCourse,
|
||||
yearlyProgrammeStudents,
|
||||
yearlyStudentsWithoutStudyright,
|
||||
yearlyOtherProgrammeStudents,
|
||||
yearlyTransferStudents,
|
||||
] = await Promise.all([
|
||||
Promise.all(yearlyStudentByCoursePromises),
|
||||
Promise.all(yearlyPassedStudentByCoursePromises),
|
||||
Promise.all(yearlyNotCompletedStudentByCoursePromises),
|
||||
Promise.all(yearlyProgrammeStudentsPromises),
|
||||
Promise.all(yearlyStudentsWithoutStudyrightPromises),
|
||||
Promise.all(yearlyOtherProgrammeStudentsPromises),
|
||||
Promise.all(yearlyTransferStudentsPromises),
|
||||
])
|
||||
|
||||
let maxYear = 0
|
||||
const allCourses = [
|
||||
...yearlyStudentByCourse.flat(),
|
||||
...yearlyPassedStudentByCourse.flat(),
|
||||
...yearlyNotCompletedStudentByCourse.flat(),
|
||||
...yearlyProgrammeStudents.flat(),
|
||||
...yearlyStudentsWithoutStudyright.flat(),
|
||||
...yearlyOtherProgrammeStudents.flat(),
|
||||
@@ -134,9 +146,12 @@ const getStudyprogrammeCoursesForStudytrack = async (unixMillis, studyprogramme,
|
||||
years: {},
|
||||
}
|
||||
}
|
||||
|
||||
if (!acc[curr.code]['years'][curr.year]) {
|
||||
acc[curr.code]['years'][curr.year] = {
|
||||
totalAllStudents: 0,
|
||||
totalPassed: 0,
|
||||
totalNotCompleted: 0,
|
||||
totalAllCredits: 0,
|
||||
totalProgrammeStudents: 0,
|
||||
totalProgrammeCredits: 0,
|
||||
@@ -149,10 +164,16 @@ const getStudyprogrammeCoursesForStudytrack = async (unixMillis, studyprogramme,
|
||||
}
|
||||
}
|
||||
switch (curr.type) {
|
||||
case 'total':
|
||||
acc[curr.code]['years'][curr.year]['totalAllStudents'] += curr.totalAllStudents
|
||||
case 'passed':
|
||||
acc[curr.code]['years'][curr.year]['totalPassed'] += curr.totalPassed
|
||||
acc[curr.code]['years'][curr.year]['totalAllStudents'] += acc[curr.code]['years'][curr.year]['totalPassed']
|
||||
acc[curr.code]['years'][curr.year]['totalAllCredits'] += curr.totalAllcredits
|
||||
break
|
||||
case 'notCompleted':
|
||||
acc[curr.code]['years'][curr.year]['totalNotCompleted'] += curr.totalNotCompleted
|
||||
acc[curr.code]['years'][curr.year]['totalAllStudents'] +=
|
||||
acc[curr.code]['years'][curr.year]['totalNotCompleted']
|
||||
break
|
||||
case 'ownProgramme':
|
||||
acc[curr.code]['years'][curr.year]['totalProgrammeStudents'] += curr.totalProgrammeStudents
|
||||
acc[curr.code]['years'][curr.year]['totalProgrammeCredits'] += curr.totalProgrammeCredits
|
||||
@@ -175,6 +196,8 @@ const getStudyprogrammeCoursesForStudytrack = async (unixMillis, studyprogramme,
|
||||
const ayCourses = Object.keys(allCourses).filter(c => c.startsWith('AY'))
|
||||
const properties = [
|
||||
'totalAllStudents',
|
||||
'totalPassed',
|
||||
'totalNotCompleted',
|
||||
'totalAllCredits',
|
||||
'totalProgrammeStudents',
|
||||
'totalProgrammeCredits',
|
||||
@@ -200,6 +223,8 @@ const getStudyprogrammeCoursesForStudytrack = async (unixMillis, studyprogramme,
|
||||
if (!allCourses[normCode]['years'][year]) {
|
||||
mergedCourse['years'][year] = {
|
||||
totalAllStudents: 0,
|
||||
totalPassed: 0,
|
||||
totalNotCompleted: 0,
|
||||
totalAllCredits: 0,
|
||||
totalProgrammeStudents: 0,
|
||||
totalProgrammeCredits: 0,
|
||||
|
||||
@@ -260,25 +260,39 @@ const getGraduationStatsForStudytrack = async ({ studyprogramme, settings }) =>
|
||||
|
||||
const reversedYears = getYearsArray(since.getFullYear(), isAcademicYear).reverse()
|
||||
|
||||
const titles = ['', 'Graduated', 'Wrote thesis']
|
||||
const titles =
|
||||
studyprogramme.includes('LIS') || studyprogramme.includes('T')
|
||||
? ['', 'Graduated']
|
||||
: ['', 'Graduated', 'Wrote thesis']
|
||||
const programmesBeforeOrAfterTitles = ['Code', 'Id', 'Programme', ...years]
|
||||
const tableStats = reversedYears.map(year => [year, graduated.tableStats[year], thesis.tableStats[year]])
|
||||
const tableStats =
|
||||
studyprogramme.includes('LIS') || studyprogramme.includes('T')
|
||||
? reversedYears.map(year => [year, graduated.tableStats[year]])
|
||||
: reversedYears.map(year => [year, graduated.tableStats[year], thesis.tableStats[year]])
|
||||
|
||||
return {
|
||||
id: studyprogramme,
|
||||
years,
|
||||
tableStats,
|
||||
titles,
|
||||
graphStats: [
|
||||
{
|
||||
name: 'Graduated students',
|
||||
data: graduated.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Wrote thesis',
|
||||
data: thesis.graphStats,
|
||||
},
|
||||
],
|
||||
graphStats:
|
||||
studyprogramme.includes('LIS') || studyprogramme.includes('T')
|
||||
? [
|
||||
{
|
||||
name: 'Graduated students',
|
||||
data: graduated.graphStats,
|
||||
},
|
||||
]
|
||||
: [
|
||||
{
|
||||
name: 'Graduated students',
|
||||
data: graduated.graphStats,
|
||||
},
|
||||
{
|
||||
name: 'Wrote thesis',
|
||||
data: thesis.graphStats,
|
||||
},
|
||||
],
|
||||
graduationTimes: graduationTimeStats.times,
|
||||
doCombo: graduationTimeStats.doCombo,
|
||||
comboTimes: graduationTimeStats.comboTimes,
|
||||
|
||||
@@ -54,6 +54,7 @@ const formatStudyright = studyright => {
|
||||
extentcode,
|
||||
student,
|
||||
studyright_elements,
|
||||
cancelled,
|
||||
} = studyright
|
||||
|
||||
return {
|
||||
@@ -69,6 +70,7 @@ const formatStudyright = studyright => {
|
||||
studentnumber: student.studentnumber,
|
||||
code: resolveStudyRightCode(studyright_elements),
|
||||
studyrightElements: studyright_elements,
|
||||
cancelled,
|
||||
name:
|
||||
studyright_elements?.length && studyright_elements[0].element_detail && studyright_elements[0].element_detail.name
|
||||
? studyright_elements[0].element_detail.name
|
||||
@@ -152,16 +154,15 @@ const isNonMajorCredit = (studyrights, attainment_date) =>
|
||||
)
|
||||
})
|
||||
|
||||
const isSpecialGroupCredit = (studyrights, attainment_date, transfers) => {
|
||||
const isSpecialGroupCredit = (studyrights, attainment_date, transfers) =>
|
||||
studyrights.some(studyright => {
|
||||
if (!studyright) return true // If there is no studyright matching the credit, is not a major student credit
|
||||
if (studyright.studystartdate > attainment_date) return true // Credits before the studyright started are not major student credits
|
||||
if (studyright.enddate && attainment_date > studyright.enddate) return true // Credits after studyright are not major student credits
|
||||
if (studyright.studystartdate && new Date(studyright.studystartdate) > new Date(attainment_date)) return true // Credits before the studyright started are not major student credits
|
||||
if (studyright.enddate && new Date(attainment_date) > new Date(studyright.enddate)) return true // Credits after studyright are not major student credits
|
||||
if ([7, 9, 16, 34, 22, 99, 14, 13].includes(studyright.extentcode)) return true // Excludes non-degree studyrights and exchange students
|
||||
if (transfers.includes(studyright.studyrightid)) return true // Excludes both transfers in and out of the programme
|
||||
return false
|
||||
})
|
||||
}
|
||||
|
||||
const getMedian = values => {
|
||||
if (values.length === 0) return 0
|
||||
@@ -315,6 +316,7 @@ const getVetenaryCreditGraphStats = years => ({
|
||||
data: getEmptyArray(years.length),
|
||||
},
|
||||
})
|
||||
|
||||
const getOnlyMasterCreditGraphStats = years => ({
|
||||
lte15: {
|
||||
name: 'Less than 15 credits',
|
||||
@@ -365,10 +367,11 @@ const getDoctoralCreditGraphStats = years => ({
|
||||
},
|
||||
})
|
||||
|
||||
const getCreditGraphStats = (studyprogramme, years) => {
|
||||
const getCreditGraphStats = (studyprogramme, years, studyprog = false) => {
|
||||
if (studyprogramme.includes('KH')) return getBachelorCreditGraphStats(years)
|
||||
if (studyprogramme === 'MH90_001') return getVetenaryCreditGraphStats(years)
|
||||
if (studyprogramme.includes('MH')) return getMasterCreditGraphStats(years)
|
||||
if (studyprogramme === 'MH90_001')
|
||||
return studyprog ? getBachelorCreditGraphStats(years) : getVetenaryCreditGraphStats(years)
|
||||
if (studyprogramme.includes('MH')) return getOnlyMasterCreditGraphStats(years)
|
||||
return getDoctoralCreditGraphStats(years)
|
||||
}
|
||||
|
||||
@@ -382,18 +385,22 @@ const onlyMasterCreditAmounts = [15, 30, 60, 90, 120, 120]
|
||||
const doctoralCreditAmounts = [10, 20, 30, 40, 40]
|
||||
const vetenaryCreditThresholds = ['lte210', 'lte240', 'lte270', 'lte300', 'lte330', 'lte360', 'mte360']
|
||||
const vetenaryCreditAmounts = [210, 240, 270, 300, 330, 360, 360]
|
||||
const getOnlyMasterThresholds = () => {
|
||||
return { msOnlyCreditThresholdKeys: onlyMasterCreditThresholds, msOnlyCreditThresholdAmount: onlyMasterCreditAmounts }
|
||||
const getBcMsThresholds = programmeCode => {
|
||||
if (programmeCode === 'MH90_001')
|
||||
return { creditThresholdKeysBcMs: vetenaryCreditThresholds, creditThresholdAmountsBcMs: vetenaryCreditAmounts }
|
||||
return { creditThresholdKeysBcMs: masterCreditThresholds, creditThresholdAmountsBcMs: masterCreditAmounts }
|
||||
}
|
||||
const getCreditThresholds = studyprogramme => {
|
||||
const getCreditThresholds = (studyprogramme, studyProg = false) => {
|
||||
if (studyprogramme === 'MH90_001') {
|
||||
return { creditThresholdKeys: vetenaryCreditThresholds, creditThresholdAmounts: vetenaryCreditAmounts }
|
||||
return studyProg
|
||||
? { creditThresholdKeys: bachelorCreditThresholds, creditThresholdAmounts: bachelorCreditAmounts }
|
||||
: { creditThresholdKeys: vetenaryCreditThresholds, creditThresholdAmounts: vetenaryCreditAmounts }
|
||||
}
|
||||
if (studyprogramme.includes('KH')) {
|
||||
return { creditThresholdKeys: bachelorCreditThresholds, creditThresholdAmounts: bachelorCreditAmounts }
|
||||
}
|
||||
if (studyprogramme.includes('MH')) {
|
||||
return { creditThresholdKeys: masterCreditThresholds, creditThresholdAmounts: masterCreditAmounts }
|
||||
return { creditThresholdKeys: onlyMasterCreditThresholds, creditThresholdAmounts: onlyMasterCreditAmounts }
|
||||
}
|
||||
return { creditThresholdKeys: doctoralCreditThresholds, creditThresholdAmounts: doctoralCreditAmounts }
|
||||
}
|
||||
@@ -460,7 +467,7 @@ const tableTitles = {
|
||||
'Graduated',
|
||||
'Men',
|
||||
'Women',
|
||||
'Finnish',
|
||||
'Finland',
|
||||
],
|
||||
programmes: [
|
||||
'',
|
||||
@@ -473,14 +480,14 @@ const tableTitles = {
|
||||
'Men',
|
||||
'Women',
|
||||
'Other/Unknown',
|
||||
'Finnish',
|
||||
'Finland',
|
||||
'Other',
|
||||
],
|
||||
}
|
||||
|
||||
const getCreditProgressTableTitles = studyprogramme => {
|
||||
if (studyprogramme.includes('KH')) return tableTitles.creditProgress.bachelor
|
||||
if (studyprogramme.includes('MH')) return tableTitles.creditProgress.master
|
||||
if (studyprogramme.includes('MH')) return tableTitles.creditProgress.masterOnly
|
||||
return tableTitles.creditProgress.doctoral
|
||||
}
|
||||
|
||||
@@ -552,7 +559,7 @@ module.exports = {
|
||||
getCreditThresholds,
|
||||
tableTitles,
|
||||
getCreditProgressTableTitles,
|
||||
getOnlyMasterThresholds,
|
||||
getBcMsThresholds,
|
||||
isNonMajorCredit,
|
||||
mapCodesToIds,
|
||||
getId,
|
||||
|
||||
@@ -30,7 +30,6 @@ const { countTimeCategories } = require('./graduationHelpers')
|
||||
const getStudentData = (startDate, students, thresholdKeys, thresholdAmounts) => {
|
||||
let data = { female: 0, male: 0, finnish: 0 }
|
||||
thresholdKeys.forEach(t => (data[t] = 0))
|
||||
|
||||
students.forEach(({ gender_code, home_country_en, credits }) => {
|
||||
const creditcount = credits
|
||||
.filter(credit => moment(credit.attainment_date).isAfter(startDate))
|
||||
@@ -84,6 +83,29 @@ const getGraduationTimeStats = async ({ year, graduated, track, graduationAmount
|
||||
]
|
||||
}
|
||||
|
||||
const getStats = (all, started, enrolled, absent, inactive, graduated, studentData) => {
|
||||
return [
|
||||
all.length,
|
||||
getPercentage(all.length, all.length),
|
||||
started.length,
|
||||
getPercentage(started.length, all.length),
|
||||
enrolled.length,
|
||||
getPercentage(enrolled.length, all.length),
|
||||
absent.length,
|
||||
getPercentage(absent.length, all.length),
|
||||
inactive.length,
|
||||
getPercentage(inactive.length, all.length),
|
||||
graduated.length,
|
||||
getPercentage(graduated.length, all.length),
|
||||
studentData.male,
|
||||
getPercentage(studentData.male, all.length),
|
||||
studentData.female,
|
||||
getPercentage(studentData.female, all.length),
|
||||
studentData.finnish,
|
||||
getPercentage(studentData.finnish, all.length),
|
||||
]
|
||||
}
|
||||
|
||||
// Goes through the programme and all its studytracks for the said year and adds the wanted stats to the data objects
|
||||
const getStudytrackDataForTheYear = async ({
|
||||
studyprogramme,
|
||||
@@ -174,7 +196,6 @@ const getStudytrackDataForTheYear = async ({
|
||||
threshold => (creditGraphStats[track][threshold].data[indexOf(years, 'Total')] += studentData[threshold])
|
||||
)
|
||||
// Count stats for the credit progress table for the year per track
|
||||
|
||||
creditTableStats[track] = [
|
||||
[year, all.length, ...creditThresholdKeys.map(threshold => studentData[threshold])],
|
||||
...creditTableStats[track],
|
||||
@@ -184,32 +205,12 @@ const getStudytrackDataForTheYear = async ({
|
||||
(a, b) => a.map((colVal, idx) => colVal + (b[idx] || 0)),
|
||||
Array(creditThresholdKeys.length + 2).fill(0)
|
||||
)
|
||||
creditTableStats[track] = [[year, all.length, ...totalCredits.slice(2)], ...creditTableStats[track]]
|
||||
creditTableStats[track] = [[year, ...totalCredits.slice(1)], ...creditTableStats[track]]
|
||||
}
|
||||
|
||||
// Count stats for the main studytrack table grouped by tracks
|
||||
mainStatsByTrack[track] = [
|
||||
[
|
||||
year,
|
||||
all.length,
|
||||
getPercentage(all.length, all.length),
|
||||
started.length,
|
||||
getPercentage(started.length, all.length),
|
||||
enrolled.length,
|
||||
getPercentage(enrolled.length, all.length),
|
||||
absent.length,
|
||||
getPercentage(absent.length, all.length),
|
||||
inactive.length,
|
||||
getPercentage(inactive.length, all.length),
|
||||
graduated.length,
|
||||
getPercentage(graduated.length, all.length),
|
||||
studentData.male,
|
||||
getPercentage(studentData.male, all.length),
|
||||
studentData.female,
|
||||
getPercentage(studentData.female, all.length),
|
||||
studentData.finnish,
|
||||
getPercentage(studentData.finnish, all.length),
|
||||
],
|
||||
[year, ...getStats(all, started, enrolled, absent, inactive, graduated, studentData)],
|
||||
...mainStatsByTrack[track],
|
||||
]
|
||||
|
||||
@@ -217,24 +218,7 @@ const getStudytrackDataForTheYear = async ({
|
||||
mainStatsByYear[year] = [
|
||||
[
|
||||
studytrackNames[track]?.name['fi'] ? `${studytrackNames[track]?.name['fi']}, ${track}` : year,
|
||||
all.length,
|
||||
getPercentage(all.length, all.length),
|
||||
started.length,
|
||||
getPercentage(started.length, all.length),
|
||||
enrolled.length,
|
||||
getPercentage(enrolled.length, all.length),
|
||||
absent.length,
|
||||
getPercentage(absent.length, all.length),
|
||||
inactive.length,
|
||||
getPercentage(inactive.length, all.length),
|
||||
graduated.length,
|
||||
getPercentage(graduated.length, all.length),
|
||||
studentData.male,
|
||||
getPercentage(studentData.male, all.length),
|
||||
studentData.female,
|
||||
getPercentage(studentData.female, all.length),
|
||||
studentData.finnish,
|
||||
getPercentage(studentData.finnish, all.length),
|
||||
...getStats(all, started, enrolled, absent, inactive, graduated, studentData),
|
||||
],
|
||||
...mainStatsByYear[year],
|
||||
]
|
||||
@@ -288,7 +272,7 @@ const getEmptyStatsObjects = (years, studytracks, studyprogramme) => {
|
||||
const totals = {}
|
||||
studytracks.forEach(async track => {
|
||||
mainStatsByTrack[track] = []
|
||||
creditGraphStats[track] = getCreditGraphStats(studyprogramme, years)
|
||||
creditGraphStats[track] = getCreditGraphStats(studyprogramme, years, true)
|
||||
creditTableStats[track] = []
|
||||
graduationAmounts[track] = getYearsObject({ years })
|
||||
totalAmounts[track] = getYearsObject({ years })
|
||||
@@ -331,7 +315,7 @@ const getStudytrackStatsForStudyprogramme = async ({ studyprogramme, settings })
|
||||
const studytrackNames = associations.studyTracks
|
||||
|
||||
const data = getEmptyStatsObjects(years, studytracks, studyprogramme)
|
||||
const { creditThresholdKeys, creditThresholdAmounts } = getCreditThresholds(studyprogramme)
|
||||
const { creditThresholdKeys, creditThresholdAmounts } = getCreditThresholds(studyprogramme, true)
|
||||
|
||||
const yearsReversed = [...years].reverse()
|
||||
|
||||
@@ -358,7 +342,10 @@ const getStudytrackStatsForStudyprogramme = async ({ studyprogramme, settings })
|
||||
studytrackOptions,
|
||||
includeGraduated: settings.graduated,
|
||||
populationTitles: tableTitles['studytracks'],
|
||||
creditTableTitles: getCreditProgressTableTitles(studyprogramme),
|
||||
creditTableTitles:
|
||||
studyprogramme === 'MH90_001'
|
||||
? tableTitles['creditProgress']['bachelor']
|
||||
: getCreditProgressTableTitles(studyprogramme),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,12 +8,10 @@ const { checkStudyGuidanceGroupsAccess, getAllStudentsUserHasInGroups } = requir
|
||||
const _ = require('lodash')
|
||||
const { User, UserElementDetails, AccessGroup, UserFaculties, sequelizeUser } = require('../models/models_user')
|
||||
const { getOrganizationAccess } = require('../util/organizationAccess')
|
||||
const { getUserIams, getAllUserAccess } = require('../util/jami')
|
||||
|
||||
const courseStatisticsGroup = 'grp-oodikone-basic-users'
|
||||
const facultyStatisticsGroup = 'grp-oodikone-users'
|
||||
const hyOneGroup = 'hy-one'
|
||||
const toskaGroup = 'grp-toska'
|
||||
const openUniGroup = 'hy-ypa-opa-dojo'
|
||||
|
||||
// Max 25 users can be stored in the cache
|
||||
const userDataCache = new LRU({
|
||||
@@ -166,32 +164,85 @@ const updateUser = async (username, fields) => {
|
||||
|
||||
const getAccessGroups = async () => await AccessGroup.findAll()
|
||||
|
||||
const updateAccessGroups = async (username, iamGroups = [], specialGroup = {}, sisId) => {
|
||||
const { jory, hyOne, superAdmin, openUni } = specialGroup
|
||||
|
||||
const userFromDb = await byUsername(username)
|
||||
const formattedUser = await formatUser(userFromDb, [], Boolean(sisId))
|
||||
|
||||
const { roles: currentAccessGroups } = formattedUser
|
||||
|
||||
// Modify accessgroups based on current groups and iamGroups
|
||||
let newAccessGroups = []
|
||||
if (currentAccessGroups.includes('studyGuidanceGroups') || (sisId && (await checkStudyGuidanceGroupsAccess(sisId))))
|
||||
newAccessGroups.push('studyGuidanceGroups')
|
||||
if (iamGroups.includes(courseStatisticsGroup)) newAccessGroups.push('courseStatistics')
|
||||
if (jory || iamGroups.includes(facultyStatisticsGroup)) newAccessGroups.push('facultyStatistics')
|
||||
if (hyOne || currentAccessGroups.includes('teachers')) newAccessGroups.push('teachers')
|
||||
if (superAdmin || currentAccessGroups.includes('admin')) newAccessGroups.push('admin')
|
||||
if (openUni) newAccessGroups.push('openUniSearch')
|
||||
|
||||
const accessGroups = await AccessGroup.findAll({
|
||||
where: {
|
||||
group_code: {
|
||||
[Op.in]: newAccessGroups,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
// In the difference method "the order and references of result values are determined by the first array." https://lodash.com/docs/4.17.15#difference
|
||||
// Both directions needs to be checked in order to update roles when the access should no longer exists.
|
||||
if (
|
||||
_.difference(newAccessGroups, currentAccessGroups).length > 0 ||
|
||||
_.difference(currentAccessGroups, newAccessGroups).length > 0
|
||||
) {
|
||||
userFromDb.setAccessgroup(accessGroups.map(({ id }) => id))
|
||||
}
|
||||
|
||||
return { newAccessGroups, accessGroups }
|
||||
}
|
||||
|
||||
// newer logic
|
||||
const enrichProgrammesFromFaculties = faculties =>
|
||||
facultiesAndProgrammesForTrends.filter(f => faculties.includes(f.faculty_code)).map(f => f.programme_code)
|
||||
|
||||
const findAll = async () =>
|
||||
(
|
||||
await User.findAll({
|
||||
include: userIncludes,
|
||||
})
|
||||
).map(user => ({
|
||||
...user.get(),
|
||||
is_enabled: true,
|
||||
elementdetails: _.uniqBy([
|
||||
...user.programme.map(p => p.elementDetailCode),
|
||||
...enrichProgrammesFromFaculties(user.faculty.map(f => f.faculty_code)),
|
||||
]),
|
||||
}))
|
||||
const findAll = async () => {
|
||||
const allUsers = await User.findAll({
|
||||
include: userIncludes,
|
||||
})
|
||||
|
||||
const formatUser = async userFromDb => {
|
||||
const userAccess = await getAllUserAccess()
|
||||
|
||||
const formattedUsers = await Promise.all(
|
||||
allUsers.map(async user => {
|
||||
const { iamGroups, specialGroup } = userAccess.find(({ id }) => id === user.sisu_person_id) || {}
|
||||
|
||||
const { accessGroups } = await updateAccessGroups(user.username, iamGroups, specialGroup)
|
||||
|
||||
return {
|
||||
...user.get(),
|
||||
is_enabled: true,
|
||||
iam_groups: iamGroups || [],
|
||||
elementdetails: _.uniqBy([
|
||||
...user.programme.map(p => p.elementDetailCode),
|
||||
...enrichProgrammesFromFaculties(user.faculty.map(f => f.faculty_code)),
|
||||
]),
|
||||
accessgroup: accessGroups,
|
||||
}
|
||||
})
|
||||
)
|
||||
|
||||
return formattedUsers
|
||||
}
|
||||
|
||||
const formatUser = async (userFromDb, extraRights, getStudentAccess = true) => {
|
||||
const [accessGroups, programmes, faculties] = [
|
||||
['accessgroup', 'group_code'],
|
||||
['programme', 'elementDetailCode'],
|
||||
['faculty', 'faculty_code'],
|
||||
].map(([field, code]) => userFromDb[field].map(entry => entry[code]))
|
||||
|
||||
const rights = _.uniqBy([...programmes, ...enrichProgrammesFromFaculties(faculties)])
|
||||
const rights = _.uniqBy([...programmes, ...enrichProgrammesFromFaculties(faculties)]).concat(extraRights)
|
||||
|
||||
const {
|
||||
dataValues: {
|
||||
@@ -205,9 +256,13 @@ const formatUser = async userFromDb => {
|
||||
},
|
||||
} = userFromDb
|
||||
|
||||
const studentsUserCanAccess = _.uniqBy(
|
||||
(await Promise.all([getStudentnumbersByElementdetails(rights), getAllStudentsUserHasInGroups(sisPersonId)])).flat()
|
||||
)
|
||||
const studentsUserCanAccess = getStudentAccess
|
||||
? _.uniqBy(
|
||||
(
|
||||
await Promise.all([getStudentnumbersByElementdetails(rights), getAllStudentsUserHasInGroups(sisPersonId)])
|
||||
).flat()
|
||||
)
|
||||
: []
|
||||
|
||||
// attribute naming is a bit confusing, but it's used so widely in oodikone, that it's not probably worth changing
|
||||
return {
|
||||
@@ -232,15 +287,18 @@ const getMockedUser = async ({ userToMock, mockedBy }) => {
|
||||
}
|
||||
|
||||
const userFromDb = await byUsername(userToMock)
|
||||
const formattedUser = await formatUser(userFromDb)
|
||||
userFromDb.iamGroups = await getUserIams(userFromDb.sisu_person_id)
|
||||
|
||||
const iamRights = Object.keys(await getOrganizationAccess(userFromDb)).filter(
|
||||
programmeCode => !formattedUser.rights.includes(programmeCode)
|
||||
)
|
||||
const { access = {}, specialGroup = {} } = await getOrganizationAccess(userFromDb)
|
||||
|
||||
const iamRights = Object.keys(access)
|
||||
|
||||
const formattedUser = await formatUser(userFromDb, specialGroup.kosu ? iamRights : [])
|
||||
|
||||
const toReturn = {
|
||||
...formattedUser,
|
||||
iamRights,
|
||||
specialGroup,
|
||||
mockedBy,
|
||||
}
|
||||
userDataCache.set(userToMock, toReturn)
|
||||
@@ -248,7 +306,7 @@ const getMockedUser = async ({ userToMock, mockedBy }) => {
|
||||
return toReturn
|
||||
}
|
||||
|
||||
const getUser = async ({ username, name, email, iamGroups, iamRights, sisId }) => {
|
||||
const getUser = async ({ username, name, email, iamGroups, iamRights, specialGroup, sisId }) => {
|
||||
if (userDataCache.has(username)) {
|
||||
return userDataCache.get(username)
|
||||
}
|
||||
@@ -262,41 +320,13 @@ const getUser = async ({ username, name, email, iamGroups, iamRights, sisId }) =
|
||||
email,
|
||||
language,
|
||||
sisu_person_id: sisId,
|
||||
iam_groups: iamGroups,
|
||||
last_login: new Date(),
|
||||
})
|
||||
|
||||
const userFromDb = await byUsername(username)
|
||||
const formattedUser = await formatUser(userFromDb)
|
||||
const { roles: currentAccessGroups } = formattedUser
|
||||
const formattedUser = await formatUser(userFromDb, specialGroup.kosu ? iamRights : [])
|
||||
|
||||
// Modify accessgroups based on current groups and iamGroups
|
||||
let newAccessGroups = []
|
||||
if (await checkStudyGuidanceGroupsAccess(sisId)) newAccessGroups.push('studyGuidanceGroups')
|
||||
if (iamGroups.includes(courseStatisticsGroup)) newAccessGroups.push('courseStatistics')
|
||||
if (iamGroups.includes(facultyStatisticsGroup) || iamGroups.some(element => /-jory$/.test(element)))
|
||||
newAccessGroups.push('facultyStatistics')
|
||||
if (iamGroups.includes(hyOneGroup) || currentAccessGroups.includes('teachers')) newAccessGroups.push('teachers')
|
||||
if (iamGroups.includes(toskaGroup) || currentAccessGroups.includes('admin')) newAccessGroups.push('admin')
|
||||
if (iamGroups.includes(openUniGroup)) newAccessGroups.push('openUniSearch')
|
||||
// In the difference method "the order and references of result values are determined by the first array." https://lodash.com/docs/4.17.15#difference
|
||||
// Both directions needs to be checked in order to update roles when the access should no longer exists.
|
||||
if (
|
||||
_.difference(newAccessGroups, currentAccessGroups).length > 0 ||
|
||||
_.difference(currentAccessGroups, newAccessGroups).length > 0
|
||||
) {
|
||||
userFromDb.setAccessgroup(
|
||||
(
|
||||
await AccessGroup.findAll({
|
||||
where: {
|
||||
group_code: {
|
||||
[Op.in]: newAccessGroups,
|
||||
},
|
||||
},
|
||||
})
|
||||
).map(({ id }) => id)
|
||||
)
|
||||
}
|
||||
const { newAccessGroups } = await updateAccessGroups(username, iamGroups, specialGroup, sisId)
|
||||
|
||||
if (isNewUser) await sendNotificationAboutNewUser({ userId: username, userFullName: name })
|
||||
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
const axios = require('axios')
|
||||
const Sentry = require('@sentry/node')
|
||||
|
||||
const { importerToken, jamiUrl } = require('../conf-backend')
|
||||
const logger = require('./logger')
|
||||
|
||||
const jamiClient = axios.create({
|
||||
baseURL: jamiUrl,
|
||||
params: {
|
||||
token: importerToken,
|
||||
},
|
||||
})
|
||||
|
||||
const getUserIamAccess = async (user, attempt = 1) => {
|
||||
if (user.iamGroups.length === 0) return {}
|
||||
|
||||
const { id, iamGroups } = user
|
||||
|
||||
try {
|
||||
const { data: iamAccess } = await jamiClient.post('/', {
|
||||
userId: id,
|
||||
iamGroups,
|
||||
})
|
||||
|
||||
const { specialGroup } = iamAccess
|
||||
delete iamAccess.specialGroup
|
||||
|
||||
return { iamAccess, specialGroup }
|
||||
} catch (error) {
|
||||
if (attempt > 3) {
|
||||
logger.error('[Jami] error: ', error)
|
||||
Sentry.captureException(error)
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
return getUserIamAccess(user, attempt + 1)
|
||||
}
|
||||
}
|
||||
|
||||
const getUserIams = async userId => {
|
||||
try {
|
||||
const { data } = await jamiClient.get(`/${userId}`)
|
||||
|
||||
return data.iamGroups
|
||||
} catch (error) {
|
||||
if (error.response.status !== 404) {
|
||||
logger.error('[Jami] error: ', error)
|
||||
Sentry.captureException(error)
|
||||
}
|
||||
|
||||
return []
|
||||
}
|
||||
}
|
||||
|
||||
const getAllUserAccess = async () => {
|
||||
const { data } = await jamiClient.get('/all-access')
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
const testJami = async () => {
|
||||
try {
|
||||
await jamiClient.get('/ping', { timeout: 4000 })
|
||||
logger.info('JAMI connected')
|
||||
} catch (error) {
|
||||
logger.error(error)
|
||||
logger.warn('JAMI not responding :(')
|
||||
logger.info('Are you sure you are using the latest JAMI image?')
|
||||
}
|
||||
}
|
||||
|
||||
testJami()
|
||||
|
||||
module.exports = {
|
||||
getUserIamAccess,
|
||||
getUserIams,
|
||||
getAllUserAccess,
|
||||
}
|
||||
@@ -1,22 +0,0 @@
|
||||
const axios = require('axios')
|
||||
const { importerToken, jamiUrl } = require('../conf-backend')
|
||||
const logger = require('./logger')
|
||||
|
||||
const jamiClient = axios.create({
|
||||
params: {
|
||||
token: importerToken,
|
||||
},
|
||||
baseURL: jamiUrl,
|
||||
})
|
||||
|
||||
const getJamiClient = () => {
|
||||
if (!importerToken) {
|
||||
logger.error("Importer token not set, can't return client!")
|
||||
return null
|
||||
}
|
||||
return jamiClient
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
getJamiClient,
|
||||
}
|
||||
@@ -1,46 +1,21 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
const _ = require('lodash')
|
||||
const Sentry = require('@sentry/node')
|
||||
|
||||
const logger = require('./logger')
|
||||
const { getJamiClient } = require('../util/jamiClient')
|
||||
const jamiClient = getJamiClient()
|
||||
|
||||
const getIAMAccessFromJami = async (user, attempt = 1) => {
|
||||
const { id, iamGroups } = user
|
||||
|
||||
try {
|
||||
const { data: iamAccess } = await jamiClient.post('/', {
|
||||
userId: id,
|
||||
iamGroups,
|
||||
})
|
||||
|
||||
return iamAccess
|
||||
} catch (error) {
|
||||
if (attempt > 3) {
|
||||
logger.error(error)
|
||||
Sentry.captureException(error)
|
||||
|
||||
return {}
|
||||
}
|
||||
|
||||
return getIAMAccessFromJami(user, attempt + 1)
|
||||
}
|
||||
}
|
||||
const { getUserIamAccess } = require('./jami')
|
||||
|
||||
const getAccessFromIAMs = async user => {
|
||||
if (user.iamGroups.length === 0) return {}
|
||||
|
||||
const { iamAccess, specialGroup } = await getUserIamAccess(user)
|
||||
|
||||
const access = {}
|
||||
if (_.isObject(iamAccess)) {
|
||||
Object.keys(iamAccess).forEach(code => {
|
||||
access[code] = iamAccess[code]
|
||||
})
|
||||
}
|
||||
|
||||
const iamAccess = await getIAMAccessFromJami(user)
|
||||
|
||||
if (!_.isObject(iamAccess)) return access
|
||||
Object.keys(iamAccess).forEach(code => {
|
||||
access[code] = iamAccess[code]
|
||||
})
|
||||
|
||||
return access
|
||||
return { access, specialGroup }
|
||||
}
|
||||
|
||||
const getOrganizationAccess = async user => {
|
||||
|
||||
Generated
+49
-49
@@ -6,7 +6,7 @@
|
||||
"": {
|
||||
"name": "frontend",
|
||||
"dependencies": {
|
||||
"@reduxjs/toolkit": "^1.9.1",
|
||||
"@reduxjs/toolkit": "^1.8.6",
|
||||
"@sentry/browser": "^6.18.2",
|
||||
"@sentry/tracing": "^6.18.2",
|
||||
"axios": "^0.21.4",
|
||||
@@ -16,7 +16,7 @@
|
||||
"highcharts-custom-events": "^3.0.10",
|
||||
"highcharts-exporting": "^0.1.7",
|
||||
"history": "^4.10.1",
|
||||
"immer": "^9.0.17",
|
||||
"immer": "^9.0.12",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.4",
|
||||
"path-to-regexp": "^0.1.7",
|
||||
@@ -25,7 +25,7 @@
|
||||
"qs": "^6.10.3",
|
||||
"query-string": "^6.14.1",
|
||||
"react": "^16.14.0",
|
||||
"react-datetime": "^3.2.0",
|
||||
"react-datetime": "^3.1.1",
|
||||
"react-dom": "^16.14.0",
|
||||
"react-highcharts": "^16.1.0",
|
||||
"react-markdown": "^6.0.3",
|
||||
@@ -37,7 +37,7 @@
|
||||
"react-scroll-to-component": "^1.0.2",
|
||||
"scheduler": "^0.23.0",
|
||||
"semantic-ui-css": "^2.5.0",
|
||||
"semantic-ui-react": "^2.1.4",
|
||||
"semantic-ui-react": "^2.1.2",
|
||||
"unfuck-spa-shibboleth-session": "^3.1.4",
|
||||
"use-context-selector": "^1.3.9",
|
||||
"uuid": "^3.4.0",
|
||||
@@ -2841,14 +2841,14 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@reduxjs/toolkit": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.9.1.tgz",
|
||||
"integrity": "sha512-HikrdY+IDgRfRYlCTGUQaiCxxDDgM1mQrRbZ6S1HFZX5ZYuJ4o8EstNmhTwHdPl2rTmLxzwSu0b3AyeyTlR+RA==",
|
||||
"version": "1.8.6",
|
||||
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.8.6.tgz",
|
||||
"integrity": "sha512-4Ia/Loc6WLmdSOzi7k5ff7dLK8CgG2b8aqpLsCAJhazAzGdp//YBUSaj0ceW6a3kDBDNRrq5CRwyCS0wBiL1ig==",
|
||||
"dependencies": {
|
||||
"immer": "^9.0.16",
|
||||
"redux": "^4.2.0",
|
||||
"redux-thunk": "^2.4.2",
|
||||
"reselect": "^4.1.7"
|
||||
"immer": "^9.0.7",
|
||||
"redux": "^4.1.2",
|
||||
"redux-thunk": "^2.4.1",
|
||||
"reselect": "^4.1.5"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"react": "^16.9.0 || ^17.0.0 || ^18",
|
||||
@@ -10186,9 +10186,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/immer": {
|
||||
"version": "9.0.17",
|
||||
"resolved": "https://registry.npmjs.org/immer/-/immer-9.0.17.tgz",
|
||||
"integrity": "sha512-+hBruaLSQvkPfxRiTLK/mi4vLH+/VQS6z2KJahdoxlleFOI8ARqzOF17uy12eFDlqWmPoygwc5evgwcp+dlHhg==",
|
||||
"version": "9.0.15",
|
||||
"resolved": "https://registry.npmjs.org/immer/-/immer-9.0.15.tgz",
|
||||
"integrity": "sha512-2eB/sswms9AEUSkOm4SbV5Y7Vmt/bKRwByd52jfLkW4OLYeaTP3EEiJ9agqU0O/tq6Dk62Zfj+TJSqfm1rLVGQ==",
|
||||
"funding": {
|
||||
"type": "opencollective",
|
||||
"url": "https://opencollective.com/immer"
|
||||
@@ -16312,15 +16312,15 @@
|
||||
}
|
||||
},
|
||||
"node_modules/react-datetime": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.2.0.tgz",
|
||||
"integrity": "sha512-w5XdeNIGzBht9CadaZIJhKUhEcDTgH0XokKxGPCxeeJRYL7B3HIKA8CM6Q0xej2JFJt0n5d+zi3maMwaY3262A==",
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.1.1.tgz",
|
||||
"integrity": "sha512-gHCTjAniCcMb6jdXpz+MpVe/uCeaHNDOofg+l41nLlJI3uBLBMV40CQbGB2TCTUpCzGT1mCs4vQzKGMjXO/WWQ==",
|
||||
"dependencies": {
|
||||
"prop-types": "^15.5.7"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"moment": "^2.16.0",
|
||||
"react": "^16.5.0 || ^17.0.0 || ^18.0.0"
|
||||
"react": "^16.5.0 || ^17.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/react-dev-utils": {
|
||||
@@ -16923,9 +16923,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/redux-thunk": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.2.tgz",
|
||||
"integrity": "sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q==",
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.1.tgz",
|
||||
"integrity": "sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q==",
|
||||
"peerDependencies": {
|
||||
"redux": "^4"
|
||||
}
|
||||
@@ -17154,9 +17154,9 @@
|
||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
|
||||
},
|
||||
"node_modules/reselect": {
|
||||
"version": "4.1.7",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.7.tgz",
|
||||
"integrity": "sha512-Zu1xbUt3/OPwsXL46hvOOoQrap2azE7ZQbokq61BQfiXvhewsKDwhMeZjTX9sX0nvw1t/U5Audyn1I9P/m9z0A=="
|
||||
"version": "4.1.6",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.6.tgz",
|
||||
"integrity": "sha512-ZovIuXqto7elwnxyXbBtCPo9YFEr3uJqj2rRbcOOog1bmu2Ag85M4hixSwFWyaBMKXNgvPaJ9OSu9SkBPIeJHQ=="
|
||||
},
|
||||
"node_modules/resolve": {
|
||||
"version": "1.18.1",
|
||||
@@ -17922,9 +17922,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/semantic-ui-react": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-2.1.4.tgz",
|
||||
"integrity": "sha512-7CxjBoFUfH7fUvtn+SPkkIocthUD9kV3niF1mUMa9TbeyPAf2brtRCZBlT2OpHaXmkscFzGjEfhbJo9gKfotzQ==",
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-2.1.3.tgz",
|
||||
"integrity": "sha512-dd2pqalMk0ycJoHf7hn4mYd0xohg0NMk7ohlpPVOigCfMLrKk2e3NZdRk0yBetvD+qJXPqZ04jA43bDwqOM5OA==",
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.10.5",
|
||||
"@fluentui/react-component-event-listener": "~0.63.0",
|
||||
@@ -24283,14 +24283,14 @@
|
||||
"integrity": "sha512-9X2obfABZuDVLCgPK9aX0a/x4jaOEweTTWE2+9sr0Qqqevj2Uv5XorvusThmc9XGYpS9yI+fhh8RTafBtGposw=="
|
||||
},
|
||||
"@reduxjs/toolkit": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.9.1.tgz",
|
||||
"integrity": "sha512-HikrdY+IDgRfRYlCTGUQaiCxxDDgM1mQrRbZ6S1HFZX5ZYuJ4o8EstNmhTwHdPl2rTmLxzwSu0b3AyeyTlR+RA==",
|
||||
"version": "1.8.6",
|
||||
"resolved": "https://registry.npmjs.org/@reduxjs/toolkit/-/toolkit-1.8.6.tgz",
|
||||
"integrity": "sha512-4Ia/Loc6WLmdSOzi7k5ff7dLK8CgG2b8aqpLsCAJhazAzGdp//YBUSaj0ceW6a3kDBDNRrq5CRwyCS0wBiL1ig==",
|
||||
"requires": {
|
||||
"immer": "^9.0.16",
|
||||
"redux": "^4.2.0",
|
||||
"redux-thunk": "^2.4.2",
|
||||
"reselect": "^4.1.7"
|
||||
"immer": "^9.0.7",
|
||||
"redux": "^4.1.2",
|
||||
"redux-thunk": "^2.4.1",
|
||||
"reselect": "^4.1.5"
|
||||
}
|
||||
},
|
||||
"@rollup/plugin-node-resolve": {
|
||||
@@ -29903,9 +29903,9 @@
|
||||
"integrity": "sha512-CmxgYGiEPCLhfLnpPp1MoRmifwEIOgjcHXxOBjv7mY96c+eWScsOP9c112ZyLdWHi0FxHjI+4uVhKYp/gcdRmQ=="
|
||||
},
|
||||
"immer": {
|
||||
"version": "9.0.17",
|
||||
"resolved": "https://registry.npmjs.org/immer/-/immer-9.0.17.tgz",
|
||||
"integrity": "sha512-+hBruaLSQvkPfxRiTLK/mi4vLH+/VQS6z2KJahdoxlleFOI8ARqzOF17uy12eFDlqWmPoygwc5evgwcp+dlHhg=="
|
||||
"version": "9.0.15",
|
||||
"resolved": "https://registry.npmjs.org/immer/-/immer-9.0.15.tgz",
|
||||
"integrity": "sha512-2eB/sswms9AEUSkOm4SbV5Y7Vmt/bKRwByd52jfLkW4OLYeaTP3EEiJ9agqU0O/tq6Dk62Zfj+TJSqfm1rLVGQ=="
|
||||
},
|
||||
"import-cwd": {
|
||||
"version": "2.1.0",
|
||||
@@ -34574,9 +34574,9 @@
|
||||
}
|
||||
},
|
||||
"react-datetime": {
|
||||
"version": "3.2.0",
|
||||
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.2.0.tgz",
|
||||
"integrity": "sha512-w5XdeNIGzBht9CadaZIJhKUhEcDTgH0XokKxGPCxeeJRYL7B3HIKA8CM6Q0xej2JFJt0n5d+zi3maMwaY3262A==",
|
||||
"version": "3.1.1",
|
||||
"resolved": "https://registry.npmjs.org/react-datetime/-/react-datetime-3.1.1.tgz",
|
||||
"integrity": "sha512-gHCTjAniCcMb6jdXpz+MpVe/uCeaHNDOofg+l41nLlJI3uBLBMV40CQbGB2TCTUpCzGT1mCs4vQzKGMjXO/WWQ==",
|
||||
"requires": {
|
||||
"prop-types": "^15.5.7"
|
||||
}
|
||||
@@ -35071,9 +35071,9 @@
|
||||
}
|
||||
},
|
||||
"redux-thunk": {
|
||||
"version": "2.4.2",
|
||||
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.2.tgz",
|
||||
"integrity": "sha512-+P3TjtnP0k/FEjcBL5FZpoovtvrTNT/UXd4/sluaSyrURlSlhLSzEdfsTBW7WsKB6yPvgd7q/iZPICFjW4o57Q==",
|
||||
"version": "2.4.1",
|
||||
"resolved": "https://registry.npmjs.org/redux-thunk/-/redux-thunk-2.4.1.tgz",
|
||||
"integrity": "sha512-OOYGNY5Jy2TWvTL1KgAlVy6dcx3siPJ1wTq741EPyUKfn6W6nChdICjZwCd0p8AZBs5kWpZlbkXW2nE/zjUa+Q==",
|
||||
"requires": {}
|
||||
},
|
||||
"regenerate": {
|
||||
@@ -35248,9 +35248,9 @@
|
||||
"integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
|
||||
},
|
||||
"reselect": {
|
||||
"version": "4.1.7",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.7.tgz",
|
||||
"integrity": "sha512-Zu1xbUt3/OPwsXL46hvOOoQrap2azE7ZQbokq61BQfiXvhewsKDwhMeZjTX9sX0nvw1t/U5Audyn1I9P/m9z0A=="
|
||||
"version": "4.1.6",
|
||||
"resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.6.tgz",
|
||||
"integrity": "sha512-ZovIuXqto7elwnxyXbBtCPo9YFEr3uJqj2rRbcOOog1bmu2Ag85M4hixSwFWyaBMKXNgvPaJ9OSu9SkBPIeJHQ=="
|
||||
},
|
||||
"resolve": {
|
||||
"version": "1.18.1",
|
||||
@@ -35841,9 +35841,9 @@
|
||||
}
|
||||
},
|
||||
"semantic-ui-react": {
|
||||
"version": "2.1.4",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-2.1.4.tgz",
|
||||
"integrity": "sha512-7CxjBoFUfH7fUvtn+SPkkIocthUD9kV3niF1mUMa9TbeyPAf2brtRCZBlT2OpHaXmkscFzGjEfhbJo9gKfotzQ==",
|
||||
"version": "2.1.3",
|
||||
"resolved": "https://registry.npmjs.org/semantic-ui-react/-/semantic-ui-react-2.1.3.tgz",
|
||||
"integrity": "sha512-dd2pqalMk0ycJoHf7hn4mYd0xohg0NMk7ohlpPVOigCfMLrKk2e3NZdRk0yBetvD+qJXPqZ04jA43bDwqOM5OA==",
|
||||
"requires": {
|
||||
"@babel/runtime": "^7.10.5",
|
||||
"@fluentui/react-component-event-listener": "~0.63.0",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"build": "DISABLE_ESLINT_PLUGIN=true react-scripts build"
|
||||
},
|
||||
"dependencies": {
|
||||
"@reduxjs/toolkit": "^1.9.1",
|
||||
"@reduxjs/toolkit": "^1.8.6",
|
||||
"@sentry/browser": "^6.18.2",
|
||||
"@sentry/tracing": "^6.18.2",
|
||||
"axios": "^0.21.4",
|
||||
@@ -16,7 +16,7 @@
|
||||
"highcharts-custom-events": "^3.0.10",
|
||||
"highcharts-exporting": "^0.1.7",
|
||||
"history": "^4.10.1",
|
||||
"immer": "^9.0.17",
|
||||
"immer": "^9.0.12",
|
||||
"lodash": "^4.17.21",
|
||||
"moment": "^2.29.4",
|
||||
"path-to-regexp": "^0.1.7",
|
||||
@@ -25,7 +25,7 @@
|
||||
"qs": "^6.10.3",
|
||||
"query-string": "^6.14.1",
|
||||
"react": "^16.14.0",
|
||||
"react-datetime": "^3.2.0",
|
||||
"react-datetime": "^3.1.1",
|
||||
"react-dom": "^16.14.0",
|
||||
"react-highcharts": "^16.1.0",
|
||||
"react-markdown": "^6.0.3",
|
||||
@@ -37,7 +37,7 @@
|
||||
"react-scroll-to-component": "^1.0.2",
|
||||
"scheduler": "^0.23.0",
|
||||
"semantic-ui-css": "^2.5.0",
|
||||
"semantic-ui-react": "^2.1.4",
|
||||
"semantic-ui-react": "^2.1.2",
|
||||
"unfuck-spa-shibboleth-session": "^3.1.4",
|
||||
"use-context-selector": "^1.3.9",
|
||||
"uuid": "^3.4.0",
|
||||
|
||||
@@ -34,7 +34,7 @@ export default {
|
||||
**Non-degree student credits**: Sisältää tiedekuntaan suoritetut opintopisteet, joiden suorittajilla ei ole tutkinto-oikeutta Helsingin yliopistossa.
|
||||
`,
|
||||
GraduatedOfTheFaculty: `Sisältää kyseisenä vuonna tiedekunnasta valmistuneet opiskelijat riippumatta siitä, minä vuonna opiskeluoikeus ohjelmaan on myönnetty. Jaottelu on tehty opinto-oikeuden päättymispäivän (=valmistumispäivän) perusteella.`,
|
||||
ThesisWritersOfTheFaculty: `Sisältää kyseisenä vuonna kandidaatintutkielman, pro gradu -tutkielman, väitöskirjan tai lisensiaatintyön hyväksytysti suorittaneet opiskelijat. Mukana ei ole mahdollisia arvosanan korotuksia.`,
|
||||
ThesisWritersOfTheFaculty: `Sisältää kyseisenä vuonna kandidaatintutkielman tai pro gradu -tutkielman suorittaneet opiskelijat. Mukana ei ole mahdollisia arvosanan korotuksia.`,
|
||||
StudentToggle: `
|
||||
All studyrights: Valinnassa ovat mukana vaihto-opiskelijat, erillisoikeudella opiskelevat ja ohjelmaan siirtyneet opiskelijat sekä ohjelmasta pois siirtyneet opiskelijat.\n
|
||||
Special studyrights excluded: Valinnasta ja kaikista luvuista on poissuljettu kaikki edellä mainitut erikoisryhmät.
|
||||
@@ -87,7 +87,7 @@ export default {
|
||||
Kuvaa tiedekunnan ohjelmissa opiskelevien opiskelijoden tilastoja. Esimerkiksi 2020-2021 aloittaneiden opintopistejakaumaa.
|
||||
|
||||
HUOM!
|
||||
- **All** Sisältää kaikki opiskelijat, joiden opinto-oikeudella on aloituspäivä kyseisenä vuonna, riippumatta siitä, onko opiskelija aloittanut opiskelemaan ko. vuonna.
|
||||
- **All** Sisältää opiskelijat, jotka siirtyneet ohjelmaan tai siitä ulos sekä aloittaneet ohjelmassa
|
||||
- **Currently enrolled** Sisältää kaikki tällä hetkellä läsnäolevat olevat opiskelija.
|
||||
- **Absent** Sisältää kaikki lakisääteisistä syistä poissaolevat opiskelijat.
|
||||
- **Started studying** Sisältää kaikki opiskelijat, jotka ovat aloittaneet opiskelemaan koulutusohjelmassa kyseisenä lukuvuonna.
|
||||
@@ -95,22 +95,18 @@ export default {
|
||||
joissa opiskelija on laiminlyönyt ilmoittautumisen tälle lukukaudelle.
|
||||
|
||||
Mukana ovat oletusarvoisesti myös vaihto-opiskelijat, ohjelmaan ja siitä pois siirtyneet opiskelijat sekä erillisopinto-oikeudella opiskelevat.
|
||||
Taulukko näyttää myös näistä opiskelijoista miesten, naisten ja suomalaisten osuudet sekä valmistuneiden määrän.
|
||||
|
||||
Yläosan valikosta on mahdollista valita tarkasteluun yhden opinto-ohjelman opiskelijat tietylle vuodelle. Sekä opiskelijoiden yleistiedot että edistyminen opintopisteittäin
|
||||
kuvaavat tällöin kyseisen opintosuunnan opiskelijoita.`,
|
||||
Taulukko näyttää myös näistä opiskelijoista miesten, naisten ja suomalaisten osuudet sekä valmistuneiden määrän. `,
|
||||
StudentProgress: `
|
||||
Kuvaa tiedekuntaan kuuluvien eri ohjemien opinto-oikeudella varustettujen opiskelijoiden etenemistä opintopisteissä mitattuna. Esimerkiksi 2021-2022 aloittaneiden opintopistejakaumaa.
|
||||
|
||||
- Bachelor: Kandidaatin opinto-oikeudella varustettujen opiskelijoiden eteneminen
|
||||
- Bachelor + Master: Kandi+maisteriopinto-oikeudella opiskelleiden ja siitä maisteriksi ohjelmiin siirtyneiden etenenminen
|
||||
- Bachelor + Master: Kandi+maisteriopinto-oikeudella opiskelleiden ja siitä maisteriksi ohjelmiin siirtyneiden etenenminen. Aloitusvuodeksi on merkitty kandiohjelman aloitusvuosi.
|
||||
Opinto-ohjelmaksi on merkitty maisteriohjelma, johon opiskelija on siirtynyt kandiksi valmistumisen jälkeen.
|
||||
- Master: Pelkällä maisterintutkinnon opinto-oikeudella varustettujen opiskelijoiden eteneminen
|
||||
- Doctor: Tohtorin ja lisensiaatin opinto-oikeudella varustettujen opiskelijoiden eteneminen
|
||||
- Doctor: Tohtorin opinto-oikeudella varustettujen opiskelijoiden eteneminen
|
||||
|
||||
HUOM! Mukana ovat myös muuhun kuin valittuun koulutusohjelmaan tai opintosuuntaan tehdyt opintopisteet.
|
||||
HUOM! Mukana ovat myös muuhun kuin valittuun koulutusohjelmaan tai opintosuuntaan tehdyt opintopisteet. Opintopisteet on laskettu opinto-oikeuden alkamisesta, eikä tällä hetkellä ota huomioon mahdollisia hyväksilukuja.
|
||||
|
||||
Mukana ovat oletusarvoisesti myös vaihto-opiskelijat, erillisopinto-oikeudella opiskelevat ja ohjelmaan siirtyneet.
|
||||
|
||||
Mikäli yläosan valikosta valittuna on jokin tietty opintosuunta, myös nämä graafit ja taulukot kuvaavat kyseisen opintosuunnan opiskelijoita.
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
export default {
|
||||
enrollmentStatus: {
|
||||
label: 'Filter students present or absent',
|
||||
label: 'Filter students present, absent or passive',
|
||||
short:
|
||||
'Suodata opiskelijoita sen mukaan ovatko he ilmoittautuneet läsnä- tai poissaoleviksi kyseiselle lukukaudelle',
|
||||
'Suodata opiskelijoita sen mukaan ovatko he joko ilmoittautuneet läsnä- tai poissaoleviksi tai jääneet passiivisiksi kyseiselle lukukaudelle. Huom. osa passiivisista opiskelijoista on jo valmistunut ko. ohjelmasta.',
|
||||
},
|
||||
studyrightStatus: {
|
||||
label: 'Rajaa opiskelijoita opinto-oikeuden statuksen mukaan',
|
||||
|
||||
@@ -66,8 +66,8 @@ export default {
|
||||
|
||||
**Taulukot**
|
||||
|
||||
- **pass/fail** - oletusnäkymä, joka sisältää kurssisuoritukset, hylätyt sekä yritykset. Taulukon tiedot voi järjestää sarakkeita (n, after retry, percentage, many times, per student, passed ja attempted) klikkaamalla.
|
||||
- **pass/fail w/ enrollments** - näkymä, joka sisältää suoritustiedot ilmoittautumisten kanssa. Huom.! ilmoittautumistiedot ovat saatavilla vain Sisun käyttöönoton jälkeiseltä ajalta.
|
||||
|
||||
- **pass/fail** - näkymä sisältää kurssisuoritukset, hylätyt sekä yritykset sekä ilmoittautumistiedot. Huom.! ilmoittautumistiedot ovat saatavilla vain Sisun käyttöönoton jälkeiseltä ajalta.
|
||||
- **grades** - arvosanajakauma.
|
||||
- **when passed** - kurssisuorituksen ajankohta. Huom.! *Passed*-sarakkeen kokonaissumma ei välttämättä täsmää puolivuosittaisten lukumäärien summan kanssa johtuen tuplakirjauksista Oodissa.
|
||||
`,
|
||||
@@ -83,31 +83,74 @@ export default {
|
||||
Tägien ja opintosuuntien valinnat ovat siirtyneet tästä omiksi filtereikseen.
|
||||
Voit tehdä valinnat siirryttyäsi tarkastelemaan ohjelman tilastoja.
|
||||
`,
|
||||
Students: `**Students**
|
||||
StudentsGuidanceGroups: `**Students**
|
||||
|
||||
Taulukko näyttää oletusarvoisesti vain opiskelijanumerot, mutta harmaata liukukytkintä klikkaamalla saa näkyviin opiskelijoiden nimet.
|
||||
|
||||
Klikkaamalla opiskelijanumeron vieressä olevaa sinistä henkilösymbolia, siirryt kyseisen opiskelijan "student statistic" -näkymään.
|
||||
|
||||
Klikkaamalla "Sisu"-nuolta, siirryt tarkastelemaan opiskelijan tietoja Sisu-järjestelmässä.
|
||||
|
||||
**General**
|
||||
|
||||
Klikkaamalla opiskelijanumeron vieressä olevaa sinistä nuolta, siirtyy "student statistic" näkymään valitun opiskelijan osalta.
|
||||
Valikoituja selvennyksiä:
|
||||
- **Credits**
|
||||
- **All** listaa opiskelijan suoritetut opintopisteet valitun tarkastelujakson ajalta.
|
||||
- **Since ... ** listaa opiskelijan suoritetut opintopisteet määritellystä ajankohdasta alkaen
|
||||
- **Start of studyright**: Opiskelijan valittuun ohjelmaan liittyvän opinto-oikeuden alkupäivä
|
||||
- **Started in programme**: Opiskelijan valitussa ohjelmassa aloituspäivämäärä. Kandi+maisteriopiskelijoille kandiksi valmistumispäivämäärä +1.
|
||||
|
||||
- **credits since start of studyright:** listaa opiskelijan suoritetut opintopisteet valitun tarkastelujakson / populaation ajalta.
|
||||
- **all credits:** listaa opiskelijan kaikki opintopisteet (myös aiemmat suoritukset, eli ne jotka tehty ennen valittuun tarkastelujaksoon ja populaatioon kuulumista)
|
||||
- **transferred from:** opiskelijan vanha koulutusohjelma, josta opiskelija on siirtynyt uuteen.
|
||||
- **studytracks:** opintosuunta
|
||||
`,
|
||||
StudentsClass: `**Students**
|
||||
|
||||
Taulukko näyttää oletusarvoisesti vain opiskelijanumerot, mutta harmaata liukukytkintä klikkaamalla saa näkyviin opiskelijoiden nimet.
|
||||
|
||||
**Mandatory Courses**
|
||||
Klikkaamalla opiskelijanumeron vieressä olevaa sinistä henkilösymbolia, siirryt kyseisen opiskelijan "student statistic" -näkymään.
|
||||
|
||||
Klikkaamalla "Sisu"-nuolta, siirryt tarkastelemaan opiskelijan tietoja Sisu-järjestelmässä.
|
||||
|
||||
**General**
|
||||
|
||||
Valikoituja selvennyksiä:
|
||||
- **Credits**
|
||||
- **All** listaa opiskelijan suoritetut opintopisteet valitun tarkastelujakson ajalta
|
||||
- **HOPS** listaa opiskelijan kaikki HOPSiin sijoitut opintopisteet (myös aiemmat suoritukset, eli ne jotka tehty ennen valittuun tarkastelujaksoon ja populaatioon kuulumista)
|
||||
- **Since start in programme** listaa opiskelijan ohjelmassa aloittamisen jälkeen suoritut opintopisteet
|
||||
- **Transferred from:** opiskelijan vanha koulutusohjelma, josta opiskelija on siirtynyt uuteen.
|
||||
- **Start of studyright**: Opiskelijan valittuun ohjelmaan liittyvän opinto-oikeuden alkupäivä
|
||||
- **Started in programme**: Opiskelijan ko. ohjelmassa aloituspäivämäärä. Kandi+maisteriopiskelijoille kandiksi valmistumispäivämäärä +1
|
||||
- **Semesters**: Läsnäololukukausien lukumäärä
|
||||
|
||||
**Courses**
|
||||
|
||||
Tällä välilehdellä näkyy, mitä pakollisiksi määriteltyjä kursseja opiskelija on suorittanut.
|
||||
Kurssit voi määrittää kohdassa "Study program" > "Overview" > haluttu koulutusohjelma. Scrollatessa kurssitaulukkoa alaspäin, kurssin nimen saa näkyviin viemällä kursorin halutun solun kohdalle.
|
||||
|
||||
|
||||
**Tags**
|
||||
|
||||
Opiskelijoille voi luoda tag:eja ryhmittelyä varten kohdassa "Study Program" > "Overview" > haluttu koulutusohjelma.
|
||||
|
||||
**Progress**
|
||||
|
||||
Tämä näkymä on tällä hetkellä käytössä vain kandivaiheen opinto-ohjelmissa.
|
||||
Tällä välilehdellä näkyy opintojen kehitys annettujen kriteerien mukaan akateemista vuotta kohti. Kurssi merkataan tehdyksi, jos sillä on suoritusmerkintä tai hyväksiluku
|
||||
minä tahansa lukuvuonna. Opintopistekriteerin täyttämiseen vaaditaan, että opintopisteet on suoritettu kyseisen akateemisen vuoden aikana.
|
||||
|
||||
|
||||
**Huomaa**, että klikkaamalla taulukon yläreunassa olevaa kolme pistettä sisältävää kuvaketta, voit ladata itsellesi Excel tiedoston. Tiedosto sisältää lisäksi muita sarakkeita, kuten läsnäolon lukukausittain sekä yhteystiedot.
|
||||
Yhteystietojen käyttö on kuitenkin sallittua vain opintoneuvontaan liittyvissä asiossa.
|
||||
|
||||
**Download**
|
||||
`,
|
||||
StudentsCustom: `**Students**
|
||||
|
||||
Taulukko näyttää oletusarvoisesti vain opiskelijanumerot, mutta harmaata liukukytkintä klikkaamalla saa näkyviin opiskelijoiden nimet.
|
||||
|
||||
Klikkaamalla tätä harmaata kuvaketta, saa ladattua .xlsx tiedoston, joka sisältää kaikki "General" ja "Mandatory Courses" välilehtien tiedot.
|
||||
Klikkaamalla opiskelijanumeron vieressä olevaa sinistä henkilösymbolia, siirryt kyseisen opiskelijan "student statistic" -näkymään.
|
||||
|
||||
Klikkaamalla "Sisu"-nuolta, siirryt tarkastelemaan opiskelijan tietoja Sisu-järjestelmässä.
|
||||
|
||||
**All credits** listaa opiskelijan kaikki opintopisteet (myös aiemmat suoritukset, eli ne jotka tehty ennen valittuun tarkastelujaksoon ja populaatioon kuulumista)
|
||||
|
||||
`,
|
||||
Filters: {
|
||||
Add: `Harmaata ”add” painiketta klikkaamalla aukeaa filters- eli suodatinvalikko,
|
||||
|
||||
@@ -105,4 +105,7 @@ export default {
|
||||
TransferredCredits: `
|
||||
Sisältää opintopisteet, jotka ovat suoritettu kyseisenä vuonna, ja hyväksiluettu tähän koulutusohjelmaan. Mukana ovat kaikenlaisilla opinto-oikeuksilla hyväksiluetut opintopisteet
|
||||
`,
|
||||
NotCompleted: `
|
||||
Sisältää opiskelijat, jotka ovat ilmoittautuneet kurssille, mutta eivät ole suorittaneet sitä ja opiskelijat, jotka ovat saaneet hylätyn arvosanan.
|
||||
`,
|
||||
}
|
||||
|
||||
@@ -352,7 +352,7 @@ export const resolveStudyPlan = (studyPlans, studyRight) => {
|
||||
.filter(e => e.element_detail.type === 20)
|
||||
.sort((a, b) => new Date(b.startdate) - new Date(a.startdate))[0] || {}
|
||||
if (!code) return null
|
||||
return studyPlans.find(p => p.programme_code === code)
|
||||
return studyPlans.find(p => p.programme_code === code && p.studyrightid === studyRight.studyrightid)
|
||||
}
|
||||
|
||||
// These are the new Bachelor's programmes in Matlu, that have BH possibility
|
||||
|
||||
@@ -628,7 +628,7 @@ const ProtoC = ({
|
||||
</Menu.Item>
|
||||
{sorterNames.map(sorterName => (
|
||||
<Menu.Item
|
||||
basic={sorter !== sorterName}
|
||||
basic={(sorter !== sorterName).toString()}
|
||||
color={sorter === sorterName ? 'blue' : 'black'}
|
||||
key={sorterName}
|
||||
active={sorter === sorterName}
|
||||
@@ -727,7 +727,7 @@ const ProtoC = ({
|
||||
</Segment>
|
||||
<RenderBelowGraph />
|
||||
<Message>
|
||||
<ReactMarkdown children={CoolDataScience.protoC} escapeHtml={false} />
|
||||
<ReactMarkdown children={CoolDataScience.protoC} />
|
||||
</Message>
|
||||
</Segment>
|
||||
)
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
/* eslint-disable babel/no-invalid-this */
|
||||
import React, { useState, useCallback, useMemo } from 'react'
|
||||
import Highcharts from 'highcharts'
|
||||
import ReactHighcharts from 'react-highcharts'
|
||||
@@ -449,7 +450,7 @@ const ProtoC = ({ programme = 'KH50_005' }) => {
|
||||
</Menu.Item>
|
||||
{sorterNames.map(sorterName => (
|
||||
<Menu.Item
|
||||
basic={sorter !== sorterName}
|
||||
basic={(sorter !== sorterName).toString()}
|
||||
color={sorter === sorterName ? 'blue' : 'black'}
|
||||
key={sorterName}
|
||||
active={sorter === sorterName}
|
||||
@@ -485,7 +486,7 @@ const ProtoC = ({ programme = 'KH50_005' }) => {
|
||||
<Message>
|
||||
{
|
||||
// eslint-disable-next-line react/no-children-prop
|
||||
<ReactMarkdown children={CoolDataScience.protoC2} escapeHtml={false} />
|
||||
<ReactMarkdown children={CoolDataScience.protoC2} />
|
||||
}
|
||||
</Message>
|
||||
</Segment>
|
||||
@@ -541,7 +542,7 @@ const ProtoC = ({ programme = 'KH50_005' }) => {
|
||||
</Menu.Item>
|
||||
{sorterNames.map(sorterName => (
|
||||
<Menu.Item
|
||||
basic={sorter !== sorterName}
|
||||
basic={(sorter !== sorterName).toString()}
|
||||
color={sorter === sorterName ? 'blue' : 'black'}
|
||||
key={sorterName}
|
||||
active={sorter === sorterName}
|
||||
@@ -594,7 +595,7 @@ const ProtoC = ({ programme = 'KH50_005' }) => {
|
||||
<Message>
|
||||
{
|
||||
// eslint-disable-next-line react/no-children-prop
|
||||
<ReactMarkdown children={CoolDataScience.protoC2} escapeHtml={false} />
|
||||
<ReactMarkdown children={CoolDataScience.protoC2} />
|
||||
}
|
||||
</Message>
|
||||
</Segment>
|
||||
|
||||
@@ -100,7 +100,7 @@ const Chart = React.memo(({ tickDates, snapshots }) => (
|
||||
return `${d.getDate()}.${d.getMonth()}.${d
|
||||
.getFullYear()
|
||||
.toString()
|
||||
.substr(-2)}`
|
||||
.substring(-2)}`
|
||||
}
|
||||
},
|
||||
tickPositions: tickDates.map(date => date.getTime()),
|
||||
@@ -292,7 +292,7 @@ const ProtoG = ({ uberdata, years, isLoading, loadingYears, getUberDispatch, get
|
||||
)}
|
||||
<Message>
|
||||
{//eslint-disable-next-line react/no-children-prop
|
||||
<ReactMarkdown children={CoolDataScience.protoC} escapeHtml={false} />
|
||||
<ReactMarkdown children={CoolDataScience.protoC} />
|
||||
}
|
||||
</Message>
|
||||
</Segment>
|
||||
|
||||
@@ -185,7 +185,7 @@ export default ({ value, changeSetting, settings, generalHelp }) => {
|
||||
<div style={{ padding: '1em' }}>
|
||||
{
|
||||
// eslint-disable-next-line react/no-children-prop
|
||||
<ReactMarkdown children={unindent(generalHelp)} escapeHtml={false} />
|
||||
<ReactMarkdown children={unindent(generalHelp)} />
|
||||
}
|
||||
</div>
|
||||
{settings.map(({ key, label, long }) => (
|
||||
@@ -196,7 +196,7 @@ export default ({ value, changeSetting, settings, generalHelp }) => {
|
||||
Valinta "<i>{label}</i>"
|
||||
</b>
|
||||
<div style={{ margin: '0.5em', fontSize: '0.9em' }}>
|
||||
<ReactMarkdown escapeHtml={false}>{unindent(long ?? '')}</ReactMarkdown>
|
||||
<ReactMarkdown>{unindent(long ?? '')}</ReactMarkdown>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ const getColumns = (stats, showDetails, showGrades, userHasAccessToAllStats, alt
|
||||
},
|
||||
{
|
||||
key: 'TOTAL',
|
||||
title: 'Total Students',
|
||||
title: 'Total\nStudents',
|
||||
helpText: 'Total count of students, including enrolled students with no grade.',
|
||||
cellProps: s => ({
|
||||
style: {
|
||||
@@ -113,7 +113,7 @@ const getColumns = (stats, showDetails, showGrades, userHasAccessToAllStats, alt
|
||||
...getGradeColumns(resolveGrades(stats)),
|
||||
{
|
||||
key: 'ENROLLMENTS_MISSING_GRADE',
|
||||
title: 'Enrolled no grade',
|
||||
title: 'Enrolled,\nno grade',
|
||||
filterType: 'range',
|
||||
helpText: 'Total count of students with a valid enrollment and no passing or failing grade.',
|
||||
getRowVal: s => (s.rowObfuscated ? 5 : s.students.enrolledStudentsWithNoGrade),
|
||||
|
||||
@@ -6,7 +6,7 @@ import { useHistory } from 'react-router-dom'
|
||||
import Highcharts from 'highcharts/highstock'
|
||||
import { Button, Radio } from 'semantic-ui-react'
|
||||
import boostcanvas from 'highcharts/modules/boost-canvas'
|
||||
import _ from 'lodash/fp'
|
||||
import _ from 'lodash'
|
||||
import boost from 'highcharts/modules/boost'
|
||||
import ReactHighstock from 'react-highcharts/ReactHighstock'
|
||||
import './creditAccumulationGraphHC.css'
|
||||
@@ -31,6 +31,7 @@ const createGraphOptions = ({
|
||||
startDate,
|
||||
endDate,
|
||||
graduations,
|
||||
transfers,
|
||||
studyRightStartLine,
|
||||
}) => {
|
||||
const tooltip = {
|
||||
@@ -113,6 +114,17 @@ const createGraphOptions = ({
|
||||
text: `Population study start`,
|
||||
},
|
||||
}))
|
||||
)
|
||||
.concat(
|
||||
transfers.map(value => ({
|
||||
value,
|
||||
color: '#cbd128',
|
||||
width: 2,
|
||||
dashStyle: 'dash',
|
||||
label: {
|
||||
text: `Transfer`,
|
||||
},
|
||||
}))
|
||||
),
|
||||
},
|
||||
series: seriesData,
|
||||
@@ -138,19 +150,20 @@ const filterCourses = (
|
||||
byStudyPlanOfCode,
|
||||
cutStudyPlanCredits,
|
||||
startDate,
|
||||
customStudyStartYear
|
||||
customStudyStartYear,
|
||||
studyrightid
|
||||
) => {
|
||||
if (byStudyPlanOfCode && cutStudyPlanCredits)
|
||||
return filterCoursesByDate(
|
||||
filterCoursesByStudyPlan(
|
||||
student.studyplans.find(p => p.programme_code === byStudyPlanOfCode),
|
||||
student.studyplans.find(p => p.programme_code === byStudyPlanOfCode && p.studyrightid === studyrightid),
|
||||
student.courses
|
||||
),
|
||||
customStudyStartYear || student.studyrightStart
|
||||
)
|
||||
if (byStudyPlanOfCode)
|
||||
return filterCoursesByStudyPlan(
|
||||
student.studyplans.find(p => p.programme_code === byStudyPlanOfCode),
|
||||
student.studyplans.find(p => p.programme_code === byStudyPlanOfCode && p.studyrightid === studyrightid),
|
||||
student.courses
|
||||
)
|
||||
if (singleStudent) return student.courses
|
||||
@@ -298,7 +311,8 @@ const createStudentCreditLines = (
|
||||
studyPlanProgrammeCode,
|
||||
cutStudyPlanCredits,
|
||||
startDate,
|
||||
customStudyStartYear
|
||||
customStudyStartYear,
|
||||
studyRightId
|
||||
),
|
||||
courses => [...courses].filter(({ date }) => new Date(date) <= new Date()),
|
||||
sortCoursesByDate,
|
||||
@@ -325,6 +339,12 @@ const filterGraduations = (student, selectedStudyRight) => {
|
||||
return [new Date(selectedGraduation.enddate).getTime()]
|
||||
}
|
||||
|
||||
const filterTransfers = student => {
|
||||
const transferTimes = student.transfers.map(transfer => new Date(transfer.transferdate).getTime())
|
||||
const removeOverlapping = transferTimes.filter((transfer, i, a) => a.indexOf(transfer) === i)
|
||||
return removeOverlapping
|
||||
}
|
||||
|
||||
const CreditAccumulationGraphHighCharts = ({
|
||||
students,
|
||||
singleStudent,
|
||||
@@ -422,6 +442,7 @@ const CreditAccumulationGraphHighCharts = ({
|
||||
}
|
||||
|
||||
const graduations = singleStudent ? filterGraduations(students[0], selectedStudyRight) : []
|
||||
const transfers = singleStudent ? filterTransfers(students[0]) : []
|
||||
const studyRightStartLine =
|
||||
!singleStudent && studyPlanFilterIsActive
|
||||
? [new Date(customStudyStartYear || students[0].studyrightStart).getTime()]
|
||||
@@ -440,6 +461,7 @@ const CreditAccumulationGraphHighCharts = ({
|
||||
}
|
||||
},
|
||||
graduations,
|
||||
transfers,
|
||||
studyRightStartLine,
|
||||
})
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ const CustomOpenUniPopulation = () => {
|
||||
<Message style={{ maxWidth: '800px', fontSize: '16px' }}>
|
||||
<Message.Header>Open uni student population</Message.Header>
|
||||
<p>
|
||||
Here you can create custom population using a list of courses. Clicking the blue custom population button will
|
||||
open a modal where you can enter a list of courses. <br />
|
||||
<Icon fitted name="check" color="green" />: Student passed the course. <br />
|
||||
<Icon fitted name="times" color="red" />: Student failed the course. <br />
|
||||
Here you can create custom population using a list of courses. Clicking the blue button will open a modal
|
||||
where you can enter a list of courses. <br />
|
||||
<Icon fitted name="check" color="green" />: Student has passed the course. <br />
|
||||
<Icon fitted name="times" color="red" />: Student has failed the course. <br />
|
||||
<Icon fitted name="minus" color="grey" />: Student has enrolled, but has not received any grade from the
|
||||
course. <br />
|
||||
<b>Empty cell</b>: Student has no enrollments for the course. <br />
|
||||
|
||||
@@ -87,7 +87,7 @@ const CustomPopulationSearch = ({
|
||||
|
||||
const onClicker = e => {
|
||||
e.preventDefault()
|
||||
const studentnumbers = input.match(/[0-9]+/g)
|
||||
const studentnumbers = input.match(/[0-9]+/g).map(sNumber => (sNumber.length === 8 ? `0${sNumber}` : sNumber))
|
||||
getCustomPopulationDispatch({ studentnumberlist: studentnumbers, onProgress })
|
||||
getCustomPopulationCoursesByStudentnumbers({ studentnumberlist: studentnumbers })
|
||||
selectCustomPopulationSearchDispatch(selectedSearchId || null)
|
||||
|
||||
@@ -0,0 +1,64 @@
|
||||
import React from 'react'
|
||||
import GraduationTimes from 'components/FacultyStatistics/TimesAndPaths/GraduationTimes'
|
||||
|
||||
const FacultyGraduations = ({ faculty, graduationStats, groupByStartYear, showMedian }) => {
|
||||
const groupBy = groupByStartYear ? 'byStartYear' : 'byGradYear'
|
||||
const label = groupByStartYear ? 'Start year' : 'Graduation year'
|
||||
const data = graduationStats?.data?.[groupBy].medians
|
||||
const goals = graduationStats?.data?.goals
|
||||
const goalExceptions = { ...goals?.exceptions, needed: faculty === 'H30' }
|
||||
const programmeData = graduationStats?.data?.[groupBy].programmes.medians
|
||||
const programmeNames = graduationStats?.data?.programmeNames
|
||||
const classSizes = graduationStats?.data?.classSizes
|
||||
const commonProps = { label, programmeNames, showMedian, classSizes, goalExceptions }
|
||||
|
||||
return (
|
||||
<>
|
||||
<div>
|
||||
<GraduationTimes
|
||||
level="bachelor"
|
||||
title="Bachelor"
|
||||
data={data?.bachelor}
|
||||
goal={goals?.bachelor}
|
||||
levelProgrammeData={programmeData?.bachelor}
|
||||
{...commonProps}
|
||||
/>
|
||||
<GraduationTimes
|
||||
level="bcMsCombo"
|
||||
title="Bachelor + Master"
|
||||
data={data?.bcMsCombo}
|
||||
goal={goals?.bcMsCombo}
|
||||
levelProgrammeData={programmeData?.bcMsCombo}
|
||||
groupBy={groupBy}
|
||||
{...commonProps}
|
||||
/>
|
||||
<GraduationTimes
|
||||
level="master"
|
||||
title="Master"
|
||||
data={data?.master}
|
||||
goal={goals?.master}
|
||||
levelProgrammeData={programmeData?.master}
|
||||
{...commonProps}
|
||||
/>
|
||||
<GraduationTimes
|
||||
level="doctor"
|
||||
title="Doctor"
|
||||
data={data?.doctor}
|
||||
goal={goals?.doctor}
|
||||
levelProgrammeData={programmeData?.doctor}
|
||||
{...commonProps}
|
||||
/>
|
||||
<GraduationTimes
|
||||
level="licentiate"
|
||||
title="Licentiate"
|
||||
data={data?.licentiate}
|
||||
goal={goals?.licentiate}
|
||||
levelProgrammeData={programmeData?.licentiate}
|
||||
{...commonProps}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default FacultyGraduations
|
||||
@@ -0,0 +1,153 @@
|
||||
import React from 'react'
|
||||
import { Message } from 'semantic-ui-react'
|
||||
|
||||
import FacultyProgressTable from '../FacultyStatistics/FacultyProgrammeOverview/FacultyProgressTable'
|
||||
import FacultyBarChart from '../FacultyStatistics/FacultyProgrammeOverview/FacultyBarChart'
|
||||
import sortProgrammeKeys from '../FacultyStatistics/facultyHelpers'
|
||||
|
||||
const FacultyProgress = ({ faculty, progressStats, language, getDivider }) => {
|
||||
return (
|
||||
<>
|
||||
{getDivider('Bachelor', 'BachelorStudentsOfTheFacultyByStartingYear', 'no-infobox')}
|
||||
<div className="section-container">
|
||||
<div className="graph-container">
|
||||
<FacultyBarChart
|
||||
cypress="FacultyBachelorsProgress"
|
||||
data={{
|
||||
id: faculty,
|
||||
stats: progressStats?.data.bachelorsGraphStats,
|
||||
years: progressStats?.data.years,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="table-container">
|
||||
<FacultyProgressTable
|
||||
data={progressStats?.data.bachelorsTableStats}
|
||||
programmeStats={progressStats?.data.bachelorsProgStats}
|
||||
titles={progressStats?.data.bachelorTitles}
|
||||
sortedKeys={sortProgrammeKeys(
|
||||
Object.keys(progressStats?.data.bachelorsProgStats).map(obj => [
|
||||
obj,
|
||||
progressStats?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty
|
||||
).map(listObj => listObj[0])}
|
||||
progressYearsVisible={Array(progressStats?.data.years.slice(1).length).fill(false)}
|
||||
programmeNames={progressStats?.data.programmeNames}
|
||||
language={language}
|
||||
cypress="FacultyBachelorsProgressTable"
|
||||
progressTitles={progressStats?.data.yearlyBachelorTitles}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{getDivider('Bachelor + Master', 'ProgressOfBachelorMaster', 'no-infobox')}
|
||||
<Message data-cy="FacultyProgrammesShownInfo">
|
||||
The starting year is the studyright start in the bachelor programme. The credits are comouted by the start date
|
||||
of the bachelor programme and at the moment, they do not include any transferred credits. Thus, in these
|
||||
statistics some students have less credits than in reality.
|
||||
</Message>
|
||||
<div className="section-container">
|
||||
<div className="graph-container">
|
||||
<FacultyBarChart
|
||||
cypress="FacultyBachelorMastersProgress"
|
||||
data={{
|
||||
id: faculty,
|
||||
stats: progressStats?.data.bcMsGraphStats,
|
||||
years: progressStats?.data.years,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="table-container">
|
||||
<FacultyProgressTable
|
||||
data={progressStats?.data.bcMsTableStats}
|
||||
programmeStats={progressStats?.data.bcMsProgStats}
|
||||
titles={progressStats?.data.bcMsTitles}
|
||||
sortedKeys={sortProgrammeKeys(
|
||||
Object.keys(progressStats?.data.bcMsProgStats).map(obj => [
|
||||
obj,
|
||||
progressStats?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty
|
||||
).map(listObj => listObj[0])}
|
||||
progressYearsVisible={Array(progressStats?.data.years.slice(1).length).fill(false)}
|
||||
programmeNames={progressStats?.data.programmeNames}
|
||||
language={language}
|
||||
cypress="FacultyBachelorMasterProgressTable"
|
||||
progressTitles={progressStats?.data.yearlyBcMsTitles}
|
||||
needsExtra={faculty === 'H60' ? 'NO EXTRA' : 'EXTRA HEIGHT'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
{!(faculty === 'H90') && (
|
||||
<>
|
||||
{getDivider('Master', 'MasterStudentsOfTheFacultyByStartingYear', 'no-infobox')}
|
||||
<div className="section-container">
|
||||
<div className="graph-container">
|
||||
<FacultyBarChart
|
||||
cypress="FacultyMastersProgress"
|
||||
data={{
|
||||
id: faculty,
|
||||
stats: progressStats?.data.mastersGraphStats,
|
||||
years: progressStats?.data.years,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="table-container">
|
||||
<FacultyProgressTable
|
||||
data={progressStats?.data.mastersTableStats}
|
||||
programmeStats={progressStats?.data.mastersProgStats}
|
||||
titles={progressStats?.data.mastersTitles}
|
||||
sortedKeys={sortProgrammeKeys(
|
||||
Object.keys(progressStats?.data.mastersProgStats).map(obj => [
|
||||
obj,
|
||||
progressStats?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty
|
||||
).map(listObj => listObj[0])}
|
||||
progressYearsVisible={Array(progressStats?.data.years.slice(1).length).fill(false)}
|
||||
programmeNames={progressStats?.data.programmeNames}
|
||||
language={language}
|
||||
cypress="FacultyMastersProgressTable"
|
||||
progressTitles={progressStats?.data.yearlyMasterTitles}
|
||||
needsExtra={faculty === 'H60' ? 'NO EXTRA' : 'EXTRA HEIGHT'}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{getDivider('Doctor', 'DoctoralStudentsOfTheFacultyByStartingYear', 'no-infobox')}
|
||||
<div className="section-container">
|
||||
<div className="graph-container">
|
||||
<FacultyBarChart
|
||||
cypress="FacultyDoctoralProgress"
|
||||
data={{
|
||||
id: faculty,
|
||||
stats: progressStats?.data.doctoralGraphStats,
|
||||
years: progressStats?.data.years,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
<div className="table-container">
|
||||
<FacultyProgressTable
|
||||
data={progressStats?.data.doctoralTableStats}
|
||||
programmeStats={progressStats?.data.doctoralProgStats}
|
||||
titles={progressStats?.data.doctoralTitles}
|
||||
sortedKeys={sortProgrammeKeys(
|
||||
Object.keys(progressStats?.data.doctoralProgStats).map(obj => [
|
||||
obj,
|
||||
progressStats?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty
|
||||
).map(listObj => listObj[0])}
|
||||
progressYearsVisible={Array(progressStats?.data.years.slice(1).length).fill(false)}
|
||||
programmeNames={progressStats?.data.programmeNames}
|
||||
language={language}
|
||||
cypress="FacultyDoctoralProgressTable"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default FacultyProgress
|
||||
@@ -0,0 +1,145 @@
|
||||
import React, { useState } from 'react'
|
||||
import { Divider, Header, Loader, Message } from 'semantic-ui-react'
|
||||
import {
|
||||
useGetFacultiesQuery,
|
||||
useGetFacultyProgressStatsQuery,
|
||||
useGetFacultyGraduationTimesQuery,
|
||||
} from 'redux/facultyStats'
|
||||
import { getTextIn } from 'common'
|
||||
|
||||
import FacultyGraduations from './FacultyGraduations'
|
||||
import FacultyProgress from './FacultyProgress'
|
||||
|
||||
import Toggle from '../StudyProgramme/Toggle'
|
||||
import InfoBox from '../Info/InfoBox'
|
||||
import InfotoolTips from '../../common/InfoToolTips'
|
||||
import useLanguage from '../LanguagePicker/useLanguage'
|
||||
import '../FacultyStatistics/faculty.css'
|
||||
|
||||
const FacultyView = ({ faculty }) => {
|
||||
const [graduatedGroup, setGraduatedGroup] = useState(false)
|
||||
const [showMedian, setShowMedian] = useState(false)
|
||||
const toolTips = InfotoolTips.Faculty
|
||||
const studyProgrammeFilter = 'NEW_STUDY_PROGRAMMES'
|
||||
const specials = 'SPECIAL_EXCLUDED'
|
||||
const graduated = graduatedGroup ? 'GRADUATED_EXCLUDED' : 'GRADUATED_INCLUDED'
|
||||
const { language } = useLanguage()
|
||||
|
||||
const allFaculties = useGetFacultiesQuery()
|
||||
const faculties = allFaculties?.data
|
||||
const facultyDetails = faculties && faculty && faculties.find(f => f.code === faculty)
|
||||
const facultyName = facultyDetails && getTextIn(facultyDetails.name, language)
|
||||
|
||||
const progressStats = useGetFacultyProgressStatsQuery({
|
||||
id: faculty,
|
||||
studyProgrammeFilter,
|
||||
specialGroups: specials,
|
||||
graduated,
|
||||
})
|
||||
|
||||
const graduationStats = useGetFacultyGraduationTimesQuery({ id: faculty, studyProgrammeFilter })
|
||||
|
||||
const getDivider = (title, toolTipText, content, cypress = undefined) => (
|
||||
<>
|
||||
<div className="divider">
|
||||
<Divider data-cy={`Section-${toolTipText}`} horizontal>
|
||||
{title}
|
||||
</Divider>
|
||||
</div>
|
||||
{content === 'no-infobox' ? null : <InfoBox content={content} cypress={cypress} />}
|
||||
</>
|
||||
)
|
||||
|
||||
if (allFaculties.isLoading || allFaculties.isFetching) {
|
||||
return <Loader active style={{ marginTop: '10em' }} />
|
||||
}
|
||||
|
||||
const isFetchingOrLoading =
|
||||
progressStats.isLoading || progressStats.isFetching || graduationStats.isLoading || graduationStats.isFetching
|
||||
|
||||
const isError =
|
||||
(progressStats.isError && graduationStats.isError) ||
|
||||
(progressStats.isSuccess && !progressStats.data && graduationStats.isSuccess && !graduationStats.data)
|
||||
|
||||
if (isError) return <h3>Something went wrong, please try refreshing the page.</h3>
|
||||
|
||||
return (
|
||||
<>
|
||||
<div align="center" style={{ padding: '30px' }}>
|
||||
<Header textAlign="center">{facultyName}</Header>
|
||||
<span>{faculty}</span>
|
||||
</div>
|
||||
<Message info>
|
||||
<Message.Header>This view is an abridged version of Oodikone's Faculty Overview</Message.Header>
|
||||
<p>
|
||||
In these statistics, all special studyrights have been excluded, eg. exchange students and non-degree
|
||||
students.
|
||||
</p>
|
||||
<p>
|
||||
<b>You can find more statistics on this and all other faculties of the university in main Faculty view. </b>
|
||||
The full view includes details such as: how many have graduated or started in each faculty and in its
|
||||
programmes; credits produced by the faculty; populations backgrounds and enrollment statuses. This view
|
||||
provides statistics both on the whole faculty level and a breakdown of how they are spread among the faculty's
|
||||
programmes.
|
||||
</p>
|
||||
<p>Access the full Faculty view by clicking 'Faculty' in the top navigation bar.</p>
|
||||
</Message>
|
||||
<div className="faculty-overview">
|
||||
{isFetchingOrLoading ? (
|
||||
<Loader active style={{ marginTop: '15em' }} />
|
||||
) : (
|
||||
<div className="programmes-overview">
|
||||
{progressStats.isSuccess && progressStats.data && (
|
||||
<>
|
||||
{getDivider(
|
||||
'Progress of students of the faculty ',
|
||||
'BachelorStudentsOfTheFacultyByStartingYear',
|
||||
toolTips.StudentProgress,
|
||||
'InfoFacultyProgress'
|
||||
)}
|
||||
<div className="toggle-container">
|
||||
<Toggle
|
||||
cypress="GraduatedToggle"
|
||||
toolTips={toolTips.GraduatedToggle}
|
||||
firstLabel="Graduated included"
|
||||
secondLabel="Graduated excluded"
|
||||
value={graduatedGroup}
|
||||
setValue={setGraduatedGroup}
|
||||
/>
|
||||
</div>
|
||||
<FacultyProgress
|
||||
faculty={faculty}
|
||||
progressStats={progressStats}
|
||||
language={language}
|
||||
getDivider={getDivider}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
{graduationStats.isSuccess && graduationStats.data && (
|
||||
<>
|
||||
{getDivider('Average graduation times', 'AverageGraduationTimes', toolTips.AverageGraduationTimes)}
|
||||
<div className="toggle-container">
|
||||
<Toggle
|
||||
cypress="GraduationTimeToggle"
|
||||
firstLabel="Breakdown"
|
||||
secondLabel="Median times"
|
||||
value={showMedian}
|
||||
setValue={setShowMedian}
|
||||
/>
|
||||
</div>
|
||||
<FacultyGraduations
|
||||
faculty={faculty}
|
||||
graduationStats={graduationStats}
|
||||
groupByStartYear={false}
|
||||
showMedian={showMedian}
|
||||
/>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default FacultyView
|
||||
@@ -0,0 +1,194 @@
|
||||
import React, { useState } from 'react'
|
||||
import { Divider, Header, Loader, Message, Segment } from 'semantic-ui-react'
|
||||
import { useGetEvaluationStatsQuery } from 'redux/studyProgramme'
|
||||
import { getTextIn } from '../../common'
|
||||
import useLanguage from '../LanguagePicker/useLanguage'
|
||||
import Toggle from '../StudyProgramme/Toggle'
|
||||
import InfoBox from '../Info/InfoBox'
|
||||
import MedianTimeBarChart from '../StudyProgramme/MedianTimeBarChart'
|
||||
import BreakdownBarChart from '../StudyProgramme/BreakdownBarChart'
|
||||
import StackedBarChart from '../StudyProgramme/BasicOverview/StackedBarChart'
|
||||
import BarChart from '../StudyProgramme/StudytrackOverview/BarChart'
|
||||
import BasicDataTable from '../StudyProgramme/StudytrackOverview/BasicDataTable'
|
||||
import DataTable from '../StudyProgramme/BasicOverview/DataTable'
|
||||
import InfotoolTips from '../../common/InfoToolTips'
|
||||
import '../StudyProgramme/studyprogramme.css'
|
||||
|
||||
const ProgrammeView = ({ studyprogramme }) => {
|
||||
const { language } = useLanguage()
|
||||
const [showMedian, setShowMedian] = useState(false)
|
||||
const [academicYear, setAcademicYear] = useState(false)
|
||||
const [graduated, setGraduated] = useState(false)
|
||||
|
||||
const toolTips = InfotoolTips.Studyprogramme
|
||||
const yearType = academicYear ? 'ACADEMIC_YEAR' : 'CALENDAR_YEAR'
|
||||
const grad = graduated ? 'GRADUATED_EXCLUDED' : 'GRADUATED_INCLUDED'
|
||||
|
||||
const statistics = useGetEvaluationStatsQuery({
|
||||
id: studyprogramme,
|
||||
yearType,
|
||||
specialGroups: 'SPECIAL_EXCLUDED',
|
||||
graduated: grad,
|
||||
})
|
||||
|
||||
const programmeName = statistics?.data?.programmeName && getTextIn(statistics?.data?.programmeName, language)
|
||||
|
||||
const graduationData = statistics?.data?.graduations
|
||||
const progressData = statistics?.data?.progress
|
||||
|
||||
const doCombo = graduationData?.doCombo
|
||||
const timesData = graduationData?.graduationTimes
|
||||
|
||||
const getDivider = (title, toolTipText) => (
|
||||
<>
|
||||
<div className="divider">
|
||||
<Divider data-cy={`Section-${toolTipText}`} horizontal>
|
||||
{title}
|
||||
</Divider>
|
||||
</div>
|
||||
<InfoBox content={toolTips[toolTipText]} />
|
||||
</>
|
||||
)
|
||||
|
||||
const displayMedian = () => (
|
||||
<>
|
||||
{doCombo && (
|
||||
<MedianTimeBarChart
|
||||
data={graduationData?.comboTimes?.medians}
|
||||
goal={graduationData?.comboTimes?.goal}
|
||||
title="Bachelor + Master studyright"
|
||||
byStartYear={false}
|
||||
/>
|
||||
)}
|
||||
<MedianTimeBarChart
|
||||
data={graduationData?.graduationTimes?.medians}
|
||||
goal={graduationData?.graduationTimes?.goal}
|
||||
title={doCombo ? 'Master studyright' : ' '}
|
||||
byStartYear={false}
|
||||
/>
|
||||
</>
|
||||
)
|
||||
|
||||
const displayBreakdown = () => (
|
||||
<>
|
||||
{doCombo && <BreakdownBarChart data={graduationData?.comboTimes?.medians} title="Bachelor + Master studyright" />}
|
||||
<BreakdownBarChart data={timesData?.medians} title={doCombo ? 'Master studyright' : ' '} />
|
||||
</>
|
||||
)
|
||||
|
||||
const isFetchingOrLoading = statistics.isLoading || statistics.isFetching
|
||||
|
||||
const isError = statistics.isError || (statistics.isSuccess && !statistics.data)
|
||||
|
||||
if (isError) return <h3>Something went wrong, please try refreshing the page.</h3>
|
||||
|
||||
return (
|
||||
<>
|
||||
<div align="center" style={{ padding: '30px' }}>
|
||||
<Header textAlign="center">{programmeName}</Header>
|
||||
<span>{studyprogramme}</span>
|
||||
</div>
|
||||
<div className="studyprogramme-overview">
|
||||
{isFetchingOrLoading ? (
|
||||
<Loader active style={{ marginTop: '10em' }} />
|
||||
) : (
|
||||
<Segment className="contentSegment">
|
||||
<Message info>
|
||||
<Message.Header>This view is an abridged version of Oodikone's Studyprogramme Overview</Message.Header>
|
||||
<p>
|
||||
In these statistics, all special studyrights have been excluded, eg. exchange students and non-degree
|
||||
students.
|
||||
</p>
|
||||
<p>
|
||||
<b>
|
||||
You can find more statistics on this and other studyprogrammes of the university in main
|
||||
Studyprogramme Overview.{' '}
|
||||
</b>
|
||||
The full view includes details such as: how many have graduated or started in each programme and in its
|
||||
studytracks; credits produced by the programme; population backgrounds and enrollment statuses.
|
||||
</p>
|
||||
<p>
|
||||
Access the full Studyprogramme Overview by clicking 'Studyprogramme' in the top navigation bar and then
|
||||
'Overview'. Alternatively, you can select 'Search by class' to explore studyprogrammes by starting class
|
||||
with interactive statistics and visualizations.
|
||||
</p>
|
||||
<p>
|
||||
{' '}
|
||||
Note that both views have access restrictions. If you can't access either view and feel you should have
|
||||
access, please contact oodikone@helsinki.fi.
|
||||
</p>
|
||||
</Message>
|
||||
<div>
|
||||
{getDivider(`Progress of students of the studyprogramme by starting year`, 'StudytrackProgress')}
|
||||
<Toggle
|
||||
cypress="GraduatedToggle"
|
||||
toolTips={toolTips.GraduatedToggle}
|
||||
firstLabel="Graduated included"
|
||||
secondLabel="Graduated excluded"
|
||||
value={graduated}
|
||||
setValue={setGraduated}
|
||||
/>
|
||||
<div className="section-container">
|
||||
<BarChart cypress="StudytrackProgress" data={progressData?.graphData} track={studyprogramme} />
|
||||
<BasicDataTable
|
||||
cypress="StudytrackProgress"
|
||||
data={progressData?.creditTableStats}
|
||||
track={studyprogramme}
|
||||
titles={progressData?.creditTableTitles}
|
||||
/>
|
||||
</div>
|
||||
{graduationData?.programmesBeforeOrAfterGraphStats && (
|
||||
<>
|
||||
{getDivider('Graduation times', 'AverageGraduationTimes')}
|
||||
<div className="toggle-container">
|
||||
<Toggle
|
||||
cypress="GraduationTimeToggle"
|
||||
firstLabel="Breakdown"
|
||||
secondLabel="Median time"
|
||||
value={showMedian}
|
||||
setValue={setShowMedian}
|
||||
/>
|
||||
<div className="toggle-container">
|
||||
<Toggle
|
||||
cypress="YearToggle"
|
||||
toolTips={toolTips.YearToggle}
|
||||
firstLabel="Calendar year"
|
||||
secondLabel="Academic year"
|
||||
value={academicYear}
|
||||
setValue={setAcademicYear}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div className={`section-container${doCombo ? '' : '-centered'}`}>
|
||||
{showMedian ? displayMedian() : displayBreakdown()}
|
||||
</div>
|
||||
{getDivider(
|
||||
studyprogramme.includes('KH')
|
||||
? 'Primary master programme studies after this programme'
|
||||
: 'Primary bachelor programme studies before this programme',
|
||||
'ProgrammesBeforeOrAfter'
|
||||
)}
|
||||
<div className="section-container">
|
||||
<StackedBarChart
|
||||
cypress="ProgrammesBeforeOrAfter"
|
||||
wideTable
|
||||
data={graduationData?.programmesBeforeOrAfterGraphStats}
|
||||
labels={graduationData?.years}
|
||||
/>
|
||||
<DataTable
|
||||
wideTable
|
||||
data={graduationData?.programmesBeforeOrAfterTableStats}
|
||||
titles={graduationData?.programmesBeforeOrAfterTitles}
|
||||
/>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</Segment>
|
||||
)}
|
||||
</div>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProgrammeView
|
||||
@@ -0,0 +1,24 @@
|
||||
import React from 'react'
|
||||
import { Redirect, withRouter } from 'react-router-dom'
|
||||
import { Segment } from 'semantic-ui-react'
|
||||
|
||||
import FacultyView from './FacultyView'
|
||||
import ProgrammeView from './ProgrammeView'
|
||||
|
||||
const EvaluationOverview = props => {
|
||||
const { id, level } = props.match.params
|
||||
|
||||
if (!(level === 'programme' || level === 'faculty') || !id) {
|
||||
return <Redirect to="/" />
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="segmentContainer">
|
||||
<Segment className="contentSegment">
|
||||
{level === 'programme' ? <ProgrammeView studyprogramme={id} /> : <FacultyView faculty={id} />}
|
||||
</Segment>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default withRouter(EvaluationOverview)
|
||||
@@ -118,13 +118,11 @@ const Overview = ({
|
||||
|
||||
if (isError) return <h3>Something went wrong, please try refreshing the page.</h3>
|
||||
|
||||
let creditShortTitles = []
|
||||
const creditShortTitles = ['Code', 'Total', 'Major', 'Non-major', 'Non-major other', 'Non-degree']
|
||||
let transferShortTitles = []
|
||||
if (special === 'SPECIAL_INCLUDED') {
|
||||
creditShortTitles = ['Code', 'Total', 'Major', 'Non-major', 'Non-major other', 'Non-degree']
|
||||
transferShortTitles = ['Code', 'Started', 'Graduated', 'Transferred in', 'Transferred away', 'Transferred to']
|
||||
} else {
|
||||
creditShortTitles = ['Code', 'Major']
|
||||
transferShortTitles = ['Code', 'Started', 'Graduated']
|
||||
}
|
||||
|
||||
@@ -222,7 +220,8 @@ const Overview = ({
|
||||
)}
|
||||
{special === 'SPECIAL_EXCLUDED' && (
|
||||
<Message data-cy="FacultyExcludeSpecialsInfo">
|
||||
Please note that the data might be inaccurate in some fields. Checking the values is in progress.
|
||||
Please note: exluding the special studyrights does not have any effects to credits produced by faculty
|
||||
-view.
|
||||
</Message>
|
||||
)}
|
||||
{basics.isSuccess && basics.data && (
|
||||
@@ -274,58 +273,6 @@ const Overview = ({
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{credits.isSuccess && credits.data && (
|
||||
<>
|
||||
{getDivider(
|
||||
'Credits produced by the faculty',
|
||||
'CreditsProducedByTheFaculty',
|
||||
credits?.data?.titles,
|
||||
credits?.data?.tableStats,
|
||||
credits?.data?.programmeTableStats,
|
||||
credits?.data?.programmeNames
|
||||
)}
|
||||
<div className="section-container">
|
||||
<div className="graph-container-narrow">
|
||||
<StackedBarChart
|
||||
cypress="CreditsProducedByTheFaculty"
|
||||
data={credits?.data?.graphStats}
|
||||
labels={credits?.data?.years}
|
||||
wideTable="narrow"
|
||||
/>
|
||||
</div>
|
||||
<div className="table-container-wide">
|
||||
<InteractiveDataTable
|
||||
cypress="CreditsProducedByTheFaculty"
|
||||
dataStats={credits?.data?.tableStats}
|
||||
dataProgrammeStats={credits?.data?.programmeTableStats}
|
||||
programmeNames={credits?.data?.programmeNames}
|
||||
sortedKeys={sortProgrammeKeys(
|
||||
Object.keys(credits?.data.programmeTableStats).map(obj => [
|
||||
obj,
|
||||
credits?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty.code
|
||||
).map(listObj => listObj[0])}
|
||||
plotLinePlaces={getChartPlotLinePlaces(
|
||||
sortProgrammeKeys(
|
||||
Object.keys(credits?.data?.programmeTableStats).map(obj => [
|
||||
obj,
|
||||
credits?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty.code
|
||||
)
|
||||
)}
|
||||
titles={credits?.data?.titles}
|
||||
extraHeight="EXTRA HEIGHT"
|
||||
sliceStart={2}
|
||||
language={language}
|
||||
yearsVisible={Array(credits?.data?.tableStats.length).fill(false)}
|
||||
shortNames={creditShortTitles}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{basics.isSuccess && basics.data && (
|
||||
<>
|
||||
{getDivider(
|
||||
@@ -423,6 +370,58 @@ const Overview = ({
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{credits.isSuccess && credits.data && (
|
||||
<>
|
||||
{getDivider(
|
||||
'Credits produced by the faculty',
|
||||
'CreditsProducedByTheFaculty',
|
||||
credits?.data?.titles,
|
||||
credits?.data?.tableStats,
|
||||
credits?.data?.programmeTableStats,
|
||||
credits?.data?.programmeNames
|
||||
)}
|
||||
<div className="section-container">
|
||||
<div className="graph-container-narrow">
|
||||
<StackedBarChart
|
||||
cypress="CreditsProducedByTheFaculty"
|
||||
data={credits?.data?.graphStats}
|
||||
labels={credits?.data?.years}
|
||||
wideTable="narrow"
|
||||
/>
|
||||
</div>
|
||||
<div className="table-container-wide">
|
||||
<InteractiveDataTable
|
||||
cypress="CreditsProducedByTheFaculty"
|
||||
dataStats={credits?.data?.tableStats}
|
||||
dataProgrammeStats={credits?.data?.programmeTableStats}
|
||||
programmeNames={credits?.data?.programmeNames}
|
||||
sortedKeys={sortProgrammeKeys(
|
||||
Object.keys(credits?.data.programmeTableStats).map(obj => [
|
||||
obj,
|
||||
credits?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty.code
|
||||
).map(listObj => listObj[0])}
|
||||
plotLinePlaces={getChartPlotLinePlaces(
|
||||
sortProgrammeKeys(
|
||||
Object.keys(credits?.data?.programmeTableStats).map(obj => [
|
||||
obj,
|
||||
credits?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty.code
|
||||
)
|
||||
)}
|
||||
titles={credits?.data?.titles}
|
||||
extraHeight="EXTRA HEIGHT"
|
||||
sliceStart={2}
|
||||
language={language}
|
||||
yearsVisible={Array(credits?.data?.tableStats.length).fill(false)}
|
||||
shortNames={creditShortTitles}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
+40
-37
@@ -36,44 +36,47 @@ const FacultyProgressTable = ({
|
||||
</Table.Header>
|
||||
|
||||
<Table.Body>
|
||||
{data?.map((yearArray, yearIndex) => (
|
||||
<React.Fragment key={`random-fragment-key-${Math.random()}`}>
|
||||
{yearIndex < lenOfYearArray ? (
|
||||
<BasicRow
|
||||
icon={visible[yearIndex] ? 'angle down' : 'angle right'}
|
||||
yearArray={yearArray}
|
||||
cypress={visible[yearIndex] ? `Hide-${cypress}` : `Show-${cypress}`}
|
||||
yearIndex={yearIndex}
|
||||
toggleVisibility={() => toggleVisibility(yearIndex)}
|
||||
/>
|
||||
) : (
|
||||
<Table.Row>
|
||||
{yearArray?.map(value => (
|
||||
<Table.Cell key={`last-row-${Math.random()}`}>{value}</Table.Cell>
|
||||
))}
|
||||
</Table.Row>
|
||||
)}
|
||||
{yearIndex < lenOfYearArray ? (
|
||||
<Table.Row
|
||||
key={`${cypress}-row-${Math.random()}`}
|
||||
style={{ display: visible[yearIndex] ? '' : 'none' }}
|
||||
>
|
||||
<Table.Cell data-cy={`Cell-${cypress}-${yearIndex}`} colSpan={100}>
|
||||
<ProgrammeProgressChart
|
||||
data={sortedKeys?.map(programme => programmeStats[programme][yearIndex])}
|
||||
longLabels={programmeNames}
|
||||
labels={sortedKeys}
|
||||
language={language}
|
||||
names={progressTitles ? progressTitles[yearIndex] : titles?.slice(2)}
|
||||
needsExtra={needsExtra === 'EXTRA HEIGHT'}
|
||||
{data?.map(
|
||||
(yearArray, yearIndex) =>
|
||||
yearArray?.slice(1).some(value => value !== 0) && (
|
||||
<React.Fragment key={`random-fragment-key-${Math.random()}`}>
|
||||
{yearIndex < lenOfYearArray ? (
|
||||
<BasicRow
|
||||
icon={visible[yearIndex] ? 'angle down' : 'angle right'}
|
||||
yearArray={yearArray}
|
||||
cypress={visible[yearIndex] ? `Hide-${cypress}` : `Show-${cypress}`}
|
||||
yearIndex={yearIndex}
|
||||
toggleVisibility={() => toggleVisibility(yearIndex)}
|
||||
/>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</React.Fragment>
|
||||
))}
|
||||
) : (
|
||||
<Table.Row>
|
||||
{yearArray?.map(value => (
|
||||
<Table.Cell key={`last-row-${Math.random()}`}>{value}</Table.Cell>
|
||||
))}
|
||||
</Table.Row>
|
||||
)}
|
||||
{yearIndex < lenOfYearArray ? (
|
||||
<Table.Row
|
||||
key={`${cypress}-row-${Math.random()}`}
|
||||
style={{ display: visible[yearIndex] ? '' : 'none' }}
|
||||
>
|
||||
<Table.Cell data-cy={`Cell-${cypress}-${yearIndex}`} colSpan={100}>
|
||||
<ProgrammeProgressChart
|
||||
data={sortedKeys?.map(programme => programmeStats[programme][yearIndex])}
|
||||
longLabels={programmeNames}
|
||||
labels={sortedKeys}
|
||||
language={language}
|
||||
names={progressTitles ? progressTitles[yearIndex] : titles?.slice(2)}
|
||||
needsExtra={needsExtra === 'EXTRA HEIGHT'}
|
||||
/>
|
||||
</Table.Cell>
|
||||
</Table.Row>
|
||||
) : (
|
||||
<></>
|
||||
)}
|
||||
</React.Fragment>
|
||||
)
|
||||
)}
|
||||
</Table.Body>
|
||||
</Table>
|
||||
</div>
|
||||
|
||||
+63
-22
@@ -11,6 +11,9 @@ const getStyle = idx => {
|
||||
return {}
|
||||
}
|
||||
|
||||
const backgroundColors = { KH: '#ffffff', MH: '#f2f6f7', T: '#e7edee' }
|
||||
const backgroundColorsDarks = { KH: '#f9f9f9', MH: '#eeeeee', T: '#dddddd' }
|
||||
|
||||
const getTitlePopup = idx => {
|
||||
if (idx === 0) return <p>All</p>
|
||||
if ([1, 2].includes(idx)) return <p>Started studying</p>
|
||||
@@ -29,6 +32,7 @@ const FacultyStudentDataTable = ({
|
||||
tableStats,
|
||||
programmeStats,
|
||||
programmeNames,
|
||||
tableLinePlaces,
|
||||
titles,
|
||||
years,
|
||||
sortedKeys,
|
||||
@@ -44,6 +48,52 @@ const FacultyStudentDataTable = ({
|
||||
setVisible(arrayToModify)
|
||||
}
|
||||
|
||||
const getRowStyle = (idx, dark = false) => {
|
||||
if (tableLinePlaces.length >= 3 && tableLinePlaces[2][0] <= idx)
|
||||
return dark
|
||||
? { backgroundColor: backgroundColorsDarks[tableLinePlaces[2][1]] }
|
||||
: { backgroundColor: backgroundColors[tableLinePlaces[2][1]] }
|
||||
if (tableLinePlaces.length >= 3 && tableLinePlaces[2][0] > idx && tableLinePlaces[1][0] <= idx)
|
||||
return dark
|
||||
? { backgroundColor: backgroundColorsDarks[tableLinePlaces[1][1]] }
|
||||
: { backgroundColor: backgroundColors[tableLinePlaces[1][1]] }
|
||||
if (tableLinePlaces.length >= 2 && tableLinePlaces[1][0] > idx && tableLinePlaces[0][0] <= idx)
|
||||
return dark
|
||||
? { backgroundColor: backgroundColorsDarks[tableLinePlaces[0][1]] }
|
||||
: { backgroundColor: backgroundColors[tableLinePlaces[0][1]] }
|
||||
return dark
|
||||
? { backgroundColor: backgroundColorsDarks[tableLinePlaces[0][1]] }
|
||||
: { backgroundColor: backgroundColors[tableLinePlaces[0][1]] }
|
||||
}
|
||||
|
||||
const calendarYears = years.reduce((all, year) => {
|
||||
if (year === 'Total') return all
|
||||
return all.concat(Number(year.slice(0, 4)))
|
||||
}, [])
|
||||
|
||||
const getRows = (idx, programme, year) => {
|
||||
return programmeStats[programme][year].map((value, valIdx) => {
|
||||
if (!showPercentages && typeof value === 'string' && (value.includes('%') || value.includes('NA'))) return null
|
||||
return (
|
||||
<Popup
|
||||
content={getTitlePopup(valIdx)}
|
||||
trigger={
|
||||
<Table.Cell
|
||||
key={`${year}-${programme}-color-${valIdx}`}
|
||||
style={
|
||||
getStyle(valIdx + 1)?.backgroundColor
|
||||
? { borderLeftWidth: getStyle(valIdx + 1).borderLeftWidth, ...getRowStyle(idx, true) }
|
||||
: { ...getStyle(valIdx + 1), ...getRowStyle(idx) }
|
||||
}
|
||||
>
|
||||
{value}
|
||||
</Table.Cell>
|
||||
}
|
||||
/>
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="datatable">
|
||||
<Toggle
|
||||
@@ -122,10 +172,14 @@ const FacultyStudentDataTable = ({
|
||||
})}
|
||||
</Table.Row>
|
||||
{yearsVisible[yearIndex] &&
|
||||
sortedKeys.map(programme => {
|
||||
return (
|
||||
sortedKeys.map((programme, idx) => {
|
||||
return programmeStats[programme][year].length === 0 ? null : (
|
||||
<Table.Row className="regular-row" key={`${year}-regular-row-${programme}`}>
|
||||
<Table.Cell textAlign="left" style={{ paddingLeft: '50px' }} key={`${year}-${programme}`}>
|
||||
<Table.Cell
|
||||
textAlign="left"
|
||||
key={`${year}-${programme}`}
|
||||
style={{ paddingLeft: '50px', ...getRowStyle(idx) }}
|
||||
>
|
||||
<Popup
|
||||
content={
|
||||
programmeNames[programme][language] ? (
|
||||
@@ -143,27 +197,14 @@ const FacultyStudentDataTable = ({
|
||||
{(requiredRights.rights?.includes(programmeNames[programme].code) ||
|
||||
requiredRights.isAdmin ||
|
||||
requiredRights.IAMrights?.includes(programmeNames[programme].code)) && (
|
||||
<PopulationLink studyprogramme={programmeNames[programme].code} year={year} />
|
||||
<PopulationLink
|
||||
studyprogramme={programmeNames[programme].code}
|
||||
year={year}
|
||||
years={calendarYears}
|
||||
/>
|
||||
)}
|
||||
</Table.Cell>
|
||||
{programmeStats[programme][year].map((value, valIdx) => {
|
||||
if (
|
||||
!showPercentages &&
|
||||
typeof value === 'string' &&
|
||||
(value.includes('%') || value.includes('NA'))
|
||||
)
|
||||
return null
|
||||
return (
|
||||
<Popup
|
||||
content={getTitlePopup(valIdx)}
|
||||
trigger={
|
||||
<Table.Cell key={`${year}-${programme}-color-${valIdx}`} style={getStyle(valIdx + 1)}>
|
||||
{value}
|
||||
</Table.Cell>
|
||||
}
|
||||
/>
|
||||
)
|
||||
})}
|
||||
{getRows(idx, programme, year)}
|
||||
</Table.Row>
|
||||
)
|
||||
})}
|
||||
|
||||
+36
-4
@@ -1,5 +1,5 @@
|
||||
import React from 'react'
|
||||
import { Divider, Loader } from 'semantic-ui-react'
|
||||
import { Divider, Loader, Message } from 'semantic-ui-react'
|
||||
import { useGetFacultyProgressStatsQuery, useGetFacultyStudentStatsQuery } from 'redux/facultyStats'
|
||||
import FacultyProgressTable from './FacultyProgressTable'
|
||||
import FacultyBarChart from './FacultyBarChart'
|
||||
@@ -20,7 +20,9 @@ const getDivider = (title, toolTipText, content, cypress) => (
|
||||
{content === 'no-infobox' ? null : <InfoBox content={content} cypress={cypress} />}
|
||||
</>
|
||||
)
|
||||
|
||||
const getKey = (programmeKeys, idx) => {
|
||||
return programmeKeys[idx][1].startsWith('T') ? 'T' : programmeKeys[idx][1].slice(0, 2)
|
||||
}
|
||||
const FacultyProgrammeOverview = ({
|
||||
faculty,
|
||||
language,
|
||||
@@ -57,6 +59,22 @@ const FacultyProgrammeOverview = ({
|
||||
(studentStats.isSuccess && !studentStats.data)
|
||||
if (isError) return <h3>Something went wrong, please try refreshing the page.</h3>
|
||||
|
||||
const getTableLinePlaces = programmeKeys => {
|
||||
if (programmeKeys.length === 0) return []
|
||||
const key = getKey(programmeKeys, 0)
|
||||
const plotLinePlaces = [[0, key]]
|
||||
for (let i = 0; i < programmeKeys.length - 1; i++) {
|
||||
if (
|
||||
(programmeKeys[i][1].startsWith('KH') && programmeKeys[i + 1][1].startsWith('MH')) ||
|
||||
(programmeKeys[i][1].startsWith('MH') && programmeKeys[i + 1][1].startsWith('T'))
|
||||
) {
|
||||
const key = getKey(programmeKeys, i + 1)
|
||||
plotLinePlaces.push([i + 1, key])
|
||||
}
|
||||
}
|
||||
return plotLinePlaces
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="faculty-overview">
|
||||
<div className="toggle-container">
|
||||
@@ -99,10 +117,19 @@ const FacultyProgrammeOverview = ({
|
||||
sortedKeys={sortProgrammeKeys(
|
||||
Object.keys(studentStats?.data.programmeStats).map(obj => [
|
||||
obj,
|
||||
studentStats?.data?.programmeNames[obj].code,
|
||||
studentStats?.data?.programmeNames[obj]?.code,
|
||||
]),
|
||||
faculty.code
|
||||
).map(listObj => listObj[0])}
|
||||
tableLinePlaces={getTableLinePlaces(
|
||||
sortProgrammeKeys(
|
||||
Object.keys(studentStats?.data?.programmeStats).map(obj => [
|
||||
obj,
|
||||
studentStats?.data?.programmeNames[obj].code,
|
||||
]),
|
||||
faculty.code
|
||||
)
|
||||
)}
|
||||
language={language}
|
||||
cypress="FacultyStudentStatsTable"
|
||||
requiredRights={requiredRights}
|
||||
@@ -152,6 +179,11 @@ const FacultyProgrammeOverview = ({
|
||||
</div>
|
||||
</div>
|
||||
{getDivider('Bachelor + Master', 'ProgressOfBachelorMaster', 'no-infobox')}
|
||||
<Message data-cy="FacultyProgrammesShownInfo">
|
||||
Please note: The starting year is the studyright start in the bachelor programme. The credits are
|
||||
computed by the start date of the bachelor programme and at the moment, they do not include any
|
||||
transferred credits. Thus, in these statistics some students have less credits than in reality.
|
||||
</Message>
|
||||
<div className="section-container">
|
||||
<div className="graph-container">
|
||||
<FacultyBarChart
|
||||
@@ -221,7 +253,7 @@ const FacultyProgrammeOverview = ({
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
{getDivider('Doctor and licentiate', 'DoctoralStudentsOfTheFacultyByStartingYear', 'no-infobox')}
|
||||
{getDivider('Doctor', 'DoctoralStudentsOfTheFacultyByStartingYear', 'no-infobox')}
|
||||
<div className="section-container">
|
||||
<div className="graph-container">
|
||||
<FacultyBarChart
|
||||
|
||||
+2
-1
@@ -17,7 +17,7 @@ const CollapsedStackedBar = ({
|
||||
const transpose = matrix => {
|
||||
return matrix.reduce((prev, next) => next.map((_item, i) => (prev[i] || []).concat(next[i])), [])
|
||||
}
|
||||
|
||||
if (names[0] === 'Started studying') names[0] += ' (new in faculty)'
|
||||
const needsExtra = extraHeight === 'EXTRA HEIGHT'
|
||||
const dataTranspose = transpose(data)
|
||||
.map((obj, idx) => ({ name: names[idx], data: obj, color: colors[idx] }))
|
||||
@@ -53,6 +53,7 @@ const CollapsedStackedBar = ({
|
||||
color: 'black',
|
||||
fontWeight: 'bold',
|
||||
fontSize: 14,
|
||||
position: 'absolute',
|
||||
},
|
||||
align: 'right',
|
||||
x: 0,
|
||||
|
||||
@@ -32,13 +32,10 @@ const sortProgrammeKeys = (programmeKeys, faculty) => {
|
||||
return programmeKeys.sort((a, b) => {
|
||||
if (a[1].includes(faculty) && !b[1].includes(faculty)) return -1
|
||||
if (!a[1].includes(faculty) && b[1].includes(faculty)) return 1
|
||||
if (a[1].startsWith('T') && !b[1].includes(faculty)) return -1
|
||||
if (!a[1].includes(faculty) && b[1].startsWith('T')) return 1
|
||||
if (a[1].startsWith('LIS') && !b[1].includes(faculty)) return -1
|
||||
if (!a[1].includes(faculty) && b[1].startsWith('LIS')) return 1
|
||||
if (testKey(a[1]) - testKey(b[1]) === 0 && testKey(a[0]) - testKey(b[0]) === 0) {
|
||||
return a[1].localeCompare(b[1])
|
||||
}
|
||||
if (a[1].startsWith('T') && !b[1].includes(faculty) && !b[1].includes('T')) return -1
|
||||
if (!a[1].includes(faculty) && b[1].startsWith('T') && !a[1].includes('T')) return 1
|
||||
if (a[1].startsWith('LIS') && !b[1].includes(faculty) && !b[1].includes('LIS')) return -1
|
||||
if (!a[1].includes(faculty) && b[1].startsWith('LIS') && !a[1].includes('LIS')) return 1
|
||||
if (testKey(a[1]) - testKey(b[1]) === 0) {
|
||||
return a[0].localeCompare(b[0])
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ const FigureContainer = ({ children, style }) => {
|
||||
height: '100% !important',
|
||||
}}
|
||||
>
|
||||
<div style={{ inset: 0, position: 'absolute', zIndex: 900, height: '100000vh' }}>
|
||||
<div style={{ inset: '70px 0px 0px 0px', position: 'absolute', zIndex: 900, height: '100000vh' }}>
|
||||
{isFullscreen && <OutPortal node={portalNode} />}
|
||||
</div>
|
||||
</Portal>
|
||||
|
||||
@@ -74,7 +74,7 @@ const FilterTray = () => {
|
||||
</div>
|
||||
{haveOptionsBeenChanged && (
|
||||
<div style={{ marginTop: '0.5rem', textAlign: 'center' }}>
|
||||
<Button compact size="mini" onClick={resetFilters}>
|
||||
<Button compact size="mini" onClick={resetFilters} data-cy="reset-all-filters">
|
||||
Reset All Filters
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -17,7 +17,7 @@ const admissionTypeFilter = code => value => student =>
|
||||
student.studyrights.some(
|
||||
sr =>
|
||||
sr.studyright_elements.some(sre => sre.code === code) &&
|
||||
(value === null ? !sr.admission_type : sr.admission_type === value)
|
||||
(value === null || value === 'Ei valintatapaa' ? !sr.admission_type : sr.admission_type === value)
|
||||
)
|
||||
|
||||
const AdmissionTypeFilterCard = ({ options, onOptionsChange, withoutSelf, code }) => {
|
||||
|
||||
@@ -7,26 +7,20 @@ import { FilterType } from './filterType'
|
||||
const filterTexts = {
|
||||
[FilterType.ALL]: { label: 'All' },
|
||||
[FilterType.PASSED]: { label: 'Passed' },
|
||||
[FilterType.PASSED_AFTER_FAILURE]: { label: 'Passed After Failure' },
|
||||
// [FilterType.FAILED]: { label: 'Failed' },
|
||||
// [FilterType.FAILED_MANY_TIMES]: { label: 'Failed Multiple Times' },
|
||||
// [FilterType.NOT_PARTICIPATED]: { label: 'Not Participated' },
|
||||
// [FilterType.DID_NOT_PASS]: { label: "Didn't Pass" },
|
||||
[FilterType.FAILED]: { label: 'Failed' },
|
||||
[FilterType.ENROLLED_NO_GRADE]: { label: 'Enrolled, No Grade' },
|
||||
// [FilterType.NOT_PARTICIPATED]: { label: 'Not Participated'},
|
||||
}
|
||||
// a bandaid solution to prevent oodikone crashing
|
||||
const translate = {
|
||||
ALL: 'all',
|
||||
PASSED: 'passed',
|
||||
PASSED_AFTER_FAILURE: 'retryPassed',
|
||||
FAILED: 'failed',
|
||||
FAILED_MANY_TIMES: 'failedMany',
|
||||
NOT_PARTICIPATED: 'notParticipated',
|
||||
DID_NOT_PASS: 'didNotPass',
|
||||
ENROLLED_NO_GRADE: 'enrolledNoGrade',
|
||||
// NOT_PARTICIPATED: 'notParticipated',
|
||||
}
|
||||
|
||||
const CourseCard = ({ course, filterType, onChange }) => {
|
||||
// Object.entries(filterTexts).map(([type, { label, info }]) => console.log(type, label, translate[type]))
|
||||
// console.log('course', course)
|
||||
const { language } = useLanguage()
|
||||
const name = 'courseFilter'
|
||||
|
||||
@@ -47,7 +41,7 @@ const CourseCard = ({ course, filterType, onChange }) => {
|
||||
fluid
|
||||
className="mini"
|
||||
button
|
||||
data-cy={`${name}-${course.course.code}-dropdown`}
|
||||
data-cy={`${name}-${course?.course?.code}-dropdown`}
|
||||
style={{ marginTop: '0.5rem' }}
|
||||
>
|
||||
<Dropdown.Menu>
|
||||
@@ -74,7 +68,7 @@ const CourseCard = ({ course, filterType, onChange }) => {
|
||||
size="tiny"
|
||||
onClick={clear}
|
||||
icon
|
||||
data-cy={`${name}-${course.course.code}-clear`}
|
||||
data-cy={`${name}-${course?.course?.code}-clear`}
|
||||
style={{ marginTop: '0.5rem' }}
|
||||
>
|
||||
<Icon name="close" />
|
||||
|
||||
@@ -2,9 +2,7 @@
|
||||
export const FilterType = {
|
||||
ALL: 'ALL',
|
||||
PASSED: 'PASSED',
|
||||
PASSED_AFTER_FAILURE: 'PASSED_AFTER_FAILURE',
|
||||
FAILED: 'FAILED',
|
||||
FAILED_MANY_TIMES: 'FAILED_MANY_TIMES',
|
||||
NOT_PARTICIPATED: 'NOT_PARTICIPATED',
|
||||
DID_NOT_PASS: 'DID_NOT_PASS',
|
||||
ENROLLED_NO_GRADE: 'ENROLLED_NO_GRADE',
|
||||
// NOT_PARTICIPATED: 'NOT_PARTICIPATED',
|
||||
}
|
||||
|
||||
@@ -72,20 +72,17 @@ const CourseFilterCard = ({ courseStats, options, onOptionsChange }) => {
|
||||
}
|
||||
|
||||
const createFilterFunc =
|
||||
(key, invert = false) =>
|
||||
({ studentNumber }, { students }) =>
|
||||
Object.keys(students[key]).includes(studentNumber) !== invert
|
||||
key =>
|
||||
({ studentNumber }, { students }) => {
|
||||
return Object.keys(students[key]).includes(studentNumber)
|
||||
}
|
||||
|
||||
const filterFunctions = {
|
||||
[FilterType.ALL]: createFilterFunc('all'),
|
||||
[FilterType.PASSED]: createFilterFunc('passed'),
|
||||
[FilterType.PASSED_AFTER_FAILURE]: createFilterFunc('retryPassed'),
|
||||
// [FilterType.FAILED]: createFilterFunc('failed'),
|
||||
// [FilterType.FAILED_MANY_TIMES]: createFilterFunc('failedMany'),
|
||||
// [FilterType.DID_NOT_PASS]: createFilterFunc('didNotPass'),
|
||||
// [FilterType.NOT_PARTICIPATED]: createFilterFunc('all', true),
|
||||
// [FilterType.DID_NOT_PASS]: ({ studentNumber }, { students }) =>
|
||||
// !Object.keys(students.all).includes(studentNumber) || Object.keys(students.failed).includes(studentNumber),
|
||||
[FilterType.FAILED]: createFilterFunc('failed'),
|
||||
[FilterType.ENROLLED_NO_GRADE]: createFilterFunc('enrolledNoGrade'),
|
||||
// [FilterType.NOT_PARTICIPATED]: createFilterFunc('not_participated'),
|
||||
}
|
||||
|
||||
const filter = createFilter({
|
||||
|
||||
@@ -8,6 +8,7 @@ import createFilter from './createFilter'
|
||||
const STATUS_OPTIONS = [
|
||||
{ key: 'enrl-status-present', text: 'Present', value: 1 },
|
||||
{ key: 'enrl-status-absent', text: 'Absent', value: 2 },
|
||||
{ key: 'enrl-status-inactive', text: 'Passive', value: 3 },
|
||||
]
|
||||
|
||||
const EnrollmentStatusFilterCard = ({ options, onOptionsChange, allSemesters, language, semesterCodes }) => {
|
||||
|
||||
@@ -73,7 +73,11 @@ export default createFilter({
|
||||
filter: (student, { active }, { args }) => {
|
||||
const { studyrightStart, studyplans } = student
|
||||
const studyrightStartDate = new Date(studyrightStart)
|
||||
const hops = studyplans.find(plan => plan.programme_code === args.programmeCode)
|
||||
const studyrights = student.studyrights.filter(sr => !sr.cancelled)?.map(sr => sr.studyrightid)
|
||||
const hops = studyplans.find(
|
||||
plan => plan.programme_code === args.programmeCode && studyrights.includes(plan.studyrightid)
|
||||
)
|
||||
|
||||
if (active) {
|
||||
if (!hops) {
|
||||
student.courses = []
|
||||
|
||||
@@ -179,7 +179,7 @@ const StudentNumberFilterCard = ({ options, onOptionsChange, withoutSelf }) => {
|
||||
export default createFilter({
|
||||
key: 'studentNumber',
|
||||
|
||||
title: 'Student number *',
|
||||
title: 'Student Number',
|
||||
|
||||
defaultOptions: {
|
||||
allowlist: [],
|
||||
|
||||
@@ -49,7 +49,7 @@ const StudyrightStatusFilterCard = ({ options, onOptionsChange }) => {
|
||||
export default createFilter({
|
||||
key: 'studyrightStatusFilter',
|
||||
|
||||
title: 'Studyright status',
|
||||
title: 'Studyright Status',
|
||||
|
||||
info: filterInfo.studyrightStatus,
|
||||
|
||||
|
||||
@@ -7,32 +7,6 @@ import { selectViewFilters, setFilterOptions, resetViewFilters, resetFilter } fr
|
||||
import FilterViewContext from './FilterViewContext'
|
||||
import FilterTray from './FilterTray'
|
||||
|
||||
/* const getFilterContext = (filter, students, options, precomputed) => ({
|
||||
options: options[filter.key] ?? filter.defaultOptions,
|
||||
students,
|
||||
precomputed: precomputed[filter.key],
|
||||
})
|
||||
|
||||
const precompute = (students, filters, options) =>
|
||||
_.chain(filters)
|
||||
.filter(({ precompute }) => precompute)
|
||||
.map(({ key, precompute, defaultOptions }) => precompute({
|
||||
students,
|
||||
options: options[key] ?? defaultOptions,
|
||||
precomputed: null,
|
||||
}))
|
||||
.fromPairs()
|
||||
.value()
|
||||
|
||||
const applyFilters = (students, filters, options, precomputed) => {
|
||||
return filters
|
||||
.map((filter) => [filter, { students, options: options[filter.key], precomputed: precomputed[filter.key] }])
|
||||
.filter(([{ key, isActive }, ctx]) => isActive(options[key], ctx))
|
||||
.reduce((students, [{ key, filter }, ctx]) => {
|
||||
return students.filter(student => filter(student, options[key], precomputed[key]))
|
||||
}, students)
|
||||
} */
|
||||
|
||||
const resolveFilterOptions = (store, filters, initialOptions) => {
|
||||
return fp.flow(
|
||||
fp.map(({ key, defaultOptions }) => [
|
||||
|
||||
@@ -35,6 +35,7 @@ const allNavigationItems = {
|
||||
items: [
|
||||
{ path: '/custompopulation', key: 'customSearch', label: 'Search by Studentnumbers' },
|
||||
{ path: '/openunipopulation', key: 'openUniSearch', label: 'Fetch Open Uni Students by Courses' },
|
||||
{ path: '/courseprerequisites', key: 'prerequisitesSearch', label: 'Check completed prerequisities' },
|
||||
],
|
||||
},
|
||||
updater: { path: '/updater', key: 'updater', label: 'Updater', reqRights: ['admin'] },
|
||||
@@ -86,6 +87,7 @@ const NavigationBar = () => {
|
||||
if (checkUserAccess(['openUniSearch', 'admin'], roles) && item.key === 'openUniSearch') return true
|
||||
if ((checkUserAccess(['studyGuidanceGroups', 'admin'], roles) || rights.length > 0) && item.key === 'customSearch')
|
||||
return true
|
||||
if (checkUserAccess(['studyGuidanceGroups', 'admin'], roles) && item.key === 'prerequisitesSearch') return true
|
||||
return false
|
||||
}
|
||||
|
||||
|
||||
+6
-4
@@ -6,6 +6,7 @@ import { Link } from 'react-router-dom'
|
||||
import CourseFilterToggle from '../CourseFilterToggle'
|
||||
import { UsePopulationCourseContext } from '../PopulationCourseContext'
|
||||
import { getTextIn } from '../../../common'
|
||||
import './passFailEnrollments.css'
|
||||
|
||||
const createModuleAggregateRow = ({ definition, children }) => ({
|
||||
label_code: definition.module.code,
|
||||
@@ -93,7 +94,7 @@ const PassFailEnrollments = ({ flat, onlyIamRights }) => {
|
||||
children: [
|
||||
{
|
||||
key: 'total',
|
||||
title: 'Total students',
|
||||
title: 'Total\nstudents',
|
||||
helpText: 'Total count of students, including enrolled students with no grade.',
|
||||
cellStyle: { textAlign: 'right' },
|
||||
filterType: 'range',
|
||||
@@ -115,7 +116,7 @@ const PassFailEnrollments = ({ flat, onlyIamRights }) => {
|
||||
},
|
||||
{
|
||||
key: 'totalEnrolledNoGrade',
|
||||
title: 'Enrolled no grade',
|
||||
title: 'Enrolled, \nno grade',
|
||||
helpText: 'Students with a valid enrollment and no passing or failing grade.',
|
||||
cellStyle: { textAlign: 'right' },
|
||||
filterType: 'range',
|
||||
@@ -159,14 +160,14 @@ const PassFailEnrollments = ({ flat, onlyIamRights }) => {
|
||||
},
|
||||
{
|
||||
key: 'passed-after-retry',
|
||||
title: 'Passed after retry',
|
||||
title: 'Passed\nafter retry',
|
||||
cellStyle: { textAlign: 'right' },
|
||||
filterType: 'range',
|
||||
getRowVal: row => row.stats?.retryPassed ?? 0,
|
||||
},
|
||||
{
|
||||
key: 'failed-many',
|
||||
title: 'Failed multiple times',
|
||||
title: 'Failed\nmultiple times',
|
||||
cellStyle: { textAlign: 'right' },
|
||||
filterType: 'range',
|
||||
getRowVal: row => row.stats?.failedMany ?? 0,
|
||||
@@ -234,6 +235,7 @@ const PassFailEnrollments = ({ flat, onlyIamRights }) => {
|
||||
return (
|
||||
<>
|
||||
<SortableTable
|
||||
tableId="pass-and-fail-statistics-of-courses"
|
||||
title="Pass and fail statistics of courses with course enrollment details"
|
||||
data={data}
|
||||
columns={columns}
|
||||
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
table#pass-and-fail-statistics-of-courses tbody tr td:nth-child(n + 1) {
|
||||
z-index: -1;
|
||||
}
|
||||
|
||||
table#pass-and-fail-statistics-of-courses tbody tr:nth-child(2n) td:nth-child(2) {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
background: rgb(242 242 242) !important;
|
||||
overflow: hidden;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
table#pass-and-fail-statistics-of-courses tbody tr:nth-child(2n + 1) td:nth-child(2) {
|
||||
position: sticky;
|
||||
left: 0;
|
||||
background: white !important;
|
||||
overflow: hidden;
|
||||
z-index: 0;
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
import React, { useState } from 'react'
|
||||
import { string } from 'prop-types'
|
||||
import { func, object, string } from 'prop-types'
|
||||
import { Button, Icon, Modal } from 'semantic-ui-react'
|
||||
import DegreeCoursesTable from '../StudyProgramme/DegreeCourses'
|
||||
import sendEvent from '../../common/sendEvent'
|
||||
|
||||
const sendAnalytics = sendEvent.common
|
||||
|
||||
const FilterDegreeCoursesModal = ({ studyProgramme }) => {
|
||||
const FilterDegreeCoursesModal = ({ studyProgramme, criteria, setCriteria }) => {
|
||||
const [open, setOpen] = useState(false)
|
||||
|
||||
const setModalOpenState = state => {
|
||||
@@ -31,7 +31,7 @@ const FilterDegreeCoursesModal = ({ studyProgramme }) => {
|
||||
<Modal.Header>Hide degree courses</Modal.Header>
|
||||
<Modal.Content image>
|
||||
<Modal.Description>
|
||||
<DegreeCoursesTable studyProgramme={studyProgramme} />
|
||||
<DegreeCoursesTable studyProgramme={studyProgramme} criteria={criteria} setCriteria={setCriteria} />
|
||||
<Button onClick={() => setModalOpenState(false)} icon labelPosition="left">
|
||||
<Icon name="save" />
|
||||
Save & Close
|
||||
@@ -44,6 +44,8 @@ const FilterDegreeCoursesModal = ({ studyProgramme }) => {
|
||||
|
||||
FilterDegreeCoursesModal.propTypes = {
|
||||
studyProgramme: string.isRequired,
|
||||
criteria: object.isRequired,
|
||||
setCriteria: func.isRequired,
|
||||
}
|
||||
|
||||
export default FilterDegreeCoursesModal
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import React, { useState, useEffect } from 'react'
|
||||
import { useSelector, useDispatch } from 'react-redux'
|
||||
import { Segment, Button, Popup } from 'semantic-ui-react'
|
||||
import { useGetProgressCriteriaQuery } from 'redux/programmeProgressCriteria'
|
||||
import SegmentDimmer from '../SegmentDimmer'
|
||||
import PopulationCourseStats from '../PopulationCourseStats'
|
||||
import CustomPopulationCourses from '../CustomPopulation/CustomPopulationCourses'
|
||||
@@ -13,8 +14,13 @@ const PopulationCourses = ({ query = {}, filteredStudents, selectedStudentsByYea
|
||||
const [showByStudytrack, setShowByStudytrack] = useState(true)
|
||||
const populationCourses = useSelector(({ populationCourses }) => populationCourses)
|
||||
const mandatoryCourses = useSelector(({ populationMandatoryCourses }) => populationMandatoryCourses)
|
||||
const progressCriteria = useGetProgressCriteriaQuery({ programmeCode: query?.studyRights?.programme })
|
||||
const dispatch = useDispatch()
|
||||
|
||||
const emptyCriteria = {
|
||||
courses: { yearOne: [], yearTwo: [], yearThree: [], yearFour: [], yearFive: [], yearSix: [] },
|
||||
credits: { yearOne: 0, yearTwo: 0, yearThree: 0, yearFour: 0, yearFive: 0, yearSix: 0 },
|
||||
}
|
||||
const [criteria, setCriteria] = useState(progressCriteria?.data ? progressCriteria.data : emptyCriteria)
|
||||
const populationSelectedStudentCourses = useSelector(
|
||||
({ populationSelectedStudentCourses }) => populationSelectedStudentCourses
|
||||
)
|
||||
@@ -39,7 +45,11 @@ const PopulationCourses = ({ query = {}, filteredStudents, selectedStudentsByYea
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (progressCriteria.data) {
|
||||
setCriteria(progressCriteria.data)
|
||||
}
|
||||
}, [progressCriteria.data])
|
||||
useEffect(() => {
|
||||
if (
|
||||
!mandatoryCourses.pending &&
|
||||
@@ -85,7 +95,11 @@ const PopulationCourses = ({ query = {}, filteredStudents, selectedStudentsByYea
|
||||
<InfoBox content={infotooltips.PopulationStatistics.CoursesOfPopulation} />
|
||||
{renderToggleStructureButton()}
|
||||
{query.studyRights.programme && !onlyIamRights && (
|
||||
<FilterDegreeCoursesModal studyProgramme={query.studyRights.programme} />
|
||||
<FilterDegreeCoursesModal
|
||||
studyProgramme={query.studyRights.programme}
|
||||
criteria={criteria}
|
||||
setCriteria={setCriteria}
|
||||
/>
|
||||
)}
|
||||
|
||||
<SegmentDimmer isLoading={pending} />
|
||||
|
||||
+18
-1
@@ -1,9 +1,14 @@
|
||||
import moment from 'moment/moment'
|
||||
import React from 'react'
|
||||
import { Table } from 'semantic-ui-react'
|
||||
import studyPlanFilter from 'components/FilterView/filters/hops'
|
||||
import CollapsibleCreditRow from './CollapsibleCreditRow'
|
||||
import useFilters from '../../FilterView/useFilters'
|
||||
|
||||
const CreditsGainedTable = ({ filteredStudents, type, year, creditDateFilterOptions }) => {
|
||||
const { useFilterSelector } = useFilters()
|
||||
const studyPlanFilterIsActive = useFilterSelector(studyPlanFilter.selectors.isActive)
|
||||
|
||||
if (!filteredStudents || !filteredStudents.length || !type) return null
|
||||
let creditList = []
|
||||
const studentCount = (min, max = Infinity) =>
|
||||
@@ -79,6 +84,18 @@ const CreditsGainedTable = ({ filteredStudents, type, year, creditDateFilterOpti
|
||||
]
|
||||
|
||||
const monthString = months === 1 ? 'Month' : 'Months'
|
||||
|
||||
const CreditsHeader = () => {
|
||||
if (studyPlanFilterIsActive) {
|
||||
return <p>All credits in studyplan</p>
|
||||
}
|
||||
return (
|
||||
<p>
|
||||
Gredits Gained Between <br /> {title} <br /> ({months} {monthString})
|
||||
</p>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="credits-gained-table" data-cy={`credits-gained-table-${type}`}>
|
||||
<h3>{type}</h3>
|
||||
@@ -87,7 +104,7 @@ const CreditsGainedTable = ({ filteredStudents, type, year, creditDateFilterOpti
|
||||
<Table.Row key={`credits-gained-table-${type}`}>
|
||||
<Table.HeaderCell collapsing />
|
||||
<Table.HeaderCell key={`${title}-${type}`}>
|
||||
Gredits Gained Between <br /> {title} <br /> ({months} {monthString})
|
||||
<CreditsHeader />
|
||||
</Table.HeaderCell>
|
||||
<Table.HeaderCell key={`credits-number-of-students-${type}`}>
|
||||
Number of Students
|
||||
|
||||
@@ -4,9 +4,9 @@ import { Accordion } from 'semantic-ui-react'
|
||||
import useFilters from 'components/FilterView/useFilters'
|
||||
import studyPlanFilter from 'components/FilterView/filters/hops'
|
||||
import { creditDateFilter } from 'components/FilterView/filters'
|
||||
import { useGetProgressCriteriaQuery } from 'redux/programmeProgressCriteria'
|
||||
import { useLocalStorage } from '../../common/hooks'
|
||||
import { useGetAuthorizedUserQuery } from '../../redux/auth'
|
||||
|
||||
import CreditAccumulationGraphHighCharts from '../CreditAccumulationGraphHighCharts'
|
||||
import PopulationStudents from '../PopulationStudents'
|
||||
import PopulationCourses from '../PopulationCourses'
|
||||
@@ -37,6 +37,7 @@ const PopulationDetails = ({
|
||||
const studentTableRef = useRef()
|
||||
const { useFilterSelector } = useFilters()
|
||||
const creditDateFilterOptions = useFilterSelector(creditDateFilter.selectors.selectOptions)
|
||||
const criteria = useGetProgressCriteriaQuery({ programmeCode: query?.studyRights?.programme })
|
||||
|
||||
const handleClick = index => {
|
||||
const indexes = [...activeIndex].sort()
|
||||
@@ -190,6 +191,9 @@ const PopulationDetails = ({
|
||||
language={language}
|
||||
filteredStudents={filteredStudents}
|
||||
dataExport={dataExport}
|
||||
criteria={criteria?.data}
|
||||
programmeCode={query?.studyRights?.programme}
|
||||
year={query?.year}
|
||||
/>
|
||||
</div>
|
||||
),
|
||||
|
||||
@@ -435,7 +435,7 @@ const PopulationSearchForm = props => {
|
||||
</Grid.Row>
|
||||
</Grid>
|
||||
<Message error color="blue" header={errorText} />
|
||||
<Form.Button onClick={handleSubmit} disabled={isQueryInvalid || query.months < 0}>
|
||||
<Form.Button color="blue" onClick={handleSubmit} disabled={isQueryInvalid || query.months < 0}>
|
||||
See class
|
||||
</Form.Button>
|
||||
<SearchHistory items={searchHistory} updateItem={updateItemInSearchHistory} handleSearch={pushQueryToUrl} />
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user