Skip to content

Commit

Permalink
Automatically calculate milestone expected ages (#157)
Browse files Browse the repository at this point in the history
* Automatically calculate milestone expected ages

- uses placeholder algorithm for now
  - calculates average score for a milestone from each age (1 month bins)
  - expected age is the first age with an average score >= 3
  - the details of this algorithm can be refined later
  - resolves #133
- add view data button below expected age slider in admin edit milestone dialog
  - displays a plot of average scores vs age for this milestone
  - includes a dotted line showing the calculated expected age based on the data
- add admin tab for this
  - displays expected age for each milestone & button to plot data
  - button to calculate new expected age for each
  - button to save changes
- add @unovis/ts chart/plotting library
  - using @unovis/ts for now due to lack of svelte 5 support in @unovis/svelte
  - can switch to the svelte version once this issue is resolved
  - svelte-vega looked more promising but gave an error at build time
  - resolves #153
- add numpy to backend dependencies
- remove default constructors from some models to improve generated typescript types
  - e.g. `milestones: list[MilestoneAdmin] = {}` used to give typescript type `MilestoneAdmin[] | undefined`
  - replace with `milestones: list[MilestoneAdmin]` to give `MilestoneAdmin[]`

* update openapi.json & openapi-ts client

* fix incorrect progress bar update

* use better translation

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
2 people authored and Majapur1 committed Nov 14, 2024
1 parent 35642eb commit 697a06e
Show file tree
Hide file tree
Showing 22 changed files with 2,666 additions and 1,099 deletions.
28 changes: 14 additions & 14 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@
"openapi-ts": "openapi-ts"
},
"devDependencies": {
"@hey-api/openapi-ts": "0.53.5",
"@sveltejs/adapter-auto": "^3.3.0",
"@sveltejs/adapter-static": "^3.0.5",
"@sveltejs/kit": "^2.7.2",
"@hey-api/openapi-ts": "0.55.2",
"@sveltejs/adapter-static": "^3.0.6",
"@sveltejs/kit": "^2.8.0",
"@sveltejs/vite-plugin-svelte": "^4.0.0",
"@tailwindcss/typography": "^0.5.15",
"@testing-library/svelte": "^5.2.4",
"@types/eslint": "^9.6.1",
"@vitest/coverage-v8": "^2.1.3",
"@vitest/coverage-v8": "^2.1.4",
"autoprefixer": "^10.4.20",
"flowbite": "^2.5.2",
"flowbite-svelte": "^0.46.23",
"flowbite-svelte-icons": "2.0.0-next.16",
"globals": "^15.11.0",
"flowbite-svelte": "^0.47.3",
"flowbite-svelte-icons": "2.0.2",
"globals": "^15.12.0",
"jsdom": "^25.0.1",
"svelte": "^5.1.2",
"svelte-check": "^3.8.6",
"svelte": "^5.1.14",
"svelte-check": "^4.0.6",
"tailwindcss": "^3.4.14",
"typescript": "^5.6.3",
"typescript-eslint": "^8.11.0",
"vite": "^5.4.10",
"vitest": "^2.1.3"
"typescript-eslint": "^8.13.0",
"vite": "^5.4.11",
"vitest": "^2.1.4"
},
"type": "module",
"dependencies": {
"@hey-api/client-fetch": "0.4.0",
"@hey-api/client-fetch": "0.4.3",
"@unovis/ts": "1.5.0-beta.0",
"iso-639-1": "3.1.3",
"svelte-i18n": "^4.0.1"
}
Expand Down
2,458 changes: 1,755 additions & 703 deletions frontend/pnpm-lock.yaml

Large diffs are not rendered by default.

71 changes: 51 additions & 20 deletions frontend/src/lib/client/schemas.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -422,23 +422,60 @@ export const MilestoneAdminSchema = {
'$ref': '#/components/schemas/MilestoneText'
},
type: 'object',
title: 'Text',
default: {}
title: 'Text'
},
images: {
items: {
'$ref': '#/components/schemas/MilestoneImage'
},
type: 'array',
title: 'Images',
default: []
title: 'Images'
}
},
type: 'object',
required: ['id', 'group_id', 'order', 'expected_age_months'],
required: ['id', 'group_id', 'order', 'expected_age_months', 'text', 'images'],
title: 'MilestoneAdmin'
} as const;

export const MilestoneAgeScoreSchema = {
properties: {
age_months: {
type: 'integer',
title: 'Age Months'
},
avg_score: {
type: 'number',
title: 'Avg Score'
},
expected_score: {
type: 'number',
title: 'Expected Score'
}
},
type: 'object',
required: ['age_months', 'avg_score', 'expected_score'],
title: 'MilestoneAgeScore'
} as const;

export const MilestoneAgeScoresSchema = {
properties: {
scores: {
items: {
'$ref': '#/components/schemas/MilestoneAgeScore'
},
type: 'array',
title: 'Scores'
},
expected_age: {
type: 'integer',
title: 'Expected Age'
}
},
type: 'object',
required: ['scores', 'expected_age'],
title: 'MilestoneAgeScores'
} as const;

export const MilestoneAnswerPublicSchema = {
properties: {
milestone_id: {
Expand Down Expand Up @@ -498,20 +535,18 @@ export const MilestoneGroupAdminSchema = {
'$ref': '#/components/schemas/MilestoneGroupText'
},
type: 'object',
title: 'Text',
default: {}
title: 'Text'
},
milestones: {
items: {
'$ref': '#/components/schemas/MilestoneAdmin'
},
type: 'array',
title: 'Milestones',
default: []
title: 'Milestones'
}
},
type: 'object',
required: ['id', 'order'],
required: ['id', 'order', 'text', 'milestones'],
title: 'MilestoneGroupAdmin'
} as const;

Expand All @@ -526,20 +561,18 @@ export const MilestoneGroupPublicSchema = {
'$ref': '#/components/schemas/MilestoneGroupTextPublic'
},
type: 'object',
title: 'Text',
default: {}
title: 'Text'
},
milestones: {
items: {
'$ref': '#/components/schemas/MilestonePublic'
},
type: 'array',
title: 'Milestones',
default: []
title: 'Milestones'
}
},
type: 'object',
required: ['id'],
required: ['id', 'text', 'milestones'],
title: 'MilestoneGroupPublic'
} as const;

Expand Down Expand Up @@ -670,20 +703,18 @@ export const MilestonePublicSchema = {
'$ref': '#/components/schemas/MilestoneTextPublic'
},
type: 'object',
title: 'Text',
default: {}
title: 'Text'
},
images: {
items: {
'$ref': '#/components/schemas/MilestoneImagePublic'
},
type: 'array',
title: 'Images',
default: []
title: 'Images'
}
},
type: 'object',
required: ['id', 'expected_age_months'],
required: ['id', 'expected_age_months', 'text', 'images'],
title: 'MilestonePublic'
} as const;

Expand Down
Loading

0 comments on commit 697a06e

Please sign in to comment.