From f557caabe1a675c6309aebbc4ff7ab9e736c250a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ilkka=20H=C3=A4nninen?= Date: Mon, 30 Dec 2024 15:27:35 +0200 Subject: [PATCH] wip: ib-tutkinto core requirements --- .../components-v2/createdialog/DialogField.ts | 2 +- web/app/ib/IBPaatasonSuoritusTiedot.tsx | 181 ++++++++++++++++-- .../dialogs/UusiIBTutkintoOppiaineDialog.tsx | 13 +- web/app/ib/oppiaineet/ibTutkintoOppiaine.ts | 67 +++++++ web/app/ib/state/extendedEssay.ts | 117 +++++++++++ web/app/ib/state/ibTutkintoKurssi.ts | 5 +- web/app/ib/state/ibTutkintoOppiaine.ts | 90 +++++---- web/app/ib/state/theoryOfKnowledge.ts | 69 +++++++ web/app/util/arvioinnit.ts | 8 +- 9 files changed, 486 insertions(+), 66 deletions(-) create mode 100644 web/app/ib/state/extendedEssay.ts create mode 100644 web/app/ib/state/theoryOfKnowledge.ts diff --git a/web/app/components-v2/createdialog/DialogField.ts b/web/app/components-v2/createdialog/DialogField.ts index b96c0749ef..24977da896 100644 --- a/web/app/components-v2/createdialog/DialogField.ts +++ b/web/app/components-v2/createdialog/DialogField.ts @@ -9,7 +9,7 @@ export type DialogField = { export const useDialogField = ( isVisible: boolean, - defaultValue?: () => T + defaultValue?: () => T | undefined ): DialogField => { const [value, set] = useState(defaultValue) const [visible, setVisible] = useState(false) diff --git a/web/app/ib/IBPaatasonSuoritusTiedot.tsx b/web/app/ib/IBPaatasonSuoritusTiedot.tsx index 63002beb77..c6a5ba54b2 100644 --- a/web/app/ib/IBPaatasonSuoritusTiedot.tsx +++ b/web/app/ib/IBPaatasonSuoritusTiedot.tsx @@ -1,4 +1,4 @@ -import React, { useCallback, useMemo } from 'react' +import React, { useCallback, useEffect, useMemo } from 'react' import { ActivePäätasonSuoritus, hasPäätasonsuoritusOf @@ -7,31 +7,42 @@ import { KeyValueRow, KeyValueTable } from '../components-v2/containers/KeyValueTable' +import { + LocalizedTextEdit, + LocalizedTextView +} from '../components-v2/controls/LocalizedTestField' +import { Select, useKoodistoOptions } from '../components-v2/controls/Select' +import { FormField } from '../components-v2/forms/FormField' import { FormModel } from '../components-v2/forms/FormModel' -import { t } from '../i18n/i18n' -import { IBOpiskeluoikeus } from '../types/fi/oph/koski/schema/IBOpiskeluoikeus' import { KoodistoEdit, KoodistoView } from '../components-v2/opiskeluoikeus/KoodistoField' -import { FormField } from '../components-v2/forms/FormField' +import { KoodistoSelect } from '../components-v2/opiskeluoikeus/KoodistoSelect' import { OrganisaatioEdit, OrganisaatioView } from '../components-v2/opiskeluoikeus/OrganisaatioField' -import { TextEdit, TextView } from '../components-v2/controls/TextField' -import { - LocalizedTextEdit, - LocalizedTextView -} from '../components-v2/controls/LocalizedTestField' +import { t } from '../i18n/i18n' +import { IBOpiskeluoikeus } from '../types/fi/oph/koski/schema/IBOpiskeluoikeus' import { IBTutkinnonSuoritus, isIBTutkinnonSuoritus } from '../types/fi/oph/koski/schema/IBTutkinnonSuoritus' import { Koodistokoodiviite } from '../types/fi/oph/koski/schema/Koodistokoodiviite' +import { parasArviointi, viimeisinArviointi } from '../util/arvioinnit' +import { koodiviiteId } from '../util/koodisto' +import { isKoodiarvoOf } from '../util/types' +import { DialogSelect } from '../uusiopiskeluoikeus/components/DialogSelect' import { createIBCASSuoritus } from './oppiaineet/ibTutkintoOppiaine' -import { isKoodiarvoOf, isKoodistoOf } from '../util/types' -import { KoodistoSelect } from '../components-v2/opiskeluoikeus/KoodistoSelect' +import { useExtendedEssayState } from './state/extendedEssay' +import { + useAineryhmäOptions, + useKielivalikoimaOptions, + useOppiaineTasoOptions +} from './state/options' +import { Checkbox } from '../components-v2/controls/Checkbox' +import { useTheoryOfKnowledgeState } from './state/theoryOfKnowledge' export type IBTutkintTiedotProps = { form: FormModel @@ -101,6 +112,7 @@ const IBTutkinnonTiedotRows: React.FC = ({ return ( <> + = ({ ) } +const TheoryOfKnowledgeRows: React.FC = ({ + form, + päätasonSuoritus +}) => { + const state = useTheoryOfKnowledgeState(form, päätasonSuoritus) + const osasuoritukset = päätasonSuoritus.suoritus.osasuoritukset || [] + + return form.editMode ? ( + <> + + + {osasuoritukset.map((os, index) => ( + + TODO + + ))} + {state.pakollinen.visible && ( + + + + )} + + {state.arvosana.visible && ( + + + + )} + + + ) : ( + + { + parasArviointi(päätasonSuoritus.suoritus.extendedEssay?.arviointi) + ?.arvosana.koodiarvo + } + + ) +} + +const ExtendedEssayFieldRows: React.FC = ({ + form, + päätasonSuoritus +}) => { + const state = useExtendedEssayState(form, päätasonSuoritus) + const tunnisteet = useKoodistoOptions('oppiaineetib') + const kielet = useKielivalikoimaOptions(true) + const ryhmät = useAineryhmäOptions(true) + const tasot = useOppiaineTasoOptions(true) + + return form.editMode ? ( + <> + + + {state.tunniste.visible && tunnisteet && ( + +