mirror of
https://github.com/UniversityOfHelsinkiCS/oodikone.git
synced 2026-10-12 19:03:39 +03:00
[Meta] Add course code to credits and enrollments of students
This commit is contained in:
committed by
Aaro Koivukangas
parent
6d169a3455
commit
172081468a
@@ -1,6 +1,6 @@
|
||||
import { Op } from 'sequelize'
|
||||
|
||||
import { Credit, Enrollment, SISStudyRight, SISStudyRightElement, Student, Studyplan } from '@oodikone/shared/models'
|
||||
import { SISStudyRight, SISStudyRightElement, Student, Studyplan } from '@oodikone/shared/models'
|
||||
import { Tag, TagStudent } from '@oodikone/shared/models/kone'
|
||||
import { EnrollmentState } from '@oodikone/shared/types'
|
||||
import { enrollmentTimeDateThreshold } from '@oodikone/shared/util'
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
SISStudyRightElementModel,
|
||||
} from '../../models'
|
||||
import { TagModel, TagStudentModel } from '../../models/kone'
|
||||
import { StudentCredit, StudentEnrollment } from '@oodikone/shared/types/studentData'
|
||||
|
||||
export type StudentTags = TagStudent & {
|
||||
tag: Pick<Tag, 'tag_id' | 'tagname' | 'personal_user_id'>
|
||||
@@ -46,17 +47,21 @@ export const getStudentTagMap = async (studyRights: string[], studentNumbers: st
|
||||
return studentTagMap
|
||||
}
|
||||
|
||||
export type StudentEnrollment = Pick<
|
||||
Enrollment,
|
||||
'course_id' | 'state' | 'enrollment_date_time' | 'semestercode' | 'studentnumber' | 'studyright_id'
|
||||
>
|
||||
export const getEnrollments = (
|
||||
studentNumbers: string[],
|
||||
startDate: string,
|
||||
endDate: string
|
||||
): Promise<StudentEnrollment[]> =>
|
||||
EnrollmentModel.findAll({
|
||||
attributes: ['course_id', 'state', 'enrollment_date_time', 'semestercode', 'studentnumber', 'studyright_id'],
|
||||
attributes: [
|
||||
'course_id',
|
||||
'course_code',
|
||||
'state',
|
||||
'enrollment_date_time',
|
||||
'semestercode',
|
||||
'studentnumber',
|
||||
'studyright_id',
|
||||
],
|
||||
where: {
|
||||
studentnumber: {
|
||||
[Op.in]: studentNumbers,
|
||||
@@ -185,19 +190,6 @@ export const getStudents = (studentNumbers: string[]): Promise<Array<StudentData
|
||||
},
|
||||
}).then(data => data.map(x => x.get({ plain: true })))
|
||||
|
||||
export type StudentCredit = Pick<
|
||||
Credit,
|
||||
| 'grade'
|
||||
| 'credits'
|
||||
| 'credittypecode'
|
||||
| 'attainment_date'
|
||||
| 'isStudyModule'
|
||||
| 'student_studentnumber'
|
||||
| 'course_id'
|
||||
| 'language'
|
||||
| 'studyright_id'
|
||||
>
|
||||
|
||||
export const getCredits = async (
|
||||
studentNumbers: string[],
|
||||
startDate: string,
|
||||
@@ -213,6 +205,7 @@ export const getCredits = async (
|
||||
'isStudyModule',
|
||||
'student_studentnumber',
|
||||
'course_id',
|
||||
'course_code',
|
||||
'language',
|
||||
'studyright_id',
|
||||
],
|
||||
|
||||
@@ -4,8 +4,6 @@ import { getCriteria } from '../studyProgramme/studyProgrammeCriteria'
|
||||
import { getCourseDetails } from '../courses'
|
||||
import { formatStudentForAPI } from './formatStatisticsForApi'
|
||||
import {
|
||||
type StudentEnrollment,
|
||||
type StudentCredit,
|
||||
type StudentTags,
|
||||
getStudents,
|
||||
getEnrollments,
|
||||
@@ -13,6 +11,7 @@ import {
|
||||
getStudyRightElementsForStudyRight,
|
||||
} from './getStudentData'
|
||||
import { getCourseGroupIds, getOptionsForStudents } from './shared'
|
||||
import { StudentCredit, StudentEnrollment } from '@oodikone/shared/types/studentData'
|
||||
|
||||
export type OptimizedStatisticsQuery = {
|
||||
userId: string
|
||||
|
||||
@@ -55,7 +55,7 @@ export const CustomPopulationContent = ({
|
||||
|
||||
useEffect(() => {
|
||||
setStudentAmountLimit(Math.round(filteredStudents.length ? filteredStudents.length * 0.3 : 0))
|
||||
}, [filteredStudents.length])
|
||||
}, [filteredStudents.length, setStudentAmountLimit])
|
||||
|
||||
const onStudentAmountLimitChange = value => {
|
||||
setStudentAmountLimit(Number.isNaN(Number(value)) ? studentAmountLimit : Number(value))
|
||||
@@ -123,7 +123,7 @@ export const CustomPopulationContent = ({
|
||||
showBachelorAndMaster: false,
|
||||
includePrimaryProgramme: false,
|
||||
|
||||
coursecodes: [],
|
||||
courseIds: [],
|
||||
from: undefined,
|
||||
to: undefined,
|
||||
})
|
||||
|
||||
@@ -78,6 +78,7 @@ export const formatPopulationData = <T extends RequiredFields>(
|
||||
|
||||
return {
|
||||
course_id: credit.course_id,
|
||||
course_code: credit.course_code,
|
||||
date: credit.attainment_date,
|
||||
passed,
|
||||
grade: passed ? credit.grade : 'Hyl.',
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Credit, Enrollment, Course } from '../models'
|
||||
import { Course } from '../models'
|
||||
import {
|
||||
Name,
|
||||
ProgrammeModuleWithRelevantAttributes,
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
ProgressCriteria,
|
||||
Unification,
|
||||
} from '../types'
|
||||
import { FormattedStudent } from '../types/studentData'
|
||||
import { FormattedStudent, StudentCredit, StudentEnrollment } from '../types/studentData'
|
||||
|
||||
export type CourseStats = Pick<Course, 'code' | 'id' | 'groupId' | 'name' | 'isStudyModule' | 'substitutionGroups'>
|
||||
|
||||
@@ -60,22 +60,8 @@ export type PopulationCourseStats = {
|
||||
// One row per groupId (isPrimary=true course for that group)
|
||||
courses: CourseStats[]
|
||||
idToGroupIdMap: Record<string, string>
|
||||
enrollments: Pick<
|
||||
Enrollment,
|
||||
'course_id' | 'state' | 'enrollment_date_time' | 'semestercode' | 'studentnumber' | 'studyright_id'
|
||||
>[]
|
||||
credits: Pick<
|
||||
Credit,
|
||||
| 'grade'
|
||||
| 'credits'
|
||||
| 'credittypecode'
|
||||
| 'attainment_date'
|
||||
| 'isStudyModule'
|
||||
| 'student_studentnumber'
|
||||
| 'course_id'
|
||||
| 'language'
|
||||
| 'studyright_id'
|
||||
>[]
|
||||
enrollments: (StudentEnrollment & { studentnumber: string })[]
|
||||
credits: StudentCredit[]
|
||||
}
|
||||
|
||||
// populationstatistics
|
||||
|
||||
@@ -70,6 +70,7 @@ export const createStudyRight = (overrides: Partial<StudentStudyRight> = {}): St
|
||||
|
||||
export const createCourse = (overrides: Partial<StudentCourse> = {}): StudentCourse => ({
|
||||
course_id: 'hy-CU-000000001-2024-08-01',
|
||||
course_code: 'MAT001',
|
||||
date: new Date('2024-08-01'),
|
||||
passed: true,
|
||||
grade: '5',
|
||||
@@ -95,6 +96,7 @@ export const createEnrollment = (
|
||||
overrides: Partial<FormattedStudent['enrollments'][number]> = {}
|
||||
): FormattedStudent['enrollments'][number] => ({
|
||||
course_id: 'hy-CU-000000001-2024-08-01',
|
||||
course_code: 'MAT001',
|
||||
state: EnrollmentState.ENROLLED,
|
||||
enrollment_date_time: new Date('2024-08-01'),
|
||||
semestercode: 149,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { Enrollment, SISStudyRight, SISStudyRightElement, Student, Studyplan } from '../models'
|
||||
import type { Credit, Enrollment, SISStudyRight, SISStudyRightElement, Student, Studyplan } from '../models'
|
||||
import type { Tag, TagStudent } from '../models/kone'
|
||||
|
||||
import type { CriteriaYear, CreditTypeCode, Name, ProgrammeModule } from '../types'
|
||||
@@ -106,6 +106,7 @@ export type StudentPageStudent = {
|
||||
|
||||
export type StudentCourse = {
|
||||
course_id: string
|
||||
course_code: string
|
||||
date: Date
|
||||
passed: boolean
|
||||
grade: string
|
||||
@@ -116,6 +117,25 @@ export type StudentCourse = {
|
||||
studyright_id: string
|
||||
}
|
||||
|
||||
export type StudentCredit = Pick<
|
||||
Credit,
|
||||
| 'grade'
|
||||
| 'credits'
|
||||
| 'credittypecode'
|
||||
| 'attainment_date'
|
||||
| 'isStudyModule'
|
||||
| 'student_studentnumber'
|
||||
| 'course_id'
|
||||
| 'course_code'
|
||||
| 'language'
|
||||
| 'studyright_id'
|
||||
>
|
||||
|
||||
export type StudentEnrollment = Pick<
|
||||
Enrollment,
|
||||
'course_id' | 'course_code' | 'state' | 'enrollment_date_time' | 'semestercode' | 'studentnumber' | 'studyright_id'
|
||||
>
|
||||
|
||||
export type FormattedStudent = {
|
||||
obfuscated?: true
|
||||
|
||||
@@ -146,5 +166,5 @@ export type FormattedStudent = {
|
||||
studyRights: StudentStudyRight[]
|
||||
studyplans: StudentStudyPlan[]
|
||||
courses: StudentCourse[]
|
||||
enrollments: Pick<Enrollment, 'course_id' | 'state' | 'enrollment_date_time' | 'semestercode' | 'studyright_id'>[]
|
||||
enrollments: Omit<StudentEnrollment, 'studentnumber'>[]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user