Compare commits

...
628 Commits
Author SHA1 Message Date
Roni Lindholm 4c3f583712 Enrollment should not be required when fetching courses of population 2022-04-13 12:00:30 +03:00
Roni Lindholm d32608a0f2 Add new enrollments tab to courses of population
Include simple total students and enrolled no grade columns
2022-04-13 09:41:30 +03:00
Saara Satokangas c920729d57 Minor improvements 2022-04-12 18:37:16 +03:00
Saara Satokangas dae5c5181f Define correct provider code for doctoral programmes 2022-04-12 18:37:16 +03:00
Saara Satokangas 60ab9a849d Add new categories for credit progress for doctoral programmes 2022-04-12 18:37:16 +03:00
Saara Satokangas 8d6c8d71ef Don't show programmes before or after if they don't exist 2022-04-12 18:37:16 +03:00
Saara Satokangas 478722b1ad Change dates of the start date to match doctoral and spec. programmes 2022-04-12 18:37:16 +03:00
Saara Satokangas 2c1341fac7 Change color to blue for other than MH or KH programmes 2022-04-12 18:37:07 +03:00
Saara Satokangas 76ffc929b0 Improve studyright status infotext 2022-04-12 18:37:07 +03:00
Saara Satokangas 99dfb4ed63 Remove unnecessary year-mapping 2022-04-12 18:37:07 +03:00
Saara Satokangas 1d8db829cb Remove "NEW"-label from places that are not so new anymore 2022-04-12 18:37:07 +03:00
Saara Satokangas 5cb67f7f24 Hide credits-table if no data is found 2022-04-12 18:37:07 +03:00
Leo Varis d6d0824b6c add lääkis to credit calculation 2022-04-12 14:31:01 +03:00
Leo Varis 59b257fb90 fix async bug 2022-04-12 14:23:44 +03:00
Leo Varis d5e175f362 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-04-12 14:11:18 +03:00
Leo Varis c2a2331013 fix total credit calculation 2022-04-12 14:11:04 +03:00
Petri Palmu fe99727a6f student statistics show open courses in name correctly 2022-04-12 13:53:51 +03:00
Leo Varis 12c076740a hops student page changes (#3534) 2022-04-12 13:37:57 +03:00
Leo Varis a8b4aa3f1f fix updater hops issue when student has graduated (#3586) 2022-04-12 13:37:34 +03:00
Roni Lindholm f0549eb4ac No tests for updater 2022-04-08 13:25:29 +03:00
Roni Lindholm eebbb2d1db Try to fix updater tests 2022-04-08 12:27:03 +03:00
Petri Palmu 389a0b8512 changed showByYear as default in trends 2022-04-06 21:16:25 +03:00
Petri Palmu 7775ef6c54 fix to population when selevting many years 2022-04-06 21:16:25 +03:00
Saara Satokangas 2e984bdb89 Filter out students without studentnumber 2022-04-06 10:57:23 +03:00
Roni Lindholm ab28becd97 Fix on first attempt and eventually column values in course stats 2022-04-06 09:33:41 +03:00
Saara Satokangas 5a5039318c Betterments to the new studyright-status-filter 2022-04-06 08:17:29 +03:00
Saara Satokangas 433dd15020 Remove last mentions of cancelled 2022-04-05 18:22:41 +03:00
Saara Satokangas a971433273 Add studyright status -filter 2022-04-05 18:16:26 +03:00
Saara Satokangas 314642c1b5 don't skip students with no studentnumber here 2022-04-05 17:16:38 +03:00
SNurmivaara 44b4a43f16 Remove unused sentry init 2022-04-05 16:10:55 +03:00
SNurmivaara f483a564e8 Refactor and consolidate updater logging 2022-04-05 15:57:50 +03:00
SNurmivaara c112c27d59 Add sentry to updater worker 2022-04-05 13:42:56 +03:00
Saara Satokangas fec8346766 Remove canceldate from studyrights in updater 2022-04-05 10:56:03 +03:00
Saara Satokangas 9d152cac10 Remove canceldate from backend studyright-model 2022-04-05 10:31:15 +03:00
Saara Satokangas 63fea99dfd Adjust filters-tests to match the removal of canceldate 2022-04-05 10:30:21 +03:00
Saara Satokangas 46bbd79a88 Include also the cancelled studyrights in the populations tests
The canceldate was used in tests which made the total amount of
CS-students to be 149. Now that populations no longer uses canceldate
and no student gets filtered out based on it, the correct number is 170.
2022-04-05 09:54:34 +03:00
Saara Satokangas 1e65c70210 Remove mentions of canceldate 2022-04-05 09:54:28 +03:00
Saara Satokangas 031d33561c Stop updating canceldate for studyrights 2022-04-05 09:19:07 +03:00
Saara Satokangas 11eab49a0f Skip students with no studentnumber 2022-04-05 08:59:17 +03:00
SNurmivaara 9b2b4bc6d8 Fix updater version number for sentry releases 2022-04-04 17:52:38 +03:00
SNurmivaara 29f94bb94e Add sentry steps to updater workflow 2022-04-04 17:32:44 +03:00
SNurmivaara 0310292531 Add sentry to updater scheduler 2022-04-04 17:32:44 +03:00
Mitja Karhusaari 6c9ac8cd2d Fix ResizeObserver issue in older Firefox versions 2022-04-04 17:28:27 +03:00
Mitja Karhusaari 5afe92d85e Add Distribution Development tab to population credit statistics 2022-04-04 17:08:08 +03:00
Leo Varis e7e19b3f1b make all credits column show acually all credits 2022-03-31 11:30:20 +03:00
Petri Palmu 6df4f8f8da fix ti TKT1 population if many years is selected 2022-03-31 08:34:56 +03:00
Leo Varis b1d6648f7f enable hops stuff again 2022-03-30 15:01:51 +03:00
Leo Varis 80e0668a3c bypass tests 2022-03-30 14:21:35 +03:00
Saara Satokangas 9b9a585057 Include different combinations to studytrack redis-updates 2022-03-30 08:27:22 +03:00
Leo Varis c396f5437a temp fix 2022-03-29 21:35:05 +03:00
Saara Satokangas 5149bb3a62 Change "peruutettu" to "passiivinen" like in Sisu 2022-03-29 15:31:05 +03:00
Saara Satokangas acd4a34048 Fix trends not showing inactive students 2022-03-29 15:31:05 +03:00
Mitja Karhusaari fba8d92c5a Some fixes to course statistics table settings 2022-03-29 15:18:13 +03:00
Mitja Karhusaari a888d171a2 Better handle invalid parameters to RangeSelector 2022-03-29 15:13:07 +03:00
Mitja Karhusaari e4c56e11b7 Fix filter combination tests 2022-03-29 15:03:47 +03:00
Mitja Karhusaari c938d2440d Use RangeSelector for the Age and Credit filters 2022-03-29 13:55:12 +03:00
Mitja Karhusaari a4b32129f1 Separate range selector widget into its own component 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 7cb8d710d7 Better handle non-number input in range widget 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 038ffefa84 Add option for reseting single columns filters 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 2a8176ebe2 Use popper-based Popup for dropdowns so that they can flow outside of the overflow-hidden container 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 2be93ef839 Avoid some renders using use-context-selector 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 319a001c0e Remove dirty workaround 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 831b00ae75 Semester-related RTK Query fixes 2022-03-29 13:55:12 +03:00
Mitja Karhusaari be923fa80d Avoid recreation of contents when fullscreening a figure 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 596ebb66cb Allow mass-cycling filter values by pressing enter on the search field 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 118315385e Use better vertical titles in PopulationStudents courses table and other small improvements 2022-03-29 13:55:12 +03:00
Mitja Karhusaari 192b1eb54b Add curried getTextIn to useLanguage 2022-03-29 13:55:11 +03:00
Mitja Karhusaari ea9a8da78d Use cellProps instead of removed getCellProps 2022-03-29 13:55:11 +03:00
Mitja Karhusaari bcd44aa644 Use SortableTable help text functionalty for the CourseStatistics attempts table 2022-03-29 13:55:11 +03:00
Mitja Karhusaari 6381363722 Fix positioning of column help text and force floating column tool mode for columns having help text 2022-03-29 13:55:11 +03:00
Saara Satokangas b8d075be42 Fix tests 2022-03-29 11:21:16 +03:00
Saara Satokangas b109accac8 Adjust infobox-texts 2022-03-29 11:07:09 +03:00
Saara Satokangas 0a98526f18 Revert changes in populations.js for now
For some reason tests fail after removal of the "CANCELLED"-field,
even though the real data looks the same in local and production
environments.
2022-03-29 11:07:09 +03:00
Saara Satokangas 0f6cf38e73 Remove cancelled-field from overview tests and replace it with inactive 2022-03-29 11:07:09 +03:00
Saara Satokangas 2df92ec068 Remove inactive-field from studyprogramme basics 2022-03-29 11:07:09 +03:00
Saara Satokangas dae7bbb058 Include also expired studyrights to inactive ones 2022-03-29 11:07:09 +03:00
Saara Satokangas ab121b7ec6 Remove inactive-selection from populations 2022-03-29 11:07:09 +03:00
Saara Satokangas a2df1944c6 Remove inactive-selection from advanced filters 2022-03-29 11:07:09 +03:00
Saara Satokangas 62821e2f3b Switch places of median and mean 2022-03-29 11:06:04 +03:00
Saara Satokangas 14bd681260 Unify the way inactives are defined 2022-03-29 11:06:04 +03:00
Saara Satokangas fc123276ff Start using the new inactive-field for populations 2022-03-29 11:06:04 +03:00
Saara Satokangas ed96ae4f95 Start using the new inactive-field in studyprogramme-overview 2022-03-29 11:06:04 +03:00
Leo Varis c0f01fb224 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-03-28 16:08:26 +03:00
Leo Varis e50f631495 fix tests 2022-03-28 16:08:15 +03:00
Leo VarisandGitHub 2838099f0a Merge pull request #3549 from UniversityOfHelsinkiCS/studyplans
maybe fix tests
2022-03-28 15:12:43 +03:00
Leo Varis 9452ce08bd maybe fix tests 2022-03-28 15:05:47 +03:00
Leo VarisandGitHub 075385c962 Merge pull request #3547 from UniversityOfHelsinkiCS/studyplans
Studyplans
2022-03-28 14:03:07 +03:00
Saara Satokangas 87e6199093 Flatmap termregistrations 2022-03-28 13:38:53 +03:00
Leo Varis d47d0c22dd change title 2022-03-28 10:24:55 +03:00
Leo Varis 240edec696 revert dev value 2022-03-28 09:59:20 +03:00
Leo Varis 6dcdaae83e fix 2022-03-28 09:57:52 +03:00
Leo Varis 608670d65d add hops to study programme view (#3533) 2022-03-28 09:57:00 +03:00
Leo Varis 50ed56471c mangle hops to sis-db 2022-03-28 09:55:49 +03:00
Leo Varis 1d54d41861 add hops to study programme view (#3533) 2022-03-28 09:54:25 +03:00
Petri Palmu 0904703a57 changed laoding to loading and hope tests works 2022-03-25 18:28:26 +02:00
Roni Lindholm 8a4063486b Fix parsing of failed grades in totals 2022-03-25 12:59:32 +02:00
Matti Luukkainen 86cebeb628 presnet -> present 2022-03-25 12:04:19 +02:00
Matti Luukkainen 6770850822 rapodiff uncomment 2022-03-24 18:51:38 +02:00
Matti Luukkainen 133edbad89 eslint igonre 2022-03-24 17:12:45 +02:00
Petri Palmu e8556d0741 fix to the maxYearsToCreatePopulationFrom 2022-03-24 16:41:22 +02:00
Saara Satokangas b654a247ae Replace "ABSENT" with "NONATTENDING" 2022-03-24 14:15:20 +02:00
Roni Lindholm bba5c7e946 Fix grades on course stats attempts tab
Display all given grades for course.
2022-03-24 11:59:46 +02:00
Mitja Karhusaari 0cbd1f2e16 Work on making the tests happy 2022-03-24 01:41:02 +02:00
Mitja Karhusaari 7f79a95385 Use better slider library 2022-03-23 23:47:23 +02:00
Mitja Karhusaari d6901a40b3 Add hover effect to DateTimeSelector semester buttons 2022-03-23 22:27:32 +02:00
Mitja Karhusaari 46d786f9e5 Use RTK-Query for fetching semesters 2022-03-23 22:18:38 +02:00
Mitja Karhusaari e059ee3f93 Move column header info tooltip functionality to SortableTable so that it does not get overlaid by the column header tool icons 2022-03-23 20:50:44 +02:00
Mitja Karhusaari 4b164b1f2a Fix z-index on fullscreen figures 2022-03-23 19:34:28 +02:00
Mitja Karhusaari c44de1e2b5 Go through tables and tweak column settings 2022-03-23 19:34:23 +02:00
Mitja Karhusaari a3d65ab87b Fix Orientable not responding to prop change 2022-03-23 19:23:53 +02:00
Mitja Karhusaari 79eec49a51 Fix handling of non-number values in range filter 2022-03-23 19:23:52 +02:00
Mitja Karhusaari b15a7a2102 Fix dropdown disappearing on blur due to css cascade 2022-03-23 19:23:52 +02:00
Mitja Karhusaari 99abeae5ad Prevent oscillation between the column header tool states fixed and floating 2022-03-23 19:23:52 +02:00
Mitja Karhusaari 3b65e39e35 Add debouncing to the range slider 2022-03-23 19:23:52 +02:00
Mitja Karhusaari 1af0bd77e9 Fix rendering of the Slider component in Dropdowns 2022-03-23 19:23:52 +02:00
Mitja Karhusaari f51bdfe23c Fix SortableTable value extraction 2022-03-23 19:23:52 +02:00
Mitja Karhusaari 2d50786093 Fix column header tooling alignment 2022-03-23 19:23:52 +02:00
Mitja Karhusaari e8f899a96e Add debouncing to the range filter component 2022-03-23 19:23:52 +02:00
Mitja Karhusaari dd0f8f966d Implement vertical titles & smart positioning of filter and sort icons in SortableTable 2022-03-23 19:23:52 +02:00
Mitja Karhusaari 2d684d1f70 Implement range sider filter for SortableTable 2022-03-23 19:23:52 +02:00
Mitja Karhusaari ec2bbfb497 Use date-filter type for appropriate columns 2022-03-23 19:23:52 +02:00
Mitja Karhusaari a07365c1a6 Split visitors into separate files and implement date-filter type for SortableTable columns 2022-03-23 19:23:52 +02:00
Mitja Karhusaari 5e3605930d Add quick select for semester start and end dates to the datetime picker 2022-03-23 19:23:52 +02:00
Petri Palmu 5ce24443f2 one fix test 2022-03-23 11:30:10 +02:00
Petri Palmu 9e825f9915 more fix to the tests 2022-03-23 10:34:14 +02:00
Petri Palmu 69c7f02dca little correction to the tests 2022-03-23 09:56:38 +02:00
Petri Palmu bf2c3638d3 selection between open and uni courses works if you drill into spesific year 2022-03-23 09:15:05 +02:00
Saara Satokangas d4ccc7a4dc Fix tests
By skipping some acually broken for now
2022-03-22 20:21:31 +02:00
Saara Satokangas 2bcafbabfd Try fixing filtering of students 2022-03-22 20:10:18 +02:00
Saara Satokangas bc5d44f18f Fix studytrack-filter showing relevant studytracks 2022-03-22 18:50:43 +02:00
Saara Satokangas 51b9e23693 Get correct populationlink also for unfolded studytrack 2022-03-22 18:49:39 +02:00
Saara Satokangas 75f0dca9f1 Add notification about all credits, not just studyprogramme credits 2022-03-22 18:49:39 +02:00
Saara Satokangas b802f92420 Change title of a test set 2022-03-22 18:49:39 +02:00
Matti Luukkainen bf54330c12 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-03-22 17:40:41 +02:00
Matti Luukkainen aba30641b2 rapodiff for bsc 2022-03-22 17:36:07 +02:00
Saara Satokangas 5dc06a8f95 Fix tests
Include also the total-line
2022-03-22 14:10:03 +02:00
Saara Satokangas 8dad3ef620 Remove unnecessary useState 2022-03-22 13:55:51 +02:00
Saara Satokangas e23774023d Fix total-row population-link
Closes #https://github.com/UniversityOfHelsinkiCS/oodikone/issues/3517
2022-03-22 13:45:54 +02:00
Saara Satokangas abd31bc807 Use the filtered studytracklist also in case where no result
If the population is searched for a studytrack, and there are no
students who has that studytrack as their latest, still use that empty
list. Instead of showing the unfiltered list like before.
2022-03-22 13:45:54 +02:00
Saara Satokangas 120a6fbc5b Take the latest studytrack based on the startdate in the track
Not the enddate of the studyright
2022-03-22 13:45:54 +02:00
Saara Satokangas a6bc58b0fc Include total-row to the current tables and graphs, remove toggle 2022-03-22 13:45:54 +02:00
Roni Lindholm 4baf6d8509 Display enrollments in course stats based on yearcode instead of hack 2022-03-21 15:40:54 +02:00
Roni Lindholm f263913c03 Refine enrollments in course stats
Calculate  stats for normal view and enrollments view.
2022-03-21 15:17:24 +02:00
Saara Satokangas e9f6eb744f Adjust tests to match the new credit progress categories 2022-03-21 09:39:30 +02:00
Saara Satokangas cd6ef17a10 Add categories >= 300 and >= 180 to credit progress charts 2022-03-21 09:18:50 +02:00
Saara Satokangas f6272a0df0 Add active-field to backend studyright-model 2022-03-21 09:01:46 +02:00
Leo Varis 9b385afb36 mangle hops to sis-db 2022-03-17 17:02:12 +02:00
Matti Luukkainen b7a2d67bcb rapo diff script betterments 2022-03-15 17:41:45 +02:00
Matti Luukkainen 2f20cd7914 disable population fix due to issues in tests 2022-03-14 19:35:58 +02:00
Matti Luukkainen 55565e1721 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-03-14 19:08:14 +02:00
Matti Luukkainen e26c35ccd6 rapodiff tweak, #3519 and temporary fix to #3398 2022-03-14 19:07:48 +02:00
Roni Lindholm 034410e534 Include only relevant enrollments to stats
Remove also unused programme and faculty enrollment stats.
2022-03-11 12:15:50 +02:00
Roni Lindholm c0ee2477be Fix course stats crash when no enrollments 2022-03-10 10:08:08 +02:00
Roni Lindholm e7b0beb2cf Try to fix course stats tests
Remove duplicate click on attemps view mode
2022-03-10 09:39:14 +02:00
Roni Lindholm 4f8dcc03c2 Add enrollments to course stats 2022-03-10 08:44:50 +02:00
Saara Satokangas ff7bedccc1 Remove the graduation-condition from activityParser
If the studyright has ended due to graduation or any other reason,
it should not be confused with inactive studyrights (thus the ones
where the student has not registered for the term or has cancelled
their studyright)
2022-03-09 15:41:24 +02:00
SNurmivaara 3b153df6ef Fix package.lock for updater 2022-03-09 15:32:22 +02:00
SNurmivaara 93b0e283fa Lock updater knex version to a known working version. 0.20.11 onwards requires changes to codebase, created ticket 2022-03-09 15:26:19 +02:00
SNurmivaara f52fddf85c Semver safe non-breaking updates for dependencies of services 2022-03-09 14:49:44 +02:00
Saara Satokangas f0fca7f7ab Add active-status to studyrigths in updater 2022-03-09 14:07:34 +02:00
Saara Satokangas 44058ce537 Remove some unused parameters 2022-03-09 14:07:23 +02:00
SNurmivaara 48356cbb8a Fix dependabot to acually do things and label PRs with correct service 2022-03-09 13:50:40 +02:00
SNurmivaara 50b579ede2 Removed outdated target branch 'trunk' from dependabot config 2022-03-09 07:52:00 +02:00
Petri Palmu 16df458433 added attainment date population of course 2022-03-08 13:51:38 +02:00
Petri Palmu 2c84a0f73d test for unify toggle 2022-03-08 10:35:51 +02:00
Petri Palmu 0152d0c549 unify open courses radio buttons disabled if no data 2022-03-08 10:35:51 +02:00
Petri Palmu fe03fa89c6 make course stats comparizon view horizontal again 2022-03-08 10:35:51 +02:00
Mitja Karhusaari 891cabfbd7 Move name columns to the left-most edge of the student search results table 2022-03-08 09:45:43 +02:00
Mitja Karhusaari b7d2b7f804 Display pointer cursor when hovering sortable column header 2022-03-08 09:45:42 +02:00
Mitja Karhusaari b7740c3b9b Unoverkillify the student search results table
Resolves #3461
2022-03-08 09:45:42 +02:00
Mitja Karhusaari 620c6859ae Limit width of the course name column in Courses of Population tables
Resolves #3459
2022-03-08 09:45:42 +02:00
Saara SatokangasandGitHub 5e30c279ed Merge pull request #3389 from UniversityOfHelsinkiCS/dependabot/npm_and_yarn/services/frontend/nanoid-3.2.0
Bump nanoid from 3.1.23 to 3.2.0 in /services/frontend
2022-03-07 16:39:26 +02:00
Saara Satokangas 637f23a96f Remove ThesisCourses-table
closes #3334
2022-03-07 15:57:01 +02:00
Saara Satokangas 9b8db2096d Remove thesisCourse-reducer and backend-logic
These are redundant after the new studyprogramme overview
2022-03-07 15:43:45 +02:00
Saara Satokangas 6d174d0275 Adjust the updates to match the new options 2022-03-07 12:51:01 +02:00
Saara Satokangas 2e882ff8a0 Clean up the options for studyprogramme overviews 2022-03-07 11:03:19 +02:00
Saara Satokangas f8a6f89199 Clean up the way years are defined for studyprogramme stats 2022-03-07 10:36:33 +02:00
Saara Satokangas b272f9e94a Clean up the toggle container 2022-03-07 09:21:05 +02:00
Saara Satokangas 4cc73d5fd8 Clean up settings for studytrack-overview 2022-03-07 09:12:31 +02:00
Saara Satokangas c19810fca8 Add "years combined"-selection to front and redis 2022-03-07 08:35:22 +02:00
Saara Satokangas 298c9e9b4b Add possibility to choose all students in the studytrack-view 2022-03-07 08:11:43 +02:00
Mitja Karhusaari 58ed0ac417 Fix course filter toggle button in Courses of Population
Resolves #3458
2022-03-06 19:12:31 +02:00
Mitja Karhusaari cb40fd970c Fix reseting table filters 2022-03-04 10:55:00 +02:00
Mitja Karhusaari cdc7331667 Fix rest of the tests 2022-03-04 10:17:45 +02:00
Mitja Karhusaari 2ffc222bcf Fix at at least some of the tests 2022-03-04 09:46:50 +02:00
Mitja Karhusaari 2fcb5fd91d Remove dead files 2022-03-03 08:43:19 +02:00
Mitja Karhusaari f4be37a3b8 Use "fully qualified" column name in exports to avoid name conflicts 2022-03-03 08:41:43 +02:00
Mitja Karhusaari 67d7b05cc6 Remove use of collapsing-property in SortableTable cells 2022-03-03 08:36:06 +02:00
Mitja Karhusaari 88ad8db7bb UI fix 2022-03-03 08:32:50 +02:00
Mitja Karhusaari dda612f284 Handle property not being present 2022-03-03 08:30:49 +02:00
Mitja Karhusaari 6a9cf26f4b Use the new SortableTable in the flat versions of PopulationCourseStats tables 2022-03-03 08:29:26 +02:00
Mitja Karhusaari 2d7b679b04 Add options to fold/unfold all groups 2022-03-03 08:28:18 +02:00
Mitja Karhusaari 5aa4c5d146 Misc. UI/UX improvements to SortableTable 2022-03-03 07:09:18 +02:00
Mitja Karhusaari ff9aaa1119 Add course filter toggles and links to all Population Courses tables 2022-03-03 07:09:18 +02:00
Mitja Karhusaari f443f3b7db Add exclude/include all buttons to export modal 2022-03-03 07:09:18 +02:00
Mitja Karhusaari a6a47e5ec8 Add Excel export to SortableTable 2022-03-03 07:09:18 +02:00
Mitja Karhusaari b414fd3501 Go through and tweak components using SortableTable 2022-03-03 07:09:18 +02:00
Mitja Karhusaari 88ce7bd2a5 Implement Courses of Population tables using SortableTable 2022-03-03 07:09:18 +02:00
Mitja Karhusaari eb35ea503d Polish the row grouping functionality 2022-03-03 07:09:18 +02:00
Mitja Karhusaari 20de79a26f Implement row grouping in sortable table 2022-03-03 07:09:18 +02:00
Mitja Karhusaari dab21ab390 Revamp sortable table 2022-03-03 07:09:18 +02:00
Leo Varis 6069dbc328 fix broken grade distribution (#3456) 2022-03-02 13:40:02 +02:00
Saara SatokangasandGitHub 7cb8041ca0 Update Pate-url 2022-03-02 09:13:14 +02:00
Roni Lindholm 729192cddc Fix enrollment updater when missing education 2022-03-01 15:14:27 +02:00
SNurmivaara 4b3b10d033 Teacher leaderboard tests go to the shadow realm 2022-03-01 14:48:50 +02:00
SNurmivaara 9c6812d7cf Return the magic wait and reload to teacher leaderboard test 2022-03-01 13:56:08 +02:00
SNurmivaara 58ce626d97 Acually fix teacher leadearboard tests 2022-03-01 13:44:58 +02:00
SNurmivaara 0834b33778 Fix teacher leaderboard tests 2022-03-01 12:54:13 +02:00
SNurmivaara cbce1d7dbd Remove statistics update button from teacher leaderboards
The button is obsolete, the update is run daily as a cronjob
2022-03-01 12:34:27 +02:00
SNurmivaara b8e214f8cd Filter faculties out of top teachers leaderboard 2022-03-01 12:00:37 +02:00
SNurmivaara 69d920015c Added required props to teacherStatisticsTable in teacher leaderboards 2022-03-01 12:00:37 +02:00
Roni Lindholm cf64249d4f Add enrollments to updater 2022-02-28 17:13:33 +02:00
Leo VarisandGitHub f372e4f362 Change required version 2022-02-28 13:57:37 +02:00
Saara SatokangasandGitHub dd619d375d Merge pull request #3421 from UniversityOfHelsinkiCS/dependabot/npm_and_yarn/updater/sis-updater-scheduler/follow-redirects-1.14.8
Bump follow-redirects from 1.14.3 to 1.14.8 in /updater/sis-updater-scheduler
2022-02-28 12:31:15 +02:00
Saara SatokangasandGitHub 0888eaf547 Merge pull request #3445 from UniversityOfHelsinkiCS/dependabot/npm_and_yarn/services/frontend/url-parse-1.5.10
Bump url-parse from 1.5.3 to 1.5.10 in /services/frontend
2022-02-28 12:15:19 +02:00
Saara Satokangas 14275a3e6f Fix faculty statistics 2022-02-28 11:54:13 +02:00
Saara Satokangas 956b9302d2 Rename newStudyprogramme.js to studyprogramme.js 2022-02-28 11:12:00 +02:00
dependabot[bot]andGitHub 51f462ce7b Bump url-parse from 1.5.3 to 1.5.10 in /services/frontend
Bumps [url-parse](https://github.com/unshiftio/url-parse) from 1.5.3 to 1.5.10.
- [Release notes](https://github.com/unshiftio/url-parse/releases)
- [Commits](https://github.com/unshiftio/url-parse/compare/1.5.3...1.5.10)

---
updated-dependencies:
- dependency-name: url-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-27 20:54:50 +00:00
Saara Satokangas a38bd1a3b0 Enable custom populations for studyguidance-group users too 2022-02-24 16:01:50 +02:00
Saara Satokangas 316f3511c2 Fix to toolTip-texts 2022-02-24 15:00:03 +02:00
Saara Satokangas e36c7aa6ba Fix semesters showing invalid dates 2022-02-24 14:35:14 +02:00
Saara Satokangas ffda9af909 Use common component also for percentage-toggle 2022-02-24 14:33:49 +02:00
Saara Satokangas 7b56978e7c Improve the appearance of toggles and move them into one file 2022-02-24 14:29:37 +02:00
Saara Satokangas b95d439836 Fix coursepopulation bugging with academic terms 2022-02-24 13:15:58 +02:00
SNurmivaara 1f7573a0ba Added oodikone architecture picture to README. Closes issue #3110 2022-02-24 08:55:12 +02:00
Petri Palmu 0204b4890f little fix to course stats tests 2022-02-23 14:20:54 +02:00
Petri Palmu 5a19e48ff9 Moved provider organization in own line because not resoponsive 2022-02-22 10:19:53 +02:00
Petri Palmu 790386a394 more course statistics course provider organization test 2022-02-22 10:19:53 +02:00
Petri Palmu e86045e8e6 few more chenges to course stats tests 2022-02-22 10:19:53 +02:00
Petri Palmu b1fb0a7cc7 fix to the Population of course header 2022-02-22 10:19:53 +02:00
Petri Palmu 0086ae69d3 removed or changed few proptypes 2022-02-22 10:19:53 +02:00
Petri Palmu 10d9731fab removed unifyOpenCourses from redux and refactored SearchForm to use redux hooks 2022-02-22 10:19:53 +02:00
Petri Palmu 83ffd5389e fixed course statistics test and cleaned console logs from the code 2022-02-22 10:19:53 +02:00
Petri Palmu fcb4328dba different course stats datas seems to work 2022-02-22 10:19:53 +02:00
Petri Palmu f196a0939d change open/unify radio renders correct data 2022-02-22 10:19:53 +02:00
Petri Palmu 52a480d6fb unify radio value is in redux state 2022-02-22 10:19:53 +02:00
Petri Palmu 0618a17830 unify radio added to the course stats 2022-02-22 10:19:53 +02:00
Saara Satokangas d54b3c0782 Fix one test 2022-02-22 08:53:16 +02:00
Saara Satokangas 28fa4e5310 Increase the viewport-size for cypress tests to see what's wrong 2022-02-22 08:37:00 +02:00
Saara Satokangas df402c4823 Try fixing some of the tests 2022-02-22 08:20:03 +02:00
Saara Satokangas 9136d41bdd Adjust tooltips to match the new table 2022-02-21 14:39:21 +02:00
Saara Satokangas e1f63c2441 Filter our transfers also from master's 2022-02-21 14:34:15 +02:00
Saara Satokangas d797b766b1 Refactor and clean-up 2022-02-21 14:30:41 +02:00
Saara Satokangas 03bed43077 Unify following masters programme -table with the bachelor one 2022-02-21 13:53:22 +02:00
Saara Satokangas 6763905b2a Adjust texts in frontend and variable names to match the new table 2022-02-21 13:23:40 +02:00
Saara Satokangas 994101732d Define studystartdate in the programme similarly as in populations 2022-02-21 13:04:19 +02:00
Saara Satokangas b1c071a507 Add table for bachelor's programmes before the chosen masters 2022-02-21 13:03:55 +02:00
Mitja Karhusaari 0e2bdc8d2d Potential fix for problems with Courses of Population -components 2022-02-16 13:26:42 +02:00
dependabot[bot]andGitHub be0f14326a Bump follow-redirects in /updater/sis-updater-scheduler
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.3 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.3...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-16 07:49:06 +00:00
Saara SatokangasandGitHub 1cd6e2f435 Merge pull request #3425 from UniversityOfHelsinkiCS/dependabot/npm_and_yarn/services/backend/follow-redirects-1.14.8
Bump follow-redirects from 1.14.3 to 1.14.8 in /services/backend
2022-02-16 09:48:12 +02:00
Saara Satokangas 0790003ae8 Fix trends-updating erroring at night 2022-02-16 08:25:30 +02:00
Saara Satokangas a77bf8b6a9 Remove old logic studyprogramme-service 2022-02-15 15:50:58 +02:00
dependabot[bot]andGitHub 00cd57dc13 Bump follow-redirects from 1.14.3 to 1.14.8 in /services/backend
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.3 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.3...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-15 12:35:10 +00:00
Saara SatokangasandGitHub 44a8f39cc1 Merge pull request #3426 from UniversityOfHelsinkiCS/dependabot/npm_and_yarn/services/frontend/follow-redirects-1.14.8
Bump follow-redirects from 1.14.1 to 1.14.8 in /services/frontend
2022-02-15 14:34:17 +02:00
Saara Satokangas 4ecdb3237d Clarify the test-structure 2022-02-15 13:37:37 +02:00
Saara Satokangas 6b544179ef Add more tests for studytrack-overview 2022-02-15 13:16:26 +02:00
Saara Satokangas 9e29afedad Fix tests 2022-02-15 11:53:34 +02:00
Saara Satokangas 8610bf1084 Add tests for new studyprogramme overview 2022-02-15 11:35:01 +02:00
Saara Satokangas fe49a63408 Remove old reducer-for previous bachelor programmes 2022-02-15 08:19:28 +02:00
dependabot[bot]andGitHub a9100b78ec Bump follow-redirects from 1.14.1 to 1.14.8 in /services/frontend
Bumps [follow-redirects](https://github.com/follow-redirects/follow-redirects) from 1.14.1 to 1.14.8.
- [Release notes](https://github.com/follow-redirects/follow-redirects/releases)
- [Commits](https://github.com/follow-redirects/follow-redirects/compare/v1.14.1...v1.14.8)

---
updated-dependencies:
- dependency-name: follow-redirects
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-02-14 20:34:45 +00:00
Saara Satokangas e3fb31ef8f Remove old productivity and progress functions from redis 2022-02-14 14:48:04 +02:00
Saara Satokangas f865796771 Remove old routes for getting option-data 2022-02-14 08:58:28 +02:00
Saara Satokangas 2532b5367e Remove routes for updating and getting old studyprogramme view's data 2022-02-14 08:58:28 +02:00
Saara Satokangas eeca5c52fc Remove old studyprogramme-reducers 2022-02-14 08:58:28 +02:00
Saara Satokangas 1e940fde73 Remove old infotooltips 2022-02-14 08:58:28 +02:00
Saara Satokangas 38a2f0a9a8 Remove propTypes from studyprogramme-overview, start using useSelector 2022-02-14 08:58:20 +02:00
Saara Satokangas 991203e08e Remove old studytrackoverview, rename new views 2022-02-14 08:13:49 +02:00
Saara Satokangas 0c8698ab04 Remove old overview 2022-02-14 08:10:46 +02:00
Saara Satokangas 57e04434b0 Remove old throughput-table and producitivity-tables 2022-02-14 08:09:52 +02:00
Saara Satokangas f1fcf9661d Remove old thesis-courses-list 2022-02-14 08:09:23 +02:00
Saara Satokangas 61ab3d9849 Add some comments 2022-02-14 08:09:09 +02:00
Saara Satokangas 52db993e1f Remove old bachelor's table 2022-02-14 08:08:28 +02:00
Saara Satokangas 66d4989fee Remove mentions of old views 2022-02-14 08:07:41 +02:00
Saara Satokangas 0439efddbe Make toggle-choices permanent between tabs 2022-02-14 07:35:46 +02:00
Saara Satokangas 453511fe5d Fix test 2022-02-06 11:02:48 +02:00
Saara Satokangas bcaa0086e5 Remove column "All" from studyprogramme-overview for now
It can be a bit misleading
2022-02-06 10:47:47 +02:00
Saara Satokangas 80a7072f73 Add some more tests 2022-02-06 10:07:08 +02:00
Saara Satokangas 33475304e9 More minor tweaks 2022-02-06 10:00:17 +02:00
Saara Satokangas 8bc5c0c3b0 Add few tests for the new studyprogramme overview 2022-02-06 09:42:02 +02:00
Saara Satokangas b852562bd2 Add basic tests for the sections of each new view 2022-02-06 09:05:59 +02:00
Saara Satokangas 6de3dc0bdb Stop updating old studyprogramme views and remove the tabs from the front
If something goes wrong, this commit could be reverted to restore the
old studyprogramme views
2022-02-06 08:48:46 +02:00
Saara Satokangas ef41c4e270 Minor tweaks 2022-02-06 08:22:43 +02:00
Saara Satokangas bd22b25cca Clarifications to the graduation time infobox 2022-02-04 13:32:55 +02:00
Saara Satokangas 0e7757ee3f Add "all"-column to studyprogramme overview basic-table 2022-02-04 13:28:46 +02:00
Saara Satokangas 89a8837e16 Add total student amount to the graduation times in programme overview 2022-02-04 12:49:59 +02:00
Saara Satokangas 1dc305601f Add total amount to the graduation gauges in studytrack overview 2022-02-04 12:49:59 +02:00
Saara Satokangas e4adda1cb3 Fix some places missing correct undefined-check 2022-02-04 12:49:59 +02:00
Saara Satokangas 9dfef1baff Move datatable titles to common place 2022-02-04 12:49:59 +02:00
Saara Satokangas 3599f3f96b Rename class "major students" 2022-02-04 12:49:59 +02:00
Saara Satokangas 1114732ac3 Infotext betterments 2022-02-04 12:49:59 +02:00
Mitja Karhusaari e2ed53a351 Fix (some?) of the tests 2022-02-03 20:16:12 +02:00
Saara Satokangas a9c354065c Clean up, refactor, comment 2022-02-03 18:23:51 +02:00
Saara Satokangas 187ed14d30 Clean up and refactor 2022-02-03 18:23:51 +02:00
Saara Satokangas 191646bb99 Include graduation to redis updates
This should be done better later. Now for some reason didn't work in the
same functionalized fashion as with basic view updating.
2022-02-03 18:23:51 +02:00
Mitja Karhusaari d2e67be9c0 Refactor course statistics results and simplify the default view 2022-02-03 17:13:50 +02:00
Saara Satokangas 2ec2cebf3b Add graduated-toggle to studytrack-overview 2022-02-03 15:29:42 +02:00
Saara Satokangas 69a8347a5a Hide empty non-major students -column when looking at majors 2022-02-03 15:29:42 +02:00
Saara Satokangas 66b63decb7 Adjust credit thresholds better to match also master's programmes 2022-02-03 15:29:42 +02:00
Petri Palmu 4943f169f5 little improvment to ooditooodikone 2022-02-03 08:08:41 +02:00
Petri Palmu 899421c88e empty box after oodikone navbar removed 2022-02-03 08:08:41 +02:00
Saara Satokangas a59ed4ce18 Add programme code to studytrack names 2022-02-02 17:34:27 +02:00
Saara Satokangas 8e85bf898f Fix population link's year for single tracks 2022-02-02 17:02:43 +02:00
Saara Satokangas 2bd4cbeda4 Find cancelled studyrights a bit differently 2022-02-02 16:32:31 +02:00
Saara Satokangas 4d4425147a Add some comments 2022-02-02 15:28:23 +02:00
Saara Satokangas b174cb852c Match the graduation stats to the ones of population overview 2022-02-02 14:11:17 +02:00
Saara Satokangas 2bdcaf7dff Change the logic of absents and enrolled to match that of populations 2022-02-02 13:45:59 +02:00
Saara Satokangas f27a755240 Add possibility to hide percentages from the studytrack-view 2022-02-02 13:45:59 +02:00
Saara Satokangas f1e8654f99 Switch special group toggle labels places 2022-02-02 13:45:51 +02:00
Saara Satokangas 00a3bfbdac Remove tooltip from graduation charts 2022-02-02 08:59:32 +02:00
Saara Satokangas 55419747d0 Improve programmes after -section's appearance 2022-02-02 08:40:20 +02:00
Saara Satokangas dfcf0788bd Add error message to studytrack overview if all data retrieval fails 2022-02-02 08:17:30 +02:00
Saara Satokangas b9935a2000 Add error message to studyprogramme overview if all data fails 2022-02-02 08:15:11 +02:00
Saara Satokangas a17af20323 Increase sequelize acquire-timeout threshold closer to the default 2022-02-02 07:49:06 +02:00
Saara Satokangas c5fbc93a9d Add logic for excluding credits by special groups in the backend 2022-02-01 17:03:31 +02:00
Saara Satokangas 2e1bb6b179 Update names for the new tabs 2022-02-01 13:42:47 +02:00
Saara Satokangas 7819d67d52 Divide studyprogramme code into smaller, comprehensible chunks 2022-02-01 13:40:40 +02:00
Saara Satokangas 0b01e67c5e Show programmesAfter only when looking at a Bachelor programme 2022-02-01 12:52:48 +02:00
Saara Satokangas 26e2060ad9 Add graph for programmes after graduation 2022-02-01 12:52:48 +02:00
Saara Satokangas 3751bfae3e Add initial table showing the programmes after the programme 2022-02-01 12:52:48 +02:00
Saara Satokangas e6d173674c Simplify how graduation time charts are shown 2022-02-01 12:52:48 +02:00
Saara Satokangas 19f7ba45ba Fix sequelize timeoutting on nightly update 2022-02-01 12:52:39 +02:00
Saara Satokangas 0b69e7999c Add graduation mean and median time charts to studytracks as well 2022-01-31 17:03:07 +02:00
Saara Satokangas da678ed29b Enable showing only major students in the basics-table and graph 2022-01-31 15:04:11 +02:00
Saara Satokangas 5250742acd Calculate graduation and thesis stats to majors on non-majors 2022-01-31 13:45:42 +02:00
Saara Satokangas 2b2a8e7e59 Center the mean- and median-charts 2022-01-31 12:25:31 +02:00
Saara Satokangas ff3f170695 Clean up 2022-01-31 12:21:16 +02:00
Saara Satokangas 077a9b4807 Move the new studyprogramme-tabs to be the first ones 2022-01-31 08:34:10 +02:00
Saara Satokangas 90c60ffc27 Add special groups to basic stats updating 2022-01-30 11:48:33 +02:00
Saara Satokangas 38d9361d47 Add special groups to studytrack stats updating 2022-01-30 11:33:40 +02:00
Saara Satokangas 7961abc56c Define special groups similarly as the year type 2022-01-30 11:32:55 +02:00
Saara Satokangas 4c8df9f0c3 Remove unused function 2022-01-30 10:34:38 +02:00
Saara Satokangas c35ab6dd5e Betterments to studyprogramme view when incomplete data 2022-01-30 10:32:04 +02:00
Saara Satokangas e52a43856e Improve loaders on the new views 2022-01-30 10:02:08 +02:00
Saara Satokangas 1a5395e9d7 Sort track data by year 2022-01-30 09:53:06 +02:00
Saara Satokangas ff1322611e Improvements to studyprogramme overview layout 2022-01-30 09:12:50 +02:00
Saara Satokangas 0bbdc9d6c0 Fix tables overlapping other sections in studyprogramme overview 2022-01-29 10:58:12 +02:00
Saara Satokangas cb732b60aa Change data starting date for doctoral programmes to be also 2017 2022-01-29 10:57:33 +02:00
Saara Satokangas fb31093ce7 Exclude toolTip from graduation time chart toggle 2022-01-29 10:56:54 +02:00
Saara Satokangas a554cf0257 Add unique key to main datatable cells 2022-01-29 10:24:22 +02:00
Saara Satokangas 2136b574c0 Add tooltip to toggle in studytrack overview 2022-01-29 10:22:13 +02:00
Saara Satokangas abb26bc34b Add tooltips for studyprogramme overview toggles 2022-01-29 10:20:22 +02:00
Saara Satokangas ca1f86a4c2 Include transferred students if "all students" are chosen 2022-01-29 10:19:21 +02:00
Saara Satokangas ce972d4b0a Try fixing the student finder 2022-01-27 18:07:29 +02:00
Saara Satokangas 02e4ee0892 Revert "Clarify how arguments are given to the student finder"
This reverts commit 719299f433.
2022-01-27 18:03:49 +02:00
Saara Satokangas 719299f433 Clarify how arguments are given to the student finder 2022-01-27 17:15:43 +02:00
Saara Satokangas 8cdefbf342 Count studytrack-stats from the filtered studentgroup 2022-01-27 17:15:30 +02:00
Saara Satokangas cf1c97b76d Add enrolled, absent and cancelled studyrights to studytrackview 2022-01-27 17:15:11 +02:00
Saara Satokangas 5af0486032 Add special group inclusion or exclusion to basic stats -view 2022-01-27 17:15:02 +02:00
Saara Satokangas 14e9f8d96d Sort credit table data 2022-01-27 17:14:54 +02:00
Saara Satokangas 4a3fce3d1f Add a way to exclude all "special groups" from studytrack-view 2022-01-27 17:14:46 +02:00
Saara Satokangas 91349936ad Remove work-in-progress-text from new overview 2022-01-27 17:14:39 +02:00
Mitja Karhusaari 0ffabf30c3 Disable updater worker reporting in production 2022-01-27 08:51:00 +02:00
Mitja Karhusaari cffad2b05e Fix the red student credit target line
Resolves #3390
2022-01-27 08:39:54 +02:00
Mitja Karhusaari e0cf547246 trends: do not show this academic year if observation date in previous year
Resolves #2374
2022-01-27 08:39:54 +02:00
Petri Palmu c0ebd66b0d Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-01-26 19:02:50 +02:00
Petri Palmu 9eae226aa3 persist language settings 2022-01-26 19:02:42 +02:00
Saara Satokangas 98281ef504 Remove extra argument 2022-01-26 16:45:11 +02:00
Saara Satokangas 90b85bd343 Add studytrack to population links 2022-01-26 16:07:02 +02:00
Saara Satokangas bb0dee241f Clean up 2022-01-26 14:43:57 +02:00
Petri Palmu 0d1f4967de changed transferre info text 2022-01-26 14:27:24 +02:00
Saara Satokangas 1a9a0780d2 Remove work-in-progress -text 2022-01-26 14:12:39 +02:00
Saara Satokangas 07b8a67d0e Remove the transferred-toggle for now 2022-01-26 14:12:05 +02:00
Saara Satokangas c6312c53f8 Re-organize studytrack datatable 2022-01-26 13:58:38 +02:00
Saara Satokangas aa40257fc7 Add "all studyrights" as its own column to the population view 2022-01-26 12:58:28 +02:00
Saara Satokangas 40e5cfe8af Move PopulationStatisticsLink into its own file 2022-01-26 11:19:27 +02:00
Saara Satokangas 0303c741ce Add links to population stats in studytrack table 2022-01-26 11:10:56 +02:00
Saara Satokangas 80bb7ce549 Add transferred toggle also to basic info -view 2022-01-26 09:35:45 +02:00
Saara Satokangas cbe21c5bfc Add toggle for including or excluding transferred students 2022-01-26 09:19:31 +02:00
dependabot[bot]andGitHub fbb17894cb Bump nanoid from 3.1.23 to 3.2.0 in /services/frontend
Bumps [nanoid](https://github.com/ai/nanoid) from 3.1.23 to 3.2.0.
- [Release notes](https://github.com/ai/nanoid/releases)
- [Changelog](https://github.com/ai/nanoid/blob/main/CHANGELOG.md)
- [Commits](https://github.com/ai/nanoid/compare/3.1.23...3.2.0)

---
updated-dependencies:
- dependency-name: nanoid
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-01-22 08:37:54 +00:00
Petri Palmu 828577487a courses of population language fix 2022-01-19 10:50:13 +02:00
Mitja Karhusaari ae8c2ae5a2 Wrong registry 2022-01-18 15:37:38 +02:00
Mitja Karhusaari cbed21ee1f Login to registry before testing 2022-01-18 15:32:25 +02:00
Mitja Karhusaari 756f5023ca Place the --file flag in the right spot 2022-01-18 15:30:02 +02:00
Mitja Karhusaari 7ec0f32355 Remember to checkout the repo 2022-01-18 15:24:27 +02:00
Mitja Karhusaari b4a990003f Use proper repo name for the action upload-artifact 2022-01-18 15:21:33 +02:00
Mitja Karhusaari 26cf57e66d Test running updater in CI 2022-01-18 15:16:55 +02:00
Saara Satokangas dcbed64611 Organize studytracks correctly in the main table 2022-01-18 12:50:22 +02:00
Saara Satokangas 37ae3bc60c Add cronjob for updating data of new overviews 2022-01-18 12:24:58 +02:00
Saara Satokangas f506989700 Separate studyprogamme updates into their own file
Easier to use in the cronjobs now
2022-01-18 10:08:43 +02:00
Saara Satokangas f75957f0d3 Add indication of loading to the new update-view 2022-01-18 09:39:04 +02:00
Saara Satokangas f58df8336b Add a way to manually update new studyprogramme overviews' stats 2022-01-18 09:35:06 +02:00
Petri Palmu bfc83ae5b5 test fix 2022-01-17 10:09:13 +02:00
Petri Palmu 3366da3016 test tests 2022-01-17 09:03:06 +02:00
Petri Palmu 649f9bd821 more fix to the tests 2022-01-14 16:35:01 +02:00
Petri Palmu b7e1a10e4d test fix 2022-01-13 14:35:59 +02:00
Petri Palmu 7d2776661f Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-01-13 13:05:13 +02:00
Petri Palmu bc133c8a76 few minor changes to the tests for new anon data 2022-01-13 13:05:02 +02:00
Otto Ahoniemi dac2892749 Add working rapodiff 2022-01-13 12:31:43 +02:00
Otto Ahoniemi f004c458a1 Add some debugging tools to backend image 2022-01-13 10:58:00 +02:00
Otto Ahoniemi 17b6592d2a Fix query typo 2022-01-13 10:46:22 +02:00
Otto Ahoniemi 83486d2719 Don't run tests when changing rapodiff script 2022-01-13 10:32:06 +02:00
Otto Ahoniemi 2652180f4b Add rapo script base 2022-01-13 10:23:09 +02:00
Otto Ahoniemi 055492b76b Add admin user to always have admin rights 2022-01-13 08:56:22 +02:00
Otto Ahoniemi c761899962 Fix populations failing because of invalid admin role check 2022-01-13 08:53:55 +02:00
Otto Ahoniemi 998bb3a453 Promote custom populations to navbar & fix normal populations being show to studyguidancegroup users 2022-01-13 08:06:53 +02:00
Otto Ahoniemi b9e9c89376 Fix embarassing bug where I forgot to return mocked user from function 2022-01-13 07:55:46 +02:00
Otto Ahoniemi 943a2145e9 Add toska group for mluukkai dev user 2022-01-13 07:35:27 +02:00
Otto Ahoniemi 4fef6a8582 Cleanup bunch of extra logic from userservice 2022-01-13 07:35:27 +02:00
Otto Ahoniemi 4cf3003dec Race when waiting for studyguidancegroup answer from importer 2022-01-13 07:35:27 +02:00
Otto Ahoniemi ec47fab422 Cleanup user and error handling for feedback 2022-01-13 07:35:27 +02:00
Otto Ahoniemi c391d7786b Merge roles and rights to be part of user object in request 2022-01-13 07:35:27 +02:00
Mitja Karhusaari cb0e4eae16 Hyvää synttäriä, I guess 🤷‍♂️ 🍰 2022-01-11 15:23:28 +02:00
Mitja Karhusaari 3b10c19a81 Fix tests after FilterCard open/close logic change 2022-01-11 15:23:28 +02:00
Mitja Karhusaari c60955c133 Fix chaining of the .cs cypress command 2022-01-11 15:23:28 +02:00
Mitja Karhusaari 14fba8d8ba Open filter options automatically if changed 2022-01-11 15:23:28 +02:00
Petri Palmu 9843e9fafa courses of population students are great again 2022-01-11 14:33:08 +02:00
Petri Palmu 08a51b05b1 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-01-11 11:46:47 +02:00
Mitja Karhusaari 1a7df991e8 Remove tag and study track selectors from population search view 2022-01-11 11:14:43 +02:00
Mitja Karhusaari 2391062e71 Do not fetch tags for study track if query does not specify a study track 2022-01-11 11:09:13 +02:00
Mitja Karhusaari f0c179e23d Fix usage of the isBetween method in the context of study rights 2022-01-11 11:09:13 +02:00
Petri Palmu b183c438bb added bscs regex in code sorting order 2022-01-06 20:21:34 +02:00
Petri Palmu 60db28f4bb fix with null check for subs in services population 2022-01-05 10:09:00 +02:00
Mitja Karhusaari e8be70bf9f Make linter happy 2022-01-05 02:06:08 +02:00
Mitja Karhusaari 7b60bc220c Improve grade filter fault tolerance 2022-01-05 01:59:15 +02:00
Mitja Karhusaari 44dfaf20a6 Adjust tests 2022-01-05 01:50:43 +02:00
Mitja Karhusaari 009a9f5397 Implement tests for the modified filters 2022-01-05 01:49:45 +02:00
Mitja Karhusaari 5ac2db44e3 Change study track filter to consider only the currently active study rights by default 2022-01-05 01:20:50 +02:00
Mitja Karhusaari 337b1f05e4 Generalize the implementation of programme filter and add it to all views 2022-01-05 01:20:50 +02:00
Mitja Karhusaari 537d9ecc33 Display a message when opening the tags filter and no tags are available 2022-01-05 01:20:50 +02:00
Mitja Karhusaari 4e9d1cd190 Display filters in alphabetical order for consistency's sake 2022-01-05 01:20:50 +02:00
Mitja Karhusaari fbe1cc93fb Implement study track filter 2022-01-05 01:20:50 +02:00
Petri Palmu 12c3c9430d little correction to the test 2022-01-05 01:05:00 +02:00
Petri Palmu 6251b69feb lint fixes 2022-01-04 23:33:03 +02:00
Petri Palmu 6960b67bfb changed anon oodi sis-db data 2022-01-04 23:26:05 +02:00
Otto AhoniemiandGitHub cb3da3d1bc Update anon db guide + fix some typos
Some of these things are now part of CI + there were some possible places for misunderstandings.
2022-01-04 17:49:17 +02:00
Otto Ahoniemi 79df421846 Remove old forwarders used for sisu api transition 2022-01-04 16:35:43 +02:00
Otto Ahoniemi d32c3c9bd9 Remove references to decodedToken in backend 2022-01-04 16:35:43 +02:00
Otto Ahoniemi af38c9fc97 Transform roles and admin thingys already in backend 2022-01-04 16:35:43 +02:00
Otto Ahoniemi 843fc4c8ec Merge usage of userRoles and roles 2022-01-04 16:35:43 +02:00
Petri Palmu 97105588df restore tests 2022-01-04 14:22:30 +02:00
Petri Palmu 6a68dd7817 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2022-01-04 13:04:34 +02:00
Petri Palmu acfd918d80 removed more temp ay code 2022-01-04 13:03:31 +02:00
Otto Ahoniemi 3aea117f2f Classic happy birthday to this one guy on the dataset -change 2022-01-04 12:06:26 +02:00
Otto Ahoniemi f290a1a3d3 Stop intercepting /superlogin path on user tests 2022-01-04 11:53:22 +02:00
Otto Ahoniemi 93db8810a3 Run migrations against built images in ci pipeline 2022-01-04 11:10:30 +02:00
Otto Ahoniemi 4675f52c2d Unify user-db and kone-db connections, fix circular logging error 2022-01-04 11:07:22 +02:00
Petri Palmu 73c29b2edf temporary ay codes removed 2022-01-03 17:42:13 +02:00
Petri Palmu 5102ba4ab3 little change to the tests 2022-01-03 12:18:14 +02:00
Petri Palmu 87746582c3 changed language distribution info text 2022-01-03 12:07:39 +02:00
Petri Palmu 2b739e9ff3 course statistics find courses works 2022-01-03 12:07:12 +02:00
Petri Palmu 3d32244238 added migration for the new avoin studyright 2022-01-03 11:45:12 +02:00
Otto Ahoniemi 3380b41e60 Refactor sending mails to users 2021-12-30 17:41:02 +02:00
Otto Ahoniemi a07129d704 Migrate sentryuser setting to current user middleware 2021-12-30 17:30:05 +02:00
Otto Ahoniemi 5adfaa6858 Implement new superlogin 2021-12-30 17:04:53 +02:00
Otto Ahoniemi 07d6ffb7e2 Timeout if importer is unresponsive 2021-12-30 17:04:53 +02:00
Otto Ahoniemi b025526e6b Re-implement auth middleware and fix some other middleware thingys 2021-12-30 17:04:52 +02:00
Otto Ahoniemi cf4ef78cbe Cleanup ignore files 2021-12-30 17:02:45 +02:00
Otto Ahoniemi 6d3ccea413 Remove unused ping route 2021-12-30 17:02:45 +02:00
Otto Ahoniemi f2ca3b4d45 Replace old auth logic with RTK query and separate login functionality from Errorboundary 2021-12-30 17:02:45 +02:00
Otto Ahoniemi 8fa6ce72e6 Remove error container 2021-12-30 17:02:45 +02:00
Otto Ahoniemi 61dba16e6c Unify index and app setup with toskaboiler 2021-12-30 17:02:45 +02:00
Otto Ahoniemi 9b1968cf2c Refactor all token and user related redux selectors under one hook 2021-12-30 17:02:44 +02:00
Otto Ahoniemi a91494fc86 Merge userservice to backend 2021-12-30 17:02:44 +02:00
Otto Ahoniemi 4a71ce4ee9 Superlogin without token 2021-12-30 17:02:44 +02:00
Otto Ahoniemi e90dd00d4d Tokenless in backend and frontend 2021-12-30 17:02:43 +02:00
Otto Ahoniemi e24df11422 Support login without token in userservice 2021-12-30 17:00:39 +02:00
Otto AhoniemiandGitHub 220d21066b Log headers temporarily 2021-12-30 14:27:58 +02:00
Saara Satokangas b80b5e5097 Make credit progress table more compact 2021-12-30 11:02:49 +02:00
Saara Satokangas 88dfb372d3 Fix studytrack overview chart colors 2021-12-30 10:59:07 +02:00
Saara Satokangas dc8edb38e5 Clean up & add some clarifying comments 2021-12-30 10:48:34 +02:00
Saara Satokangas 5edaa3abd9 Style the studytrack table better 2021-12-30 10:13:09 +02:00
Saara Satokangas 20da53a22e Add option of all the students back to the selector 2021-12-30 10:07:05 +02:00
Saara Satokangas f598536b6d Exclude tracks with empty stats from studytrack options 2021-12-30 09:21:17 +02:00
Saara Satokangas d2862364db Make studytrack overview work with other programmes 2021-12-30 08:39:10 +02:00
Saara Satokangas b5b032c33c Enable single studytrack for the maintable in front 2021-12-29 16:31:37 +02:00
Petri Palmu f86dce3fb8 Fixes to the codeless avoin 2021-12-29 16:04:44 +02:00
Saara Satokangas b34a38e479 Add data for the main studytrack table by studytrack 2021-12-29 15:58:42 +02:00
Saara Satokangas ba7a0cd531 Add a no-data-message when no studytrack data 2021-12-29 12:37:06 +02:00
Saara Satokangas 57d98d33aa Enable selecting data only for some studytrack 2021-12-29 12:07:54 +02:00
Saara Satokangas f8d17179a9 Add exporting possibility to the studytrack graph 2021-12-29 09:35:01 +02:00
Saara Satokangas c8c6565208 Fix studytrack-selector overflowing 2021-12-29 09:24:57 +02:00
Saara Satokangas f207aee266 Add infotexts for the progress chart and table 2021-12-29 08:37:52 +02:00
Saara Satokangas 8c20daf686 Style the graph container for studytrack overview graph 2021-12-28 15:41:30 +02:00
Saara Satokangas 8bddad1795 Separate programmes stat -counting and studytrack stat -counting 2021-12-28 15:39:05 +02:00
Saara Satokangas 04b5627f8d Move academic year startDate and endDate defining into its own function 2021-12-28 15:11:08 +02:00
Saara Satokangas d89799cb89 Add loader to the new studytrack overview 2021-12-28 15:01:50 +02:00
Saara Satokangas ca35323b50 Initial adding of data to the credits graph in studytrackoverview 2021-12-28 14:48:38 +02:00
Saara Satokangas 3db15898d8 Clean up css for studytrack overview 2021-12-28 11:17:31 +02:00
Saara Satokangas b264685b16 Show progress only for the entire studyprogramme
Not individual studytracks at first
2021-12-28 11:12:31 +02:00
Saara Satokangas 6713d45f98 Add credit-stats to the table 2021-12-28 11:01:32 +02:00
Saara Satokangas 89e8c4508f Add counting student progress in the backend 2021-12-28 10:46:18 +02:00
Saara Satokangas 47f70469f6 Add basis for the credit-tables in studytrack-overview 2021-12-28 10:08:33 +02:00
Saara Satokangas ec1e77ddbb Add some unique keys to the datatable 2021-12-28 09:46:18 +02:00
Saara Satokangas 5446befb81 Simplify how names are fetched for studytracks 2021-12-28 09:36:05 +02:00
Saara Satokangas 85a56083f4 Don't show studytracks by default 2021-12-28 08:53:11 +02:00
Saara Satokangas 137ca05095 Add track codes to studytrack names 2021-12-28 08:48:38 +02:00
Saara Satokangas 36b8c81ec1 Map studytrack names to the selector 2021-12-28 08:48:38 +02:00
Saara Satokangas 33c0210347 Only show arrows if there is data hidden 2021-12-28 08:48:14 +02:00
Saara Satokangas 8da67b2998 Most recent year first in studytrack overview 2021-12-28 08:48:14 +02:00
Saara Satokangas f0864bcd33 Add infobox-text for the new studytrack-overview 2021-12-28 08:48:14 +02:00
Saara Satokangas 5634d23a51 Add percentages to the studytrack-table 2021-12-28 08:48:14 +02:00
Saara Satokangas c2008b634c Exclude studytracks with no students from the datatable 2021-12-28 08:48:14 +02:00
Otto Ahoniemi e7783af0f9 Drop affiliations from userservice 2021-12-27 14:51:59 +02:00
Petri Palmu 229904187e course statistics find courses works 2021-12-23 08:54:52 +02:00
Saara Satokangas a0e92a1944 Add studyright startdates to the excel export 2021-12-21 15:42:11 +02:00
Saara Satokangas b4468d3713 Change how totals are shown for the new studytrack overview 2021-12-21 15:02:11 +02:00
Saara Satokangas e94ccaae3e Move new studyprogramme tabs to be the last ones 2021-12-21 14:52:33 +02:00
Saara Satokangas 0dfeaff1f9 Add initial datatable for studytrack data 2021-12-21 14:50:30 +02:00
Saara Satokangas 39cc589acc Initial version for mankeling studytrack-data
This should still be cleaned up, but just saving it here before
it gets deleted
2021-12-21 14:01:47 +02:00
Petri Palmu 88a14f235b Merge branch 'master' into feature/newAvoin 2021-12-21 10:45:40 +02:00
Petri Palmu 67736b295b added migration for the new avoin studyright 2021-12-21 10:44:31 +02:00
Saara Satokangas ee11c3b47d Barebones backend pipeline for studytracks-data 2021-12-20 11:20:16 +02:00
Saara Satokangas 9dd9e41001 Combine infotexts for graduation mean and median times 2021-12-20 09:02:34 +02:00
Saara Satokangas e467689e27 Initial commit for new Studytrack-overview 2021-12-20 08:58:22 +02:00
Saara Satokangas d0a23b6038 Add toggle for choosing average graduation time 2021-12-20 08:12:44 +02:00
Saara Satokangas 42a5bff039 Remove enrolled-stats from the graphs for now 2021-12-20 07:42:51 +02:00
Otto Ahoniemi d601dbe597 Run all the filter tests again 2021-12-17 00:15:51 +02:00
Otto Ahoniemi e356186152 Remove sis warning flag toggle since it's not used anymore 2021-12-16 23:17:13 +02:00
Otto Ahoniemi 4c6153c76d Restore couple of student tests and test that student page doesn't crash without studyrights or courses 2021-12-16 23:17:10 +02:00
Otto Ahoniemi abebc5d410 Start adding separate and agreement studyrights to sis-db 2021-12-16 21:45:56 +02:00
Otto Ahoniemi 3dcb5f299c Fix credit graph failing if student has no studyrights 2021-12-16 21:19:39 +02:00
Otto Ahoniemi 0632fa94f7 Don't crash if study guidance groups not available 2021-12-16 19:57:28 +02:00
Mitja Karhusaari ed85513290 Make courses filter resilient against missing course information 2021-12-16 12:47:25 +02:00
Mitja Karhusaari 07ad8cb434 Use rtk query to fetch course statistics 2021-12-16 12:47:25 +02:00
Mitja Karhusaari 901b719888 Second try at the previous 2021-12-16 03:03:37 +02:00
Mitja Karhusaari 9850faf400 Don't show custom population filters before population has been loaded
Resolves #3341
2021-12-16 02:17:21 +02:00
Mitja Karhusaari 176eca36eb Refetch population course data whenever filter results change 2021-12-16 01:38:07 +02:00
Saara Satokangas 77d5435c30 Start using the course_unit_type in the new studyprogramme-view 2021-12-14 16:17:00 +02:00
Saara Satokangas 3f99df4971 Add course_unit_type to customAttainmentParser in updater 2021-12-14 09:18:50 +02:00
Saara Satokangas 819ba0db15 Add course_unit_type to the course-mapper in updater 2021-12-14 09:06:21 +02:00
Mitja Karhusaari e8871cc845 Make the date selection not persistent 2021-12-10 17:26:55 +02:00
Mitja Karhusaari e2c152ddc1 Extract common functionality from status pages 2021-12-10 16:58:09 +02:00
Mitja Karhusaari 63c9d316d0 Move info texts from component files to under the InfoToolTips directory 2021-12-10 08:04:49 +02:00
Mitja Karhusaari 6b1ff9e9cb Fix graduation trends page on initial page load 2021-12-10 07:47:12 +02:00
Petri Palmu 7f913c9927 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2021-12-09 13:58:00 +02:00
Petri Palmu b7616ec2ed moved info texts to commons 2021-12-09 11:54:14 +02:00
Mitja Karhusaari d0840a7de3 Fix data export 2021-12-09 11:12:51 +02:00
Petri Palmu cc214179f6 solved merge conflicts with pukinkontti 2021-12-09 10:45:13 +02:00
Otto Ahoniemi cbfe5aedc1 Fix workflow job dependencies 2021-12-09 02:35:08 +02:00
Otto Ahoniemi c0b61d6d4e Run migrations also for anon user-db and kone-db 2021-12-09 02:33:09 +02:00
Otto Ahoniemi dd28ee3c48 Run migration push also when test yaml changes + fix script trying to run down docker-compose 2021-12-09 02:24:09 +02:00
Otto Ahoniemi 3f5e1e53b9 Add sis person ids to students 2021-12-09 02:14:15 +02:00
Otto Ahoniemi a5ef63bc2f Add creds 2021-12-09 02:04:55 +02:00
Mitja Karhusaari 5f7f496472 Copy settings and usage instruction components from attainment status page 2021-12-09 02:01:00 +02:00
Mitja Karhusaari 8058f8ca0a Use the DrillStack component on the graduation trends page 2021-12-09 02:01:00 +02:00
Mitja Karhusaari 6fd5304414 Separate drilling into a separate component 2021-12-09 02:01:00 +02:00
Otto Ahoniemi 2fde626606 Remove garbage column from student model 2021-12-09 02:00:16 +02:00
Otto Ahoniemi 75ff72e545 Fix typo in ci docker-compose container name and add profile so sis-updater won't be run by default 2021-12-09 01:56:18 +02:00
Otto Ahoniemi 8b80f11728 Build anon sis-db and push to toska hub if there are new sis-db migrations 2021-12-09 01:42:16 +02:00
Otto Ahoniemi 4648f49ebc Fix lint staged shell linter failing because it was being ran inside alpine container 2021-12-09 01:31:59 +02:00
Otto Ahoniemi 92fbe3b2d3 Move anonyymioodi scripts and readme to this main repo 2021-12-09 01:31:29 +02:00
Otto Ahoniemi 1e6c418c7e Hotfix user right check when user has rights for programme and studyguidancegroups 2021-12-09 01:00:30 +02:00
Otto Ahoniemi c120b9c6a9 Add note about tests failing if anon db hasn't been updated manually 2021-12-08 23:12:39 +02:00
Saara Satokangas ec7d77dca0 Add course_unit_type to course-model 2021-12-08 14:02:51 +02:00
Saara Satokangas 4a15d97207 Show Studyprogramme options for others than admins as well 2021-12-08 13:03:06 +02:00
Saara Satokangas 40bb1dbc3e Make new studyprogramme view to admins with teachers-role 2021-12-08 13:03:06 +02:00
Saara Satokangas ad95ab6ce3 Initial version of adding enrolled students to the graphs 2021-12-08 13:03:06 +02:00
Saara Satokangas 4d0a62f26c Separate helpers, stats and db-queries for newStudyprogramme
And try to avoid modules with 500 rows
2021-12-08 13:00:11 +02:00
Saara Satokangas f30b415f05 Add loader to new studyprogramme overview 2021-12-08 13:00:11 +02:00
Saara Satokangas c0de93ce55 Add total-column to credits of the studyprogramme 2021-12-08 13:00:11 +02:00
Saara Satokangas 6560e7bf26 Adjust data table size 2021-12-08 13:00:11 +02:00
Saara Satokangas 4d782f9ec0 Correct order for radio-labels 2021-12-08 12:59:42 +02:00
Saara Satokangas 62dcd0a4ca Enable fetching graduation and thesis status by academic year 2021-12-08 12:59:42 +02:00
Saara Satokangas 994cb180a0 Enable getting credits stats also by academic year 2021-12-08 12:59:42 +02:00
Saara Satokangas a28a1b0a6c Add possibility to get basic stats by academic year 2021-12-08 12:59:42 +02:00
Petri Palmu 2a5c690ab5 added test for the language filter 2021-12-08 12:19:32 +02:00
Saara SatokangasandGitHub d7e739e20e Update importer-path for api-gateway 2021-12-08 10:04:35 +02:00
Mitja Karhusaari e2c77fe63b Revert changes to studyprogramme tests 2021-12-08 09:28:35 +02:00
Petri Palmu 39e9a3084b little correction to the language dist 2021-12-07 10:37:21 +02:00
Petri Palmu 13dc659d18 language distribution added to the course stats 2021-12-03 18:44:42 +02:00
Mitja Karhusaari aeee083d0a Implement "Show all credits" button using the new filter system 2021-12-03 04:37:04 +02:00
Mitja Karhusaari cd56b74d25 Add spinner study guidance group course stats 2021-12-03 04:26:21 +02:00
Mitja Karhusaari 77eb31f840 Fix course statistics in study guidance groups view 2021-12-03 04:25:21 +02:00
Mitja Karhusaari 1988182134 Fix course filter in study guidance groups 2021-12-03 03:55:09 +02:00
Mitja Karhusaari 1b248665c4 Reimplement #3303 using the new filter system 2021-12-03 03:44:08 +02:00
Mitja Karhusaari 942b02c8e2 Take initial filter view options into account in filter selectors 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 7a34ad66e8 Improve the behavior of default and initial filter options when reseting a filter 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 4fc7b97813 Fix course statistics 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 77a87c5b1e Implement default filter values for study guidance groups 2021-12-03 03:23:58 +02:00
Mitja Karhusaari c7d2a552c9 Fix tests and make them pass 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 63205fbfa1 Implement functionality for the "Clear All Filters" -button 2021-12-03 03:23:58 +02:00
Mitja Karhusaari df68671181 Change filter reset button look 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 00cee9f14b Fix filter card layouts 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 905d19f46f Update admission type filter 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 019d10c938 Fix filters in study guidance groups 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 7a0d91a510 Hide filter tray until a population has been selected 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 10169e92a6 Fix filter view layout and tray stickiness 2021-12-03 03:23:58 +02:00
Mitja Karhusaari c74112a356 Implement actions and selectors for filters 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 9dee8d4669 Implement a new filter architecture 2021-12-03 03:23:58 +02:00
Mitja Karhusaari fc875d30b6 Allow clearing of the credit date filter dates 2021-12-03 03:23:58 +02:00
Mitja Karhusaari 47fc6ea215 Change student credit column title based on the credit date filter
options
2021-12-03 03:23:58 +02:00
Saara Satokangas 26420f9a36 Add initial infobox-texts for new studyprogramme-view 2021-12-02 13:50:04 +02:00
Saara Satokangas c8f461b7f5 Add some unique keys 2021-12-02 13:31:11 +02:00
Saara Satokangas c17e53cec5 Organize stuff 2021-12-02 13:06:50 +02:00
Saara Satokangas 9cff76f498 Add possibility to export charts from new overview 2021-12-02 13:03:56 +02:00
Saara Satokangas b91991ac37 Betterments to responsiveness of the graphs 2021-12-02 12:20:24 +02:00
Saara Satokangas 9eff7057e7 Include only thesis with ATTAINED-state to the graphs
So no improvements, and one per student
2021-12-02 10:35:48 +02:00
Saara Satokangas 4c096199d2 Start using RTK Query for new studyprogramme overview 2021-12-01 20:33:10 +02:00
Saara Satokangas 9f39ee6b87 Add graduation mean and median time charts 2021-12-01 19:20:42 +02:00
Petri Palmu d06462d727 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2021-12-01 16:36:14 +02:00
Petri Palmu e4f65407ed Merge branch 'kieli' 2021-12-01 16:36:01 +02:00
Petri Palmu 26d8f2befc language added to course statitics 2021-12-01 16:34:54 +02:00
Saara Satokangas 2713545eda Remove proptypes from Thesis Courses 2021-12-01 13:41:08 +02:00
Saara Satokangas fa619fed38 Fix Thesis Courses -tab breaking because of unselected language 2021-12-01 13:36:48 +02:00
Saara Satokangas 6d4f49879b Add graph and table for graduated and thesis-writers 2021-12-01 13:27:58 +02:00
Saara Satokangas 37aeb9ebe4 Add percentages to barchart tooltips 2021-12-01 09:34:30 +02:00
Saara Satokangas 5f5423971c Add colors to new overview charts 2021-12-01 09:34:21 +02:00
Petri Palmu 39b3fde1a0 backend ready for the language 2021-11-30 15:44:03 +02:00
Petri Palmu 382c900d28 Merge branch 'master' of github.com:UniversityOfHelsinkiCS/oodikone 2021-11-30 13:37:50 +02:00
Petri Palmu 5ac2cfb13c moved filter info texts to front common infotooltip filters 2021-11-30 13:02:02 +02:00
Otto Ahoniemi aa6d2b83f5 Revert hiding of programme filter 2021-11-29 15:08:12 +02:00
Petri Palmu 201250b8af fix that open uni course goes into substitutions only once 2021-11-29 13:56:48 +02:00
Otto Ahoniemi ff36a0e8f7 Add date to study guidance group filter set 2021-11-29 13:48:11 +02:00
Otto Ahoniemi 71c1ce703a Add better selector for datetime picker header hider 2021-11-29 13:42:27 +02:00
Otto Ahoniemi c94711234f Don't show tag filter when tags aren't available 2021-11-29 13:34:08 +02:00
Otto Ahoniemi 563d2cb4b0 Fix course tab in population student table 2021-11-29 12:59:50 +02:00
Otto Ahoniemi 3727bd03dd Set datepicker to start from 2017 + hide year header 2021-11-29 11:05:36 +02:00
Otto Ahoniemi efb0b98cdc Update README 2021-11-29 10:19:12 +02:00
Petri Palmu ef5aec5fc1 language migration added to the credit 2021-11-25 08:36:11 +02:00
Petri Palmu cdbbf06c18 added info options to the filters 2021-11-24 08:55:02 +02:00
Saara SatokangasandGitHub e471b1e73a Merge pull request #3310 from UniversityOfHelsinkiCS/new_studyprogramme
New studyprogramme overview -pukinkontti
2021-11-18 16:09:59 +02:00
Saara Satokangas 1d7f9d250a Remove waste 2021-11-18 16:01:54 +02:00
Saara Satokangas 0207e58fa3 Years in correct order for tables and graphs 2021-11-18 16:01:54 +02:00
Saara Satokangas aecca8426d Modify tooltips 2021-11-18 16:01:54 +02:00
Saara Satokangas ef0d0a5eb7 Refactor stats basis into its own function 2021-11-18 16:01:54 +02:00
Saara Satokangas 284c5b270d Rewrite how major and non-major students' credits are defined 2021-11-18 16:01:54 +02:00
Saara Satokangas 51f2a7573e Increase height of the containers 2021-11-18 16:01:54 +02:00
Saara Satokangas 0837e1d972 Add transferred credits and non-major credits to studyprogramme credits
And general betterments
2021-11-18 16:01:54 +02:00
Saara Satokangas e468186af2 Add major students credit stats to the data table 2021-11-18 16:01:54 +02:00
Saara Satokangas 3fcfe56bd0 Show credits for major students in the graph 2021-11-18 16:01:54 +02:00
Saara Satokangas 85ad68c97d Move also new studyprogramme-stuff in backend into its own file
Again, why did I not do this already last week?
2021-11-18 16:01:54 +02:00
Saara Satokangas ede3b8efac Move the new view into its own folder
Should have done this from the start
2021-11-18 16:01:54 +02:00
Saara Satokangas cd1d65b29b Add basis for fetching credit stats 2021-11-18 16:01:54 +02:00
Saara Satokangas 456fe927e7 Initial adding of credits stats to studyprogramme-view 2021-11-18 16:01:54 +02:00
Saara Satokangas df36d58288 Add datatable, clean up graph 2021-11-18 16:01:54 +02:00
Saara Satokangas 918869b307 Add also started to the initial graph 2021-11-18 16:01:54 +02:00
Saara Satokangas 2ba06ae787 Add also cancelled and transfers to the initial new graph 2021-11-18 16:01:54 +02:00
Saara Satokangas ac0dc90661 Very initial commit for new studyprogramme graphs 2021-11-18 16:01:54 +02:00
429 changed files with 21176 additions and 33540 deletions
+45 -13
View File
@@ -1,15 +1,47 @@
version: 2
updates:
- package-ecosystem: npm
directory: "/"
schedule:
interval: weekly
time: "03:00"
open-pull-requests-limit: 10
target-branch: "trunk"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
time: "03:00"
target-branch: "trunk"
- package-ecosystem: npm
directory: '/'
schedule:
interval: weekly
time: '03:00'
labels:
- 'dependencies'
- 'infra'
- package-ecosystem: npm
directory: '/updater/sis-updater-scheduler'
schedule:
interval: weekly
time: '03:00'
labels:
- 'dependencies'
- 'updater'
- package-ecosystem: npm
directory: '/updater/sis-updater-worker'
schedule:
interval: weekly
time: '03:00'
labels:
- 'dependencies'
- 'updater'
- package-ecosystem: npm
directory: '/services/backend'
schedule:
interval: weekly
time: '03:00'
labels:
- 'dependencies'
- 'back'
- package-ecosystem: npm
directory: '/services/frontend'
schedule:
interval: weekly
time: '03:00'
labels:
- 'dependencies'
- 'front'
- package-ecosystem: 'github-actions'
directory: '/'
schedule:
interval: weekly
time: '03:00'
+23 -57
View File
@@ -1,4 +1,4 @@
name: "Release oodikone to production"
name: 'Release oodikone to production'
on:
release:
@@ -6,23 +6,23 @@ on:
jobs:
build_and_release_backend:
name: "Build and release backend"
name: 'Build and release backend'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: "Login to DockerHub"
- name: 'Login to DockerHub'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Extract release version"
- name: 'Extract release version'
# Github context (e.g. github.ref) only has ref formatted as /refs/tags/vX.X.X
# This steps extracts release version from GITHUB_REF env var
# See: https://github.community/t/how-to-get-just-the-tag-name/16241/10
id: extract_version
run: echo ::set-output name=VERSION::"${GITHUB_REF#refs/tags/}"
- name: "Build and push"
- name: 'Build and push'
uses: docker/build-push-action@v2
with:
build-args: |
@@ -38,26 +38,26 @@ jobs:
target: production
build_and_release_frontend:
name: "Build and release frontend"
name: 'Build and release frontend'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: "Login to DockerHub"
- name: 'Login to DockerHub'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Get current time"
- name: 'Get current time'
id: get_current_time
run: echo ::set-output name=NOW::"$(date --iso-8601=seconds)"
- name: "Extract release version"
- name: 'Extract release version'
# Github context (e.g. github.ref) only has ref formatted as /refs/tags/vX.X.X
# This steps extracts release version from GITHUB_REF env var
# See: https://github.community/t/how-to-get-just-the-tag-name/16241/10
id: extract_version
run: echo ::set-output name=VERSION::"${GITHUB_REF#refs/tags/}"
- name: "Build and push"
- name: 'Build and push'
uses: docker/build-push-action@v2
with:
build-args: |
@@ -72,11 +72,11 @@ jobs:
push: true
tags: toska/oodikone2-frontend:latest
target: production
- name: "Create a container from built image "
- name: 'Create a container from built image '
run: docker create --name frontend toska/oodikone2-frontend:latest
- name: "Copy assets from the container"
- name: 'Copy assets from the container'
run: docker cp frontend:/usr/src/app/build ./build
- name: "Create Sentry release"
- name: 'Create Sentry release'
uses: getsentry/action-release@v1
env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
@@ -90,49 +90,16 @@ jobs:
url_prefix: '~/static/js'
version: ${{ steps.extract_version.outputs.VERSION }}
build_and_release_userservice:
name: "Build and release userservice"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: "Login to DockerHub"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Extract release version"
# Github context (e.g. github.ref) only has ref formatted as /refs/tags/vX.X.X
# This steps extracts release version from GITHUB_REF env var
# See: https://github.community/t/how-to-get-just-the-tag-name/16241/10
id: extract_version
run: echo ::set-output name=VERSION::"${GITHUB_REF#refs/tags/}"
- name: "Build and push"
uses: docker/build-push-action@v2
with:
build-args: |
SENTRY_RELEASE=${{ steps.extract_version.outputs.VERSION }}
SENTRY_ENVIRONMENT=production
cache-from: |
type=registry,ref=toska/oodikone2-userservice:staging
type=registry,ref=toska/oodikone2-userservice:latest
cache-to: type=inline
context: services/userservice
push: true
tags: toska/oodikone2-userservice:latest
target: production
report_success:
runs-on: ubuntu-latest
name: "Report deployment success to oodikone notifications"
name: 'Report deployment success to oodikone notifications'
needs:
- build_and_release_backend
- build_and_release_frontend
- build_and_release_userservice
- build_and_release_backend
- build_and_release_frontend
if: success()
steps:
- name: "Send notification to slack"
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
- name: 'Send notification to slack'
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
message-type: deployment
@@ -141,15 +108,14 @@ jobs:
report_failure:
runs-on: ubuntu-latest
name: "Report deployment failure to oodikone notifications"
name: 'Report deployment failure to oodikone notifications'
needs:
- build_and_release_backend
- build_and_release_frontend
- build_and_release_userservice
- build_and_release_backend
- build_and_release_frontend
if: failure()
steps:
- name: "Send notification to slack"
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
- name: 'Send notification to slack'
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
message-type: deployment-failure
@@ -1,54 +0,0 @@
name: "Release sis-updater-scheduler"
on:
push:
branches:
- master
paths:
- '.github/workflows/release-sis-updater-scheduler.yaml'
- 'updater/sis-updater-scheduler/**'
jobs:
build_and_release:
name: "Build and release sis-updater-scheduler"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: "Login to DockerHub"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Build and push"
uses: docker/build-push-action@v2
with:
cache-from: type=registry,ref=toska/sis-updater-scheduler:latest
cache-to: type=inline
context: updater/sis-updater-scheduler/
push: true
tags: toska/sis-updater-scheduler:latest
target: production
- name: "Send notification to slack"
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
message-type: deployment
softa-url: https://oodikone.cs.helsinki.fi
deployment-target: production
softa-to-deploy: sis-updater-scheduler
report_failure:
runs-on: ubuntu-latest
name: "Report deployment failure to oodikone notifications"
needs:
- build_and_release
if: failure()
steps:
- name: "Send notification to slack"
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
message-type: deployment-failure
deployment-target: production
softa-to-deploy: sis-updater-scheduler
@@ -1,54 +0,0 @@
name: "Release sis-updater-worker"
on:
push:
branches:
- master
paths:
- '.github/workflows/release-sis-updater-worker.yaml'
- 'updater/sis-updater-worker/**'
jobs:
build_and_release:
name: "Build and release sis-updater-worker"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: "Login to DockerHub"
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: "Build and push"
uses: docker/build-push-action@v2
with:
cache-from: type=registry,ref=toska/sis-updater-worker:latest
cache-to: type=inline
context: updater/sis-updater-worker/
push: true
tags: toska/sis-updater-worker:latest
target: production
- name: "Send notification to slack"
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
message-type: deployment
softa-url: https://oodikone.cs.helsinki.fi
deployment-target: production
softa-to-deploy: sis-updater-worker
report_failure:
runs-on: ubuntu-latest
name: "Report deployment failure to oodikone notifications"
needs:
- build_and_release
if: failure()
steps:
- name: "Send notification to slack"
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
message-type: deployment-failure
deployment-target: production
softa-to-deploy: sis-updater-worker
@@ -0,0 +1,158 @@
name: 'Test and release updater'
on:
push:
branches:
- master
paths:
- '.github/workflows/test-and-release-updater.yaml'
- 'updater/sis-updater-worker/**'
- 'updater/sis-updater-scheduler/**'
jobs:
build_worker:
name: 'Build sis-updater-worker'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: 'Build the image'
uses: docker/build-push-action@v2
with:
build-args: |
SENTRY_RELEASE=${{ github.sha }}
SENTRY_ENVIRONMENT=production
context: updater/sis-updater-worker/
target: production
push: false
outputs: type=docker,dest=/tmp/worker.tar
tags: toska/sis-updater-worker:latest
cache-from: type=registry,ref=toska/sis-updater-worker:latest
cache-to: type=inline
- name: 'Store built image'
uses: actions/upload-artifact@v2
with:
path: /tmp/worker.tar
build_scheduler:
name: 'Build sis-updater-scheduler'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: 'Build the image'
uses: docker/build-push-action@v2
with:
build-args: |
SENTRY_RELEASE=${{ github.sha }}
SENTRY_ENVIRONMENT=production
context: updater/sis-updater-scheduler/
target: production
push: false
outputs: type=docker,dest=/tmp/scheduler.tar
tags: toska/sis-updater-scheduler:latest
cache-from: type=registry,ref=toska/sis-updater-scheduler:latest
cache-to: type=inline
- name: 'Store built image'
uses: actions/upload-artifact@v2
with:
path: /tmp/scheduler.tar
test_updater:
name: 'Test updater'
runs-on: ubuntu-latest
needs:
- build_worker
- build_scheduler
steps:
- uses: actions/checkout@v2
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
registry: registry.toska.cs.helsinki.fi
username: ${{ secrets.TOSKAREGISTRY_USERNAME }}
password: ${{ secrets.TOSKAREGISTRY_PASSWORD }}
- name: 'Download built images'
uses: actions/download-artifact@v2
with:
path: /tmp/
- name: 'Load worker image'
run: docker load --input /tmp/artifact/worker.tar
- name: 'Load scheduler image'
run: docker load --input /tmp/artifact/scheduler.tar
- name: 'Start worker'
run: docker-compose --file docker-compose.ci.yml up --detach --no-recreate sis-updater-worker
- name: 'Run hourly jobs'
run: docker-compose --file docker-compose.ci.yml run sis-updater-scheduler npm start
env:
SCHEDULE_IMMEDIATE: hourly
EXIT_AFTER_IMMEDIATES: yes
- name: 'Run weekly jobs'
run: docker-compose --file docker-compose.ci.yml run sis-updater-scheduler npm start
env:
SCHEDULE_IMMEDIATE: weekly
EXIT_AFTER_IMMEDIATES: yes
- name: 'Run prepurge'
run: docker-compose --file docker-compose.ci.yml run sis-updater-scheduler npm start
env:
SCHEDULE_IMMEDIATE: prepurge
EXIT_AFTER_IMMEDIATES: yes
- name: 'Run purge'
run: docker-compose --file docker-compose.ci.yml run sis-updater-scheduler npm start
env:
SCHEDULE_IMMEDIATE: purge
EXIT_AFTER_IMMEDIATES: yes
release_updater:
name: 'Release updater'
runs-on: ubuntu-latest
needs:
- build_worker
- build_scheduler
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: 'Login to DockerHub'
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: 'Build and push scheduler'
uses: docker/build-push-action@v2
with:
cache-from: type=registry,ref=toska/sis-updater-scheduler:latest
cache-to: type=inline
context: updater/sis-updater-scheduler/
push: true
tags: toska/sis-updater-scheduler:latest
target: production
- name: 'Build and push worker'
uses: docker/build-push-action@v2
with:
cache-from: type=registry,ref=toska/sis-updater-worker:latest
cache-to: type=inline
context: updater/sis-updater-worker/
push: true
tags: toska/sis-updater-worker:latest
target: production
- name: 'Create Sentry release'
uses: getsentry/action-release@v1
env:
SENTRY_URL: ${{ secrets.SENTRY_URL }}
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: toska
SENTRY_PROJECT: updater
with:
environment: production
set_commits: 'skip'
sourcemaps: './build/static/js'
url_prefix: '~/static/js'
version: ${{ steps.extract_version.outputs.VERSION }}
- name: 'Send notification to slack'
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
with:
webhook-url: ${{ secrets.WEBHOOK_URL }}
message-type: deployment
softa-url: https://oodikone.cs.helsinki.fi
deployment-target: production
softa-to-deploy: sis-updater
+106 -63
View File
@@ -9,6 +9,7 @@ on:
- 'cypress/**'
- 'cypress.json'
- 'services/**'
- '!services/backend/src/rapodiff.js'
- 'docker-compose.ci.yml'
- 'docker-compose.test.yml'
- 'nginx.conf'
@@ -45,21 +46,7 @@ jobs:
'eslint --ext .jsx,.js services/frontend' \
'stylelint services/frontend/src/**/*.css'
lint_userservice:
name: 'Lint userservice'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 14
- name: 'Install dependencies'
run: npm ci && cd services/userservice && npm ci
- name: 'Run frontend linter'
run: npm run eslint services/userservice
# === Build images ===
build_backend:
name: 'Build backend'
runs-on: ubuntu-latest
@@ -116,50 +103,106 @@ jobs:
with:
path: /tmp/frontend.tar
build_userservice:
name: 'Build userservice'
build_and_push_anon_sis_db:
name: 'Build anon sis-db and push to toska hub if new migrations have been added'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: docker/setup-buildx-action@v1
- name: 'Build image and export it'
uses: docker/build-push-action@v2
- uses: dorny/paths-filter@v2
id: check_migrations
with:
build-args: |
SENTRY_RELEASE=${{ github.sha }}
SENTRY_ENVIRONMENT=staging
cache-from: |
type=registry,ref=toska/oodikone2-userservice:staging
type=registry,ref=toska/oodikone2-userservice:latest
cache-to: type=inline
context: services/userservice
push: false
tags: toska/oodikone2-userservice:staging
target: production
outputs: type=docker,dest=/tmp/userservice.tar
- name: 'Upload image for other jobs'
uses: actions/upload-artifact@v2
filters: |
migrations:
- 'updater/sis-updater-worker/src/db/migrations/**'
- '.github/workflows/test-oodikone.yaml'
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
path: /tmp/userservice.tar
registry: registry.toska.cs.helsinki.fi
username: ${{ secrets.TOSKAREGISTRY_USERNAME }}
password: ${{ secrets.TOSKAREGISTRY_PASSWORD }}
- name: 'Let sis-updater-worker run migrations, then push new version of image to toska hub'
if: steps.check_migrations.outputs.migrations == 'true'
run: |
docker-compose --file docker-compose.ci.yml up --detach sis-updater-worker
sleep 30 # wait for sis-updater-worker to start and run migrations
./anonyymioodi/commit_and_push_to_toska_hub.sh sis-db
# === Integration tests ===
#
run_userservice_integration_tests:
name: 'Run userservice integration tests'
build_and_push_anon_kone_db:
name: 'Build anon kone-db and push to toska hub if new migrations have been added'
needs:
- build_backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: 'Run tests included in docker build'
run: docker-compose --file docker-compose.test.yml up --build userservice-test
- uses: dorny/paths-filter@v2
id: check_migrations
with:
filters: |
migrations:
- 'services/backend/src/database/migrations_kone/**'
- '.github/workflows/test-oodikone.yaml'
- name: 'Download images'
uses: actions/download-artifact@v2
with:
path: /tmp/
- name: 'Load built backend image'
run: docker load --input /tmp/artifact/backend.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
registry: registry.toska.cs.helsinki.fi
username: ${{ secrets.TOSKAREGISTRY_USERNAME }}
password: ${{ secrets.TOSKAREGISTRY_PASSWORD }}
- name: 'Let backend run migrations, then push new version of image to toska hub'
if: steps.check_migrations.outputs.migrations == 'true'
run: |
docker-compose --file docker-compose.ci.yml up --detach backend
sleep 30 # wait for sis-updater-worker to start and run migrations
./anonyymioodi/commit_and_push_to_toska_hub.sh kone-db
build_and_push_anon_user_db:
name: 'Build anon user-db and push to toska hub if new migrations have been added'
needs:
- build_backend
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: check_migrations
with:
filters: |
migrations:
- 'services/backend/src/database/migrations_user/**'
- '.github/workflows/test-oodikone.yaml'
- name: 'Download images'
uses: actions/download-artifact@v2
with:
path: /tmp/
- name: 'Load built backend image'
run: docker load --input /tmp/artifact/backend.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
registry: registry.toska.cs.helsinki.fi
username: ${{ secrets.TOSKAREGISTRY_USERNAME }}
password: ${{ secrets.TOSKAREGISTRY_PASSWORD }}
- name: 'Let backend run migrations, then push new version of image to toska hub'
if: steps.check_migrations.outputs.migrations == 'true'
run: |
docker-compose --file docker-compose.ci.yml up --detach backend
sleep 30 # wait for sis-updater-worker to start and run migrations
./anonyymioodi/commit_and_push_to_toska_hub.sh user-db
# === End-to-end tests ===
test_course_statistics:
name: 'Test course statistics'
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -171,7 +214,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -202,7 +244,9 @@ jobs:
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -214,7 +258,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -245,7 +288,9 @@ jobs:
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -257,7 +302,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -288,7 +332,9 @@ jobs:
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -300,7 +346,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -331,7 +376,9 @@ jobs:
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -343,7 +390,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -374,7 +420,9 @@ jobs:
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -386,7 +434,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -417,7 +464,9 @@ jobs:
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -429,7 +478,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -464,7 +512,9 @@ jobs:
needs:
- build_backend
- build_frontend
- build_userservice
- build_and_push_anon_sis_db
- build_and_push_anon_kone_db
- build_and_push_anon_user_db
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
@@ -476,7 +526,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to toska docker registry'
uses: docker/login-action@v1
with:
@@ -504,8 +553,6 @@ jobs:
needs:
- lint_backend
- lint_frontend
- lint_userservice
- run_userservice_integration_tests
- test_course_statistics
- test_custom_population
- test_filters
@@ -524,7 +571,6 @@ jobs:
run: |
docker load --input /tmp/artifact/backend.tar
docker load --input /tmp/artifact/frontend.tar
docker load --input /tmp/artifact/userservice.tar
- name: 'Login to DockerHub'
uses: docker/login-action@v1
with:
@@ -551,7 +597,6 @@ jobs:
run: |
docker push toska/oodikone2-backend:staging
docker push toska/oodikone2-frontend:staging
docker push toska/oodikone2-userservice:staging
- name: 'Send deployment success notification to slack'
if: success()
uses: UniversityOfHelsinkiCS/slackbot-action@v1.4.2
@@ -574,8 +619,6 @@ jobs:
needs:
- lint_backend
- lint_frontend
- lint_userservice
- run_userservice_integration_tests
- test_course_statistics
- test_custom_population
- test_filters
+2 -2
View File
@@ -7,8 +7,8 @@ module.exports = {
'{services,updater}/**/*.{js,jsx}': files => `eslint --fix ${files.join(' ')}`,
'*.{js,json,md,yml,yaml,html}': files => `prettier --write ${files.join(' ')}`,
'*.css': files => `stylelint --fix ${files.join(' ')}`,
Dockerfile: files => `${dockerCmdBase} hadolint/hadolint:v2.7.0-alpine hadolint ${relativeFilePaths(files)}`,
'*.sh': files => `${dockerCmdBase} koalaman/shellcheck-alpine:v0.7.2 ${relativeFilePaths(files)} -x`,
Dockerfile: files => `${dockerCmdBase} hadolint/hadolint:v2.7.0 hadolint ${relativeFilePaths(files)}`,
'*.sh': files => `${dockerCmdBase} koalaman/shellcheck:v0.7.2 ${relativeFilePaths(files)} -x`,
'.github/workflows/*': files => `${dockerCmdBase} rhysd/actionlint:1.6.2 ${relativeFilePaths(files)}`,
'docker-compose*': files => {
const composeFiles = file => {
BIN
View File
Binary file not shown.

After

Width:  |  Height:  |  Size: 106 KiB

+13 -5
View File
@@ -8,7 +8,7 @@ To run Oodikone locally, you will need the following:
1. Applications:
- [Docker](https://docs.docker.com/install/) (version 20.10+),
- [Docker Compose](https://docs.docker.com/compose/install/)(version 0.29+) and
- [Docker Compose](https://docs.docker.com/compose/install/)(version 1.29+) and
- [npm](https://docs.npmjs.com/cli/v7) (version 7+)
2. Access to Toska Docker Hub,
3. For real data setup, access to Toskas production servers.
@@ -43,11 +43,15 @@ What different CLI options do:
- Cleans up any previous real data databases
- Downloads needed database dumps from production servers.
- Creates real data databases and populates them with downloaded dumps.
3. Reset sis-importer data
- Like option 2, but only for sis-importer database. Useful when developing updater microservice.
3. Reset single database
- Like option 2, but only for single database. Leaves other databases untouched.
## ⌨️ Development
### Architecture
![Oodikone architecture](Oodikone.png)
### Basics
The development environment is entirely configured in the `docker-compose.yml` file located in this repository. The file defines the services for oodikone's two main components: **oodikone** and **updater**.
@@ -79,7 +83,7 @@ It is recommended to spend some time to become familiar with `docker` and `docke
- `docker-compose ps`: view the containers in the running environment
- `docker-compose logs frontend`: print logs for just frontend
- `docker-compose logs --follow --tail 100 backend`: print last hundred rows of backend logs and begin to follow them in your terminal window
- `docker exec -it userservice sh`: open bash terminal inside userservice container
- `docker exec -it backend sh`: open bash terminal inside backend container
- `docker exec -it sis-db psql -U postgres sis-db-real`: open psql client to investigate sis real data database.
### User types for development
@@ -124,12 +128,16 @@ Continuous integration (CI) works with Github actions and is defined in workflow
### Modules are missing after updating package.json
You should always install the dependencies **inside** the container to have the application **inside** the container access them. This might be the case when someone else installs a new library and you only pull the changes in package.json. Use `docker exec -it <service> sh` to get inside the container and run `npm ci` to install modules.
You should always install the dependencies **inside** the container to have the application **inside** the container access them. Module might be missing for example when someone else installs a new library and you only pull the changes in package.json. Use `docker exec <service> npm ci` to install modules inside the container.
### I get the "You are not authorized to use Oodikone" -message when I try to work with anon-data
Make sure you have your VPN on
### I made a change to sis-db models aand created a migration, but tests are failing in CI!
Migrations are handled by sis-importer-worker, since oodikone is using only replica. Since CI is testing only services included in oodikone, your new changes aren't migrated and thus are failing. Open anonyymioodi-folder in this repo to find more about how to to update the anon sis-db.
### Everything is broken, can't get oodikone running, data is not there etc.
Just do clean install by launching cli with `npm cli` and running option 1: _Set up oodikone from scratch_.
+2
View File
@@ -0,0 +1,2 @@
*.sqz
+65
View File
@@ -0,0 +1,65 @@
# Anonyymioodi - anonymous database setup for oodikone
(name anonyymioodi for :culture: reasons)
This folder contains a guide and scripts to create anonymous database images for oodikone, mainly used for testing.
## How to create / modify database images
Creating / modifying images varies a bit depending on the db. Generally, to modify images, you can either use `psql` directly in docker by running `docker exec -it <dbname> psql -U postgres <dbname>` or start adminer with oodikone's docker-compose.
By default, previous db images from Toska Hub are used as a base. If needed, comment out Toska hub image and uncomment corresponding clean postgres image in docker-compose before running other steps.
See more details on how to create / modify databases below.
### Sis-importer-db
The following steps are for building a clean sis-importer-db image from scratch. If you want to just modify the existing image a bit, follow the steps defined for user-db / kone-db.
- See [sis-importer/importer-db-staging-sampletaker](https://github.com/UniversityOfHelsinkiCS/sis-importer/tree/master/importer-db-staging-sampletaker) and create `sis-importer-db.sqz` dump
- Move `sis-importer-db.sqz` to this folder
- Run `./create_container_from_dump.sh sis-importer-db`
- Enrich db with command in file `enrich_data.sql` either by piping command to container or by running command inside container.
### Sis-db:
The following steps are for building a clean sis-db image from scratch using oodikone's updater. If you want to just modify the existing image a bit, follow the steps defined for user-db / kone-db.
- Temporarily replace sis-db -service in oodikone's docker-compose.yml with sis-db -service from this repo's docker-compose.yml
- Ensure the newest sis-importer-db image is pulled from toska hub in oodikone repo
- Modify sis scheduler limit in config.js by setting: `module.exports.DEV_SCHEDULE_COUNT = null`
- Start updater, see oodikone readme for more info.
- Populate sis-db from sis-importer-db:
```
curl --request GET --url 'http://localhost:8082/v1/meta?token=dev' && \
curl --request GET --url 'http://localhost:8082/v1/programmes?token=dev' && \
curl --request GET --url 'http://localhost:8082/v1/students?token=dev'
```
(or run these from frontend. You might also want to follow sis-updater-workers logs to ensure things are running smoothly.)
- Clean up any extra stuff you don't want to keep in sis-db.
- Bonus: check that cypress tests run okay
### User-db / kone-db
- Temporarily replace the db service in oodikone's docker-compose.yml with the same db service from this folder's docker-compose.yml
- Ensure the newest user-db/kone-db image is pulled from the registry with `docker-compose pull`
- Modify db to wanted state. Tips:
- Run oodikone if you want to upgrade something from frontend (e.g. tags in kone-db, courses in sis-db etc.).
- Easy way to create new users to user-db is to modify dev user details in the frontend API config. A new user is created during login if the given uid is not present in user-db.
## Publishing the image
After completing the steps above and making sure your local version has the correct data, run `./commit_and_push_to_toska_hub.sh <dbname>` to publish the db image to Toska Hub.
## How to update Postgres versions
When Postgres is updated on the server, anon db images need to be updated to match server versions. Do following:
- Ensure you're using toska hub image in docker-compose and that you've pulled the newest image from toska hub: `docker-compose pull <dbname>`.
- Start database with docker-compose
- Create dump from database by running `docker exec -i <dbname> pg_dump -Fc -U postgres <dbname> > <dbname>.sqz`
- Close container with docker-compose down.
- Update the Postgres version in docker-compose.yml in this folder.
- Uncomment row with Postgres image and comment row with Toskahub image.
- Run `./create_container_from_dump.sh <dbname>`, followed by `./commit_and_push_to_toska_hub.sh <dbname>`
+48
View File
@@ -0,0 +1,48 @@
#!/usr/bin/env bash
# === Config ===
# Quit if failing
set -euo pipefail
# Print messages and logs that are not script output to stderr
msg() {
echo >&2 -e "${1-}"
}
# Some special types of messages with colours
successmsg() {
msg "${GREEN}$1${NOFORMAT}
"
}
errormsg() {
msg "${RED}$1${NOFORMAT}
"
}
infomsg() {
msg "${BLUE}$1${NOFORMAT}
"
}
warningmsg() {
msg "${ORANGE}$1${NOFORMAT}
"
}
# Setup colors for messages if running interactive shell
if [[ -t 2 ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE=''
fi
args=("$@")
if [[ ${#args[@]} -ne 1 ]]; then
errormsg "No database given, exiting"
exit 1
fi
infomsg "Committing and pushing to registry"
database=${args[0]}
docker commit "$database" "registry.toska.cs.helsinki.fi/$database"
docker push "registry.toska.cs.helsinki.fi/$database"
successmsg "Succesfully pushed"
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
# === Config ===
# Quit if failing
set -euo pipefail
# Print messages and logs that are not script output to stderr
msg() {
echo >&2 -e "${1-}"
}
# Some special types of messages with colours
successmsg() {
msg "${GREEN}$1${NOFORMAT}
"
}
errormsg() {
msg "${RED}$1${NOFORMAT}
"
}
infomsg() {
msg "${BLUE}$1${NOFORMAT}
"
}
warningmsg() {
msg "${ORANGE}$1${NOFORMAT}
"
}
# Setup colors for messages if running interactive shell
if [[ -t 2 ]] && [[ "${TERM-}" != "dumb" ]]; then
NOFORMAT='\033[0m' RED='\033[0;31m' GREEN='\033[0;32m' ORANGE='\033[0;33m' BLUE='\033[0;34m'
else
NOFORMAT='' RED='' GREEN='' ORANGE='' BLUE=''
fi
# === Create images ===
retry () {
sleep 5
for i in {1..60}; do
"$@" && break || warningmsg "Retry attempt $i failed, waiting..." && sleep 5;
done
}
args=("$@")
if [[ ${#args[@]} -ne 1 ]]; then
errormsg "No database given, exiting"
exit 1
fi
infomsg "Restoring PostgreSQL dumps from backups. This might take a while."
database=${args[0]}
docker-compose down --remove-orphans
docker-compose up -d "$database"
database_dump="$database.sqz"
infomsg "Attempting to restore database $database from dump $database_dump"
retry docker-compose exec "$database" pg_isready --dbname="$database"
docker exec -i "$database" /bin/bash -c "pg_restore --username=postgres \
--format=custom --dbname=$database --no-owner" < "$database_dump"
successmsg "Database $database succesfully created"
+50
View File
@@ -0,0 +1,50 @@
x-defaults: &defaults
restart: unless-stopped
services:
kone-db:
<<: *defaults
container_name: kone-db
environment:
PGDATA: /data
POSTGRES_DB: kone-db
POSTGRES_HOST_AUTH_METHOD: trust
image: registry.toska.cs.helsinki.fi/kone-db
# image: postgres:13.4-alpine
profiles:
- oodikone
sis-db:
<<: *defaults
container_name: sis-db
environment:
PGDATA: /data
POSTGRES_DB: sis-db
POSTGRES_HOST_AUTH_METHOD: trust
# image: registry.toska.cs.helsinki.fi/sis-db
image: postgres:13.2
shm_size: 2gb
sis-importer-db:
<<: *defaults
container_name: sis-importer-db
environment:
PGDATA: /data
POSTGRES_DB: sis-importer-db
POSTGRES_HOST_AUTH_METHOD: trust
# image: registry.toska.cs.helsinki.fi/sis-importer-db
image: postgres:13.1
profiles:
- updater
user-db:
<<: *defaults
container_name: user-db
environment:
PGDATA: /data
POSTGRES_DB: user-db
POSTGRES_HOST_AUTH_METHOD: trust
image: registry.toska.cs.helsinki.fi/user-db
# image: postgres:13.4-alpine
profiles:
- oodikone
+133
View File
@@ -0,0 +1,133 @@
-- add these to sis-importer db by running:
-- docker exec -i sis-importer-db psql -U postgres sis-importer-db < enrich_sampledata.sql
-- if you need to run updater for these students only, see studentnumberlist in the end
-- this file
-- Add admission types (valintaperusteet) to studyrights for some of the computer
-- science 2018-2019 population students. See person_ids / student_number below
-- (in case you need to update dumps).
-- TODO: this should be moved into the sampledata creator script in
-- importer repo, but since this file contains studentnumbers and person ids, it's
-- better to keep this here
-- KP (koepisteet)
-- hy-hlo-1412620 | 013683126
-- hy-hlo-1485246 | 014340523
-- hy-hlo-32230770 | 010589388
-- hy-hlo-35626233 | 010775888
-- hy-hlo-40150144 | 011065995
UPDATE studyrights
SET admission_type_urn = 'urn:code:admission-type:kp'
WHERE person_id IN (
'hy-hlo-1412620',
'hy-hlo-1485246',
'hy-hlo-32230770',
'hy-hlo-35626233',
'hy-hlo-40150144'
);
-- TV (todistusvalinta)
-- hy-hlo-45783433 | 011321150
-- hy-hlo-48537946 | 010764653
-- hy-hlo-49801905 | 011194400
-- hy-hlo-53321302 | 011338871
-- hy-hlo-51223300 | 013951984
-- hy-hlo-53310137 | 012520688
-- hy-hlo-53621583 | 011196796
-- hy-hlo-53863064 | 011736884
-- hy-hlo-57711592 | 010262566
-- hy-hlo-57732872 | 013670647
UPDATE studyrights
SET admission_type_urn = 'urn:code:admission-type:tv'
WHERE person_id IN (
'hy-hlo-45783433',
'hy-hlo-48537946',
'hy-hlo-49801905',
'hy-hlo-53321302',
'hy-hlo-51223300',
'hy-hlo-53310137',
'hy-hlo-53621583',
'hy-hlo-53863064',
'hy-hlo-57711592',
'hy-hlo-57732872'
);
-- YP:
-- hy-hlo-67768022 | 011952325
-- hy-hlo-73740025 | 011736606
-- hy-hlo-74780917 | 012775433
-- hy-hlo-79615371 | 014113941
-- hy-hlo-78118455 | 014300615
UPDATE studyrights
SET admission_type_urn = 'urn:code:admission-type:yp'
WHERE person_id IN (
'hy-hlo-67768022',
'hy-hlo-73740025',
'hy-hlo-74780917',
'hy-hlo-79615371',
'hy-hlo-78118455'
);
-- AV:
-- hy-hlo-78777265 | 010779392
-- hy-hlo-81909550 | 011894153
-- hy-hlo-84571890 | 013897158
-- hy-hlo-80330834 | 015085926
-- hy-hlo-84775722 | 011791272
UPDATE studyrights
SET admission_type_urn = 'urn:code:admission-type:av'
WHERE person_id IN (
'hy-hlo-78777265',
'hy-hlo-81909550',
'hy-hlo-84571890',
'hy-hlo-80330834',
'hy-hlo-84775722'
);
-- M:
-- hy-hlo-87439827 | 011928456
-- hy-hlo-96612371 | 014418361
-- hy-hlo-84840261 | 010975895
-- hy-hlo-90330681 | 010522688
-- hy-hlo-96594603 | 013951573
UPDATE studyrights
SET admission_type_urn = 'urn:code:admission-type:m'
WHERE person_id IN (
'hy-hlo-87439827',
'hy-hlo-96612371',
'hy-hlo-84840261',
'hy-hlo-90330681',
'hy-hlo-96594603'
);
-- all studentnumbers for running updater:
013683126
014340523
010589388
010775888
011065995
011321150
010764653
011194400
011338871
013951984
012520688
011196796
011736884
010262566
013670647
011952325
011736606
012775433
014113941
014300615
010779392
011894153
013897158
015085926
011791272
011928456
014418361
010975895
010522688
013951573
+111 -45
View File
@@ -20,15 +20,13 @@ describe('Course Statistics tests', () => {
cy.contains('.tabular.menu a', 'Table').click()
cy.contains('All')
cy.contains('.modeSelectorRow a', 'Attempts').click()
cy.contains('.modeSelectorRow a', 'Students').click()
cy.cs('viewMode-Attempts').click()
cy.cs('viewMode-Students').click()
cy.contains('.tabular.menu a', 'Pass rate chart').click()
cy.get('div.modeSelectorContainer').click()
cy.contains('svg', 'Pass rate chart')
cy.contains('.tabular.menu a', 'Grade distribution chart').click()
cy.get('div.modeSelectorContainer').click()
cy.contains('svg', 'Grades')
cy.contains('a', 'New query').click()
@@ -98,7 +96,7 @@ describe('Course Statistics tests', () => {
cy.get("input[placeholder='Search by entering a course name']").type('tietokantojen perusteet')
cy.contains('Tietokantojen perusteet')
cy.contains('Avoin yo: Tietokantojen perusteet')
cy.contains('Tietokantojen perusteet')
cy.contains('A581328')
cy.contains('AYTKT10004')
cy.contains('TKT10004, 581328')
@@ -107,46 +105,39 @@ describe('Course Statistics tests', () => {
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('Search for courses').should('not.exist')
cy.contains('TKT10004, 581328 Tietokantojen perusteet')
cy.contains('TKT10004, 581328, AYTKT10004, A581328 Tietokantojen perusteet')
cy.get('.right').click()
cy.contains('No results')
})
it('Provider organization toggle works', () => {
cy.url().should('include', '/coursestatistics')
cy.contains('Search for courses')
cy.get("input[placeholder='Search by entering a course name']").type('tietokantojen perusteet')
cy.contains('td', /^AYTKT10004/).click()
cy.contains('td', /^TKT10004/).click()
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('Search for courses').should('not.exist')
cy.contains('AYTKT10004 Avoin yo: Tietokantojen perusteet')
cy.contains('TKT10004, 581328, AYTKT10004, A581328 Tietokantojen perusteet')
cy.get('[data-cy=unify_radio_reqular]').click()
cy.contains('TKT10004, 581328 Tietokantojen perusteet')
})
it('Searching course by name displays right courses, 10 credit courses', () => {
cy.url().should('include', '/coursestatistics')
cy.contains('Search for courses')
cy.get("input[placeholder='Search by entering a course name']").type('tietorakenteet ja algoritmit')
cy.contains('Tietorakenteet ja algoritmit')
cy.contains('Avoin yo: Tietorakenteet ja algoritmit')
cy.contains('AYTKT20001')
cy.contains('TKT20001, 58131')
cy.contains('td', /^TKT20001/).click()
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('Search for courses').should('not.exist')
cy.contains('TKT20001, 58131 Tietorakenteet ja algoritmit')
cy.contains('TKT20001, 58131, AYTKT20001 Tietorakenteet ja algoritmit')
cy.get('.right').click()
cy.contains('No results')
cy.get("input[placeholder='Search by entering a course name']").type('tietorakenteet ja algoritmit')
cy.contains('td', /^AYTKT20001/).click()
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('Search for courses').should('not.exist')
cy.contains('AYTKT20001 Avoin yo: Tietorakenteet ja algoritmit')
cy.get('.right').click()
cy.contains('No results')
cy.get("input[name='unifyOpenUniCourses']").parent().click()
cy.get("input[placeholder='Search by entering a course name']").type('tietorakenteet ja algoritmit')
cy.contains('td', 'TKT20001, 58131, AYTKT20001').click()
@@ -161,12 +152,11 @@ describe('Course Statistics tests', () => {
cy.get("input[placeholder='Search by a course code']").type('TKT20003')
cy.contains('tr', 'TKT20003').click()
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('Käyttöjärjestelmät')
cy.contains('TKT20003')
cy.get(':nth-child(3) > :nth-child(1) > div > .item > .level').click()
cy.contains('Population of course Käyttöjärjestelmät 2019-2020')
cy.get(':nth-child(3) > :nth-child(2) .level').click()
cy.contains('Population of course Käyttöjärjestelmät 2019-2020 (open and normal')
cy.contains('TKT20003')
cy.contains('Students (127)').click()
@@ -176,21 +166,33 @@ describe('Course Statistics tests', () => {
it('Population of course shows grades for each student', () => {
cy.get("input[placeholder='Search by a course code']").type('TKT20001')
cy.contains(/^TKT20001$/).click()
cy.contains(/^TKT20001, AYTKT20001$/).click()
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('TKT20001, 58131 Tietorakenteet ja algoritmit')
cy.get(':nth-child(3) > :nth-child(1) > div > .item > .level').click()
cy.contains('Population of course Tietorakenteet ja algoritmit 2018-2019')
cy.contains('Students (197)').click()
cy.contains('TKT20001, 58131, AYTKT20001 Tietorakenteet ja algoritmit')
cy.get(':nth-child(3) > :nth-child(2) .level').click()
cy.contains('Population of course Tietorakenteet ja algoritmit 2018-2019 (open and normal)')
cy.contains('Students (204)').click()
cy.contains('td', '010262566').siblings().contains('4')
cy.contains('td', '010674989').siblings().contains('1')
})
it('Language distribution is correct', () => {
cy.get("input[placeholder='Search by a course code']").type('TKT20003')
cy.contains(/^TKT20003$/).click()
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('TKT20003, 582219 Käyttöjärjestelmät')
cy.get('[data-cy=unify_radio_reqular]').click()
cy.get(':nth-child(3) > :nth-child(2) .level').click()
cy.contains('Population of course Käyttöjärjestelmät 2019-2020')
cy.contains('Language distribution').click()
cy.contains('td', 'finnish').siblings().contains('122')
cy.contains('td', 'english').siblings().contains('5')
})
describe('When searching unified course stats', () => {
beforeEach(() => {
cy.url().should('include', '/coursestatistics')
cy.contains('Search for courses')
cy.get("input[name='unifyOpenUniCourses']").parent().click()
cy.get("input[placeholder='Search by a course code']").type('TKT10002')
cy.contains('td', 'TKT10002, AYTKT10002').click()
cy.contains('Fetch statistics').should('be.enabled').click()
@@ -202,18 +204,28 @@ describe('Course Statistics tests', () => {
const yearRange = { from: '2000-2001', to: '2020-2021' }
const attemptsTableContents = [
// [time, passed, failed, passrate]
['Total', 511, 486, 25],
['Total', null, 511, 486, 25],
]
const attemptsTableContentsOpen = [
// [time, passed, failed, passrate]
['Total', null, 175, 175, 0],
]
const attemptsTableContentsReqular = [
// [time, passed, failed, passrate]
['Total', null, 312, 298, 14],
]
const gradesTableContents = [
// [time, attempts, 0, 1, 2, 3, 4, 5, other passed]
['Total', 511, 25, 11, 17, 21, 59, 365, 13],
['2020-2021', 1, 0, 0, 0, 0, 0, 1, 0],
['2019-2020', 54, 4, 3, 1, 3, 4, 39, 0],
['2018-2019', 154, 7, 2, 6, 5, 15, 119, 0],
['2017-2018', 186, 9, 3, 5, 6, 16, 139, 8],
['2016-2017', 71, 2, 1, 2, 5, 13, 48, 0],
['2015-2016', 21, 1, 1, 1, 0, 7, 8, 3],
['Total', null, 511, 25, 11, 17, 21, 59, 365, 13],
['2020-2021', null, 1, 0, 0, 0, 0, 0, 1, 0],
['2019-2020', null, 54, 4, 3, 1, 3, 4, 39, 0],
['2018-2019', null, 154, 7, 2, 6, 5, 15, 119, 0],
['2017-2018', null, 186, 9, 3, 5, 6, 16, 139, 8],
['2016-2017', null, 71, 2, 1, 2, 5, 13, 48, 0],
['2015-2016', null, 21, 1, 1, 1, 0, 7, 8, 3],
]
it('shows stats', () => {
@@ -240,6 +252,7 @@ describe('Course Statistics tests', () => {
.eq(trIndex)
.within(() => {
values.forEach((value, tdIndex) => {
if (value === null) return
cy.get('td').eq(tdIndex).contains(value)
})
})
@@ -253,6 +266,7 @@ describe('Course Statistics tests', () => {
.eq(trIndex)
.within(() => {
values.forEach((value, tdIndex) => {
if (value === null) return
cy.get('td').eq(tdIndex).contains(value)
})
})
@@ -261,6 +275,44 @@ describe('Course Statistics tests', () => {
})
})
it('Toggling course provider changes stats correctly', () => {
cy.get('[data-cy=unify_radio_reqular]').click()
cy.get("div[name='toYear']").within(() => {
cy.get("div[role='option']").first().should('have.text', '2020-2021')
cy.contains("div[role='option']", yearRange.to).should('have.class', 'selected')
cy.get("div[role='option']").last().should('have.text', yearRange.from)
cy.get("div[role='option']").should('have.length', 21)
})
cy.contains('#CourseStatPanes a.item', 'Table').click()
cy.contains('#CourseStatPanes a.item', 'Attempts').click()
cy.get('#CourseStatPanes table>tbody').within(() => {
attemptsTableContentsReqular.forEach((values, trIndex) => {
cy.get('tr')
.eq(trIndex)
.within(() => {
values.forEach((value, tdIndex) => {
if (value === null) return
cy.get('td').eq(tdIndex).contains(value)
})
})
})
})
cy.get('[data-cy=unify_radio_open]').click()
cy.get('#CourseStatPanes table>tbody').within(() => {
attemptsTableContentsOpen.forEach((values, trIndex) => {
cy.get('tr')
.eq(trIndex)
.within(() => {
values.forEach((value, tdIndex) => {
if (value === null) return
cy.get('td').eq(tdIndex).contains(value)
})
})
})
})
cy.get('[data-cy=unify_radio_unify]').click()
})
it('after changing time range shows same stats', () => {
const newYearRange = { from: '2016-2017', to: '2019-2020' }
cy.get("div[name='fromYear']")
@@ -290,6 +342,15 @@ describe('Course Statistics tests', () => {
cy.contains('Show population').should('be.enabled')
})
})
it('If no data available, unify toggle is disabled', () => {
cy.get("input[placeholder='Search by a course code']").type('AYCSM14111')
cy.contains('AYCSM14111').click()
cy.contains('Fetch statistics').should('be.enabled').click()
cy.contains('AYCSM14111 Avoin yo: Full Stack -websovelluskehitys: React Native')
cy.get('[data-cy=unify_radio_reqular]').find('input').should('be.disabled')
cy.get('[data-cy=unify_radio_unify]').find('input').should('not.be.disabled')
})
})
it('Some features of Course Statistics are hidden for courseStatistics-users without other rights', () => {
@@ -302,13 +363,17 @@ describe('Course Statistics tests', () => {
cy.contains('Faculty statistics').should('not.exist')
cy.contains('Show population').should('not.exist')
cy.cs('viewMode-Attempts').click()
const attemptsTableContents = [
// [time, passed, failed, passrate]
['Total*', 288, 213, 75, '73.96 %'],
['2020-2021', '5 or less students', 'NA', 'NA', 'NA'],
['2019-2020', 164, 121, 43, '73.78 %'],
['2018-2019', 85, 60, 25, '70.59 %'],
['2017-2018', 39, 32, 7, '82.05 %'],
// ['Total', 288, 213, 75, '73.96 %'],
// ['2020-2021', '5 or less students', 'NA', 'NA', 'NA'],
['Total', null, 295, 216, 79, '73.22 %'],
['2020-2021', null, 5, 2, 3, '40.00 %'],
['2019-2020', null, 164, 121, 43, '73.78 %'],
['2018-2019', null, 85, 60, 25, '70.59 %'],
['2017-2018', null, 39, 32, 7, '82.05 %'],
]
cy.contains('#CourseStatPanes a.item', 'Attempts').click()
@@ -318,6 +383,7 @@ describe('Course Statistics tests', () => {
.eq(trIndex)
.within(() => {
values.forEach((value, tdIndex) => {
if (value === null) return
cy.get('td').eq(tdIndex).contains(value)
})
})
+211 -113
View File
@@ -9,30 +9,67 @@ const checkFilteringResult = studentCount => {
// Semantic UI doesn't allow injection of data-cy:s for single multiple dropdown selection.
// This function tries to click "x" on all selections inside dropdown matching given attribute
const clearSemanticUIMultipleDropDownSelection = dataCyAttribute => {
cy.cs(dataCyAttribute).find('i.delete').click()
cy.cs(dataCyAttribute).find('i.delete').click({ force: true })
cy.cs(dataCyAttribute).click()
}
const clearSingleDropdownSelection = dataCyAttribute => {
cy.cs(dataCyAttribute).find('i.clear').click()
cy.cs(dataCyAttribute).find('i.clear').click({ force: true })
}
const testRangeFilter = (parentEl, min, max, expected) => {
cy.cs(parentEl)
.cs('range-selector-min')
.find('input')
.invoke('val')
.then(initialMin => {
cy.cs(parentEl)
.cs('range-selector-max')
.find('input')
.invoke('val')
.then(initialMax => {
cy.cs(parentEl).cs('range-selector-min').find('input').type(`{selectall}{backspace}${min}`).blur()
cy.cs(parentEl).cs('range-selector-max').find('input').type(`{selectall}{backspace}${max}`).blur()
checkFilteringResult(expected)
cy.cs(parentEl).cs('range-selector-min').find('input').type(`{selectall}{backspace}${initialMin}`).blur()
cy.cs(parentEl).cs('range-selector-max').find('input').type(`{selectall}{backspace}${initialMax}`).blur()
})
})
}
// Helper tool to create pre and post steps for each filter step. Created to avoid copypasting clicking and checking
// to every it-function. Reason behind using test function wrapper is that Cypresses internal beforeEach / afterEach
// functions don't take any parameters and using global object for matching test step name seemed overcomplicated.
const createRunTestStepWithPreAndPostPartsFunction = amountWithoutFiltering => {
return (dataCyAttributeOfHeaderToClick, testStepFunctionToRun) => {
cy.cs(dataCyAttributeOfHeaderToClick).click()
checkFilteringResult(amountWithoutFiltering)
testStepFunctionToRun()
checkFilteringResult(amountWithoutFiltering)
cy.cs(dataCyAttributeOfHeaderToClick).click()
return (filterName, testStepFunctionToRun) => {
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') {
getHeader().click({ force: true })
}
checkFilteringResult(amountWithoutFiltering)
testStepFunctionToRun()
checkFilteringResult(amountWithoutFiltering)
if (open === 'false') {
getHeader().click({ force: true })
}
})
}
}
describe('Population Statistics', () => {
const pathToCSBach2018 =
'/populations?months=36&semesters=FALL&semesters=SPRING&studyRights={%22programme%22%3A%22KH50_005%22}&tag&year=2018'
const defaultAmountOfStudents = 148
const defaultAmountOfStudents = 159
const runTestStepWithPreAndPostParts = createRunTestStepWithPreAndPostPartsFunction(defaultAmountOfStudents)
before(() => {
@@ -41,91 +78,116 @@ describe('Population Statistics', () => {
it('Transfer filter is on not transferred by default', () => {
cy.contains('By default only students who have not transferred to this study programme are shown.')
cy.cs('transferredToProgrammeFilter-havenot').find('input').should('be.checked')
runTestStepWithPreAndPostParts('TransferredToProgramme', () => {
const card = cy.cs('TransferredToProgramme-filter-card')
card.get('[data-cy="option-havenot"] input').should('be.checked')
})
})
it('Programme defaults to "Active Study Right" mode', () => {
runTestStepWithPreAndPostParts('Programme', () => {
cy.cs('Programme-filter-mode-selector').children().eq(0).should('contain', 'Active Study Right')
})
})
it('Programme filter works', () => {
runTestStepWithPreAndPostParts('Programme', () => {
const card = cy.cs('Programme-filter-card')
const programmeDropdown = card.cs('Programme-filter-dropdown').selectFromDropdown(0)
checkFilteringResult(5)
programmeDropdown.get('i.delete').click()
})
})
// The test does not work since it tries to filter by "Ravitsemustiede"-studytrack when checking
// CS Bachelor students. Now that the irrelevant studytracks have been removed, the test fails.
// So fix this
it.skip('Study track filter works', () => {
runTestStepWithPreAndPostParts('StudyTrack', () => {
const card = cy.cs('StudyTrack-filter-card')
const programmeDropdown = card.cs('StudyTrack-filter-dropdown').selectFromDropdown(0)
checkFilteringResult(1)
programmeDropdown.get('i.delete').click()
})
})
it('Graduation filter works', () => {
runTestStepWithPreAndPostParts('graduatedFromProgrammeFilter-header', () => {
runTestStepWithPreAndPostParts('GraduatedFromProgramme', () => {
const getCard = () => cy.cs('GraduatedFromProgramme-filter-card')
const graduated = 11
cy.cs('graduatedFromProgrammeFilter-graduated-true').click()
getCard().cs('option-graduated-true').click()
checkFilteringResult(graduated)
cy.cs('graduatedFromProgrammeFilter-graduated-false').click()
getCard().cs('option-graduated-false').click()
checkFilteringResult(defaultAmountOfStudents - graduated)
cy.cs('graduatedFromProgrammeFilter-all').click()
getCard().cs('option-all').click()
})
})
it('Transfer filter works', () => {
runTestStepWithPreAndPostParts('transferredToProgrammeFilter-header', () => {
runTestStepWithPreAndPostParts('TransferredToProgramme', () => {
const transferred = 1
cy.cs('transferredToProgrammeFilter-have').click()
cy.cs('TransferredToProgramme-filter-card').cs('option-have').click()
checkFilteringResult(transferred)
cy.cs('transferredToProgrammeFilter-all').click()
cy.cs('TransferredToProgramme-filter-card').cs('option-all').click()
checkFilteringResult(defaultAmountOfStudents + transferred)
cy.cs('transferredToProgrammeFilter-havenot').click()
cy.cs('TransferredToProgramme-filter-card').cs('option-havenot').click()
})
})
it('Enrollment filter works', () => {
runTestStepWithPreAndPostParts('enrollmentStatusFilter-header', () => {
cy.selectFromDropdown('enrollmentStatusFilter-status', 0)
cy.selectFromDropdown('enrollmentStatusFilter-semesters', [0])
checkFilteringResult(137)
runTestStepWithPreAndPostParts('EnrollmentStatus', () => {
cy.cs('enrollmentStatusFilter-status').selectFromDropdown(0)
cy.cs('enrollmentStatusFilter-semesters').selectFromDropdown(0)
checkFilteringResult(148)
clearSemanticUIMultipleDropDownSelection('enrollmentStatusFilter-semesters')
})
})
it('Credit filter works', () => {
runTestStepWithPreAndPostParts('credit-filter-header', () => {
cy.cs('credit-filter-min').type('50')
cy.cs('credit-filter-max').type('150')
checkFilteringResult(116)
cy.cs('credit-filter-min').find('input').clear()
cy.cs('credit-filter-max').find('input').clear()
runTestStepWithPreAndPostParts('CreditsEarned', () => {
testRangeFilter('CreditsEarned-filter-card', 50, 150, 118)
})
})
it('Age filter works', () => {
runTestStepWithPreAndPostParts('ageFilter-header', () => {
cy.cs('ageFilter-min').type('20')
cy.cs('ageFilter-max').type('40')
checkFilteringResult(42)
cy.cs('ageFilter-min').find('input').clear()
cy.cs('ageFilter-max').find('input').clear()
runTestStepWithPreAndPostParts('Age', () => {
testRangeFilter('Age-filter-card', 20, 40, 49)
})
})
it('Gender filter works', () => {
runTestStepWithPreAndPostParts('genderFilter-header', () => {
cy.selectFromDropdown('genderFilter-dropdown', 0)
checkFilteringResult(36)
cy.selectFromDropdown('genderFilter-dropdown', 1)
checkFilteringResult(112)
cy.selectFromDropdown('genderFilter-dropdown', 2)
runTestStepWithPreAndPostParts('Gender', () => {
cy.cs('genderFilter-dropdown').selectFromDropdown(0)
checkFilteringResult(42)
cy.cs('genderFilter-dropdown').selectFromDropdown(1)
checkFilteringResult(117)
cy.cs('genderFilter-dropdown').selectFromDropdown(2)
checkFilteringResult(0)
cy.selectFromDropdown('genderFilter-dropdown', 3)
cy.cs('genderFilter-dropdown').selectFromDropdown(3)
checkFilteringResult(0)
clearSingleDropdownSelection('genderFilter-dropdown')
})
})
it('Starting year filter works', () => {
runTestStepWithPreAndPostParts('startYearAtUni-header', () => {
cy.selectFromDropdown('startYearAtUni-dropdown', 0)
runTestStepWithPreAndPostParts('StartYearAtUni', () => {
cy.cs('startYearAtUni-dropdown').selectFromDropdown(0)
checkFilteringResult(1)
clearSemanticUIMultipleDropDownSelection('startYearAtUni-dropdown')
cy.selectFromDropdown('startYearAtUni-dropdown', 14)
checkFilteringResult(121)
cy.cs('startYearAtUni-dropdown').selectFromDropdown(7)
checkFilteringResult(152)
clearSemanticUIMultipleDropDownSelection('startYearAtUni-dropdown')
})
})
// Return when we have +2020 population with admission types in data
it.skip('Admission type filter works', () => {
runTestStepWithPreAndPostParts('admissionTypeFilter-header', () => {
cy.selectFromDropdown('admissionTypeFilter-dropdown', 0)
runTestStepWithPreAndPostParts('AdmissionTypeFilter', () => {
cy.cs('admissionTypeFilter-dropdown').selectFromDropdown(0)
checkFilteringResult(5)
cy.selectFromDropdown('admissionTypeFilter-dropdown', 2)
cy.cs('admissionTypeFilter-dropdown').selectFromDropdown(2)
checkFilteringResult(10)
clearSingleDropdownSelection('admissionTypeFilter-dropdown')
})
@@ -135,31 +197,28 @@ describe('Population Statistics', () => {
it.skip('Courses filter works', () => {
// courses takes some time to load, wait for it to complete
cy.wait(10000)
runTestStepWithPreAndPostParts('courseFilter-header', () => {
runTestStepWithPreAndPostParts('Courses', () => {
cy.cs('courseFilter-course-dropdown').click()
const courses = ['TKT20001', 'MAT11002']
cy.cs('courseFilter-course-dropdown').click().contains(courses[0]).click()
checkFilteringResult(140)
cy.selectFromDropdown(`courseFilter-${courses[0]}-dropdown`, 1)
cy.cs(`courseFilter-${courses[0]}-dropdown`).selectFromDropdown(1)
checkFilteringResult(131)
cy.cs('courseFilter-course-dropdown').click().contains(courses[1]).click()
checkFilteringResult(56)
cy.selectFromDropdown(`courseFilter-${courses[1]}-dropdown`, 2)
cy.cs(`courseFilter-${courses[1]}-dropdown`).selectFromDropdown(2)
checkFilteringResult(2)
courses.forEach(course => cy.cs(`courseFilter-${course}-clear`).click())
})
})
it('Filter combinations work', () => {
runTestStepWithPreAndPostParts('graduatedFromProgrammeFilter-header', () => {
runTestStepWithPreAndPostParts('ageFilter-header', () => {
cy.cs('graduatedFromProgrammeFilter-graduated-true').click()
cy.cs('ageFilter-min').type('20')
cy.cs('ageFilter-max').type('30')
checkFilteringResult(11)
cy.cs('ageFilter-min').find('input').clear()
cy.cs('ageFilter-max').find('input').clear()
cy.cs('graduatedFromProgrammeFilter-all').click()
runTestStepWithPreAndPostParts('GraduatedFromProgramme', () => {
runTestStepWithPreAndPostParts('Age', () => {
const getCard = () => cy.cs('GraduatedFromProgramme-filter-card')
getCard().cs('option-graduated-true').click()
testRangeFilter('Age-filter-card', 20, 30, 11)
getCard().cs('option-all').click()
})
})
})
@@ -167,7 +226,7 @@ describe('Population Statistics', () => {
describe('Course Statistics', () => {
const pathToDSAndAlgoSpring2019 =
'/coursepopulation?coursecodes=%5B%22TKT20001%22%2C%2258131%22%5D&from=138&separate=true&to=138&years=Kev%C3%A4t%202019'
'/coursepopulation?coursecodes=%5B%22TKT20001%22%2C%2258131%22%5D&from=138&separate=true&to=138&years=Kev%C3%A4t%202019&unifyCourses=unifyStats'
const defaultAmountOfStudents = 118
const runTestStepWithPreAndPostParts = createRunTestStepWithPreAndPostPartsFunction(defaultAmountOfStudents)
@@ -176,7 +235,7 @@ describe('Course Statistics', () => {
})
it('Grade filter works', () => {
runTestStepWithPreAndPostParts('gradeFilter-header', () => {
runTestStepWithPreAndPostParts('Grade', () => {
cy.cs('gradeFilter-5').click()
checkFilteringResult(20)
cy.cs('gradeFilter-3').click()
@@ -186,50 +245,69 @@ describe('Course Statistics', () => {
})
})
it('Programme defaults to "Attainment" mode', () => {
runTestStepWithPreAndPostParts('Programme', () => {
cy.cs('Programme-filter-mode-selector').children().eq(0).should('contain', 'Attainment')
})
})
it('Programme filter works', () => {
runTestStepWithPreAndPostParts('Programme', () => {
const card = cy.cs('Programme-filter-card')
const programmeDropdown = card.cs('Programme-filter-dropdown').selectFromDropdown(1)
checkFilteringResult(116)
programmeDropdown.get('i.delete').click()
})
})
// The test does not work since it tries to filter by "Ravitsemustiede"-studytrack when checking
// CS Bachelor students. Now that the irrelevant studytracks have been removed, the test fails.
// So fix this
it.skip('Study track filter works', () => {
runTestStepWithPreAndPostParts('StudyTrack', () => {
const card = cy.cs('StudyTrack-filter-card')
const programmeDropdown = card.cs('StudyTrack-filter-dropdown').selectFromDropdown(0)
checkFilteringResult(1)
programmeDropdown.get('i.delete').click()
})
})
it('Age filter works', () => {
runTestStepWithPreAndPostParts('ageFilter-header', () => {
cy.cs('ageFilter-min').type('20')
cy.cs('ageFilter-max').type('40')
checkFilteringResult(32)
cy.cs('ageFilter-min').find('input').clear()
cy.cs('ageFilter-max').find('input').clear()
runTestStepWithPreAndPostParts('Age', () => {
testRangeFilter('Age-filter-card', 20, 40, 35)
})
})
it('Gender filter works', () => {
runTestStepWithPreAndPostParts('genderFilter-header', () => {
cy.selectFromDropdown('genderFilter-dropdown', 0)
runTestStepWithPreAndPostParts('Gender', () => {
cy.cs('genderFilter-dropdown').selectFromDropdown(0)
checkFilteringResult(27)
cy.selectFromDropdown('genderFilter-dropdown', 1)
cy.cs('genderFilter-dropdown').selectFromDropdown(1)
checkFilteringResult(91)
cy.selectFromDropdown('genderFilter-dropdown', 2)
cy.cs('genderFilter-dropdown').selectFromDropdown(2)
checkFilteringResult(0)
cy.selectFromDropdown('genderFilter-dropdown', 3)
cy.cs('genderFilter-dropdown').selectFromDropdown(3)
checkFilteringResult(0)
clearSingleDropdownSelection('genderFilter-dropdown')
})
})
it('Starting year filter works', () => {
runTestStepWithPreAndPostParts('startYearAtUni-header', () => {
cy.selectFromDropdown('startYearAtUni-dropdown', [0])
runTestStepWithPreAndPostParts('StartYearAtUni', () => {
cy.cs('startYearAtUni-dropdown').selectFromDropdown([0])
checkFilteringResult(1)
clearSemanticUIMultipleDropDownSelection('startYearAtUni-dropdown')
cy.selectFromDropdown('startYearAtUni-dropdown', 12)
checkFilteringResult(29)
cy.cs('startYearAtUni-dropdown').selectFromDropdown(3)
checkFilteringResult(84)
clearSemanticUIMultipleDropDownSelection('startYearAtUni-dropdown')
})
})
it('Filter combinations work', () => {
runTestStepWithPreAndPostParts('gradeFilter-header', () => {
runTestStepWithPreAndPostParts('ageFilter-header', () => {
runTestStepWithPreAndPostParts('Grade', () => {
runTestStepWithPreAndPostParts('Age', () => {
cy.cs('gradeFilter-3').click()
cy.cs('ageFilter-min').type('20')
cy.cs('ageFilter-max').type('30')
checkFilteringResult(1)
cy.cs('ageFilter-min').find('input').clear()
cy.cs('ageFilter-max').find('input').clear()
testRangeFilter('Age-filter-card', 20, 30, 1)
cy.cs('gradeFilter-3').click()
})
})
@@ -245,51 +323,71 @@ describe('Custom Population Statistics', () => {
cy.fixture('customPopulations').then(({ studentNumbersForCSStudentsSet1, studentNumbersForCSStudentsSet2 }) => {
const students = [...studentNumbersForCSStudentsSet1, ...studentNumbersForCSStudentsSet2]
runTestStepWithPreAndPostParts = createRunTestStepWithPreAndPostPartsFunction(students.length)
cy.cs('student-no-input').click().type(students.join('/n'))
cy.cs('student-no-input').click().type(students.join('\n'))
cy.wait(10000)
})
cy.cs('search-button').click()
})
it('Age filter works', () => {
runTestStepWithPreAndPostParts('ageFilter-header', () => {
cy.cs('ageFilter-min').type('20')
cy.cs('ageFilter-max').type('30')
checkFilteringResult(1)
cy.cs('ageFilter-min').find('input').clear()
cy.cs('ageFilter-max').find('input').clear()
runTestStepWithPreAndPostParts('Age', () => {
testRangeFilter('Age-filter-card', 20, 30, 1)
})
})
it('Programme defaults to "Active Study Right" mode', () => {
runTestStepWithPreAndPostParts('Programme', () => {
cy.cs('Programme-filter-mode-selector').children().eq(0).should('contain', 'Active Study Right')
})
})
it('Programme filter works', () => {
runTestStepWithPreAndPostParts('Programme', () => {
const card = cy.cs('Programme-filter-card')
const programmeDropdown = card.cs('Programme-filter-dropdown').selectFromDropdown(0)
checkFilteringResult(5)
programmeDropdown.get('i.delete').click()
})
})
it('Gender filter works', () => {
cy.cs('genderFilter-header').click()
cy.selectFromDropdown('genderFilter-dropdown', 0)
checkFilteringResult(3)
cy.selectFromDropdown('genderFilter-dropdown', 1)
checkFilteringResult(2)
cy.selectFromDropdown('genderFilter-dropdown', 2)
checkFilteringResult(0)
clearSingleDropdownSelection('genderFilter-dropdown')
checkFilteringResult(5, true)
})
it('Starting year filter works', () => {
runTestStepWithPreAndPostParts('startYearAtUni-header', () => {
cy.selectFromDropdown('startYearAtUni-dropdown', [0])
checkFilteringResult(1)
clearSemanticUIMultipleDropDownSelection('startYearAtUni-dropdown')
runTestStepWithPreAndPostParts('Gender', () => {
cy.cs('genderFilter-dropdown').selectFromDropdown(0)
checkFilteringResult(3)
cy.cs('genderFilter-dropdown').selectFromDropdown(1)
checkFilteringResult(2)
cy.cs('genderFilter-dropdown').selectFromDropdown(2)
checkFilteringResult(0)
clearSingleDropdownSelection('genderFilter-dropdown')
checkFilteringResult(5, true)
})
})
it('Courses filter works', () => {
runTestStepWithPreAndPostParts('courseFilter-header', () => {
it('Starting year filter works', () => {
runTestStepWithPreAndPostParts('StartYearAtUni', () => {
cy.cs('startYearAtUni-dropdown').selectFromDropdown([0])
checkFilteringResult(1)
clearSemanticUIMultipleDropDownSelection('startYearAtUni-dropdown')
cy.cs('startYearAtUni-dropdown').click()
})
})
it.skip('Courses filter works', () => {
runTestStepWithPreAndPostParts('Courses', () => {
const courses = ['MAT11001', 'TKT20004']
cy.cs('courseFilter-course-dropdown').click().contains(courses[0]).click()
cy.cs('courseFilter-course-dropdown')
.click()
.contains(courses[0] + ' ')
.click()
checkFilteringResult(5)
cy.selectFromDropdown(`courseFilter-${courses[0]}-dropdown`, 1)
cy.cs(`courseFilter-${courses[0]}-dropdown`).selectFromDropdown(1)
checkFilteringResult(5)
cy.cs('courseFilter-course-dropdown').click().contains(courses[1]).click()
cy.cs('courseFilter-course-dropdown')
.click()
.contains(courses[1] + ' ')
.click()
checkFilteringResult(3)
cy.selectFromDropdown(`courseFilter-${courses[1]}-dropdown`, 3)
cy.cs(`courseFilter-${courses[1]}-dropdown`).selectFromDropdown(3)
checkFilteringResult(1)
courses.forEach(course => cy.cs(`courseFilter-${course}-clear`).click())
})
+27 -27
View File
@@ -3,15 +3,15 @@
const moment = require('moment')
const _ = require('lodash')
const setPopStatsUntil = (until, includeSettings = []) => {
cy.contains('Advanced settings').siblings().get('[data-cy=advanced-toggle]').click()
includeSettings.forEach(setting => {
cy.contains('Advanced settings').parent().siblings().contains(setting).click()
})
cy.get('.adv-stats-until > .form-control').click().clear().type(until)
cy.contains('Fetch population with new settings').click()
cy.contains('Advanced settings')
}
// const setPopStatsUntil = (until, includeSettings = []) => {
// cy.contains('Advanced settings').siblings().get('[data-cy=advanced-toggle]').click()
// includeSettings.forEach(setting => {
// cy.contains('Advanced settings').parent().siblings().contains(setting).click()
// })
// cy.get('.adv-stats-until > .form-control').click().clear().type(until)
// cy.contains('Fetch population with new settings').click()
// cy.contains('Advanced settings')
// }
describe('Population Statistics tests', () => {
const pathToCSBach2017 =
@@ -65,13 +65,14 @@ describe('Population Statistics tests', () => {
it('Population statistics is usable on general level', () => {
cy.visit(pathToCSBach2017)
cy.cs('filtered-students')
setPopStatsUntil('toukokuu 2020')
// This advanced settings does not work correctly
// see https://github.com/UniversityOfHelsinkiCS/oodikone/issues/3552
// setPopStatsUntil('toukokuu 2020')
cy.get('.card').within(() => {
cy.contains('Tietojenkäsittelytieteen kandiohjelma')
cy.contains('Sample size: 149 students')
cy.contains('Sample size: 170 students')
cy.contains('Excludes exchange students')
cy.contains("Excludes students who haven't enrolled present nor absent")
cy.contains('Excludes students with non-degree study right')
cy.contains('Excludes students who have transferred out of this programme')
})
@@ -80,17 +81,17 @@ describe('Population Statistics tests', () => {
cy.intercept('/api/v3/courseyearlystats**').as('coursePage')
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(10000) // a bit hacky way, wait until ui is ready
cy.get('[data-cy=expand-TKT1]').click()
cy.get('[data-cy=coursestats-link-TKT10002]').click()
cy.wait(25000) // a bit hacky way, wait until ui is ready
cy.get('[data-cy=toggle-group-module-TKT1]').click()
cy.contains('td', 'TKT10002').siblings().find('i.level.up').click()
cy.wait('@coursePage')
cy.url().should('include', '/coursestatistics')
cy.contains('TKT10002, 581325 Ohjelmoinnin perusteet')
cy.contains('TKT10002, 581325, AYTKT10002, A581325 Ohjelmoinnin perusteet')
})
it("Empty 'tags' tab has a link to the page where tags can be created", () => {
cy.visit(pathToCSBach2017)
cy.contains('Students (149)').click()
cy.contains('Students (170)').click()
cy.get('[data-cy=student-table-tabs]').contains('Tags').click()
cy.contains('No tags defined. You can define them here.').find('a').click()
cy.contains('Tags').click()
@@ -119,12 +120,11 @@ describe('Population Statistics tests', () => {
cy.contains('Fetch population').click()
cy.contains('Credit accumulation (for 149 students)')
cy.contains('Credit accumulation (for 170 students)')
// spring + fall and include cancelled
// spring + fall
cy.get('[data-cy=advanced-toggle]').click()
cy.cs('toggle-spring').click()
cy.cs('toggle-cancelled').click()
cy.contains('Fetch population').click()
cy.contains('Credit accumulation (for 170 students)')
@@ -140,7 +140,7 @@ describe('Population Statistics tests', () => {
const limits = [1, ..._.range(1, 4).map(p => Math.ceil(months * ((p * 15) / 12))), null]
const ranges = _.range(1, limits.length).map(i => _.slice(limits, i - 1, i + 1))
cy.get('.credits-gained-table').should('contain', '(n=149)')
cy.get('.credits-gained-table').should('contain', '(n=170)')
for (const [start, end] of ranges) {
let value = 'credits'
@@ -159,7 +159,7 @@ describe('Population Statistics tests', () => {
cy.get("[data-cy='credits-gained-table-body'] td:nth-child(3)").then($els => {
const sum = [...$els].map($el => parseInt($el.innerText)).reduce((a, b) => a + b, 0)
expect(sum).to.equal(149)
expect(sum).to.equal(170)
})
cy.get("[data-cy='credits-gained-table-Ei valintatapaa']").should('not.exist')
@@ -182,10 +182,10 @@ describe('Population Statistics tests', () => {
cy.contains('Credit statistics').click({ force: true })
cy.get("[data-cy='credit-stats-tab'] > .menu > :nth-child(2)").click()
cy.get("[data-cy='credit-stats-table-name-header']").should('contain', 'Statistic for n = 149 Students')
cy.get("[data-cy='credit-stats-mean']").should('contain', '123.89')
cy.get("[data-cy='credit-stats-stdev']").should('contain', '61.32')
cy.get("[data-cy='credit-stats-min']").should('contain', '11')
cy.get("[data-cy='credit-stats-table-name-header']").should('contain', 'Statistic for n = 170 Students')
cy.get("[data-cy='credit-stats-mean']").should('contain', '114.75')
cy.get("[data-cy='credit-stats-stdev']").should('contain', '65.53')
cy.get("[data-cy='credit-stats-min']").should('contain', '5')
cy.get("[data-cy='credit-stats-max']").should('contain', '314')
})
})
@@ -198,7 +198,7 @@ describe('Population Statistics tests', () => {
const existing = '010113437'
const nonExisting = '66666666'
cy.visit(pathToCSBach2017)
cy.contains('Students (149)').click()
cy.contains('Students (170)').click()
cy.contains(existing)
cy.contains(nonExisting).should('not.exist')
cy.contains('button', 'Check studentnumbers').click()
+17 -7
View File
@@ -13,7 +13,7 @@ describe('Student Statistics tests', () => {
studentnumber: '010654019',
}
it.only('Student statistics search form is usable', () => {
it('Student statistics search form is usable', () => {
cy.contains('Show student names')
cy.url().should('include', '/students')
cy.get('.prompt').type(student.lastname)
@@ -37,8 +37,8 @@ describe('Student Statistics tests', () => {
it('Can get student specific page by clicking student', () => {
cy.url().should('include', '/students')
cy.get('.prompt').type(student.studentnumber)
cy.contains(student.studentnumber).click()
cy.contains('Started: 01.08.2011')
cy.contains('td a', student.studentnumber).click()
cy.contains('Started: 01.08.2017')
cy.contains('Tietojenkäsittelytieteen kandiohjelma (01.08.2017 - 01.08.2025')
cy.contains(student.lastname).should('not.exist')
cy.contains(student.firstnames).should('not.exist')
@@ -54,7 +54,7 @@ describe('Student Statistics tests', () => {
it('Can get back to search menu', () => {
cy.get('.prompt').type(student.studentnumber)
cy.contains(student.studentnumber).click()
cy.contains('td a', student.studentnumber).click()
cy.get('.remove').click()
cy.contains('Student number').should('not.exist')
cy.contains('Credits').should('not.exist')
@@ -62,7 +62,7 @@ describe('Student Statistics tests', () => {
it('Can jump to course', () => {
cy.get('.prompt').type(student.studentnumber)
cy.contains(student.studentnumber).click()
cy.contains('td a', student.studentnumber).click()
cy.contains('Introduction to Machine Learning (DATA11002)')
.siblings()
.within(() => {
@@ -80,11 +80,21 @@ describe('Student Statistics tests', () => {
cy.contains('Student number').should('not.exist')
})
it.only('Can jump to population page', () => {
it('Can jump to population page', () => {
cy.get('.prompt').type(student.studentnumber)
cy.contains(student.studentnumber).click()
cy.contains('td a', student.studentnumber).click()
cy.get('i.level.up.alternate.icon').eq(0).click()
cy.contains('Population statistics')
cy.contains('Tietojenkäsittelytieteen kandiohjelma')
})
})
// Use admin to see all students
describe('Testing with admin rights', () => {
it('Does not crash if student has no studyright or courses', () => {
const studentNumber = '011825096'
cy.init(`/students/${studentNumber}`, 'admin') // use admin to see all students
cy.contains('Started: Unavailable')
cy.contains('Credits: 0')
})
})
+345 -141
View File
@@ -1,172 +1,376 @@
/// <reference types="Cypress" />
const deleteTag = name => {
cy.contains(name).siblings().contains('Delete').click()
cy.contains('td', name).siblings().contains('Delete').click()
cy.contains('Are you sure you want to delete tag')
cy.contains('Confirm').click()
cy.contains(name).should('not.exist')
cy.contains('td', name).should('not.exist')
}
const getEmptyYears = isAcademicYear => {
const thisYear = new Date().getFullYear()
const years = []
for (let year = thisYear; year > 2021; year--) {
if (isAcademicYear) {
years.push(`${year} - ${year + 1}`)
} else {
years.push(year)
}
}
return years
}
describe('Studyprogramme overview', () => {
// check is used by couple of tests
const checkProgressAndProductivity = (user = 'basic') => {
// Column amount depends on user. Note that with dev user, you'll see even more
// stuff than with admin or basic.
const CSBachPopulationProgress2018ForAdmin = [
'162',
'44 (27%)',
'118 (72%)',
'161 (99%)',
'161',
'1',
'11',
'11',
'152',
'125',
'78',
'42',
'16',
]
const CSBachPopulationProgress2018ForBasic = [
'162',
'44 (27%)',
'118 (72%)',
'161 (99%)',
'161',
'1',
'11',
'11',
'152',
'125',
'78',
'42',
'16',
] // cancelled and transferred from are missing
const population = user === 'basic' ? CSBachPopulationProgress2018ForBasic : CSBachPopulationProgress2018ForAdmin
cy.contains('Population progress')
cy.contains('Yearly productivity')
cy.contains('2018-2019')
.siblings()
.each((elem, index) => {
cy.wrap(elem).contains(population[index])
})
const populationproductivity2019 = ['7388.0', '17', '7388.00', '0.00', '349.00']
cy.get('table')
.eq(1)
.contains('2019')
.siblings()
.each((elem, index) => {
cy.wrap(elem).contains(populationproductivity2019[index])
})
}
describe('when opening programme page with admin user', () => {
/* Basic information overview -tests*/
describe('Basic information -view works for basic user', () => {
beforeEach(() => {
cy.init('/study-programme/KH50_005', 'admin')
cy.init('/study-programme')
cy.viewport(1536, 960)
})
it('progress should not be recalculating when opened for the first time', () => {
cy.contains('Recalculating').should('not.exist')
cy.contains('Last updated').should('exist')
// If the backend breaks for one of the sections, the section header is not rendered and this will fail
it('Basic information -tab loads', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('[data-cy=Section-StudentsOfTheStudyprogramme]')
cy.get('[data-cy=Section-CreditsProducedByTheStudyprogramme]')
cy.get('[data-cy=Section-GraduatedAndThesisWritersOfTheProgramme]')
cy.get('[data-cy=Section-ProgrammesBeforeOrAfter]')
cy.get('[data-cy=Section-AverageGraduationTimes]')
})
// Following vars are used to compare values before and after stats calculation
// Taken from https://docs.cypress.io/api/commands/should#Compare-text-values-of-two-elements
const normalizeText = s => s.replace(/\s/g, '').toLowerCase()
let originalProgressCalculatedText
let originalProductivityCalculatedText
const doRecalculation = () => {
// Wait for page to load before clicking to admin page, TODO: change to cy.intercept
cy.wait(5000)
cy.get('.attached').contains('Admin').click()
cy.contains('recalculate productivity').click()
cy.contains('recalculate throughput').click()
cy.get('.attached').contains('Overview').click() // TODO: add data-cy tags for tabs
// Wait to "recalculating" to disappear, TODO: change this to cy.intercept
cy.wait(5000)
cy.reload()
}
it('Basic information contains correct students', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
const years = getEmptyYears()
const tableContents = [
// [Year, Started, Graduated, Transferred Away, Transferred to]
...years.map(year => [year, 0, 0, 0, 0]),
[2021, 0, 0, 1, 0],
[2020, 12, 36, 3, 2],
[2019, 87, 17, 0, 1],
[2018, 161, 1, 0, 0],
[2017, 171, 0, 0, 0],
]
it('renders progress and productivity tables with calculated status', () => {
doRecalculation()
// check contains also study programme options for admin
cy.contains('Study programme options')
cy.get('table').should('have.length', 3)
checkProgressAndProductivity('admin')
// Grab update dates to be compared later
cy.cs('throughputUpdateStatus')
.invoke('text')
.then(text => {
originalProgressCalculatedText = normalizeText(text)
expect(originalProgressCalculatedText).not.to.contain('recalculating')
expect(originalProgressCalculatedText).not.to.contain('refresh')
})
cy.cs('productivityUpdateStatus')
.invoke('text')
.then(text => {
originalProductivityCalculatedText = normalizeText(text)
expect(originalProductivityCalculatedText).not.to.contain('recalculating')
expect(originalProgressCalculatedText).not.to.contain('refresh')
})
cy.checkTableStats(tableContents, 'StudentsOfTheStudyprogramme')
})
it('renders progress and productivity tables with calculated status after recalculating stats again', () => {
doRecalculation()
checkProgressAndProductivity('admin')
it('Basic information contains correct credits', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
const years = getEmptyYears()
const tableContents = [
// [Year, Total, Major credits, Non-major credits, Transferred credits]
...years.map(year => [year, 0, 0, 0, 0]),
[2021, 0, 0, 0, 0],
[2020, 4928, 548, 4213, 167],
[2019, 7737, 1644, 5744, 349],
[2018, 6730, 1820, 4638, 272],
[2017, 2900, 788, 1724, 388],
]
// Check new calculation statuses are reported
const newProgressCalculatedTextElement = cy.cs('throughputUpdateStatus').invoke('text')
const newProductivityCalculatedTextElement = cy.cs('productivityUpdateStatus').invoke('text')
cy.checkTableStats(tableContents, 'CreditsProducedByTheStudyprogramme')
})
newProgressCalculatedTextElement.should(text => {
const newProgressCalculatedText = normalizeText(text)
expect(newProgressCalculatedText).not.to.contain('recalculating')
expect(newProgressCalculatedText).not.to.contain('refresh')
expect(newProgressCalculatedText).not.to.contain(originalProgressCalculatedText)
})
it('Basic information contains correct thesis writers and graduates', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
const years = getEmptyYears()
const tableContents = [
// [Year, Graduated, Wrote thesis]
...years.map(year => [year, 0, 0]),
[2021, 0, 0],
[2020, 36, 35],
[2019, 17, 25],
[2018, 1, 5],
[2017, 0, 0],
]
newProductivityCalculatedTextElement.should(text => {
const newProductivityCalculatedText = normalizeText(text)
expect(newProductivityCalculatedText).not.to.contain('recalculating')
expect(newProductivityCalculatedText).not.to.contain('refresh')
expect(newProductivityCalculatedText).not.to.contain(originalProgressCalculatedText)
})
cy.checkTableStats(tableContents, 'GraduatedAndThesisWritersOfTheProgramme')
})
it.skip('Special studyrights can be excluded and basic data changes accordingly', () => {
cy.contains('a', 'Tietojenkäsittelytieteen maisteriohjelma').click()
cy.get('[data-cy=StudentToggle]').click()
const years = getEmptyYears()
const studentTableContents = [
// [Year, Started, Graduated]
...years.map(year => [year, 0, 0]),
[2021, 0, 0],
[2020, 22, 0],
[2019, 12, 0],
[2018, 0, 0],
[2017, 0, 0],
]
cy.checkTableStats(studentTableContents, 'StudentsOfTheStudyprogramme')
const creditTableContents = [
// [Year, Total, Major students credits, Transferred credits]
...years.map(year => [year, 0, 0, 0]),
[2021, 0, 0, 0],
[2020, 117.5, 0, 7.5],
[2019, 67, 0, 0],
[2018, 0, 0, 0],
[2017, 0, 0, 0],
]
cy.checkTableStats(creditTableContents, 'CreditsProducedByTheStudyprogramme')
const graduatedTableContents = [
// [Year, Graduated, Wrote thesis]
...years.map(year => [year, 0, 0]),
[2021, 0, 0],
[2020, 0, 0],
[2019, 0, 0],
[2018, 0, 0],
[2017, 0, 0],
]
cy.checkTableStats(graduatedTableContents, 'GraduatedAndThesisWritersOfTheProgramme')
cy.get('[data-cy=StudentToggle]').click()
})
it('Year can be changed to academic year, and data changes accordingly', () => {
cy.contains('a', 'Tietojenkäsittelytieteen maisteriohjelma').click()
cy.get('[data-cy=YearToggle]').click()
const isAcademicYear = true
const years = getEmptyYears(isAcademicYear)
const studentTableContents = [
// [Year, Started, Graduated, Transferred away, Transferred to]
...years.map(year => [year, 0, 0, 0, 0]),
['2021 - 2022', 0, 0, 0, 0],
['2020 - 2021', 5, 0, 0, 0],
['2019 - 2020', 27, 0, 0, 0],
['2018 - 2019', 4, 0, 0, 0],
['2017 - 2018', 0, 0, 0, 0],
]
cy.checkTableStats(studentTableContents, 'StudentsOfTheStudyprogramme')
const creditTableContents = [
// [Year, Total, Major students credits, Non-major students credits, Transferred credits]
...years.map(year => [year, 0, 0, 0, 0]),
['2021 - 2022', 0, 0, 0, 0],
['2020 - 2021', 0, 0, 0, 0],
['2019 - 2020', 338.5, 0, 331, 7.5],
['2018 - 2019', 173, 0, 173, 0],
['2017 - 2018', 42, 0, 42, 0],
]
cy.checkTableStats(creditTableContents, 'CreditsProducedByTheStudyprogramme')
cy.get('[data-cy=YearToggle]').click()
})
it('Basic information graphs render', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('[data-cy=Graph-StudentsOfTheStudyprogramme')
.should('contain', 'Started')
.should('contain', 'Graduated')
.should('contain', 'Transferred away')
cy.get('[data-cy=Graph-CreditsProducedByTheStudyprogramme')
.should('contain', 'Major students credits')
.should('contain', 'Non-major students credits')
.should('contain', 'Transferred credits')
.should('contain', 788)
.should('contain', 1820)
cy.get('[data-cy=Graph-GraduatedAndThesisWritersOfTheProgramme')
.should('contain', 'Graduated students')
.should('contain', 'Wrote thesis')
.should('contain', 1)
.should('contain', 5)
.should('contain', 17)
.should('contain', 25)
.should('contain', 36)
.should('contain', 35)
cy.get('[data-cy=Graph-2019-AverageGraduationTimes]')
.should('contain', '2019')
.should('contain', 'n = 17')
.should('contain', '23 kk')
cy.get('[data-cy=Graph-ProgrammesBeforeOrAfter')
.should('contain', 'Tietojenkäsittelytieteen maisteriohjelma')
.should('contain', 'Datatieteen maisteriohjelma')
.should('contain', 'Matematiikan ja tilastotieteen maisteriohjelma')
.should('contain', 1)
.should('contain', 4)
.should('contain', 13)
})
})
describe('when opening programme page with basic user', () => {
/* Studytrack overview -tests*/
describe('Studytrack overview works for basic user', () => {
beforeEach(() => {
cy.init('/study-programme/KH50_005')
cy.init('/study-programme')
})
it('renders progress and productivity tables with previosly calculated values', () => {
// check doesn't contain study programme options for admin
cy.contains('Study programme options').should('not.exist')
cy.get('table').should('have.length', 2)
checkProgressAndProductivity()
// If the backend breaks for one of the sections, the section header is not rendered and this will fail
it('Studytracks and student populations -tab loads', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('.attached').contains('Studytracks and student populations').click()
cy.get('[data-cy=Section-StudytrackOverview]')
cy.get('[data-cy=Section-StudytrackProgress]')
cy.get('[data-cy=Section-AverageGraduationTimes]')
})
it('can open Thesis page', () => {
cy.contains('Tietojenkäsittelytieteen kandiohjelma').click()
cy.contains('Thesis Courses').click()
cy.contains('Add thesis course').click()
cy.contains('No results')
it('Students of the studyprogramme are shown correctly', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('.attached').contains('Studytracks and student populations').click()
const tableContents = [
// [Year, All, Started studying, Currently enrolled, Absent, Cancelled, Graduated, Men, Women, Finnish]
[
'2020 - 2021',
12,
'100.0 %',
10,
'83.3 %',
0,
'0 %',
0,
'0 %',
0,
'0 %',
0,
'0 %',
10,
'83.3 %',
2,
'16.7 %',
12,
'100.0 %',
],
[
'2019 - 2020',
86,
'100.0 %',
86,
'100.0 %',
0,
'0 %',
0,
'0 %',
0,
'0 %',
1,
'1.2 %',
65,
'75.6 %',
21,
'24.4 %',
86,
'100.0 %',
],
[
'2018 - 2019',
162,
'100.0 %',
161,
'99.4 %',
0,
'0 %',
0,
'0 %',
0,
'0 %',
11,
'6.8 %',
118,
'72.8 %',
44,
'27.2 %',
161,
'99.4 %',
],
[
'2017 - 2018',
171,
'100.0 %',
171,
'100.0 %',
0,
'0 %',
0,
'0 %',
3,
'1.8 %',
42,
'24.6 %',
135,
'78.9 %',
36,
'21.1 %',
166,
'97.1 %',
],
[
'Total',
431,
'100.0 %',
431,
'100.0 %',
0,
'0 %',
0,
'0 %',
3,
'0.7 %',
54,
'12.5 %',
328,
'76.1 %',
103,
'23.9 %',
425,
'98.6 %',
],
]
cy.checkTableStats(tableContents, 'StudytrackOverview')
})
it('can move to Population statistics page by clickin', () => {
cy.get('i.level.up.alternate.icon').eq(0).click()
cy.contains('Students (10)')
it('Student progress data is shown correctly', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('.attached').contains('Studytracks and student populations').click()
const tableContents = [
['2020 - 2021', 12, 5, 2, 2, 0, 2, 0, 1],
['2019 - 2020', 86, 13, 15, 32, 11, 2, 0, 13],
['2018 - 2019', 162, 7, 16, 35, 33, 27, 18, 26],
['2017 - 2018', 171, 10, 22, 18, 22, 24, 27, 48],
['Total', 431, 35, 55, 87, 66, 55, 45, 88],
]
cy.checkTableStats(tableContents, 'StudytrackProgress')
})
it('Studytrack overview graphs render', () => {
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('.attached').contains('Studytracks and student populations').click()
cy.get('[data-cy=Graph-StudytrackProgress]')
.should('contain', 'Less than 30 credits')
.should('contain', '30-59 credits')
.should('contain', 'More than 180 credits')
.should('contain', '5.8%') // The percentage for less than 30 credits in 2017-2018, to check that the graph renders
.should('contain', '4.3%') // The percentage for less than 30 credits in 2018-2019
.should('contain', '15.1%') // The percentage for less than 30 credits in 2019-2020
cy.get('[data-cy=Graph-2018-AverageGraduationTimes]')
.should('contain', '2018 - 2019')
.should('contain', 'n = 11 / 162')
.should('contain', '22 kk')
})
})
/* Tag-tests*/
describe('Basic information -view works for basic user', () => {
beforeEach(() => {
cy.init('/study-programme')
})
it('can create and delete tags for population', () => {
const name = `tag-${new Date().getTime()}`
cy.contains('Tietojenkäsittelytieteen kandiohjelma').click()
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('.attached').contains('Tags').click()
cy.get('.tagNameSelectInput > .ui > input').type(name)
cy.get('.yearSelectInput').type('2018')
@@ -178,7 +382,7 @@ describe('Studyprogramme overview', () => {
it('can create personal tags', () => {
const name = `tag-${new Date().getTime()}`
cy.contains('Tietojenkäsittelytieteen kandiohjelma').click()
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('.attached').contains('Tags').click()
cy.get('.tagNameSelectInput > .ui > input').type(name)
cy.get('.yearSelectInput').type('2018')
@@ -194,7 +398,7 @@ describe('Studyprogramme overview', () => {
const student = '010113437'
cy.contains('Tietojenkäsittelytieteen kandiohjelma').click()
cy.contains('a', 'Tietojenkäsittelytieteen kandiohjelma').click()
cy.get('.attached').contains('Tags').click()
cy.get('.tagNameSelectInput > .ui > input').type(name)
cy.get('.yearSelectInput').type('2018')
@@ -202,7 +406,7 @@ describe('Studyprogramme overview', () => {
cy.contains(name)
cy.contains('Add tags to students').click()
cy.get('.form > .field > .dropdown').click().get('.ui > .search').type(name).click()
cy.get('.form > .field > .dropdown').click().get('.ui > input.search').type(name).click()
cy.get('.form > .field > .dropdown > .visible').contains(name).click()
@@ -211,7 +415,7 @@ describe('Studyprogramme overview', () => {
cy.contains('Student statistics').click()
cy.get('.prompt').type(student)
cy.contains(student).click()
cy.contains('a', student).click()
cy.contains(name)
cy.go('back')
@@ -221,7 +425,7 @@ describe('Studyprogramme overview', () => {
cy.contains('Student statistics').click()
cy.get('.prompt').type(student)
cy.contains(student).click()
cy.contains('a', student).click()
cy.contains(name).should('not.exist')
})
})
+3 -11
View File
@@ -16,7 +16,7 @@ describe('Teachers page tests', () => {
cy.contains('Tietojenkäsittelytieteen kandiohjelma').click()
cy.cs('course-providers').children('.icon').click()
cy.get('.form > .fluid').click()
cy.contains('Name')
cy.contains('Teacher')
cy.contains(teacher1)
cy.contains(teacher2)
})
@@ -32,21 +32,13 @@ describe('Teachers page tests', () => {
cy.url().should('include', '/teachers')
cy.get('.borderless > :nth-child(3)').click()
cy.get('.prompt').type(teacher1.split()[0])
cy.contains(teacher1).click()
cy.contains('td', teacher1).click()
cy.contains('Aineopintojen harjoitustyö: Tietokantasovellus')
})
it('Check leaderboad works', () => {
cy.get('.borderless > :nth-child(2)').click({ force: true })
cy.get(':nth-child(1) > .ui > .search').click({ force: true })
cy.get(':nth-child(1) > .ui > .search').click({ force: true })
cy.contains('2019-2020').click({ force: true })
cy.contains('Recalculate this year').click({ force: true })
cy.wait(5000)
cy.reload()
cy.contains('2019-2020').click({ force: true })
cy.get(':nth-child(1) > .ui > .search').click({ force: true })
cy.contains('Passed')
cy.contains('Ahokas Jarmo Ilkka')
cy.contains('2020-2021').click({ force: true })
})
})
+2 -9
View File
@@ -39,22 +39,15 @@ describe('Users tests', () => {
it("mocking normal user shows only the mocked user's programmes", () => {
cy.contains('mocking').should('not.exist')
cy.contains('tr', 'basic').within($row => {
cy.contains('.button', 'Edit').click()
})
cy.intercept({
method: 'POST',
path: '/api/superlogin/basic',
}).as('superlogin')
cy.cs('user-edit-button-basic').click()
cy.get('i.spy').click()
cy.wait('@superlogin')
cy.contains('mocking as basic')
cy.wait(1000)
cy.contains('Study programme').click().siblings().contains('Search by class').click()
cy.contains('label', 'Study programme')
cy.contains('label', 'Study programme')
.siblings()
.within($row => {
.within(() => {
cy.get("div[role='option']").should('have.length', 2).contains('Tietojenkäsittelytieteen kandiohjelma')
})
})
+34 -8
View File
@@ -7,7 +7,7 @@ const adminUserHeaders = {
uid: 'admin',
displayname: 'Admin User',
'shib-session-id': 'mock-cypress-session',
hygroupcn: 'grp-oodikone-users;grp-oodikone-basic-users',
hygroupcn: 'grp-oodikone-users;grp-oodikone-basic-users;grp-toska',
edupersonaffiliation: 'member;employee;faculty',
mail: 'grp-toska+mockadminuser@helsinki.fi',
hypersonsisuid: 'hy-hlo-6666666',
@@ -54,8 +54,6 @@ Cypress.Commands.add('init', (path = '', userId = 'basic') => {
if (!headersToUse) throw Error(`${userId} is not valid user id!`)
req.headers = headersToUse
})
// Hide SIS warning flag to avoid screen size problems when running headlessly
window.localStorage.setItem('SIS_WARNING_FLAG', 'true')
const baseUrl = Cypress.config().baseUrl
cy.visit(baseUrl.concat(path))
})
@@ -63,24 +61,37 @@ Cypress.Commands.add('init', (path = '', userId = 'basic') => {
/**
* Shorthand for using "Cypress Selectors" (CS), i.e., `data-cy` attributes.
*/
Cypress.Commands.add('cs', name => {
return cy.get(`[data-cy='${name}']`)
Cypress.Commands.add('cs', { prevSubject: 'optional' }, (subject, name) => {
const selector = `[data-cy="${name}"]`
if (subject === undefined) {
return cy.get(selector)
} else {
return cy.wrap(subject).find(selector)
}
})
/**
* Select item specified by `index` number from a semantic-ui dropdown with
* `data-cy` attribute value `name`.
*/
Cypress.Commands.add('selectFromDropdown', (name, index) => {
Cypress.Commands.add('selectFromDropdown', { prevSubject: true }, (s, index) => {
const subject = cy.wrap(s)
const indexes = Array.isArray(index) ? index : [index]
indexes.forEach(i => {
cy.cs(name).click().children('.menu').children().eq(i).click({ force: true })
subject.click()
if (typeof i === 'number') {
subject.children('.menu').children().eq(i).click({ force: true })
} else {
subject.children('.menu').containing(i).eq(0).click({ force: true })
}
})
// Close multiple selection so it does not block elements underneath it.
if (Array.isArray(index)) {
cy.cs(name).children('.icon').click({ force: true })
cy.wrap(s).children('.icon').click({ force: true })
}
})
@@ -93,3 +104,18 @@ Cypress.Commands.add('selectStudyProgramme', name => {
cy.cs('select-study-programme').click().children().contains(name).click()
cy.contains('See population').click()
})
Cypress.Commands.add('checkTableStats', (correctStats, tableName) => {
cy.get(`[data-cy=Table-${tableName}]>tbody`).within(() => {
correctStats.forEach((values, trIndex) => {
cy.get('tr')
.eq(trIndex)
.within(() => {
values.forEach((value, tdIndex) => {
cy.get('td').eq(tdIndex).contains(value)
})
})
})
cy.get('tr').should('have.length', correctStats.length)
})
})
+10
View File
@@ -14,3 +14,13 @@
// ***********************************************************
import './commands'
// This error is benign and seems to be only present in Cypress
const resizeObserverLoopErrRe = /^[^(ResizeObserver loop limit exceeded)]/
Cypress.on('uncaught:exception', err => {
/* returning false here prevents Cypress from failing the test */
if (resizeObserverLoopErrRe.test(err.message)) {
return false
}
})
+82 -20
View File
@@ -2,7 +2,6 @@ x-defaults: &defaults
restart: unless-stopped
services:
backend:
<<: *defaults
container_name: backend
@@ -10,17 +9,16 @@ services:
- kone-db
- redis
- sis-db
- user-db
environment:
CI: "true"
CI: 'true'
DB_URL_USER: postgres://postgres@user-db:5432/user-db
DB_URL_KONE: postgres://postgres@kone-db:5432/kone-db
FRONT_URL: http://localhost:1337
REDIS: redis
SECRET_TOKEN: dev
SIS_DB_URL: postgres://postgres@sis-db:5432/sis-db
SIS_UPDATER_URL: http://sis-updater-scheduler:8082
TOKEN_SECRET: IWannaBeTheVeryBest
USERSERVICE_SECRET: Luukk4inenApprov3dVitunMinttuSalainenAvain666NurmivaaraPJ2019
USERSERVICE_URL: http://userservice:4567
image: toska/oodikone2-backend:staging
frontend:
@@ -31,11 +29,15 @@ services:
kone-db:
<<: *defaults
container_name: kone-db
environment:
PGDATA: /data
POSTGRES_DB: kone-db
POSTGRES_HOST_AUTH_METHOD: trust
image: registry.toska.cs.helsinki.fi/kone-db
redis:
<<: *defaults
command: "redis-server --appendonly yes"
command: 'redis-server --appendonly yes'
container_name: redis
image: redis
ports:
@@ -45,23 +47,20 @@ services:
<<: *defaults
container_name: sis-db
image: registry.toska.cs.helsinki.fi/sis-db
environment:
PGDATA: /data
POSTGRES_DB: sis-db
POSTGRES_HOST_AUTH_METHOD: trust
shm_size: 2gb
user-db:
<<: *defaults
container_name: user-db
image: registry.toska.cs.helsinki.fi/user-db
userservice:
<<: *defaults
container_name: userservice
depends_on:
- user-db
environment:
CI: "true"
DB_URL: postgres://postgres@user-db:5432/user-db
SECRET: Luukk4inenApprov3dVitunMinttuSalainenAvain666NurmivaaraPJ2019
TOKEN_SECRET: IWannaBeTheVeryBest
image: toska/oodikone2-userservice:staging
PGDATA: /data
POSTGRES_DB: user-db
POSTGRES_HOST_AUTH_METHOD: trust
image: registry.toska.cs.helsinki.fi/user-db
nginx:
image: nginx:latest
@@ -69,8 +68,71 @@ services:
depends_on:
- frontend
- backend
- userservice
ports:
- 1337:80
- 1337:80
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf
# Following services are used to run sis-updater-worker when anon sis-db needs to be updated. Could probably also use production version, but this certainly works.
sis-importer-db:
<<: *defaults
container_name: sis-importer-db
image: registry.toska.cs.helsinki.fi/sis-importer-db
profiles:
- updater
sis-updater-worker:
<<: *defaults
build:
target: development
context: updater/sis-updater-worker
depends_on:
- redis
- sis-db
- sis-importer-db
- sis-updater-nats
environment:
DB_URL: postgres://postgres@sis-db:5432/sis-db
REDIS_URI: //redis:6379
SIS_IMPORTER_DATABASE: sis-importer-db
SIS_IMPORTER_HOST: sis-importer-db
SIS_IMPORTER_PASSWORD: postgres
SIS_IMPORTER_USER: postgres
SIS_NATS_TOKEN: dev
SIS_NATS_URI: sis-updater-nats://sis-updater-nats:4222
profiles:
- updater
sis-updater-scheduler:
<<: *defaults
build:
target: development
context: updater/sis-updater-scheduler
container_name: sis-updater-scheduler
depends_on:
- redis
- sis-importer-db
- sis-updater-nats
environment:
REDIS_URI: //redis:6379
SECRET_TOKEN: dev
SIS_IMPORTER_DATABASE: sis-importer-db
SIS_IMPORTER_HOST: sis-importer-db
SIS_IMPORTER_PASSWORD: postgres
SIS_IMPORTER_USER: postgres
SIS_NATS_TOKEN: dev
SIS_NATS_URI: sis-updater-nats://sis-updater-nats:4222
SCHEDULE_IMMEDIATE: '${SCHEDULE_IMMEDIATE}'
EXIT_AFTER_IMMEDIATES: '${EXIT_AFTER_IMMEDIATES}'
ports:
- 8082:8082
profiles:
- updater
sis-updater-nats:
<<: *defaults
command: '-cid sis-updater-nats -m 8222 -p 4222 --max_channels 1000 --max_age 2h --hb_fail_count 2 --hb_timeout 10s --hb_interval 10s --auth dev --file_slice_max_bytes 0 --file_slice_max_age 60s --max_msgs 0 -store file -dir datastore'
container_name: sis-updater-nats
image: nats-streaming:0.16.2
profiles:
- updater
+1 -5
View File
@@ -1,7 +1,7 @@
services:
backend:
environment:
DB_URL_USER: postgres://postgres@user-db:5432/user-db-real
DB_URL_KONE: postgres://postgres@kone-db:5432/kone-db-real
SIS_DB_URL: postgres://postgres@sis-db:5432/sis-db-real
@@ -18,9 +18,5 @@ services:
DB_URL: postgres://postgres@sis-db:5432/sis-db-real
SIS_IMPORTER_DATABASE: sis-importer-db-real
userservice:
environment:
DB_URL: postgres://postgres@user-db:5432/user-db-real
volumes:
redis-data-real:
-10
View File
@@ -1,10 +0,0 @@
services:
userservice-test:
build:
context: services/userservice
target: test
container_name: userservice-test
environment:
SECRET: Luukk4inenApprov3dVitunMinttuSalainenAvain666NurmivaaraPJ2019
TOKEN_SECRET: IWannaBeTheVeryBest
+7 -25
View File
@@ -1,3 +1,5 @@
version: '2.1'
x-defaults: &defaults
restart: unless-stopped
@@ -26,18 +28,17 @@ services:
- kone-db
- redis
- sis-db
- user-db
env_file:
- .env
environment:
DB_URL_KONE: postgres://postgres@kone-db:5432/kone-db
DB_URL_USER: postgres://postgres@user-db:5432/user-db
FRONT_URL: http://localhost:3000
REDIS: redis
SECRET_TOKEN: dev
SIS_DB_URL: postgres://postgres@sis-db:5432/sis-db
SIS_UPDATER_URL: http://sis-updater-scheduler:8082
TOKEN_SECRET: IWannaBeTheVeryBest
USERSERVICE_SECRET: Luukk4inenApprov3dVitunMinttuSalainenAvain666NurmivaaraPJ2019
USERSERVICE_URL: http://userservice:4567
ports:
- 8080:8080
profiles:
@@ -98,7 +99,7 @@ services:
sis-updater-nats:
<<: *defaults
command: '-cid sis-updater-nats -m 8222 -p 4222 --max_age 2h --hb_fail_count 2 --hb_timeout 10s --hb_interval 10s --auth dev --file_slice_max_bytes 0 --file_slice_max_age 60s --max_msgs 0 -store file -dir datastore'
command: '-cid sis-updater-nats -m 8222 -p 4222 --max_channels 1000 --max_age 2h --hb_fail_count 2 --hb_timeout 10s --hb_interval 10s --auth dev --file_slice_max_bytes 0 --file_slice_max_age 60s --max_msgs 0 -store file -dir datastore'
container_name: sis-updater-nats
image: nats-streaming:0.16.2
profiles:
@@ -123,6 +124,8 @@ services:
SIS_IMPORTER_USER: postgres
SIS_NATS_TOKEN: dev
SIS_NATS_URI: sis-updater-nats://sis-updater-nats:4222
SCHEDULE_IMMEDIATE: '${SCHEDULE_IMMEDIATE}'
EXIT_AFTER_IMMEDIATES: '${EXIT_AFTER_IMMEDIATES}'
ports:
- 8082:8082
profiles:
@@ -165,26 +168,6 @@ services:
volumes:
- user-db-data:/data
userservice:
<<: *defaults
build:
<<: *build_defaults
context: services/userservice
container_name: userservice
depends_on:
- user-db
environment:
DB_URL: postgres://postgres@user-db:5432/user-db
SECRET: Luukk4inenApprov3dVitunMinttuSalainenAvain666NurmivaaraPJ2019
TOKEN_SECRET: IWannaBeTheVeryBest
ports:
- 4567:4567
profiles:
- oodikone
volumes:
- userservice-nodemod:/usr/src/app/node_modules
- ./services/userservice/:/usr/src/app
volumes:
backend-nodemod:
frontend-nodemod:
@@ -195,4 +178,3 @@ volumes:
sis-updater-scheduler-nodemod:
sis-updater-worker-nodemod:
user-db-data:
userservice-nodemod:
+822 -333
View File
File diff suppressed because it is too large Load Diff
+15 -14
View File
@@ -15,7 +15,8 @@
"both": "./run.sh both anon up --detach",
"both:real": "./run.sh both real up --detach",
"docker:down": "./run.sh both anon down --remove-orphans; ./run.sh both real down --remove-orphans",
"prepare": "husky install"
"prepare": "husky install",
"rapodiff": "docker exec backend node /usr/src/app/src/rapodiff.js"
},
"repository": {
"type": "git",
@@ -27,24 +28,24 @@
},
"homepage": "https://github.com/UniversityOfHelsinkiCS/oodikone#readme",
"devDependencies": {
"@babel/eslint-parser": "^7.15.0",
"@babel/plugin-syntax-jsx": "^7.14.5",
"concurrently": "^6.2.1",
"cypress": "^8.3.1",
"@babel/eslint-parser": "^7.17.0",
"@babel/plugin-syntax-jsx": "^7.16.7",
"concurrently": "^6.5.1",
"cypress": "^8.7.0",
"eslint": "^7.32.0",
"eslint-config-airbnb": "^18.2.1",
"eslint-config-prettier": "^8.3.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-babel": "^5.3.1",
"eslint-plugin-cypress": "^2.11.3",
"eslint-plugin-import": "^2.24.2",
"eslint-plugin-jsx-a11y": "^6.4.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": "^3.4.1",
"eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0",
"husky": "^7.0.2",
"lint-staged": "^11.1.2",
"prettier": "^2.3.2",
"eslint-plugin-react": "^7.29.3",
"eslint-plugin-react-hooks": "^4.3.0",
"husky": "^7.0.4",
"lint-staged": "^11.2.6",
"prettier": "^2.5.1",
"stylelint": "^13.13.1",
"stylelint-config-prettier": "^8.0.2",
"stylelint-config-standard": "^22.0.0",
-1
View File
@@ -165,7 +165,6 @@ set_up_oodikone_from_scratch() {
folders_to_set_up=(
"$PROJECT_ROOT"
"$PROJECT_ROOT/services/frontend"
"$PROJECT_ROOT/services/userservice"
"$PROJECT_ROOT/services/backend"
"$PROJECT_ROOT/updater/sis-updater-scheduler"
"$PROJECT_ROOT/updater/sis-updater-worker"
-3
View File
@@ -1,6 +1,3 @@
.dockerignore
Dockerfile
node_modules/
requests/
scripts/
*.log
-3
View File
@@ -1,3 +0,0 @@
# Student diff output
/student_diff_*
/diff_partial_att_data.json
+1 -1
View File
@@ -17,7 +17,7 @@ ENV SENTRY_ENVIRONMENT=$SENTRY_ENVIRONMENT
ARG SENTRY_RELEASE
ENV SENTRY_RELEASE=$SENTRY_RELEASE
COPY --chown=node:node ./package* /usr/src/app/
RUN npm ci --production
RUN npm ci --production && apk add --no-cache vim curl nano
COPY --chown=node:node . /usr/src/app/
USER node
CMD ["npm", "start"]
+288 -348
View File
File diff suppressed because it is too large Load Diff
+10 -15
View File
@@ -4,36 +4,31 @@
"scripts": {
"start": "node --max_old_space_size=4096 index.js",
"dev": "nodemon --max_old_space_size=4096 index.js",
"diff:students": "node /usr/src/app/src/sisoodi_diff/students/index.js",
"diff:populations": "node /usr/src/app/src/sisoodi_diff/populations.js",
"diff:courses": "node /usr/src/app/src/sisoodi_diff/courses/index.js",
"diff:transfers": "node /usr/src/app/src/sisoodi_diff/transfers.js",
"diff:trends": "node /usr/src/app/src/sisoodi_diff/trends.js"
"rapodiff": "node /usr/src/app/src/rapodiff.js"
},
"dependencies": {
"@sentry/node": "^5.30.0",
"@sentry/tracing": "^6.11.0",
"async": "^3.2.1",
"async-lock": "^1.3.0",
"axios": "^0.21.2",
"@sentry/tracing": "^6.18.2",
"async": "^3.2.3",
"async-lock": "^1.3.1",
"axios": "^0.21.4",
"bluebird": "^3.7.2",
"cors": "^2.8.5",
"cron": "^1.8.2",
"express": "^4.17.1",
"express": "^4.17.3",
"express-async-errors": "^3.1.1",
"jsonwebtoken": "^8.5.1",
"lodash": "^4.17.21",
"lru-cache": "^5.1.1",
"moment": "^2.29.1",
"moment-timezone": "^0.5.33",
"moment-timezone": "^0.5.34",
"morgan": "^1.10.0",
"pg": "^8.7.1",
"pg": "^8.7.3",
"redis": "^3.1.2",
"sequelize": "^6.6.5",
"sequelize": "^6.17.0",
"umzug": "^2.3.0",
"unfuck-utf8-headers-middleware": "^1.0.1",
"uuid": "^3.4.0",
"winston": "^3.3.3"
"winston": "^3.6.0"
},
"devDependencies": {
"nodemon": "^1.19.4"
+2 -23
View File
@@ -1,13 +1,9 @@
require('express-async-errors')
const express = require('express')
const cors = require('cors')
const Sentry = require('@sentry/node')
const { baseUrl, backendPort, frontUrl } = require('./conf-backend')
const { baseUrl, backendPort } = require('./conf-backend')
const routes = require('./routes')
const { startCron } = require('./events')
const { initializeDatabaseConnection, dbConnections } = require('./database/connection')
const initializeSentry = require('./util/sentry')
const errorMiddleware = require('./middleware/errormiddleware')
const logger = require('./util/logger')
initializeDatabaseConnection()
@@ -21,28 +17,11 @@ initializeDatabaseConnection()
dbConnections.on('error', () => {
logger.error('Failed to connect to sis db!')
})
const app = express()
initializeSentry(app)
app.use(Sentry.Handlers.requestHandler())
app.use(Sentry.Handlers.tracingHandler())
startCron()
app.use(cors({ credentials: true, origin: frontUrl }))
app.use(express.json())
const app = express()
routes(app, baseUrl)
app.get('*', async (_, res) => {
const results = { error: 'unknown endpoint' }
res.status(404).json(results)
})
app.use(Sentry.Handlers.errorHandler())
app.use(errorMiddleware)
const server = app.listen(backendPort, () => logger.info(`Backend listening on port ${backendPort}!`))
process.on('SIGTERM', () => {
server.close(() => {
+2 -7
View File
@@ -36,6 +36,7 @@ const MATOMO_URL = process.env.MATOMO_URL
// Other stuff
const DB_URL_KONE = process.env.DB_URL_KONE
const DB_URL_USER = process.env.DB_URL_USER
let DB_MAX_CONNECTIONS = parseInt(process.env.DB_MAX_CONNECTIONS, 10)
if (isNaN(DB_MAX_CONNECTIONS)) {
@@ -47,10 +48,8 @@ if (DB_MAX_CRON_CONNECTIONS < 1) {
}
const redis = process.env.REDIS
const TOKEN_SECRET = process.env.TOKEN_SECRET
const SECRET_TOKEN = process.env.SECRET_TOKEN
const DB_SCHEMA_KONE = process.env.DB_SCHEMA_KONE || 'public'
const USERSERVICE_URL = process.env.USERSERVICE_URL
const SIS_UPDATER_URL = process.env.SIS_UPDATER_URL
const formatURL = url => {
@@ -59,18 +58,14 @@ const formatURL = url => {
const addSlashToEnd = url => (url.endsWith('/') ? url : url + '/')
const ACCESS_TOKEN_HEADER_KEY = 'x-access-token'
module.exports = {
DB_URL_USER,
DB_URL_KONE,
DB_MAX_CONNECTIONS,
DB_MAX_CRON_CONNECTIONS,
redis,
TOKEN_SECRET,
SECRET_TOKEN,
DB_SCHEMA_KONE,
USERSERVICE_URL: formatURL(USERSERVICE_URL),
ACCESS_TOKEN_HEADER_KEY,
requiredGroup,
SIS_UPDATER_URL,
ANALYTICS_INFLUXDB_URL: formatURL(ANALYTICS_INFLUXDB_URL),
+42 -23
View File
@@ -16,7 +16,7 @@ class DbConnection extends EventEmitter {
pool: {
max: 25,
min: 0,
acquire: 10000,
acquire: 30000,
idle: 300000000,
},
logging: false,
@@ -39,54 +39,73 @@ class DbConnection extends EventEmitter {
}
}
// Old-style kone + user db connections
const sequelizeKone = new Sequelize(conf.DB_URL_KONE, {
schema: conf.DB_SCHEMA_KONE,
searchPath: conf.DB_SCHEMA_KONE,
logging: false,
})
sequelizeKone.query(`SET SESSION search_path to ${conf.DB_SCHEMA_KONE}`)
const sequelizeUser = new Sequelize(conf.DB_URL_USER, {
logging: false,
})
const initializeDatabaseConnection = async () => {
const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
const waitSeconds = 60
for (let i = 1; i <= waitSeconds; i++) {
try {
await sequelizeKone.authenticate()
break
} catch (e) {
if (i === waitSeconds) {
logger.error(`Could not connect to database in ${waitSeconds} seconds`)
throw e
const rounds = 60
for (const [seq, dbName] of [
[sequelizeKone, 'kone-db'],
[sequelizeUser, 'user-db'],
]) {
logger.info(`Connecting to ${dbName}...`)
for (let round = 1; round <= rounds; round++) {
try {
await seq.authenticate()
break
} catch (error) {
if (round === rounds) {
logger.error(`${dbName} database connection failed!`)
throw error
}
await sleep(1000)
}
await sleep(1000)
}
}
try {
logger.info(`${dbName} database connection established`)
const schema = dbName === 'kone-db' ? conf.DB_SCHEMA_KONE : undefined
const migrationsFolder = dbName === 'kone-db' ? 'migrations_kone' : 'migrations_user'
const migrator = new Umzug({
storage: 'sequelize',
storageOptions: {
sequelize: sequelizeKone,
sequelize: seq,
tableName: 'migrations',
schema: conf.DB_SCHEMA_KONE,
schema,
},
migrations: {
params: [sequelizeKone.getQueryInterface(), Sequelize],
path: `${process.cwd()}/src/database/migrations_kone`,
params: [seq.getQueryInterface(), Sequelize],
path: `${process.cwd()}/src/database/${migrationsFolder}`,
pattern: /\.js$/,
schema: conf.DB_SCHEMA_KONE,
schema,
},
})
const migrations = await migrator.up()
logger.info({ message: 'Kone Migrations up to date', meta: migrations })
} catch (e) {
logger.error({ message: 'Kone Migration error: ', meta: e })
throw e
try {
const migrations = await migrator.up()
logger.info({ message: `${dbName} migrations up to date: `, meta: migrations.map(m => m.file) })
} catch (error) {
logger.error({ message: `${dbName} migrations failed`, meta: error })
throw error
}
}
}
const dbConnections = new DbConnection()
module.exports = {
dbConnections,
sequelizeKone,
sequelizeUser,
initializeDatabaseConnection,
}
@@ -0,0 +1,6 @@
module.exports = {
up: async queryInterface => {
await queryInterface.dropTable('thesis_courses')
},
down: async () => {},
}
@@ -0,0 +1,9 @@
module.exports = {
up: async queryInterface => {
await queryInterface.dropTable('user_affiliation')
await queryInterface.sequelize.query('DROP SEQUENCE IF EXISTS user_affilation_id_seq')
await queryInterface.dropTable('affiliations')
await queryInterface.sequelize.query('DROP SEQUENCE IF EXISTS affiliations_id_seq')
},
down: async () => {},
}
@@ -0,0 +1,9 @@
module.exports = {
up: async queryInterface => {
await queryInterface.dropTable('user_hy_group')
await queryInterface.sequelize.query('DROP SEQUENCE IF EXISTS user_hy_group_id_seq')
await queryInterface.dropTable('hy_groups')
await queryInterface.sequelize.query('DROP SEQUENCE IF EXISTS hy_groups_id_seq')
},
down: async () => {},
}
+11 -37
View File
@@ -10,9 +10,8 @@ const {
} = require('./services/trends')
const { refreshAssociationsInRedis } = require('./services/studyrights')
const { getAllProgrammes } = require('./services/studyrights')
const { productivityStatsForStudytrack, throughputStatsForStudytrack } = require('./services/studyprogramme')
const { updateBasicView, updateStudytrackView } = require('./services/studyprogrammeUpdates')
const { findAndSaveTeachers } = require('./services/topteachers')
const { setProductivity, setThroughput, patchProductivity, patchThroughput } = require('./services/analyticsService')
const { isProduction } = require('./conf-backend')
const { getCurrentSemester } = require('./services/semesters')
const logger = require('./util/logger')
@@ -24,47 +23,21 @@ const refreshStudyrightAssociations = async () => {
logger.info('Studyright associations refreshed!')
}
const refreshOverview = async () => {
logger.info('Refreshing throughput and productivity for programmes...')
const refreshNewOverviews = async () => {
logger.info('Refreshing studyprogramme and studytrack overview statistics for all programmes')
const codes = (await getAllProgrammes()).map(p => p.code).filter(code => code.includes('KH') || code.includes('MH'))
let ready = 0
for (const code of codes) {
let programmeStatsSince = new Date('2017-07-31')
if (code.includes('MH') || code.includes('KH')) {
programmeStatsSince = new Date('2017-07-31')
} else {
programmeStatsSince = new Date('2000-07-31')
}
try {
await patchThroughput({ [code]: { status: 'RECALCULATING' } })
const data = await throughputStatsForStudytrack(code, programmeStatsSince.getFullYear())
await setThroughput(data)
await updateBasicView(code)
await updateStudytrackView(code)
ready += 1
} catch (e) {
logger.error({ message: `failed to recalculate throughput for ${code}`, meta: e })
try {
await patchThroughput({ [code]: { status: 'RECALCULATION ERRORED' } })
} catch (e) {
logger.error({ message: 'failed to update throughtput status to error', meta: e })
}
logger.error({ message: `Failed to update overview stats for programme ${code}`, meta: e })
}
try {
await patchProductivity({ [code]: { status: 'RECALCULATING' } })
const data = await productivityStatsForStudytrack(code, programmeStatsSince)
await setProductivity(data)
} catch (e) {
logger.error({ message: `failed to recalculate productivity for ${code}`, meta: e })
try {
await patchProductivity({
[code]: { status: 'RECALCULATION ERRORED' },
})
} catch (e) {
logger.error({ message: 'failed to update productivity status to error', meta: e })
}
}
ready += 1
logger.info(`${ready}/${codes.length} programmes done`)
}
logger.info('Throughput and productivity for programmes refreshed')
logger.info('Studyprogramme and studytrack overview stats refreshed!')
}
const refreshTeacherLeaderboard = async () => {
@@ -147,7 +120,7 @@ const refreshProtoCProgrammeToRedis = async () => {
}
const refreshStatistics = async () => {
const statfuncs = [refreshStudyrightAssociations, refreshOverview, refreshTeacherLeaderboard]
const statfuncs = [refreshStudyrightAssociations, refreshTeacherLeaderboard]
logger.info('Refreshing statistics')
for (const func of statfuncs) {
await func()
@@ -166,9 +139,10 @@ const refreshTrends = async () => {
const startCron = () => {
if (isProduction) {
logger.info('Cronjob for refreshing stats started: runs at 3am every day.')
// refresh 3am every day
schedule('0 3 * * *', async () => {
for (const func of [refreshStatistics, refreshTrends]) {
for (const func of [refreshStatistics, refreshTrends, refreshNewOverviews]) {
await func()
}
})
@@ -1,5 +1,6 @@
const morgan = require('morgan')
const logger = require('../util/logger')
const _ = require('lodash')
// So this appears to be a hack to get neatly formatted stats like response-time etc. from morgan
// without actually using morgan what it's used for (LOGGING REQUESTS!).
@@ -7,7 +8,8 @@ const logger = require('../util/logger')
// so don't e.g. make it into an async function or it'll print [object Promise] on every request
const accessLogger = morgan((tokens, req, res) => {
const fields = ['method', 'url', 'status', 'response-time', 'remote-addr', 'remote-user', 'user-agent', 'referrer']
const meta = { ...req.decodedToken }
const { user } = req
const meta = { ...user }
fields.forEach(field => (meta[field] = tokens[field](req, res)))
meta['time'] = tokens['date'](req, res, 'iso')
if (req.route) {
@@ -15,7 +17,7 @@ const accessLogger = morgan((tokens, req, res) => {
}
const message = [
req.decodedToken.name,
user.name,
':',
tokens['method'](req, res),
tokens['url'](req, res),
@@ -26,7 +28,8 @@ const accessLogger = morgan((tokens, req, res) => {
].join(' ')
logger.info(message, {
...meta,
// don't log student list which might be huge
..._.omit(meta, ['studentsUserCanAccess']),
// pass this as a custom field so we can filter by it in graylog
isUsageStats: true,
})
+4 -70
View File
@@ -1,43 +1,8 @@
const jwt = require('jsonwebtoken')
const conf = require('../conf-backend')
const blacklist = require('../services/blacklist')
const { getUserDataFor } = require('../services/userService')
const { ACCESS_TOKEN_HEADER_KEY } = require('../conf-backend')
const { hasRequiredGroup, parseHyGroups } = require('../util/utils')
const TOKEN_VERSION = 1.1 // When token structure changes, increment in userservice, backend and frontend
const checkAuth = async (req, res, next) => {
const token = req.headers[ACCESS_TOKEN_HEADER_KEY]
const uid = req.headers['uid']
if (!token) {
return res.status(403).json({ error: 'No token in headers' })
}
jwt.verify(token, conf.TOKEN_SECRET, async (err, decoded) => {
if (err) {
return res.status(403).json(err)
}
if (decoded.version !== TOKEN_VERSION) {
return res.status(401).json({ error: 'Token needs to be refreshed - invalid version' })
}
if (decoded.mockedBy ? decoded.mockedBy !== uid : decoded.userId !== uid) {
return res.status(403).json({ error: 'User shibboleth id and token id did not match' })
}
const userData = await getUserDataFor(decoded.userId)
req.decodedToken = decoded
Object.assign(req, userData)
next()
})
}
const roles = requiredRoles => async (req, res, next) => {
if (req.decodedToken) {
const { roles } = req
if (req.user) {
const {
user: { roles },
} = req
if (requiredRoles.every(r => roles.indexOf(r) >= 0) || roles.includes('admin')) {
return next()
@@ -47,37 +12,6 @@ const roles = requiredRoles => async (req, res, next) => {
res.status(403).json({ error: 'missing required roles' })
}
const checkRequiredGroup = async (req, res, next) => {
const hyGroups = parseHyGroups(req.headers['hygroupcn'])
const enabled = hasRequiredGroup(hyGroups)
const tokenOutdated = req.decodedToken.enabled !== enabled
if (tokenOutdated) {
return res.status(401).json({
error: 'Token needs to be refreshed - enabled does not match hy-group requirement',
})
}
if (!enabled) {
return res.status(403).json({ error: 'User is not enabled' })
}
next()
}
const checkUserBlacklisting = async (req, res, next) => {
const { userId, createdAt } = req.decodedToken
const isBlacklisted = await blacklist.isUserBlacklisted(userId, createdAt)
if (isBlacklisted) {
return res.status(401).json({ error: 'Token needs to be refreshed - blacklisted' })
}
next()
}
module.exports = {
checkAuth,
roles,
checkRequiredGroup,
checkUserBlacklisting,
}
@@ -0,0 +1,53 @@
const Sentry = require('@sentry/node')
const { ApplicationError } = require('../util/customErrors')
const { getUser, getMockedUser } = require('../services/userService')
const { requiredGroup } = require('../conf-backend')
const _ = require('lodash')
const parseIamGroups = iamGroups => iamGroups?.split(';').filter(Boolean) ?? []
const hasRequiredIamGroup = iamGroups => _.intersection(iamGroups, requiredGroup).length > 0
const currentUserMiddleware = async (req, _res, next) => {
const {
'shib-session-id': sessionId,
'x-show-as-user': showAsUser,
displayname: name,
hygroupcn,
hypersonsisuid: sisId,
mail: email,
shib_logout_url: logoutUrl,
uid: username,
} = req.headers
if (!sessionId || !username) {
throw new ApplicationError('Not enough data in request headers', 403, { logoutUrl })
}
const iamGroups = parseIamGroups(hygroupcn)
if (!hasRequiredIamGroup(iamGroups)) {
throw new ApplicationError('User does not have required iam group', 403, { logoutUrl })
}
let user = await getUser({
username,
name,
email,
iamGroups,
sisId,
})
if (showAsUser && user.isAdmin) {
user = await getMockedUser({ userToMock: showAsUser, mockedBy: username })
}
Sentry.setUser({ username: user.mockedBy ?? username })
req.user = user
req.logoutUrl = logoutUrl
next()
}
module.exports = currentUserMiddleware
@@ -1,13 +0,0 @@
const Sentry = require('@sentry/node')
const sentryUserIdMiddleware = (req, res, next) => {
Sentry.getCurrentHub().configureScope(scope => {
scope.setUser({
username: req.decodedToken && req.decodedToken.userId,
})
})
next()
}
module.exports = sentryUserIdMiddleware
@@ -0,0 +1,5 @@
const headersMiddleware = require('unfuck-utf8-headers-middleware')
const headers = ['uid', 'displayName', 'shib-session-id', 'hyGroupCn', 'mail', 'hyPersonSisuId']
module.exports = headersMiddleware(headers)
+3
View File
@@ -47,6 +47,9 @@ Course.init(
substitutions: {
type: JSONB,
},
course_unit_type: {
type: STRING,
},
},
{
underscored: false,
+6
View File
@@ -75,6 +75,12 @@ Credit.init(
updatedAt: {
type: DATE,
},
language: {
type: STRING,
},
is_open: {
type: BOOLEAN,
},
},
{
underscored: false,
+69
View File
@@ -0,0 +1,69 @@
const { Model, DATE, INTEGER, STRING, BOOLEAN } = require('sequelize')
const { dbConnections } = require('../database/connection')
class Enrollment extends Model {}
Enrollment.init(
{
id: {
primaryKey: true,
type: STRING,
},
studentnumber: {
type: STRING,
references: {
model: 'student',
key: 'studentnumber',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
course_code: {
type: STRING,
},
state: {
type: STRING,
},
enrollment_date_time: {
type: DATE,
},
course_id: {
type: STRING,
references: {
model: 'course',
key: 'id',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
semester_composite: {
type: STRING,
references: {
model: 'semesters',
key: 'composite',
},
onUpdate: 'cascade',
onDelete: 'cascade',
},
semestercode: {
type: INTEGER,
},
createdAt: {
type: DATE,
},
updatedAt: {
type: DATE,
},
is_open: {
type: BOOLEAN,
},
},
{
underscored: false,
sequelize: dbConnections.sequelize,
modelName: 'enrollment',
tableName: 'enrollment',
}
)
module.exports = Enrollment
+13
View File
@@ -10,6 +10,7 @@ const CreditType = require('./creditType')
const Credit = require('./credit')
const CreditTeacher = require('./creditTeacher')
const ElementDetail = require('./elementDetail')
const Studyplan = require('./studyplan')
const StudyrightExtent = require('./studyrightExtent')
const Studyright = require('./studyright')
const StudyrightElement = require('./studyrightElement')
@@ -17,6 +18,7 @@ const Transfer = require('./transfer')
const ProgrammeModule = require('./programmeModule')
const ProgrammeModuleChild = require('./programmeModuleChild')
const ExcludedCourse = require('./excludedCourse')
const Enrollment = require('./enrollment')
CourseType.hasMany(Course, { foreignKey: 'coursetypecode', sourceKey: 'coursetypecode' })
Course.belongsTo(CourseType, { foreignKey: 'coursetypecode', targetKey: 'coursetypecode' })
@@ -62,6 +64,9 @@ Teacher.belongsToMany(Credit, { through: CreditTeacher, foreignKey: 'teacher_id'
Organization.hasMany(Studyright, { foreignKey: 'facultyCode', sourceKey: 'code' })
Studyright.belongsTo(Organization, { foreignKey: 'facultyCode', targetKey: 'code' })
Studyplan.belongsTo(Student, { foreignKey: 'studentnumber', targetKey: 'studentnumber' })
Student.hasMany(Studyplan, { foreignKey: 'studentnumber', sourceKey: 'studentnumber' })
Studyright.belongsTo(Student, { foreignKey: 'studentStudentnumber', targetKey: 'studentnumber' })
Student.hasMany(Studyright, { foreignKey: 'studentStudentnumber', sourceKey: 'studentnumber' })
@@ -88,6 +93,12 @@ Studyright.hasMany(Transfer, { foreignKey: 'studyrightid', sourceKey: 'studyrigh
Transfer.belongsTo(ElementDetail, { as: 'source', foreignKey: 'sourcecode' })
Transfer.belongsTo(ElementDetail, { as: 'target', foreignKey: 'targetcode' })
Enrollment.belongsTo(Student, { foreignKey: 'studentnumber', targetKey: 'studentnumber' })
Student.hasMany(Enrollment, { foreignKey: 'studentnumber', sourceKey: 'studentnumber' })
Enrollment.belongsTo(Course, { foreignKey: 'course_id' })
Course.hasMany(Enrollment, { foreignKey: 'course_id' })
Enrollment.belongsTo(Semester, { foreignKey: { name: 'semester_composite', allowNull: false } })
ProgrammeModule.belongsToMany(ProgrammeModule, {
as: 'parents',
through: ProgrammeModuleChild,
@@ -114,6 +125,7 @@ module.exports = {
Credit,
CreditTeacher,
ElementDetail,
Studyplan,
StudyrightExtent,
Studyright,
StudyrightElement,
@@ -121,4 +133,5 @@ module.exports = {
ProgrammeModule,
ProgrammeModuleChild,
ExcludedCourse,
Enrollment,
}
@@ -104,20 +104,6 @@ const MandatoryCourseLabels = sequelizeKone.define('mandatory_course_labels', {
},
})
const ThesisCourse = sequelizeKone.define('thesis_courses', {
programmeCode: {
primaryKey: true,
type: Sequelize.STRING,
},
courseCode: {
primaryKey: true,
type: Sequelize.STRING,
},
thesisType: {
type: Sequelize.ENUM([ThesisTypeEnums.BACHELOR, ThesisTypeEnums.MASTER]),
},
})
const CustomPopulationSearch = sequelizeKone.define('custom_population_searches', {
id: {
primaryKey: true,
@@ -173,7 +159,6 @@ module.exports = {
MandatoryCourse,
TagStudent,
Tag,
ThesisCourse,
ThesisTypeEnums,
MandatoryCourseLabels,
CustomPopulationSearch,
@@ -1,7 +1,7 @@
const Sequelize = require('sequelize')
const { sequelize } = require('../database/connection')
const { sequelizeUser } = require('../database/connection')
const UserElementDetails = sequelize.define(
const UserElementDetails = sequelizeUser.define(
'user_elementdetails',
{
userId: {
@@ -18,7 +18,7 @@ const UserElementDetails = sequelize.define(
}
)
const AccessGroup = sequelize.define('access_group', {
const AccessGroup = sequelizeUser.define('access_group', {
id: {
primaryKey: true,
type: Sequelize.BIGINT,
@@ -39,7 +39,7 @@ const AccessGroup = sequelize.define('access_group', {
},
})
const UserFaculties = sequelize.define('user_faculties', {
const UserFaculties = sequelizeUser.define('user_faculties', {
userId: {
primaryKey: true,
type: Sequelize.BIGINT,
@@ -60,7 +60,7 @@ const UserFaculties = sequelize.define('user_faculties', {
},
})
const User = sequelize.define(
const User = sequelizeUser.define(
'users',
{
id: {
@@ -83,41 +83,6 @@ const User = sequelize.define(
timestamps: false,
}
)
const HyGroup = sequelize.define('hy_group', {
id: {
primaryKey: true,
type: Sequelize.BIGINT,
autoIncrement: true,
},
code: { type: Sequelize.STRING },
createdAt: {
type: Sequelize.DATE,
},
updatedAt: {
type: Sequelize.DATE,
},
})
const Affiliation = sequelize.define('affiliations', {
id: {
primaryKey: true,
type: Sequelize.BIGINT,
autoIncrement: true,
},
code: { type: Sequelize.STRING },
createdAt: {
type: Sequelize.DATE,
},
updatedAt: {
type: Sequelize.DATE,
},
})
User.hasMany(UserElementDetails, { as: 'programme' })
UserElementDetails.belongsTo(User)
@@ -128,23 +93,12 @@ User.belongsToMany(AccessGroup, {
})
AccessGroup.belongsToMany(User, { through: 'user_accessgroup' })
User.belongsToMany(HyGroup, { through: 'user_hy_group', as: 'hy_group' })
HyGroup.belongsToMany(User, { through: 'user_hy_group' })
User.belongsToMany(Affiliation, {
through: 'user_affiliation',
as: 'affiliation',
})
Affiliation.belongsToMany(User, { through: 'user_affiliation' })
User.hasMany(UserFaculties, { as: 'faculty', foreignKey: 'userId' })
module.exports = {
User,
UserElementDetails,
AccessGroup,
HyGroup,
Affiliation,
UserFaculties,
sequelize,
sequelizeUser,
}
+1 -1
View File
@@ -17,7 +17,6 @@ Student.init(
dateofuniversityenrollment: { type: DATE },
email: { type: STRING },
national_student_number: { type: STRING },
home_county_id: { type: INTEGER },
country_fi: { type: STRING },
country_sv: { type: STRING },
country_en: { type: STRING },
@@ -25,6 +24,7 @@ Student.init(
home_country_sv: { type: STRING },
home_country_en: { type: STRING },
gender_code: { type: INTEGER },
sis_person_id: { type: STRING },
createdAt: {
type: DATE,
},
+48
View File
@@ -0,0 +1,48 @@
const { Model, DATE, ARRAY, STRING, INTEGER } = require('sequelize')
const { dbConnections } = require('../database/connection')
class Studyplan extends Model {}
Studyplan.init(
{
id: {
primaryKey: true,
type: INTEGER,
autoIncrement: true,
allowNull: false,
},
studentnumber: {
type: STRING,
references: {
model: 'student',
key: 'studentnumber',
},
onUpdate: 'cascade',
onDelete: 'cascade',
unique: 'source', // This and programme_code create a composite key for this table.
allowNull: false,
},
programme_code: {
type: STRING,
allowNull: false,
unique: 'source',
},
included_courses: {
type: ARRAY(STRING),
},
createdAt: {
type: DATE,
},
updatedAt: {
type: DATE,
},
},
{
underscored: false,
sequelize: dbConnections.sequelize,
modelName: 'studyplan',
tableName: 'studyplan',
}
)
module.exports = Studyplan
+3 -3
View File
@@ -9,9 +9,6 @@ Studyright.init(
primaryKey: true,
type: STRING,
},
canceldate: {
type: DATE,
},
startdate: {
type: DATE,
},
@@ -27,6 +24,9 @@ Studyright.init(
graduated: {
type: INTEGER,
},
active: {
type: INTEGER,
},
// irtisanomisperuste
studentStudentnumber: {
type: STRING,
+363
View File
@@ -0,0 +1,363 @@
/* eslint no-console: 0 */
/*
depends on nodeproxy running in importer.cs.helsinki.fi, and env RAPO_NODEPROXY (see importer for a proper value)
needs also acces to importer db api, uses env IMPORTER_API
known differences in APIs
- rapo does not show students that have graduated (it however takes some days for rapo to notice a graduation)
- rapo does not handle the starting year of transfers properly (shows in old staring population)
- rapo show some students incorrectly passive, see https://github.com/UniversityOfHelsinkiCS/oodikone/issues/3521
*/
const axios = require('axios').default
const _ = require('lodash')
const { optimizedStatisticsOf } = require('./services/populations')
const { Student, Transfer, StudyrightElement, Studyright } = require('./models')
const token = process.env.RAPO_NODEPROXY
const getFromRapo = async (urlStart, urlEnd) => {
const { data: rapoStuffLasna } = await axios.get(urlStart)
const { data: rapoStuffLasnaMinus } = await axios.get(urlEnd)
const rapoStudents = _.difference(
rapoStuffLasna.map(s => s.opiskelijanumero),
rapoStuffLasnaMinus.map(s => s.opiskelijanumero)
)
return rapoStudents
}
const known_problems_in_oodikone = {
KH30_001: ['013896191'],
KH40_003: ['013200457'],
KH55_001: ['013195834', '015119708', '015138336'],
}
const known_problems_in_rapo = {
KH55_001: ['015160142', '015135575', '015119708', '015138336'],
}
const getFromOodikone = async (programme, year) => {
const isNotAmongKnownProblems = student => {
const hasProblems = known_problems_in_oodikone[programme] ? known_problems_in_oodikone[programme] : []
return !hasProblems.includes(student.studentNumber)
}
const theStudyrights = student => {
const theOne = s => s.studyright_elements.find(e => e.code === programme)
// in some rare cases student may have more than one studyright for same programme
return student.studyrights.filter(theOne)
}
const notGraduated = student => {
const graduation = theStudyrights(student).filter(r => r.graduated === 1)
return graduation.length === 0
}
const notTransferred = student => {
const transfer = student.transfers.find(t => t.targetcode === programme)
return transfer === undefined
}
const months = 12
const oodikoneQuery = {
semesters: ['FALL', 'SPRING'],
months,
studyRights: { programme },
year,
}
const oodikoneStuff = (await optimizedStatisticsOf(oodikoneQuery)).students
return oodikoneStuff
.filter(notGraduated)
.filter(notTransferred)
.filter(isNotAmongKnownProblems)
.map(s => s.studentNumber)
}
const isAcuallyActive = async student => {
const currentSemester = 144
const tokenImporterApi = process.env.IMPORTER_API
const url = `https://importer.cs.helsinki.fi/api/importer/students/${student}/rapo_semester_enrollments?token=${tokenImporterApi}`
const { data } = await axios.get(url)
const terms = data.reduce((all, s) => all.concat(s.terms), []).filter(t => t.semester_code === currentSemester)
const active = terms.filter(t => t.type !== 'NEGLECTED')
const negl = terms.filter(t => t.type === 'NEGLECTED')
return active.length > 0 && negl.length > 0
}
const hasTransferred = async (student, programme) => {
const data = await Student.findByPk(student, {
include: [
{
model: Transfer,
},
],
})
const transferTo = data.transfers.find(t => t.targetcode === programme)
return transferTo !== undefined
}
const graduatedVeryRecently = async (student, programme) => {
const data = await Student.findByPk(student, {
include: [
{
model: Studyright,
include: [
{
model: StudyrightElement,
required: true,
where: {
code: programme,
},
},
],
where: {
graduated: 1,
},
},
],
})
if (!data || data.studyrights.length === 0) {
return false
}
const graduated = new Date(data.studyrights[0].enddate)
const weekAgo = new Date(new Date().getTime() - 7 * 24 * 60 * 60 * 1000)
return graduated > weekAgo
}
const programme_diff_year = async (programme, facultyCode, year, brief = false) => {
const oodikoneStudents = await getFromOodikone(programme, year)
const studyrightStartDate = `${year}-08-01`
const studyrightEndDate = `${year + 1}-08-01`
const rapoUrlStart = presence =>
encodeURI(
`https://importer.cs.helsinki.fi/test/rapo/${facultyCode}/${programme}/${studyrightStartDate}/${presence}?token=${token}`
)
const rapoUrlEnd = presence =>
encodeURI(
`https://importer.cs.helsinki.fi/test/rapo/${facultyCode}/${programme}/${studyrightEndDate}/${presence}?token=${token}`
)
const rapoStudentsLasna = await getFromRapo(rapoUrlStart('Läsnä'), rapoUrlEnd('Läsnä'))
const rapoStudentsPoissa = await getFromRapo(rapoUrlStart('Poissa'), rapoUrlEnd('Poissa'))
const rapoStudentPoissaLaki = await getFromRapo(
rapoUrlStart('Poissa ei kuluta opintoaikaa'),
rapoUrlEnd('Poissa ei kuluta opintoaikaa')
)
const isNotAmongKnownProblems = student => {
const hasProblems = known_problems_in_rapo[programme] ? known_problems_in_rapo[programme] : []
return !hasProblems.includes(student.studentNumber)
}
const rapoStudents = rapoStudentsLasna
.concat(rapoStudentsPoissa)
.concat(rapoStudentPoissaLaki)
.filter(isNotAmongKnownProblems)
const onlyInOodikone = _.difference(oodikoneStudents, rapoStudents)
const onlyInRapo = _.difference(rapoStudents, oodikoneStudents)
const wrongMissingInRapo = []
for (let student of onlyInOodikone) {
const status = await isAcuallyActive(student)
if (status) {
wrongMissingInRapo.push(student)
}
}
// these are in wrong RAPO-population
const transferred = []
for (let student of onlyInRapo) {
const isTransfer = await hasTransferred(student, programme)
if (isTransfer) {
transferred.push(student)
} else {
const isRecentGraduation = await graduatedVeryRecently(student, programme)
if (isRecentGraduation) {
transferred.push(student)
}
}
}
const checkOodikoneOnly = _.difference(onlyInOodikone, wrongMissingInRapo)
const checkRapoOnly = _.difference(onlyInRapo, transferred)
if (!brief) {
console.log('vuosi', year)
console.log('')
console.log('oodikone', oodikoneStudents.length, ' transferred', transferred.length)
console.log('rapo', rapoStudents.length, ' activeness wrong rapo', wrongMissingInRapo.length)
console.log('only rapo', checkRapoOnly.length)
console.log('only oodikone', checkOodikoneOnly.length)
console.log('')
if (checkRapoOnly.length > 0) {
console.log('Only in Rapo:')
console.log(checkRapoOnly.join('\n'))
}
if (checkOodikoneOnly.length > 0) {
console.log('Only in Oodikone:')
console.log(checkOodikoneOnly.join('\n'))
}
}
if (checkRapoOnly.length + checkOodikoneOnly.length) {
console.log('******************************', year)
if (checkRapoOnly.length > 0) {
console.log('Only in Rapo:')
console.log(checkRapoOnly.join('\n'))
}
if (checkOodikoneOnly.length > 0) {
console.log('Only in Oodikone:')
console.log(checkOodikoneOnly.join('\n'))
}
}
if (!brief) {
console.log('')
}
}
const programme_diff = async (programme, faculty, brief) => {
console.log()
console.log(programme)
console.log('--------', '\n')
await programme_diff_year(programme, faculty, 2017, brief)
await programme_diff_year(programme, faculty, 2018, brief)
await programme_diff_year(programme, faculty, 2019, brief)
await programme_diff_year(programme, faculty, 2020, brief)
await programme_diff_year(programme, faculty, 2021, brief)
}
const faculty_diff = async (faculty, programmes, brief) => {
console.log('\n')
console.log(faculty)
console.log('==')
for (let programme of programmes) {
await programme_diff(programme, faculty, brief)
}
}
// eslint-disable-next-line no-unused-vars
const msc_programme_diff_year = async (programme, facultyCode, year, brief = false) => {
const oodikoneStudents = await getFromOodikone(programme, year)
const studyrightStartDate = `${year}-08-01`
const studyrightEndDate = `${year + 1}-08-01`
const rapoUrlStart = presence =>
encodeURI(
`https://importer.cs.helsinki.fi/test/rapo/${facultyCode}/${programme}/${studyrightStartDate}/${presence}?token=${token}`
)
const rapoUrlEnd = presence =>
encodeURI(
`https://importer.cs.helsinki.fi/test/rapo/${facultyCode}/${programme}/${studyrightEndDate}/${presence}?token=${token}`
)
const rapoStudentsLasna = await getFromRapo(rapoUrlStart('Läsnä'), rapoUrlEnd('Läsnä'))
const rapoStudentsPoissa = await getFromRapo(rapoUrlStart('Poissa'), rapoUrlEnd('Poissa'))
const rapoStudentPoissaLaki = await getFromRapo(
rapoUrlStart('Poissa ei kuluta opintoaikaa'),
rapoUrlEnd('Poissa ei kuluta opintoaikaa')
)
const rapoStudents = rapoStudentsLasna.concat(rapoStudentsPoissa).concat(rapoStudentPoissaLaki)
const onlyInOodikone = _.difference(oodikoneStudents, rapoStudents)
const onlyInRapo = _.difference(rapoStudents, oodikoneStudents)
const wrongInRapo = []
for (let student of onlyInOodikone) {
const status = await isAcuallyActive(student)
if (status) {
//wrongInRapo.push(student)
}
}
// in wrong RAPO population
const transferred = []
for (let student of onlyInRapo) {
const status = await hasTransferred(student, programme)
if (status) {
transferred.push(student)
}
}
const checkOodikoneOnly = _.difference(onlyInOodikone, wrongInRapo)
const checkRapoOnly = _.difference(onlyInRapo, transferred)
const both = _.intersection(oodikoneStudents, rapoStudents)
console.log('vuosi', year)
if (!brief) {
console.log('')
console.log('oodikone', oodikoneStudents.length, ' transferred', transferred.length)
console.log('rapo', rapoStudents.length, ' activeness wrong rapo', wrongInRapo.length)
console.log('both', both.length)
console.log('only rapo', checkRapoOnly.length)
console.log('only oodikone', checkOodikoneOnly.length)
console.log('')
if (checkRapoOnly.length > 0) {
console.log('Only in Rapo:')
console.log(checkRapoOnly.join('\n'))
}
if (checkOodikoneOnly.length > 0) {
console.log('Only in Oodikone:')
console.log(checkOodikoneOnly.join('\n'))
}
}
if (checkRapoOnly.length + checkOodikoneOnly.length) {
console.log('******************************************************')
}
if (!brief) {
console.log('')
}
}
const bsc_priogrammes_of_faculties = {
H10: ['KH10_001'],
H20: ['KH20_001'],
H30: ['KH30_001', 'KH30_002'],
H40: ['KH40_001', 'KH40_002', 'KH40_003', 'KH40_004', 'KH40_005', 'KH40_006'],
H50: ['KH50_001', 'KH50_002', 'KH50_003', 'KH50_004', 'KH50_005', 'KH50_006', 'KH50_007', 'KH50_008'],
H55: ['KH55_001'],
H60: ['KH60_001'],
H70: ['KH70_001', 'KH70_002', 'KH70_003', 'KH70_004'],
H74: ['KH74_001'],
H80: ['KH80_001', 'KH80_002', 'KH80_003', 'KH80_004'],
H90: ['KH90_001'],
}
const main = async () => {
for (let faculty of Object.keys(bsc_priogrammes_of_faculties)) {
await faculty_diff(faculty, bsc_priogrammes_of_faculties[faculty], true)
}
//await programme_diff_year('KH55_001', 'H55', 2021, true)
//await programme_diff('KH60_001', 'H60', true)
}
main().then(() => process.exit(0))
+31 -22
View File
@@ -1,50 +1,52 @@
const shibbolethHeadersFix = require('unfuck-utf8-headers-middleware')
const accessLogger = require('./middleware/accesslogger')
const sentryUserId = require('./middleware/sentryUserId')
const Sentry = require('@sentry/node')
const express = require('express')
const cors = require('cors')
const { frontUrl } = require('./conf-backend')
const shibbolethCharsetMiddleware = require('./middleware/shibbolethCharsetMiddleware')
const matomoInit = require('./routes/matomo-init')
const currentUserMiddleware = require('./middleware/currentUserMiddleware')
const accessLogger = require('./middleware/accessLogger')
const auth = require('./middleware/auth')
const courses = require('./routes/courses')
const students = require('./routes/students')
const population = require('./routes/population')
const login = require('./routes/login')
const superlogin = require('./routes/superlogin')
const language = require('./routes/language')
const users = require('./routes/users')
const elementdetails = require('./routes/elementdetails')
const auth = require('./middleware/auth')
const teachers = require('./routes/teachers')
const providers = require('./routes/providers')
const faculties = require('./routes/faculties')
const semesters = require('./routes/semesters')
const mandatoryCourses = require('./routes/mandatorycourses')
const mandatoryCourseLabels = require('./routes/mandatorycourselabels')
const ping = require('./routes/ping')
const feedback = require('./routes/feedback')
const tags = require('./routes/tags')
const updater = require('./routes/updater')
const tsaAnalytics = require('./routes/tsaAnalytics')
const matomoInit = require('./routes/matomo-init')
const customPopulationSearch = require('./routes/customPopulationSearch')
const trends = require('./routes/trends')
const programmeModules = require('./routes/programmeModules')
const studyGuidanceGroups = require('./routes/studyGuidanceGroups')
const studyProgramme = require('./routes/studyProgramme')
const initializeSentry = require('./util/sentry')
const errorMiddleware = require('./middleware/errorMiddleware')
module.exports = (app, url) => {
app.use(url, ping)
app.use(
shibbolethHeadersFix([
'hyGroupCn',
'SHIB_LOGOUT_URL',
'eduPersonAffiliation',
'uid',
'displayName',
'mail',
'hyPersonSisuId',
'preferredLanguage',
])
)
initializeSentry(app)
app.use(Sentry.Handlers.requestHandler())
app.use(Sentry.Handlers.tracingHandler())
app.use(cors({ credentials: true, origin: frontUrl }))
app.use(express.json())
app.use(shibbolethCharsetMiddleware)
app.use(url, matomoInit)
app.use(currentUserMiddleware)
app.use(accessLogger)
app.use(url, login)
app.use(`${url}/superlogin`, superlogin)
app.use(auth.checkAuth, auth.checkRequiredGroup, auth.checkUserBlacklisting, accessLogger, sentryUserId)
app.use(url, elementdetails)
app.use(url, courses)
app.use(url, students)
@@ -54,6 +56,7 @@ module.exports = (app, url) => {
app.use(url, semesters)
app.use(url, tags)
app.use(url, programmeModules)
app.use(url, studyProgramme)
app.use(`${url}/faculties`, faculties)
app.use(`${url}/updater`, auth.roles(['admin']), updater)
app.use(`${url}/teachers`, auth.roles(['teachers']), teachers)
@@ -65,4 +68,10 @@ module.exports = (app, url) => {
app.use(`${url}/custom-population-search`, customPopulationSearch)
app.use(`${url}/cool-data-science`, trends)
app.use(`${url}/studyguidancegroups`, auth.roles(['studyGuidanceGroups']), studyGuidanceGroups)
app.get('*', async (_, res) => {
const results = { error: 'unknown endpoint' }
res.status(404).json(results)
})
app.use(Sentry.Handlers.errorHandler())
app.use(errorMiddleware)
}
+3 -3
View File
@@ -16,7 +16,9 @@ router.get('/v2/coursesmulti', async (req, res) => {
})
router.get('/v3/courseyearlystats', async (req, res) => {
const { rights, roles } = req
const {
user: { rights, roles },
} = req
const allowedRoles = roles && ['admin', 'courseStatistics'].find(role => roles.includes(role))
@@ -42,6 +44,4 @@ router.get('/v3/courseyearlystats', async (req, res) => {
}
})
router.use('*', (req, res, next) => next())
module.exports = router
@@ -8,7 +8,7 @@ const {
router.get('/', async (req, res) => {
const {
decodedToken: { id },
user: { id },
} = req
const customPopulationSearches = await getCustomPopulationSearchesByUser(id)
res.json(customPopulationSearches)
@@ -16,7 +16,7 @@ router.get('/', async (req, res) => {
router.post('/', async (req, res) => {
const {
decodedToken: { id },
user: { id },
body: { name, students },
} = req
@@ -29,7 +29,7 @@ router.post('/', async (req, res) => {
router.put('/:id', async (req, res) => {
const {
decodedToken: { id: userId },
user: { id: userId },
body: { students },
} = req
const { id } = req.params
@@ -46,7 +46,7 @@ router.put('/:id', async (req, res) => {
router.delete('/:id', async (req, res) => {
const {
decodedToken: { id: userId },
user: { id: userId },
} = req
const { id } = req.params
@@ -1,23 +1,6 @@
const router = require('express').Router()
const MandatoryCourses = require('../services/mandatoryCourses')
const {
productivityStatsForStudytrack,
throughputStatsForStudytrack,
optionData,
} = require('../services/studyprogramme')
const { findProgrammeTheses, createThesisCourse, deleteThesisCourse } = require('../services/thesis')
const {
getProductivity,
setProductivity,
getThroughput,
setThroughput,
patchProductivity,
patchThroughput,
} = require('../services/analyticsService')
const { getAllProgrammes, getAllElementDetails } = require('../services/studyrights')
const logger = require('../util/logger')
const programmeStatsSince = new Date('2017-07-31')
router.get('/elementdetails/all', async (req, res) => {
const elementdetails = await getAllElementDetails()
@@ -29,22 +12,6 @@ router.get('/studyprogrammes', async (req, res) => {
res.json(studyrights)
})
router.get('/v2/studyprogrammes/:id/optiondata', async (req, res) => {
const code = req.params.id
let level
if (code.includes('MH')) {
level = 'MSC'
} else if (code.includes('KH')) {
level = 'BSC'
} else {
return res.json([])
}
const data = await optionData(new Date('2017-07-31'), new Date(), code, level)
res.json(data)
})
router.get('/v2/studyprogrammes/:id/mandatory_courses', async (req, res) => {
if (req.params.id) {
const codes = await MandatoryCourses.byStudyprogramme(req.params.id)
@@ -54,140 +21,4 @@ router.get('/v2/studyprogrammes/:id/mandatory_courses', async (req, res) => {
}
})
router.get('/v2/studyprogrammes/:id/productivity', async (req, res) => {
const code = req.params.id
if (code) {
let data = null
try {
data = await getProductivity(code)
} catch (e) {
logger.error(`Failed to get code ${code} productivity`)
}
if (!data) {
try {
const stats = await productivityStatsForStudytrack(code, programmeStatsSince)
data = await setProductivity(stats)
} catch (e) {
logger.error(`Failed to update code ${code} patching status to recalculation erroring`)
}
}
return res.json(data)
} else {
res.status(422).end()
}
})
router.get('/v2/studyprogrammes/productivity/recalculate', async (req, res) => {
const code = req.query.code
await patchThroughput({ [code]: { status: 'RECALCULATING' } })
res.status(200).end()
try {
if (code.includes('MH') || code.includes('KH')) {
const data = await productivityStatsForStudytrack(code, new Date('2017-07-31'))
await setProductivity(data)
} else {
const data = await productivityStatsForStudytrack(code, new Date('2000-07-31'))
await setProductivity(data)
}
} catch (e) {
try {
await patchProductivity({
[code]: { status: 'RECALCULATION ERRORED' },
})
} catch (e) {
logger.error(`Failed to update code ${code} patching status to recalculation erroring`)
return
}
logger.error(`Failed to update productivity stats for code: ${code}, reason: ${e.message}`)
}
logger.info(`Produdtiviy stats recalculation for studyprogramme ${code} done`)
})
router.get('/v2/studyprogrammes/:id/throughput', async (req, res) => {
const code = req.params.id
if (code) {
const thesisPromise = findProgrammeTheses(req.params.id)
let data = null
try {
data = await getThroughput(code)
} catch (e) {
logger.error(`Failed to get code ${code} throughput`)
}
if (!data) {
try {
const result = await throughputStatsForStudytrack(req.params.id, programmeStatsSince.getFullYear())
data = await setThroughput(result)
} catch (e) {
logger.error(`Failed to update code ${code} patching status to recalculation erroring`)
}
}
return res.json({ ...data, thesis: await thesisPromise })
} else {
res.status(422).end()
}
})
router.get('/v2/studyprogrammes/throughput/recalculate', async (req, res) => {
const code = req.query.code
await patchThroughput({ [code]: { status: 'RECALCULATING' } })
res.status(200).end()
try {
if (code.includes('MH') || code.includes('KH')) {
const data = await throughputStatsForStudytrack(code, 2017)
await setThroughput(data)
} else {
const data = await throughputStatsForStudytrack(code, 2000)
await setThroughput(data)
}
} catch (e) {
try {
await patchThroughput({ [code]: { status: 'RECALCULATION ERRORED' } })
} catch (e) {
logger.error(`Failed to update code ${code} patching status to recalculation erroring`)
return
}
logger.error(`Failed to update throughput stats for code: ${code}, reason: ${e.message}`)
}
logger.info(`Throughput stats recalculation for studyprogramme ${code} done`)
})
router.get('/v2/studyprogrammes/:id/thesis', async (req, res) => {
const { id } = req.params
if (id) {
const thesis = await findProgrammeTheses(id)
res.json(thesis)
} else {
res.status(422).end()
}
})
router.post('/v2/studyprogrammes/:id/thesis', async (req, res) => {
const { id } = req.params
const { course, thesisType } = req.body
if (id && course && thesisType) {
const thesis = await createThesisCourse(id, course, thesisType)
res.status(201).json(thesis)
} else {
res.status(422).end()
}
})
router.delete('/v2/studyprogrammes/:id/thesis/:course', async (req, res) => {
const { id, course } = req.params
if (id && course) {
const deleted = await deleteThesisCourse(id, course)
res.status(204).json(deleted)
} else {
res.status(422).end()
}
})
router.use('*', (req, res, next) => next())
module.exports = router
+6 -15
View File
@@ -1,28 +1,19 @@
const router = require('express').Router()
const { getUserDataFor } = require('../services/userService')
const { sendFeedbackToToska } = require('../services/mailservice')
const logger = require('../util/logger')
router.post('/email', async (req, res) => {
const { content } = req.body
router.post('/email', async req => {
const {
decodedToken: { userId },
body: { content },
user,
} = req
const { email, full_name } = await getUserDataFor(userId)
const result = await sendFeedbackToToska({
await sendFeedbackToToska({
feedbackContent: content,
userId,
userEmail: email,
userFullName: full_name,
user,
})
if (result.error) {
return res.status(400).json(result).end()
}
logger.info(`${userId} succesfully sent some feedback mail to toska`)
res.status(200).json('success').end()
logger.info(`${user.userId} succesfully sent feedback to toska`)
})
module.exports = router
+4 -2
View File
@@ -2,8 +2,10 @@ const router = require('express').Router()
const userService = require('../services/userService')
router.post('/language', async (req, res) => {
const { language } = req.body
const { userId } = req.decodedToken
const {
body: { language },
user: { userId },
} = req
if (!['fi', 'sv', 'en'].includes(language)) {
return res.status(400).json('invalid language')
}
+12 -40
View File
@@ -1,47 +1,19 @@
const router = require('express').Router()
const userService = require('../services/userService')
const { parseHyGroups } = require('../util/utils')
const { sendNotificationAboutNewUser } = require('../services/mailservice')
const logger = require('../util/logger')
const { ApplicationError } = require('../util/customErrors')
const _ = require('lodash')
router.post('/login', async (req, res) => {
const uid = req.headers['uid']
if (req.headers['shib-session-id'] && uid) {
const full_name = req.headers.displayname || ''
const mail = req.headers.mail || ''
const hyGroups = parseHyGroups(req.headers['hygroupcn'])
const affiliations = parseHyGroups(req.headers['edupersonaffiliation'])
const hyPersonSisuId = req.headers.hypersonsisuid || ''
logger.info(`${uid} trying to login, referring to userservice`)
let { token, isNew } = await userService.login(uid, full_name, hyGroups, affiliations, mail, hyPersonSisuId)
if (isNew) {
const result = await sendNotificationAboutNewUser({ userId: uid, userFullName: full_name })
if (result.error) {
return res.status(400).json(result).end()
}
}
res.status(200).json({ token })
} else {
res
.status(401)
.json({
message: `Not enough headers login, uid: ${req.headers.uid}
session-id ${req.headers['shib-session-id']}`,
})
.end()
}
})
router.get('/login', async (req, res) => {
const { user, logoutUrl } = req
router.delete('/logout', async (req, res) => {
const logoutUrl = req.headers.shib_logout_url
const { returnUrl } = req.body
if (logoutUrl) {
return res
.status(200)
.send({ logoutUrl: `${logoutUrl}?return=${returnUrl}` })
.end()
if (!user) {
throw new ApplicationError('User not found', 404)
}
res.status(200).send({ logoutUrl: returnUrl }).end()
res.send({
// don't send possibly huge list of students to frontend
user: _.omit(user, ['studentsUserCanAccess']),
logoutUrl,
})
})
module.exports = router
+1 -1
View File
@@ -28,7 +28,7 @@ _paq.push(["enableLinkTracking"]);
const script = config.MATOMO_URL ? acual : ''
router.get('/matomo-init', (req, res) => {
router.get('/matomo-init', (_, res) => {
res.contentType('text/javascript; charset=UTF-8')
res.send(script)
})
-85
View File
@@ -1,85 +0,0 @@
/* eslint-disable */
const { router, wrapper } = require('./router').routerWithWrapper()
const axios = require('axios')
wrapper.get('/ping', async (req, res) => {
res.json({
message: 'pong'
})
})
wrapper.get('/v3/mandatory_courses/:code', async (req, res) => {
const courses = []
const included = new Set()
const dumb_flatten = module => {
if (module.children) {
module.children.forEach(child => {
dumb_flatten(child)
})
} else if (module.code && !module.code.startsWith('KK') && !courses.map(c => c.code).includes(module.code)) {
courses.push({
name: {
fi: module.name,
en: module.name
},
code: module.code,
label: { id: `${courses.length}`, label: module.code.replace('-', '').slice(0, 4), orderNumber: courses.length }
})
}
}
const better_flatten = (module, label) => {
if (module.children) {
module.children.forEach(child => {
better_flatten(child, module.module ? module.module.name : label)
})
} else if (module.code && !module.code.startsWith('KK')) {
courses.push({
name: {
fi: module.name,
en: module.name
},
code: module.code,
label: { id: `${courses.length}`, label, orderNumber: courses.length }
})
}
}
const superFlattenFlatten = (module, label) => {
if (module.children) {
module.children.forEach(child => {
superFlattenFlatten(child, module.module ? module.module.name : label)
})
} else if (Array.isArray(module)) {
module.forEach(elem => superFlattenFlatten(elem, label))
} else if (module.code && !module.code.startsWith('KK')) {
if (!included.has(`${label}${module.code}`)) {
included.add(`${label}${module.code}`)
courses.push({
name: {
fi: module.name,
en: module.name
},
code: module.code,
label: { id: `${courses.length}`, label, orderNumber: courses.length }
})
}
}
}
const code = req.params.code
const response = await axios.get(`http://sis-updater-scheduler:8082/v1/courses/${code}?token=dev&superFlatten=true`)
// dumb_flatten(response.data)
// better_flatten(response.data)
superFlattenFlatten(response.data)
const byCode = (c1, c2) => (c1.code < c2.code ? -1 : 1)
courses.sort(byCode)
res.json(courses)
})
module.exports = router
+76 -99
View File
@@ -1,15 +1,14 @@
const crypto = require('crypto')
const Sentry = require('@sentry/node')
const router = require('express').Router()
const _ = require('lodash')
const Population = require('../services/populations')
const Student = require('../services/students')
const StudyrightService = require('../services/studyrights')
const UserService = require('../services/userService')
const TagService = require('../services/tags')
const CourseService = require('../services/courses')
const StatMergeService = require('../services/statMerger')
const { getAllStudentsUserHasInGroups } = require('../services/studyGuidanceGroups')
const { logger } = require('../util/logger')
const { ApplicationError } = require('../util/customErrors')
const filterPersonalTags = (population, userId) => {
return {
@@ -80,20 +79,13 @@ router.post('/v2/populationstatistics/coursesbycoursecode', async (req, res) =>
if (Math.abs(to - from + 1) > maxYearsToCreatePopulationFrom) {
return res.status(400).json({ error: `Max years to create population from is ${maxYearsToCreatePopulationFrom}` })
}
let studentnumberlist
const studentnumbers = await Student.findByCourseAndSemesters(coursecodes, from, to)
const {
decodedToken: { userId },
roles,
user: { isAdmin, studentsUserCanAccess },
} = req
if (roles && roles.includes('admin')) {
studentnumberlist = studentnumbers
} else {
const unitsUserCanAccess = await UserService.getUnitsFromElementDetails(userId)
const codes = unitsUserCanAccess.map(unit => unit.id)
studentnumberlist = await Student.filterStudentnumbersByAccessrights(studentnumbers, codes)
}
const studentnumbers = await Student.findByCourseAndSemesters(coursecodes, from, to)
const studentnumberlist = isAdmin ? studentnumbers : _.intersection(studentnumbers, studentsUserCanAccess)
const result = await Population.bottlenecksOf(
{
@@ -120,19 +112,12 @@ router.post('/v2/populationstatistics/coursesbytag', async (req, res) => {
res.status(400).json({ error: 'The body should have a tag defined' })
return
}
let studentnumberlist
const studentnumbers = await Student.findByTag(tag)
const {
decodedToken: { userId },
roles,
user: { isAdmin, studentsUserCanAccess },
} = req
if (roles && roles.includes('admin')) {
studentnumberlist = studentnumbers
} else {
const unitsUserCanAccess = await UserService.getUnitsFromElementDetails(userId)
const codes = unitsUserCanAccess.map(unit => unit.id)
studentnumberlist = await Student.filterStudentnumbersByAccessrights(studentnumbers, codes)
}
const studentnumbers = await Student.findByTag(tag)
const studentnumberlist = isAdmin ? studentnumbers : _.intersection(studentnumbers, studentsUserCanAccess)
const result = await Population.bottlenecksOf(
{
year: 1900,
@@ -154,27 +139,17 @@ router.post('/v2/populationstatistics/coursesbytag', async (req, res) => {
})
router.post('/v2/populationstatistics/coursesbystudentnumberlist', async (req, res) => {
if (!req.body.studentnumberlist) {
res.status(400).json({ error: 'The body should have a studentnumberlist defined' })
return
}
let studentnumberlist
const {
decodedToken: { userId, sisPersonId },
roles,
user: { isAdmin, studentsUserCanAccess },
body: { studentnumberlist: studentnumbersInReq },
} = req
if (roles && roles.includes('admin')) {
studentnumberlist = req.body.studentnumberlist
} else if (req.body.usingStudyGuidanceGroups) {
const studentsUserCanAccess = await getAllStudentsUserHasInGroups(sisPersonId)
studentnumberlist = req.body.studentnumberlist.filter(s => studentsUserCanAccess.has(s))
} else {
const unitsUserCanAccess = await UserService.getUnitsFromElementDetails(userId)
const codes = unitsUserCanAccess.map(unit => unit.id)
studentnumberlist = await Student.filterStudentnumbersByAccessrights(req.body.studentnumberlist, codes)
if (!studentnumbersInReq) {
throw new ApplicationError('The body should have a studentnumberlist defined', 400)
}
const studentnumberlist = isAdmin ? studentnumbersInReq : _.intersection(studentnumbersInReq, studentsUserCanAccess)
const result = await Population.bottlenecksOf(
{
year: 1900,
@@ -195,7 +170,7 @@ router.post('/v2/populationstatistics/coursesbystudentnumberlist', async (req, r
router.get('/v3/populationstatistics', async (req, res) => {
const { year, semesters, studyRights: studyRightsJSON } = req.query
const { decodedToken } = req
const { user } = req
if (!year || !semesters || !studyRightsJSON) {
res.status(400).json({ error: 'The query should have a year, semester and studyRights defined' })
@@ -204,13 +179,13 @@ router.get('/v3/populationstatistics', async (req, res) => {
let studyRights = null
try {
studyRights = JSON.parse(studyRightsJSON)
const { rights, roles } = req
const {
user: { rights, isAdmin },
} = req
if (!roles || !roles.includes('admin')) {
if (!rights.includes(studyRights.programme)) {
res.status(403).json([])
return
}
if (!isAdmin && !rights.includes(studyRights.programme)) {
res.status(403).json([])
return
}
} catch (e) {
res.status(400).json({ error: 'The query had invalid studyRights' })
@@ -245,7 +220,7 @@ router.get('/v3/populationstatistics', async (req, res) => {
return
}
res.json(filterPersonalTags(result, decodedToken.id))
res.json(filterPersonalTags(result, user.id))
} else {
const result = await Population.optimizedStatisticsOf({ ...req.query, studyRights })
if (result.error) {
@@ -254,32 +229,26 @@ router.get('/v3/populationstatistics', async (req, res) => {
return
}
res.json(filterPersonalTags(result, decodedToken.id))
res.json(filterPersonalTags(result, user.id))
}
})
router.get('/v3/populationstatisticsbytag', async (req, res) => {
const { tag, studyRights: studyRightsJSON, months, year } = req.query
const { decodedToken } = req
const {
user: { id, isAdmin, studentsUserCanAccess },
query: { tag, studyRights: studyRightsJSON, months, year },
} = req
if (!tag) return res.status(400).json({ error: 'The query should have a tag defined' })
const foundTag = await TagService.findTagById(tag)
if (!foundTag) return res.status(404).json({ error: 'Tag not found' })
const semesters = ['FALL', 'SPRING']
let studentnumberlist
const studentnumbers = await Student.findByTag(tag)
const {
decodedToken: { userId },
roles,
} = req
if (roles && roles.includes('admin')) {
studentnumberlist = studentnumbers
} else {
const unitsUserCanAccess = await UserService.getUnitsFromElementDetails(userId)
const codes = unitsUserCanAccess.map(unit => unit.id)
studentnumberlist = await Student.filterStudentnumbersByAccessrights(studentnumbers, codes)
}
const studentnumberlist = isAdmin ? studentnumbers : _.intersection(studentnumbers, studentsUserCanAccess)
const studyRights = JSON.parse(studyRightsJSON)
const newStartYear = await Population.getEarliestYear(studentnumberlist, studyRights)
const yearDifference = Number(year) - Number(newStartYear)
@@ -301,12 +270,14 @@ router.get('/v3/populationstatisticsbytag', async (req, res) => {
return
}
res.json(filterPersonalTags(result, decodedToken.id))
res.json(filterPersonalTags(result, id))
})
router.get('/v3/populationstatisticsbycourse', async (req, res) => {
const { coursecodes, from, to, separate: sep } = req.query
const { decodedToken, roles } = req
const { coursecodes, from, to, separate: sep, unifyCourses } = req.query
const {
user: { id, isAdmin, studentsUserCanAccess: allStudentsUserCanAccess },
} = req
const separate = sep ? JSON.parse(sep) : false
if (!coursecodes || !from || !to) {
@@ -322,7 +293,13 @@ router.get('/v3/populationstatisticsbycourse', async (req, res) => {
}
const semesters = ['FALL', 'SPRING']
const studentnumbers = await Student.findByCourseAndSemesters(JSON.parse(coursecodes), from, to, separate)
const studentnumbers = await Student.findByCourseAndSemesters(
JSON.parse(coursecodes),
from,
to,
separate,
unifyCourses
)
const result = await Population.optimizedStatisticsOf(
{
// Useless, because studentnumbers are already filtered above by from & to.
@@ -335,14 +312,9 @@ router.get('/v3/populationstatisticsbycourse', async (req, res) => {
studentnumbers
)
let studentsUserCanAccess
if (roles && roles.includes('admin')) {
studentsUserCanAccess = new Set(studentnumbers)
} else {
const unitsUserCanAccess = await UserService.getUnitsFromElementDetails(decodedToken.userId)
const codes = unitsUserCanAccess.map(unit => unit.id)
studentsUserCanAccess = new Set(await Student.filterStudentnumbersByAccessrights(studentnumbers, codes))
}
const studentsUserCanAccess = isAdmin
? new Set(studentnumbers)
: new Set(_.intersection(studentnumbers, allStudentsUserCanAccess))
const randomHash = crypto.randomBytes(12).toString('hex')
const obfuscateStudent = ({ studyrights, studentNumber, courses, gender_code }) => ({
@@ -368,26 +340,16 @@ router.get('/v3/populationstatisticsbycourse', async (req, res) => {
return
}
res.json(filterPersonalTags(result, decodedToken.id))
res.json(filterPersonalTags(result, id))
})
router.post('/v3/populationstatisticsbystudentnumbers', async (req, res) => {
const { studentnumberlist, usingStudyGuidanceGroups } = req.body
const { roles, decodedToken } = req
const { studentnumberlist } = req.body
const {
user: { isAdmin, id, studentsUserCanAccess },
} = req
if (usingStudyGuidanceGroups) {
if (!decodedToken.sisPersonId) {
logger.error(
`User ${decodedToken.userId} tried to get person groups but personId was ${decodedToken.sisPersonId} in header`
)
return res.status(400).json({ error: 'Not possible to get groups without personId' })
}
}
const studentsUserCanAccess = usingStudyGuidanceGroups
? await getAllStudentsUserHasInGroups(decodedToken.sisPersonId)
: await UserService.getStudentsUserCanAccess(studentnumberlist, roles, decodedToken.userId)
const filteredStudentNumbers = studentnumberlist.filter(s => studentsUserCanAccess.has(s))
const filteredStudentNumbers = isAdmin ? studentnumberlist : _.intersection(studentnumberlist, studentsUserCanAccess)
const result = await Population.optimizedStatisticsOf(
{
@@ -402,12 +364,14 @@ router.post('/v3/populationstatisticsbystudentnumbers', async (req, res) => {
Sentry.captureException(new Error(result.error))
return
}
res.status(200).json(filterPersonalTags(result, decodedToken.id))
res.status(200).json(filterPersonalTags(result, id))
})
router.get('/v3/populationstatistics/studyprogrammes', async (req, res) => {
const { rights, roles } = req
if (roles && roles.includes('admin')) {
const {
user: { rights, roles },
} = req
if (roles?.includes('admin')) {
const studyrights = await StudyrightService.getAssociations()
res.json(studyrights)
} else {
@@ -423,10 +387,23 @@ router.get('/v3/populationstatistics/studyprogrammes/unfiltered', async (req, re
router.get('/v3/populationstatistics/maxYearsToCreatePopulationFrom', async (req, res) => {
const { courseCodes } = req.query
const maxYearsToCreatePopulationFrom = await CourseService.maxYearsToCreatePopulationFrom(JSON.parse(courseCodes))
return res.json(maxYearsToCreatePopulationFrom)
const maxYearsToCreatePopulationFromOpen = await CourseService.maxYearsToCreatePopulationFrom(
JSON.parse(courseCodes),
'openStats'
)
const maxYearsToCreatePopulationFromUni = await CourseService.maxYearsToCreatePopulationFrom(
JSON.parse(courseCodes),
'reqularStats'
)
const maxYearsToCreatePopulationFromBoth = await CourseService.maxYearsToCreatePopulationFrom(
JSON.parse(courseCodes),
'unifyStats'
)
return res.json({
openCourses: maxYearsToCreatePopulationFromOpen,
uniCourses: maxYearsToCreatePopulationFromUni,
unifyCourses: maxYearsToCreatePopulationFromBoth,
})
})
router.use('*', (req, res, next) => next())
module.exports = router
-2
View File
@@ -6,6 +6,4 @@ router.get('/semesters/codes', async (req, res) => {
res.json(providers)
})
router.use('*', (req, res, next) => next())
module.exports = router
+15 -60
View File
@@ -1,8 +1,6 @@
const router = require('express').Router()
const Student = require('../services/students')
const userService = require('../services/userService')
const Unit = require('../services/units')
const { getAllStudentsUserHasInGroups } = require('../services/studyGuidanceGroups')
const { ApplicationError } = require('../util/customErrors')
const filterStudentTags = (student, userId) => {
return {
@@ -13,8 +11,7 @@ const filterStudentTags = (student, userId) => {
router.get('/students', async (req, res) => {
const {
roles,
decodedToken: { userId, sisPersonId },
user: { isAdmin, studentsUserCanAccess },
query: { searchTerm },
} = req
@@ -26,72 +23,30 @@ router.get('/students', async (req, res) => {
.slice(0, 2)
.find(t => t.length > 3)
) {
return res.status(400).json({ error: 'at least one search term must be longer than 3 characters' })
throw new ApplicationError('at least one search term must be longer than 3 characters', 400)
}
if (roles && roles.includes('admin')) {
let results = []
if (trimmedSearchTerm) {
results = await Student.bySearchTerm(trimmedSearchTerm)
}
return res.status(200).json(results).end()
} else {
const unitsUserCanAccess = await userService.getUnitsFromElementDetails(userId)
const codes = unitsUserCanAccess.map(unit => unit.id)
let extraStudents = []
if (roles.includes('studyGuidanceGroups')) {
const matchingOnlyByTerm = await Student.bySearchTerm(trimmedSearchTerm)
const studentsUserCanAccess = await getAllStudentsUserHasInGroups(sisPersonId)
extraStudents.push(...matchingOnlyByTerm.filter(s => studentsUserCanAccess.has(s.studentNumber)))
}
const matchingStudents = await Student.bySearchTermAndElements(trimmedSearchTerm, codes)
res.json([...matchingStudents, ...extraStudents])
let results = []
if (trimmedSearchTerm) {
results = isAdmin
? await Student.bySearchTerm(trimmedSearchTerm)
: await Student.bySearchTermAndStudentNumbers(trimmedSearchTerm, studentsUserCanAccess)
}
res.json(results)
})
router.get('/students/:id', async (req, res) => {
const { id: studentId } = req.params
const { roles, decodedToken } = req
const {
user: { id, isAdmin, studentsUserCanAccess },
} = req
if (roles && roles.includes('admin')) {
const results = await Student.withId(studentId)
return results.error
? res.status(400).json({ error: 'error finding student' }).end()
: res.status(200).json(filterStudentTags(results, decodedToken.id)).end()
if (!isAdmin && !studentsUserCanAccess.includes(studentId)) {
throw new ApplicationError('Error finding student', 400)
}
if (roles && roles.includes('studyGuidanceGroups')) {
const studentsUserCanAccess = await getAllStudentsUserHasInGroups(decodedToken.sisPersonId)
if (!studentsUserCanAccess.has(studentId)) {
return res.status(400).json({ error: 'error finding student' }).end()
}
const results = await Student.withId(studentId)
return results.error
? res.status(400).json({ error: 'error finding student' }).end()
: res.status(200).json(filterStudentTags(results, decodedToken.id)).end()
}
const uid = req.decodedToken.userId
const student = await Student.withId(studentId)
if (student.error) {
return res.status(400).json({ error: 'error finding student' }).end()
}
const units = await userService.getUnitsFromElementDetails(uid)
const rights = await Promise.all(
units.map(async unit => {
const jtn = await Unit.hasStudent(unit.id, student.studentNumber)
return jtn
})
)
if (rights.some(right => right !== null)) {
res.status(200).json(filterStudentTags(student, decodedToken.id)).end()
} else {
res.status(400).json({ error: 'error finding student' }).end()
}
res.json(filterStudentTags(student, id))
})
router.use('*', (req, res, next) => next())
module.exports = router
@@ -4,7 +4,7 @@ const { getAllGroupsAndStudents, changeGroupTags } = require('../services/studyG
router.get('/', async (req, res) => {
const {
decodedToken: { uid, sisPersonId },
user: { uid, sisPersonId },
} = req
if (!sisPersonId) {
logger.error(`User ${uid} tried to get person groups but personId was ${sisPersonId} in header`)
@@ -15,7 +15,7 @@ router.get('/', async (req, res) => {
router.put('/:id/tags', async (req, res) => {
const {
decodedToken: { uid, sisPersonId },
user: { uid, sisPersonId },
body: tags,
params: { id: groupId },
} = req
@@ -0,0 +1,177 @@
const router = require('express').Router()
const { getBasicStatsForStudytrack } = require('../services/studyprogrammeBasics')
const { getCreditStatsForStudytrack } = require('../services/studyprogrammeCredits')
const { getGraduationStatsForStudytrack } = require('../services/studyprogrammeGraduations')
const { getStudytrackStatsForStudyprogramme } = require('../services/studytrackStats')
const {
getBasicStats,
setBasicStats,
getCreditStats,
setCreditStats,
getGraduationStats,
setGraduationStats,
getStudytrackStats,
setStudytrackStats,
} = require('../services/analyticsService')
const { updateBasicView, updateStudytrackView } = require('../services/studyprogrammeUpdates')
const logger = require('../util/logger')
router.get('/v2/studyprogrammes/:id/basicstats', async (req, res) => {
const code = req.params.id
const yearType = req.query?.year_type
const specialGroups = req.query?.special_groups
if (code) {
let data = null
try {
data = await getBasicStats(code, yearType, specialGroups)
} catch (e) {
logger.error(`Failed to get code ${code} basic stats: ${e}`)
}
if (!data) {
try {
const result = await getBasicStatsForStudytrack({
studyprogramme: req.params.id,
settings: {
isAcademicYear: yearType === 'ACADEMIC_YEAR',
includeAllSpecials: specialGroups === 'SPECIAL_INCLUDED',
},
})
data = await setBasicStats(result, yearType, specialGroups)
} catch (e) {
logger.error(`Failed to update code ${code} basic stats: ${e}`)
}
}
return res.json(data)
} else {
res.status(422).end()
}
})
router.get('/v2/studyprogrammes/:id/creditstats', async (req, res) => {
const code = req.params.id
const yearType = req.query?.year_type
const specialGroups = req.query?.special_groups
if (code) {
let data = null
try {
data = await getCreditStats(code, yearType, specialGroups)
} catch (e) {
logger.error(`Failed to get code ${code} credit stats`)
}
if (!data) {
try {
const result = await getCreditStatsForStudytrack({
studyprogramme: req.params.id,
settings: {
isAcademicYear: yearType === 'ACADEMIC_YEAR',
includeAllSpecials: specialGroups === 'SPECIAL_INCLUDED',
},
})
data = await setCreditStats(result, yearType, specialGroups)
} catch (e) {
logger.error(`Failed to update code ${code} credit stats`)
}
}
return res.json(data)
} else {
res.status(422).end()
}
})
router.get('/v2/studyprogrammes/:id/graduationstats', async (req, res) => {
const code = req.params.id
const yearType = req.query?.year_type
const specialGroups = req.query?.special_groups
if (code) {
let data = null
try {
data = await getGraduationStats(code, yearType, specialGroups)
} catch (e) {
logger.error(`Failed to get code ${code} graduation stats`)
}
if (!data) {
try {
const result = await getGraduationStatsForStudytrack({
studyprogramme: req.params.id,
settings: {
isAcademicYear: yearType === 'ACADEMIC_YEAR',
includeAllSpecials: specialGroups === 'SPECIAL_INCLUDED',
},
})
data = await setGraduationStats(result, yearType, specialGroups)
} catch (e) {
logger.error(`Failed to update code ${code} graduation stats`)
}
}
return res.json(data)
} else {
res.status(422).end()
}
})
router.get('/v2/studyprogrammes/:id/studytrackstats', async (req, res) => {
const code = req.params.id
const graduated = req.query?.graduated
const specialGroups = req.query?.special_groups
if (code) {
let data = null
try {
data = await getStudytrackStats(code, graduated, specialGroups)
} catch (e) {
logger.error(`Failed to get code ${code} studytrack stats: ${e}`)
}
if (!data) {
try {
const result = await getStudytrackStatsForStudyprogramme({
studyprogramme: code,
settings: {
graduated: graduated === 'GRADUATED_INCLUDED',
specialGroups: specialGroups === 'SPECIAL_INCLUDED',
},
})
data = await setStudytrackStats(result, graduated, specialGroups)
} catch (e) {
logger.error(`Failed to update code ${code} studytrack stats: ${e}`)
}
}
return res.json(data)
} else {
res.status(422).end()
}
})
router.get('/v2/studyprogrammes/:id/update_basicview', async (req, res) => {
const code = req.params.id
if (code) {
let result = null
try {
result = await updateBasicView(code)
} catch (e) {
logger.error(`Failed to update code ${code} basic stats: ${e}`)
}
return res.json(result)
} else {
res.status(422).end()
}
})
router.get('/v2/studyprogrammes/:id/update_studytrackview', async (req, res) => {
const code = req.params.id
if (code) {
let result = null
try {
result = await updateStudytrackView(code)
} catch (e) {
logger.error(`Failed to update code ${code} studytrack stats: ${e}`)
}
return res.json(result)
} else {
res.status(422).end()
}
})
module.exports = router
-21
View File
@@ -1,21 +0,0 @@
const router = require('express').Router()
const userService = require('../services/userService')
router.post('/:uid', async (req, res) => {
const uid = req.headers['uid']
if (req.headers['shib-session-id'] && uid) {
const asUser = req.params.uid
const token = await userService.superlogin(uid, asUser)
res.status(200).json(token)
} else {
res
.status(401)
.json({
message: `Not enough headers login, uid:
${req.headers.uid} session-id ${req.headers['shib-session-id']}`,
})
.end()
}
})
module.exports = router
+43 -33
View File
@@ -12,48 +12,50 @@ const filterRelevantStudentTags = (studentTags, userId) => {
return studentTags.filter(({ tag }) => !tag.personal_user_id || tag.personal_user_id === userId)
}
router.get('/tags', async (req, res) => {
router.get('/tags', async (_req, res) => {
const tags = await Tags.findTags()
res.status(200).json(tags)
})
router.get('/tags/:studytrack', async (req, res) => {
const { studytrack } = req.params
const { rights, roles, decodedToken } = req
const {
user: { rights, roles, id },
} = req
if (!rights.includes(studytrack) && !(roles && roles.includes('admin'))) return res.status(403).end()
if (!rights.includes(studytrack) && !roles?.includes('admin')) return res.status(403).end()
const tags = await Tags.findTagsByStudytrack(studytrack)
res.status(200).json(filterRelevantTags(tags, decodedToken.id))
res.status(200).json(filterRelevantTags(tags, id))
})
router.post('/tags', async (req, res) => {
const {
tag: { studytrack, tagname, year, personal_user_id },
} = req.body
const { rights, roles, decodedToken } = req
const {
user: { rights, roles, id },
} = req
if (!rights.includes(studytrack) && !(roles && roles.includes('admin'))) return res.status(403).end()
if (!rights.includes(studytrack) && !roles?.includes('admin')) return res.status(403).end()
await Tags.createNewTag({ studytrack, tagname, year, personal_user_id })
const tags = await Tags.findTagsByStudytrack(studytrack)
res.status(200).json(filterRelevantTags(tags, decodedToken.id))
res.status(200).json(filterRelevantTags(tags, id))
})
router.delete('/tags', async (req, res) => {
const { tag } = req.body
const { rights, roles, decodedToken } = req
const {
user: { rights, roles, id },
} = req
if (
!rights.includes(tag.studytrack) &&
!(roles && roles.includes('admin')) &&
!(tag.personal_user_id === decodedToken.id)
)
if (!rights.includes(tag.studytrack) && !roles?.includes('admin') && !(tag.personal_user_id === id))
return res.status(403).end()
await Tags.deleteTag(tag)
const t = await Tags.findTagsByStudytrack(tag.studytrack)
res.status(200).json(filterRelevantTags(t, decodedToken.id))
res.status(200).json(filterRelevantTags(t, id))
})
router.get('/studenttags', async (req, res) => {
@@ -63,37 +65,43 @@ router.get('/studenttags', async (req, res) => {
router.get('/studenttags/:studytrack', async (req, res) => {
const { studytrack } = req.params
const { rights, roles, decodedToken } = req
const {
user: { rights, roles, id },
} = req
if (!rights.includes(studytrack) && !(roles && roles.includes('admin'))) return res.status(403).end()
if (!rights.includes(studytrack) && !roles?.includes('admin')) return res.status(403).end()
const result = await TagStudent.getStudentTagsByStudytrack(studytrack)
res.status(200).json(filterRelevantStudentTags(result, decodedToken.id))
res.status(200).json(filterRelevantStudentTags(result, id))
})
router.get('/studenttags/:studentnumber', async (req, res) => {
const { studentnumber } = req.params
const { decodedToken } = req
const { user } = req
const result = await TagStudent.getStudentTagsByStudentnumber(studentnumber)
res.status(200).json(filterRelevantStudentTags(result, decodedToken.id))
res.status(200).json(filterRelevantStudentTags(result, user.id))
})
router.post('/studenttags/:studentnumber', async (req, res) => {
const { tag, studytrack } = req.body
const { rights, roles, decodedToken } = req
const {
user: { roles, rights, id },
} = req
if (!rights.includes(studytrack) && !(roles && roles.includes('admin'))) return res.status(403).end()
if (!rights.includes(studytrack) && !roles?.includes('admin')) return res.status(403).end()
await TagStudent.createStudentTag(tag)
const result = await TagStudent.getStudentTagsByStudytrack(studytrack)
res.status(200).json(filterRelevantStudentTags(result, decodedToken.id))
res.status(200).json(filterRelevantStudentTags(result, id))
})
router.post('/studenttags', async (req, res) => {
const { tags, studytrack } = req.body
const { rights, roles, decodedToken } = req
const {
user: { rights, roles, id },
} = req
if (!rights.includes(studytrack) && !(roles && roles.includes('admin'))) return res.status(403).end()
if (!rights.includes(studytrack) && !roles?.includes('admin')) return res.status(403).end()
const existingtags = await Tags.findTagsByStudytrack(studytrack)
const existingTagids = existingtags.map(t => t.tag_id)
@@ -110,37 +118,39 @@ router.post('/studenttags', async (req, res) => {
await TagStudent.createMultipleStudentTags(tags)
const result = await TagStudent.getStudentTagsByStudytrack(studytrack)
res.status(200).json(filterRelevantStudentTags(result, decodedToken.id))
res.status(200).json(filterRelevantStudentTags(result, id))
})
router.delete('/studenttags/delete_one', async (req, res) => {
const { tag_id, studentnumber, studytrack } = req.body
const { rights, roles, decodedToken } = req
const {
user: { rights, roles, id },
} = req
if (!rights.includes(studytrack) && !(roles && roles.includes('admin'))) return res.status(403).end()
if (!rights.includes(studytrack) && !roles?.includes('admin')) return res.status(403).end()
const tags = await Tags.findTagsFromStudytrackById(studytrack, [tag_id])
if (tags.length === 0) return res.status(403).json({ error: 'The tag does not exist' })
await TagStudent.deleteStudentTag(studentnumber, tag_id)
const result = await TagStudent.getStudentTagsByStudytrack(studytrack)
res.status(200).json(filterRelevantStudentTags(result, decodedToken.id))
res.status(200).json(filterRelevantStudentTags(result, id))
})
router.delete('/studenttags/delete_many', async (req, res) => {
const { tagId, studentnumbers, studytrack } = req.body
const { rights, roles, decodedToken } = req
const {
user: { rights, roles, id },
} = req
if (!rights.includes(studytrack) && !(roles && roles.includes('admin'))) return res.status(403).end()
if (!rights.includes(studytrack) && !roles?.includes('admin')) return res.status(403).end()
const tags = await Tags.findTagsFromStudytrackById(studytrack, [tagId])
if (tags.length === 0) return res.status(403).json({ error: 'The tag does not exist' })
await TagStudent.deleteMultipleStudentTags(tagId, studentnumbers)
const result = await TagStudent.getStudentTagsByStudytrack(studytrack)
res.status(200).json(filterRelevantStudentTags(result, decodedToken.id))
res.status(200).json(filterRelevantStudentTags(result, id))
})
router.use('*', (req, res, next) => next())
module.exports = router
+3 -3
View File
@@ -42,7 +42,9 @@ router.get('/top/categories', async (req, res) => {
})
router.get('/stats', async (req, res) => {
const { rights, roles } = req
const {
user: { rights, roles },
} = req
const { providers, semesterStart, semesterEnd } = req.query
if (!providers || !semesterStart) {
@@ -78,6 +80,4 @@ router.get('/:id', async (req, res) => {
res.json(result)
})
router.use('*', (req, res, next) => next())
module.exports = router
+5 -1
View File
@@ -9,8 +9,12 @@ router.post('/event', (req, res) => {
return res.status(400).json({ error: 'group, name and value are required' })
}
const {
user: { userId },
} = req
// don't await here because frontend doesn't care if it succeeds
tsaService.sendTsaEvent(req.decodedToken.userId, { group, name, label, value }).catch(e => {
tsaService.sendTsaEvent(userId, { group, name, label, value }).catch(e => {
Sentry.withScope(scope => {
// if error was caused by a 400, dig out the JSON response for Sentry
if (e.isAxiosError && e.response && e.response.data) {
-18
View File
@@ -1,18 +1,8 @@
const router = require('express').Router()
const userService = require('../services/userService')
const blacklist = require('../services/blacklist')
const { userDataCache } = require('../services/cache')
const { sendNotificationAboutAccessToUser, previewNotificationAboutAccessToUser } = require('../services/mailservice')
const logger = require('../util/logger')
const addUserToBlacklist = async (user, decodedToken) => {
if (user) {
const { username } = user
userDataCache.del(username)
if (username != decodedToken.userId) await blacklist.addUserToBlacklist(username)
}
}
router.get('/', async (req, res) => {
const results = await userService.findAll()
res.json(results)
@@ -25,12 +15,7 @@ router.get('/access_groups', async (req, res) => {
router.post('/modifyaccess', async (req, res) => {
try {
const { username } = req.body
const result = await userService.modifyAccess(req.body)
const user = {
username,
}
await addUserToBlacklist(user, req.decodedToken)
res.status(200).json(result)
} catch (e) {
res.status(400).json(e)
@@ -60,7 +45,6 @@ router.post('/:uid/elements', async (req, res) => {
const { uid } = req.params
const { codes } = req.body
const user = await userService.enableElementDetails(uid, codes)
await addUserToBlacklist(user, req.decodedToken)
res.json(user)
})
@@ -68,7 +52,6 @@ router.delete('/:uid/elements', async (req, res) => {
const { uid } = req.params
const { codes } = req.body
const user = await userService.removeElementDetails(uid, codes)
await addUserToBlacklist(user, req.decodedToken)
res.json(user)
})
@@ -76,7 +59,6 @@ router.post('/:uid/faculties', async (req, res) => {
const { uid } = req.params
const { faculties } = req.body
const user = await userService.setFaculties(uid, faculties)
await addUserToBlacklist(user, req.decodedToken)
res.json(user)
})
@@ -1,21 +1,23 @@
const { redisClient } = require('../services/redis')
const moment = require('moment')
const createRedisKeyForProductivity = id => `PRODUCTIVITY_${id}`
const createRedisKeyForThroughput = id => `THROUGHPUT_${id}`
const createRedisKeyForBasicStats = (id, yearType, specialGroups) => `BASIC_STATS_${id}_${yearType}_${specialGroups}`
const createRedisKeyForCreditStats = (id, yearType, specialGroups) => `CREDIT_STATS_${id}_${yearType}_${specialGroups}`
const createRedisKeyForGraduationStats = (id, yearType, specialGroups) =>
`GRADUATION_STATS_${id}_${yearType}_${specialGroups}`
const createRedisKeyForStudytrackStats = (id, graduated, specialGroups) =>
`STUDYTRACK_STATS_${id}_${graduated}_${specialGroups}`
const getProductivity = async id => {
const redisKey = createRedisKeyForProductivity(id)
const getBasicStats = async (id, yearType, specialGroups) => {
const redisKey = createRedisKeyForBasicStats(id, yearType, specialGroups)
const dataFromRedis = await redisClient.getAsync(redisKey)
if (!dataFromRedis) return null
return {
[id]: JSON.parse(dataFromRedis),
}
return JSON.parse(dataFromRedis)
}
const setProductivity = async data => {
const setBasicStats = async (data, yearType, specialGroups) => {
const { id } = data
const redisKey = createRedisKeyForProductivity(id)
const redisKey = createRedisKeyForBasicStats(id, yearType, specialGroups)
const dataToRedis = {
...data,
status: 'DONE',
@@ -23,75 +25,76 @@ const setProductivity = async data => {
}
const setOperationStatus = await redisClient.setAsync(redisKey, JSON.stringify(dataToRedis))
if (setOperationStatus !== 'OK') return null
return {
[id]: dataToRedis,
}
return dataToRedis
}
const patchProductivity = async data => {
const { id } = data
const redisKey = createRedisKeyForProductivity(id)
const dataFromRedis = JSON.parse(await redisClient.getAsync(redisKey))
const patchedData = {
...dataFromRedis,
...data,
lastUpdated: moment().format(),
}
const setOperationStatus = await redisClient.setAsync(redisKey, JSON.stringify(patchedData))
if (setOperationStatus !== 'OK') return null
return {
[id]: patchedData,
}
}
const getThroughput = async id => {
const redisKey = createRedisKeyForThroughput(id)
const getCreditStats = async (id, yearType, specialGroups) => {
const redisKey = createRedisKeyForCreditStats(id, yearType, specialGroups)
const dataFromRedis = await redisClient.getAsync(redisKey)
if (!dataFromRedis) return null
return {
[id]: JSON.parse(dataFromRedis),
}
return JSON.parse(dataFromRedis)
}
const setThroughput = async data => {
const { id, data: dataToSet } = data
const redisKey = createRedisKeyForThroughput(id)
const setCreditStats = async (data, yearType, specialGroups) => {
const { id } = data
const redisKey = createRedisKeyForCreditStats(id, yearType, specialGroups)
const dataToRedis = {
data: dataToSet.years,
totals: dataToSet.totals,
stTotals: dataToSet.stTotals,
...data,
status: 'DONE',
lastUpdated: moment().format(),
}
const setOperationStatus = await redisClient.setAsync(redisKey, JSON.stringify(dataToRedis))
if (setOperationStatus !== 'OK') return null
return {
[id]: dataToRedis,
}
return dataToRedis
}
const patchThroughput = async data => {
const [id, dataToPatch] = Object.entries(data)[0]
const redisKey = createRedisKeyForThroughput(id)
const { status } = dataToPatch
const dataFromRedis = JSON.parse(await redisClient.getAsync(redisKey))
const patchedData = {
...dataFromRedis,
status,
const getGraduationStats = async (id, yearType, specialGroups) => {
const redisKey = createRedisKeyForGraduationStats(id, yearType, specialGroups)
const dataFromRedis = await redisClient.getAsync(redisKey)
if (!dataFromRedis) return null
return JSON.parse(dataFromRedis)
}
const setGraduationStats = async (data, yearType, specialGroups) => {
const { id } = data
const redisKey = createRedisKeyForGraduationStats(id, yearType, specialGroups)
const dataToRedis = {
...data,
status: 'DONE',
lastUpdated: moment().format(),
}
const setOperationStatus = await redisClient.setAsync(redisKey, JSON.stringify(patchedData))
const setOperationStatus = await redisClient.setAsync(redisKey, JSON.stringify(dataToRedis))
if (setOperationStatus !== 'OK') return null
return {
[id]: patchedData,
return dataToRedis
}
const getStudytrackStats = async (id, graduated, specialGroups) => {
const redisKey = createRedisKeyForStudytrackStats(id, graduated, specialGroups)
const dataFromRedis = await redisClient.getAsync(redisKey)
if (!dataFromRedis) return null
return JSON.parse(dataFromRedis)
}
const setStudytrackStats = async (data, graduated, specialGroups) => {
const { id } = data
const redisKey = createRedisKeyForStudytrackStats(id, graduated, specialGroups)
const dataToRedis = {
...data,
status: 'DONE',
lastUpdated: moment().format(),
}
const setOperationStatus = await redisClient.setAsync(redisKey, JSON.stringify(dataToRedis))
if (setOperationStatus !== 'OK') return null
return dataToRedis
}
module.exports = {
getProductivity,
setProductivity,
patchProductivity,
getThroughput,
setThroughput,
patchThroughput,
getBasicStats,
setBasicStats,
getCreditStats,
setCreditStats,
getGraduationStats,
setGraduationStats,
getStudytrackStats,
setStudytrackStats,
}
@@ -1,22 +0,0 @@
const { redisClient } = require('./redis')
const moment = require('moment')
const logger = require('../util/logger')
const MAKE_REDIS_HASH_KEY = id => `BLACKLIST ${id}`
const addUserToBlacklist = async userId => {
logger.info(`user ${userId} added to token blacklist`)
await redisClient.setAsync(MAKE_REDIS_HASH_KEY(userId), moment().toISOString(false))
}
const isUserBlacklisted = async (userId, tokenCreatedAt) => {
const isBlacklisted = async () => {
const blacklistTimestamp = await redisClient.getAsync(MAKE_REDIS_HASH_KEY(userId))
return tokenCreatedAt && blacklistTimestamp && moment(tokenCreatedAt) < moment(blacklistTimestamp)
}
const timer = () => new Promise(resolve => setTimeout(() => resolve(true), 5000))
return Promise.race([isBlacklisted(), timer()])
}
module.exports = { addUserToBlacklist, isUserBlacklisted }
-12
View File
@@ -1,12 +0,0 @@
const LRU = require('lru-cache')
// Max 25 users can be stored in the cache
const userDataCache = new LRU({
max: 25,
length: () => 1,
maxAge: 1000 * 60 * 60,
})
module.exports = {
userDataCache,
}
@@ -40,18 +40,22 @@ class CourseStatsCounter {
triedOfPopulation: undefined,
passingSemesters: this.initializePassingSemesters(),
}
this.enrollments = {
enrolledNoGrade: new Set(),
semesters: this.initializePassingSemesters({}),
}
this.grades = {}
}
initializePassingSemesters() {
initializePassingSemesters(initialValue = 0) {
const passingSemesters = {
BEFORE: 0,
LATER: 0,
BEFORE: initialValue,
LATER: initialValue,
}
for (let i = 0; i < 7; i++) {
passingSemesters[fall[i]] = 0
passingSemesters[spring[i]] = 0
passingSemesters[fall[i]] = initialValue
passingSemesters[spring[i]] = initialValue
}
return passingSemesters
@@ -91,6 +95,13 @@ class CourseStatsCounter {
}
}
markEnrollment(studentnumber, state, semester) {
if (!this.enrollments[state]) this.enrollments[state] = new Set()
this.enrollments[state].add(studentnumber)
if (!this.enrollments.semesters[semester][state]) this.enrollments.semesters[semester][state] = new Set()
this.enrollments.semesters[semester][state].add(studentnumber)
}
failedBefore(studentnumber) {
return this.students.failed[studentnumber] !== undefined
}
@@ -173,6 +184,10 @@ 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
stats.students = lengthOf(students.all)
stats.passed = lengthOf(students.passed)
@@ -185,6 +200,9 @@ 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.percentageWithEnrollments = percentageOf(stats.passed, stats.totalStudents)
return {
stats,
@@ -8,12 +8,23 @@ class CourseYearlyStatsCounter {
}
initProgramme(code, name) {
this.programmes[code] = { name, students: {}, passed: {}, credits: {} }
this.programmes[code] = {
name,
students: {},
passed: {},
credits: {},
}
}
initFacultyYear(code) {
const year = `${1949 + Number(code)}-${1950 + Number(code)}`
this.facultyStats[code] = { year, allStudents: [], allPassed: [], faculties: {}, allCredits: 0 }
this.facultyStats[code] = {
year,
allStudents: [],
allPassed: [],
faculties: {},
allCredits: 0,
}
}
initFaculty(yearcode, faculty_code, organization) {
@@ -45,6 +56,8 @@ class CourseYearlyStatsCounter {
},
studentnumbers: [],
},
enrollments: [],
allEnrollments: [],
yearcode,
}
}
@@ -97,6 +110,21 @@ class CourseYearlyStatsCounter {
})
}
markStudyProgrammesEnrollment(studentnumber, programmes, yearcode, state, enrollment_date_time) {
programmes.forEach(({ code, name, faculty_code, organization }) => {
this.markStudyProgrammeEnrollment(
code,
name,
studentnumber,
yearcode,
state,
enrollment_date_time,
faculty_code,
organization
)
})
}
markCreditToGroup(studentnumber, passed, grade, groupcode, groupname, coursecode, yearcode) {
if (!this.groups[groupcode]) {
this.initGroup(groupcode, groupname, coursecode, yearcode)
@@ -104,6 +132,20 @@ class CourseYearlyStatsCounter {
this.markCreditToAttempts(studentnumber, passed, grade, groupcode)
}
markEnrollmentToGroup(studentnumber, state, enrollment_date_time, groupcode, groupname, coursecode, yearcode) {
if (!this.groups[groupcode]) this.initGroup(groupcode, groupname, coursecode, yearcode)
const enrollment = { studentnumber, state, enrollment_date_time }
this.groups[groupcode].allEnrollments.push(enrollment)
const oldEnrollment = this.groups[groupcode].enrollments.find(e => e.studentnumber === studentnumber)
if (!oldEnrollment) return this.groups[groupcode].enrollments.push({ studentnumber, state, enrollment_date_time })
if (oldEnrollment.state === 'ENROLLED' || oldEnrollment.state === 'CONFIRMED') return
if (state !== 'ENROLLED' || state !== 'CONFIRMED') return
this.groups[groupcode].enrollments = this.groups[groupcode].enrollments
.filter(e => e.studentnumber !== studentnumber)
.concat([enrollment])
}
markCreditToAttempts(studentnumber, passed, grade, groupcode) {
const { attempts } = this.groups[groupcode]
const { grades, categories } = attempts

Some files were not shown because too many files have changed in this diff Show More