mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[ApiTests][CourseYearlyStats] Fix tests to handle CU changes
This commit is contained in:
+2
-2
@@ -4,12 +4,12 @@ import { describe, it, beforeAll, assert } from 'vitest'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
void describe('Course yearly attempt statistics - MAT11001 (no substitutions)', () => {
|
||||
void describe('Course yearly attempt statistics - MAT11001 (hy-CU-117375151, no substitutions)', () => {
|
||||
let app: Express
|
||||
let body: CourseYearlyStats
|
||||
beforeAll(async () => {
|
||||
app = await initTests()
|
||||
body = await getCourseYearlyStats(app, 'codes=MAT11001&combineSubstitutions=false')
|
||||
body = await getCourseYearlyStats(app, 'courses=hy-CU-117375151&substitutions=false')
|
||||
})
|
||||
|
||||
it('should include every attempt of a student who has only failed the course', () => {
|
||||
|
||||
+2
-2
@@ -4,12 +4,12 @@ import { describe, it, beforeAll, assert } from 'vitest'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
void describe('Course yearly attempt statistics - MAT11002 (no substitutions)', () => {
|
||||
void describe('Course yearly attempt statistics - MAT11002 (hy-CU-117375394, no substitutions)', () => {
|
||||
let app: Express
|
||||
let body: CourseYearlyStats
|
||||
beforeAll(async () => {
|
||||
app = await initTests()
|
||||
body = await getCourseYearlyStats(app, 'codes=MAT11002&combineSubstitutions=false')
|
||||
body = await getCourseYearlyStats(app, 'courses=hy-CU-117375394&substitutions=false')
|
||||
})
|
||||
|
||||
// FIXME: What is this even testing??
|
||||
|
||||
+12
-8
@@ -5,7 +5,11 @@ import { yearToYearCode } from '@oodikone/shared/util'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
void describe('Course yearly attempt statistics - MAT21003 (no substitutions)', () => {
|
||||
const courseCodeToGroupId = {
|
||||
MAT21003: 'hy-CU-117375829',
|
||||
}
|
||||
|
||||
void describe('Course yearly attempt statistics - MAT21003 (hy-CU-117375394, no substitutions)', () => {
|
||||
let app: Express
|
||||
beforeAll(async () => {
|
||||
app = await initTests()
|
||||
@@ -14,7 +18,7 @@ void describe('Course yearly attempt statistics - MAT21003 (no substitutions)',
|
||||
describe('duplicate failed attempts across a large timespan are counted separately', () => {
|
||||
let body: CourseYearlyStats
|
||||
beforeAll(async () => {
|
||||
body = await getCourseYearlyStats(app, 'codes=MAT21003&combineSubstitutions=false')
|
||||
body = await getCourseYearlyStats(app, `courses=${courseCodeToGroupId.MAT21003}&substitutions=false`)
|
||||
})
|
||||
|
||||
it('2017-2018 should include a single failed attempt (539036)', () => {
|
||||
@@ -42,7 +46,7 @@ void describe('Course yearly attempt statistics - MAT21003 (no substitutions)',
|
||||
])('should include correct years for %s', async (name, from, to) => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=MAT21003&combineSubstitutions=false&fromYearCode=${yearToYearCode(from)}&toYearCode=${yearToYearCode(to)}`
|
||||
`courses=hy-CU-117375394&substitutions=false&fromYearCode=${yearToYearCode(from)}&toYearCode=${yearToYearCode(to)}`
|
||||
)
|
||||
|
||||
const years: string[] = []
|
||||
@@ -50,7 +54,7 @@ void describe('Course yearly attempt statistics - MAT21003 (no substitutions)',
|
||||
years.push(`${i}-${i + 1}`)
|
||||
}
|
||||
assert.deepStrictEqual(
|
||||
body.unifyStats!.statistics.map(({ name }) => name),
|
||||
body.unifyStats.statistics.map(({ name }) => name),
|
||||
years,
|
||||
`${name} included incorrect years`
|
||||
)
|
||||
@@ -61,9 +65,9 @@ void describe('Course yearly attempt statistics - MAT21003 (no substitutions)',
|
||||
it('2017-2018 should include a failed attempt (539036)', async () => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=MAT21003&combineSubstitutions=false&fromYearCode=${yearToYearCode(2017)}&toYearCode=${yearToYearCode(2017)}`
|
||||
`courses=${courseCodeToGroupId.MAT21003}&substitutions=false&fromYearCode=${yearToYearCode(2017)}&toYearCode=${yearToYearCode(2017)}`
|
||||
)
|
||||
const year = body.unifyStats!.statistics.find(year => year.name === '2017-2018')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2017-2018')
|
||||
assert(year && 'enrollments' in year, 'Missing stats for 2017-2018')
|
||||
assert.deepStrictEqual(
|
||||
year.attempts.categories.failed,
|
||||
@@ -75,9 +79,9 @@ void describe('Course yearly attempt statistics - MAT21003 (no substitutions)',
|
||||
it('2018-2019 should include a failed attempt (539036)', async () => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=MAT21003&combineSubstitutions=false&fromYearCode=${yearToYearCode(2018)}&toYearCode=${yearToYearCode(2018)}`
|
||||
`courses=${courseCodeToGroupId.MAT21003}&substitutions=false&fromYearCode=${yearToYearCode(2018)}&toYearCode=${yearToYearCode(2018)}`
|
||||
)
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2018-2019')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
assert(year && 'enrollments' in year, 'Missing stats for 2018-2019')
|
||||
assert.include(year.attempts.categories.failed, '539036', 'Failed attempts included the incorrect students')
|
||||
})
|
||||
|
||||
+12
-12
@@ -5,7 +5,7 @@ import { yearToYearCode } from '@oodikone/shared/util'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
void describe('Course yearly attempt statistics - TKT10002 (no substitutions)', () => {
|
||||
void describe('Course yearly attempt statistics - TKT10002 (hy-CU-118023867, no substitutions)', () => {
|
||||
let app: Express
|
||||
beforeAll(async () => {
|
||||
app = await initTests()
|
||||
@@ -16,14 +16,14 @@ void describe('Course yearly attempt statistics - TKT10002 (no substitutions)',
|
||||
beforeAll(async () => {
|
||||
body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=TKT10002&combineSubstitutions=false&fromYearCode=${yearToYearCode(2016)}&toYearCode=${yearToYearCode(2023)}`
|
||||
`courses=hy-CU-118023867&substitutions=false&fromYearCode=${yearToYearCode(2016)}&toYearCode=${yearToYearCode(2023)}`
|
||||
)
|
||||
})
|
||||
|
||||
it('has one entry per statistic year', () => {
|
||||
assert.strictEqual(body.unifyStats!.statistics.length, 8, 'unifyStats years')
|
||||
assert.strictEqual(body.regularStats!.statistics.length, 8, 'regularStats years')
|
||||
assert.strictEqual(body.openStats!.statistics.length, 4, 'openStats years')
|
||||
assert.strictEqual(body.unifyStats.statistics.length, 8, 'unifyStats years')
|
||||
assert.strictEqual(body.regularStats.statistics.length, 8, 'regularStats years')
|
||||
assert.strictEqual(body.openStats.statistics.length, 4, 'openStats years')
|
||||
})
|
||||
|
||||
it.each([
|
||||
@@ -60,7 +60,7 @@ void describe('Course yearly attempt statistics - TKT10002 (no substitutions)',
|
||||
],
|
||||
['2023-2024', { total: 1, passed: 1, failed: 0 }, { 5: 1, 4: 0, 3: 0, 2: 0, 1: 0, 0: 0, 'Hyl.': 0, 'Hyv.': 0 }],
|
||||
])('for attempt statistic content during (%s)', (year, categories, grades) => {
|
||||
const stats = body.unifyStats!.statistics.find(yearStats => yearStats.name === year)!
|
||||
const stats = body.unifyStats.statistics.find(yearStats => yearStats.name === year)!
|
||||
assert('enrollments' in stats, 'Missing field enrollment in statsitics')
|
||||
|
||||
assert.strictEqual(
|
||||
@@ -89,10 +89,10 @@ void describe('Course yearly attempt statistics - TKT10002 (no substitutions)',
|
||||
})
|
||||
|
||||
it('should include every attempt of a student who has failed a course in 2017 and later completed it', () => {
|
||||
const year2017 = body.unifyStats!.statistics.find(year => year.name === '2017-2018')
|
||||
const year2018 = body.unifyStats!.statistics.find(year => year.name === '2018-2019')
|
||||
const year2020 = body.unifyStats!.statistics.find(year => year.name === '2020-2021')
|
||||
const year2022 = body.unifyStats!.statistics.find(year => year.name === '2022-2023')
|
||||
const year2017 = body.unifyStats.statistics.find(year => year.name === '2017-2018')
|
||||
const year2018 = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
const year2020 = body.unifyStats.statistics.find(year => year.name === '2020-2021')
|
||||
const year2022 = body.unifyStats.statistics.find(year => year.name === '2022-2023')
|
||||
assert(year2017 && 'enrollments' in year2017, 'Missing stats for 2017-2018')
|
||||
assert(year2018 && 'enrollments' in year2018, 'Missing stats for 2018-2019')
|
||||
assert(year2020 && 'enrollments' in year2020, 'Missing stats for 2020-2021')
|
||||
@@ -124,9 +124,9 @@ void describe('Course yearly attempt statistics - TKT10002 (no substitutions)',
|
||||
])('should include correct attempt stats for one academic year (%s)', async (year, categories) => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=TKT10002&combineSubstitutions=false&fromYearCode=${yearToYearCode(year.split('-').at(0))}&toYearCode=${yearToYearCode(parseInt(year.split('-').at(1)!)) - 1}`
|
||||
`courses=hy-CU-118023867&substitutions=false&fromYearCode=${yearToYearCode(year.split('-').at(0))}&toYearCode=${yearToYearCode(parseInt(year.split('-').at(1)!)) - 1}`
|
||||
)
|
||||
const stats = body.unifyStats!.statistics.find(yearStats => yearStats.name === year)!
|
||||
const stats = body.unifyStats.statistics.find(yearStats => yearStats.name === year)!
|
||||
assert('enrollments' in stats, 'Missing field enrollment in statsitics')
|
||||
|
||||
assert.strictEqual(
|
||||
|
||||
+3
-3
@@ -4,16 +4,16 @@ import { describe, it, beforeAll, assert } from 'vitest'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { calculatePassedAndFailed, getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
void describe('Course yearly statistics - MAT11001 (no substitutions)', () => {
|
||||
void describe('Course yearly statistics - MAT11001 (hy-CU-117375151, no substitutions)', () => {
|
||||
let app: Express
|
||||
let body: CourseYearlyStats
|
||||
beforeAll(async () => {
|
||||
app = await initTests()
|
||||
body = await getCourseYearlyStats(app, 'codes=MAT11001&combineSubstitutions=false')
|
||||
body = await getCourseYearlyStats(app, 'courses=hy-CU-117375151&substitutions=false')
|
||||
})
|
||||
|
||||
it('should include a student who has only failed the course', () => {
|
||||
const stats = body.unifyStats?.statistics!.find(year => year.name === '2018-2019')
|
||||
const stats = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
assert(stats && 'enrollments' in stats, 'Missing field enrollment in statsitics')
|
||||
|
||||
const studentCategories = calculatePassedAndFailed(stats.students.grades)
|
||||
|
||||
+11
-7
@@ -4,23 +4,27 @@ import { describe, it, beforeAll, assert } from 'vitest'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { calculatePassedAndFailed, getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
void describe('Course yearly statistics - MAT11002 (no substitutions)', () => {
|
||||
const courseCodeToGroupId = {
|
||||
MAT11002: 'hy-CU-117375394',
|
||||
}
|
||||
|
||||
void describe('Course yearly statistics - MAT11002 (hy-CU-117375394, no substitutions)', () => {
|
||||
let app: Express
|
||||
let body: CourseYearlyStats
|
||||
beforeAll(async () => {
|
||||
app = await initTests()
|
||||
body = await getCourseYearlyStats(app, 'codes=MAT11002&combineSubstitutions=false')
|
||||
body = await getCourseYearlyStats(app, `courses=${courseCodeToGroupId.MAT11002}&combineSubstitutions=false`)
|
||||
})
|
||||
|
||||
it('should not include students for AY code', () => {
|
||||
const stats = body.unifyStats?.statistics!.find(year => year.name === '2017-2018')
|
||||
const stats = body.unifyStats.statistics.find(year => year.name === '2017-2018')
|
||||
assert(stats && 'enrollments' in stats, 'Missing field enrollment in statsitics')
|
||||
const studentCategories = calculatePassedAndFailed(stats.students.grades)
|
||||
assert(!studentCategories.failed.includes('534980'))
|
||||
})
|
||||
|
||||
it('should not include student with failed grade after passed grade', () => {
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2018-2019')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
assert(year && 'enrollments' in year, 'Stats missing completely')
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
assert(!studentCategories.failed.includes('501716'), 'Failed students included incorrectly the student in question')
|
||||
@@ -30,7 +34,7 @@ void describe('Course yearly statistics - MAT11002 (no substitutions)', () => {
|
||||
|
||||
// FIXME: Doesn't test anything acually. Student doesn't have a passed AY grade
|
||||
it.skip('should include student with failed grade and passed AY grade', () => {
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2020-2021')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2020-2021')
|
||||
assert(year && 'enrollments' in year, 'Stats missing completely')
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
assert(
|
||||
@@ -45,7 +49,7 @@ void describe('Course yearly statistics - MAT11002 (no substitutions)', () => {
|
||||
})
|
||||
|
||||
it('should include student with only approved grade', () => {
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2022-2023')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2022-2023')
|
||||
assert(year && 'enrollments' in year, 'Stats missing completely')
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
assert(!studentCategories.failed.includes('543385'), 'Failed students included incorrectly the student in question')
|
||||
@@ -54,7 +58,7 @@ void describe('Course yearly statistics - MAT11002 (no substitutions)', () => {
|
||||
})
|
||||
|
||||
it('should not count a student with only improved grades as passed (509770)', () => {
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2018-2019')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
assert(year && 'enrollments' in year, 'Missing stats for 2018-2019')
|
||||
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
|
||||
+13
-9
@@ -5,6 +5,10 @@ import { yearToYearCode } from '@oodikone/shared/util'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { calculatePassedAndFailed, getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
const courseCodeToGroupId = {
|
||||
MAT21003: 'hy-CU-117375829',
|
||||
}
|
||||
|
||||
void describe('Course yearly statistics - MAT21003 (no substitutions)', () => {
|
||||
let app: Express
|
||||
beforeAll(async () => {
|
||||
@@ -14,11 +18,11 @@ void describe('Course yearly statistics - MAT21003 (no substitutions)', () => {
|
||||
describe('duplicate failed grades across a large timespan are not double-counted', () => {
|
||||
let body: CourseYearlyStats
|
||||
beforeAll(async () => {
|
||||
body = await getCourseYearlyStats(app, 'codes=MAT21003&combineSubstitutions=false')
|
||||
body = await getCourseYearlyStats(app, `courses=${courseCodeToGroupId.MAT21003}&substitutions=false`)
|
||||
})
|
||||
|
||||
it('2017-2018 should not include a failed grade', () => {
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2017-2018')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2017-2018')
|
||||
assert(year && 'enrollments' in year, 'Missing stats for 2017-2018')
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
assert.strictEqual(studentCategories.failed.length, 0, 'Failed stats should not include any students')
|
||||
@@ -26,7 +30,7 @@ void describe('Course yearly statistics - MAT21003 (no substitutions)', () => {
|
||||
})
|
||||
|
||||
it('2018-2019 should include a failed grade', () => {
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2018-2019')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
assert(year && 'enrollments' in year, 'Missing stats for 2018-2019')
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
assert.strictEqual(studentCategories.failed.length, 1, 'Failed stats should include only one student')
|
||||
@@ -42,7 +46,7 @@ void describe('Course yearly statistics - MAT21003 (no substitutions)', () => {
|
||||
])('should include correct years for %s', async (name, from, to) => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=MAT21003&combineSubstitutions=false&fromYearCode=${yearToYearCode(from)}&toYearCode=${yearToYearCode(to)}`
|
||||
`courses=${courseCodeToGroupId.MAT21003}&substitutions=false&fromYearCode=${yearToYearCode(from)}&toYearCode=${yearToYearCode(to)}`
|
||||
)
|
||||
|
||||
const years: string[] = []
|
||||
@@ -50,7 +54,7 @@ void describe('Course yearly statistics - MAT21003 (no substitutions)', () => {
|
||||
years.push(`${i}-${i + 1}`)
|
||||
}
|
||||
assert.deepStrictEqual(
|
||||
body.unifyStats!.statistics.map(({ name }) => name),
|
||||
body.unifyStats.statistics.map(({ name }) => name),
|
||||
years,
|
||||
`${name} included incorrect years`
|
||||
)
|
||||
@@ -61,9 +65,9 @@ void describe('Course yearly statistics - MAT21003 (no substitutions)', () => {
|
||||
it('2017-2018 should include a failed grade', async () => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=MAT21003&combineSubstitutions=false&fromYearCode=${yearToYearCode(2017)}&toYearCode=${yearToYearCode(2017)}`
|
||||
`courses=${courseCodeToGroupId.MAT21003}&substitutions=false&fromYearCode=${yearToYearCode(2017)}&toYearCode=${yearToYearCode(2017)}`
|
||||
)
|
||||
const year = body.unifyStats!.statistics.find(year => year.name === '2017-2018')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2017-2018')
|
||||
assert(year && 'enrollments' in year, 'Missing stats for 2017-2018')
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
|
||||
@@ -74,9 +78,9 @@ void describe('Course yearly statistics - MAT21003 (no substitutions)', () => {
|
||||
it('2018-2019 should include a failed grade', async () => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=MAT21003&combineSubstitutions=false&fromYearCode=${yearToYearCode(2018)}&toYearCode=${yearToYearCode(2018)}`
|
||||
`courses=${courseCodeToGroupId.MAT21003}&substitutions=false&fromYearCode=${yearToYearCode(2018)}&toYearCode=${yearToYearCode(2018)}`
|
||||
)
|
||||
const year = body.unifyStats?.statistics.find(year => year.name === '2018-2019')
|
||||
const year = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
assert(year && 'enrollments' in year, 'Missing stats for 2018-2019')
|
||||
const studentCategories = calculatePassedAndFailed(year.students.grades)
|
||||
assert.deepStrictEqual(
|
||||
|
||||
+24
-26
@@ -5,6 +5,10 @@ import { yearToYearCode } from '@oodikone/shared/util'
|
||||
import { initTests } from '../../../../utils'
|
||||
import { calculatePassedAndFailed, getCourseYearlyStats, CourseYearlyStats } from '../helpers'
|
||||
|
||||
const courseCodeToGroupId = {
|
||||
TKT10002: 'hy-CU-118023867',
|
||||
}
|
||||
|
||||
void describe('Course yearly statistics - TKT10002 (no substitutions)', () => {
|
||||
let app: Express
|
||||
beforeAll(async () => {
|
||||
@@ -16,19 +20,19 @@ void describe('Course yearly statistics - TKT10002 (no substitutions)', () => {
|
||||
beforeAll(async () => {
|
||||
body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=TKT10002&combineSubstitutions=false&fromYearCode=${yearToYearCode(2016)}&toYearCode=${yearToYearCode(2023)}`
|
||||
`courses=${courseCodeToGroupId.TKT10002}&substitutions=false&fromYearCode=${yearToYearCode(2016)}&toYearCode=${yearToYearCode(2023)}`
|
||||
)
|
||||
})
|
||||
|
||||
it('has one entry per statistic year', () => {
|
||||
assert.strictEqual(body.unifyStats!.statistics.length, 8, 'unifyStats years')
|
||||
assert.strictEqual(body.regularStats!.statistics.length, 8, 'regularStats years')
|
||||
assert.strictEqual(body.openStats!.statistics.length, 4, 'openStats years')
|
||||
assert.strictEqual(body.unifyStats.statistics.length, 8, 'unifyStats years')
|
||||
assert.strictEqual(body.regularStats.statistics.length, 8, 'regularStats years')
|
||||
assert.strictEqual(body.openStats.statistics.length, 4, 'openStats years')
|
||||
|
||||
// Faculties should have the same amount of years as normal statistics (above)
|
||||
assert.strictEqual(Object.keys(body.unifyStats!.facultyStats).length, 8, 'unifyStats years')
|
||||
assert.strictEqual(Object.keys(body.regularStats!.facultyStats).length, 8, 'regularStats years')
|
||||
assert.strictEqual(Object.keys(body.openStats!.facultyStats).length, 4, 'openStats years')
|
||||
assert.strictEqual(Object.keys(body.unifyStats.facultyStats).length, 8, 'unifyStats years')
|
||||
assert.strictEqual(Object.keys(body.regularStats.facultyStats).length, 8, 'regularStats years')
|
||||
assert.strictEqual(Object.keys(body.openStats.facultyStats).length, 4, 'openStats years')
|
||||
})
|
||||
|
||||
// TODO: Rewrite /courseyearlystats so that total = passed + failed + enrolledNoGrade
|
||||
@@ -76,7 +80,7 @@ void describe('Course yearly statistics - TKT10002 (no substitutions)', () => {
|
||||
{ 5: 1, 4: 0, 3: 0, 2: 0, 1: 0, 0: 0, 'Hyv.': 0 },
|
||||
],
|
||||
])('for statistic content during ($0)', (year, categories, grades) => {
|
||||
const stats = body.unifyStats!.statistics.find(yearStats => yearStats.name === year)!
|
||||
const stats = body.unifyStats.statistics.find(yearStats => yearStats.name === year)!
|
||||
assert('enrollments' in stats, 'Missing field enrollment in statsitics')
|
||||
|
||||
const studentCategories = calculatePassedAndFailed(stats.students.grades)
|
||||
@@ -115,24 +119,18 @@ void describe('Course yearly statistics - TKT10002 (no substitutions)', () => {
|
||||
})
|
||||
|
||||
it('should include students who have failed a course and then completed it only once', () => {
|
||||
const stats2017 = body.unifyStats!.statistics.find(year => year.name === '2017-2018')!
|
||||
const stats2017 = body.unifyStats.statistics.find(year => year.name === '2017-2018')!
|
||||
const { studentNumbers } = stats2017.students
|
||||
|
||||
assert(
|
||||
!(
|
||||
(
|
||||
'457686' in studentNumbers || // SPRING 2019
|
||||
'455478' in studentNumbers || // FALL 2020
|
||||
'547994' in studentNumbers
|
||||
) // FALL 2022
|
||||
),
|
||||
assert.notIncludeMembers(
|
||||
studentNumbers,
|
||||
['457686' /* SPRING 2019*/, '455478' /* FALL 2020 */, '547994' /* FALL 2022*/],
|
||||
"Students that have completed course later should not be included in the previous year's stats"
|
||||
)
|
||||
|
||||
const year2017 = body.unifyStats!.statistics.find(year => year.name === '2017-2018')
|
||||
const year2018 = body.unifyStats!.statistics.find(year => year.name === '2018-2019')
|
||||
const year2020 = body.unifyStats!.statistics.find(year => year.name === '2020-2021')
|
||||
const year2022 = body.unifyStats!.statistics.find(year => year.name === '2022-2023')
|
||||
const year2017 = body.unifyStats.statistics.find(year => year.name === '2017-2018')
|
||||
const year2018 = body.unifyStats.statistics.find(year => year.name === '2018-2019')
|
||||
const year2020 = body.unifyStats.statistics.find(year => year.name === '2020-2021')
|
||||
const year2022 = body.unifyStats.statistics.find(year => year.name === '2022-2023')
|
||||
assert(year2017 && 'enrollments' in year2017, 'Missing stats for 2017-2018')
|
||||
assert(year2018 && 'enrollments' in year2018, 'Missing stats for 2018-2019')
|
||||
assert(year2020 && 'enrollments' in year2020, 'Missing stats for 2020-2021')
|
||||
@@ -172,8 +170,8 @@ void describe('Course yearly statistics - TKT10002 (no substitutions)', () => {
|
||||
})
|
||||
|
||||
it("should mark student's enrollment time correctly with mismatched semestercode and enrollment_date_time", () => {
|
||||
const stats2021 = body.unifyStats!.statistics.find(year => year.name === '2021-2022')!
|
||||
const stats2022 = body.unifyStats!.statistics.find(year => year.name === '2022-2023')!
|
||||
const stats2021 = body.unifyStats.statistics.find(year => year.name === '2021-2022')!
|
||||
const stats2022 = body.unifyStats.statistics.find(year => year.name === '2022-2023')!
|
||||
assert('enrollments' in stats2021, 'Missing field enrollment in statsitics (2021)')
|
||||
assert('enrollments' in stats2022, 'Missing field enrollment in statsitics (2022)')
|
||||
// Student with enrollment_date_time outside of semestert start and end dates
|
||||
@@ -238,9 +236,9 @@ void describe('Course yearly statistics - TKT10002 (no substitutions)', () => {
|
||||
])('should include correct stats for one academic year ($0)', async (year, categories, grades) => {
|
||||
const body = await getCourseYearlyStats(
|
||||
app,
|
||||
`codes=TKT10002&combineSubstitutions=false&fromYearCode=${yearToYearCode(year.split('-').at(0))}&toYearCode=${yearToYearCode(parseInt(year.split('-').at(1)!)) - 1}`
|
||||
`courses=${courseCodeToGroupId.TKT10002}&substitutions=false&fromYearCode=${yearToYearCode(year.split('-').at(0))}&toYearCode=${yearToYearCode(parseInt(year.split('-').at(1)!)) - 1}`
|
||||
)
|
||||
const stats = body.unifyStats!.statistics.find(yearStats => yearStats.name === year)!
|
||||
const stats = body.unifyStats.statistics.find(yearStats => yearStats.name === year)!
|
||||
assert('enrollments' in stats, 'Missing field enrollment in statsitics')
|
||||
|
||||
const studentCategories = calculatePassedAndFailed(stats.students.grades)
|
||||
|
||||
Reference in New Issue
Block a user