Loading editor/src/assets/pageContent/injectSpecification.ts +10 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,16 @@ export const QUESTIONNAIRE_FORM: Form = { label: 'Title', tooltip: '', }, content: { label: 'Content', tooltip: '', optional: true, }, file: { label: 'Files', tooltip: '', optional: true, }, questions: { label: 'Questions', tooltip: '', Loading editor/src/components/FileSelector/FileSelectorLabel.tsx +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ const FileSelectorLabel: FC<FileSelectorProps> = ({ }) => ( <TooltipLabel label={label} style={{ flexGrow: '1', paddingBlock: '1rem' }} style={{ flexGrow: '1', marginBlock: '1rem' }} htmlFor='' > <FileSelector onChange={onChange} selectedFiles={selectedFiles} /> Loading editor/src/components/InjectSpecification/QuestionnaireForm/index.tsx +48 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import { Collapse, InputGroup, NumericInput, TextArea, } from '@blueprintjs/core' import { css } from '@emotion/css' import { ShallowGetSet } from '@inject/shared' Loading @@ -13,8 +14,13 @@ import { addQuestionnaire, getQuestionnaireByInjectInfoId, } from '../../../indexeddb/operations' import type { InjectType, Questionnaire } from '../../../indexeddb/types' import type { ContentFile, InjectType, Questionnaire, } from '../../../indexeddb/types' import { InjectsRoute } from '../../../routes/create/injects.index' import FileSelectorLabel from '../../FileSelector/FileSelectorLabel' import SaveButtonGroup from '../../SaveButtonGroup' import TooltipLabel from '../../Tooltips/TooltipLabel' import TooltipSwitch from '../../Tooltips/TooltipSwitch' Loading @@ -30,6 +36,8 @@ import RadioForm from './RadioForm' export interface QuestionnaireInjectData { title: string content: string files: ContentFile[] postExerciseSubmission: boolean repeatable: boolean onFail: MilestoneType[] Loading @@ -56,6 +64,8 @@ const QuestionnaireForm: FC<{ maxAttempts: questionnaire.maxAttempts, repeatable: questionnaire.repeatable, onFail: questionnaire.onFail, content: questionnaire.content, files: questionnaire.files, }) } Loading @@ -67,6 +77,8 @@ const QuestionnaireForm: FC<{ repeatable: false, onFail: [], maxAttempts: 1, content: '', files: [], }) } }, [questionnaire, injectInfoId, state]) Loading @@ -93,6 +105,41 @@ const QuestionnaireForm: FC<{ </ShallowGetSet> </TooltipLabel> <TooltipLabel label={QUESTIONNAIRE_FORM.content}> <ShallowGetSet store={state} get={state => state.content} set={state => state.set} > {(value, setValue) => ( <TextArea value={value} className={css` resize: none !important; min-height: 5rem; `} autoResize fill placeholder='Input text' onChange={e => setValue('content', e.target.value)} /> )} </ShallowGetSet> </TooltipLabel> <ShallowGetSet store={state} get={({ files }) => files} set={({ set }) => set} > {(files, set) => ( <FileSelectorLabel label={QUESTIONNAIRE_FORM.file} selectedFiles={files} onChange={newFiles => set('files', newFiles)} /> )} </ShallowGetSet> <ShallowGetSet store={state} get={state => state.postExerciseSubmission} Loading editor/src/components/InjectSpecification/store.ts +6 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,8 @@ export const initInjectSpecState = (type: InjectType) => ...overlayEmpty, ...connectionsEmpty, title: '', content: '', files: [], postExerciseSubmission: false, repeatable: false, onFail: [], Loading @@ -169,6 +171,8 @@ export const initInjectSpecState = (type: InjectType) => maxAttempts, repeatable, onFail, content, files, } = get() as State<InjectType.QUESTIONNAIRE> try { await updateQuestionnaire({ Loading @@ -178,6 +182,8 @@ export const initInjectSpecState = (type: InjectType) => repeatable, maxAttempts, onFail, content, files, }) await genericUpdate(injectInfoId) } catch (error) { Loading editor/src/indexeddb/db.ts +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ db.version(dbVersion).stores({ informationInjects: '&injectInfoId, content, files, informationChannelId', informationChannels: '++id, name', questionnaires: '&injectInfoId, &title, postExerciseSubmission, repeatable, maxAttempts, onFail', '&injectInfoId, &title, postExerciseSubmission, repeatable, maxAttempts, onFail, content, files', questionnaireQuestions: '++id, injectInfoId, text, type', questionnaireQuestionRadio: '[id+injectInfoId], correct, labels, labelsActivateControl, labelsDeactivateControl, max', Loading Loading
editor/src/assets/pageContent/injectSpecification.ts +10 −0 Original line number Diff line number Diff line Loading @@ -81,6 +81,16 @@ export const QUESTIONNAIRE_FORM: Form = { label: 'Title', tooltip: '', }, content: { label: 'Content', tooltip: '', optional: true, }, file: { label: 'Files', tooltip: '', optional: true, }, questions: { label: 'Questions', tooltip: '', Loading
editor/src/components/FileSelector/FileSelectorLabel.tsx +1 −1 Original line number Diff line number Diff line Loading @@ -17,7 +17,7 @@ const FileSelectorLabel: FC<FileSelectorProps> = ({ }) => ( <TooltipLabel label={label} style={{ flexGrow: '1', paddingBlock: '1rem' }} style={{ flexGrow: '1', marginBlock: '1rem' }} htmlFor='' > <FileSelector onChange={onChange} selectedFiles={selectedFiles} /> Loading
editor/src/components/InjectSpecification/QuestionnaireForm/index.tsx +48 −1 Original line number Diff line number Diff line Loading @@ -3,6 +3,7 @@ import { Collapse, InputGroup, NumericInput, TextArea, } from '@blueprintjs/core' import { css } from '@emotion/css' import { ShallowGetSet } from '@inject/shared' Loading @@ -13,8 +14,13 @@ import { addQuestionnaire, getQuestionnaireByInjectInfoId, } from '../../../indexeddb/operations' import type { InjectType, Questionnaire } from '../../../indexeddb/types' import type { ContentFile, InjectType, Questionnaire, } from '../../../indexeddb/types' import { InjectsRoute } from '../../../routes/create/injects.index' import FileSelectorLabel from '../../FileSelector/FileSelectorLabel' import SaveButtonGroup from '../../SaveButtonGroup' import TooltipLabel from '../../Tooltips/TooltipLabel' import TooltipSwitch from '../../Tooltips/TooltipSwitch' Loading @@ -30,6 +36,8 @@ import RadioForm from './RadioForm' export interface QuestionnaireInjectData { title: string content: string files: ContentFile[] postExerciseSubmission: boolean repeatable: boolean onFail: MilestoneType[] Loading @@ -56,6 +64,8 @@ const QuestionnaireForm: FC<{ maxAttempts: questionnaire.maxAttempts, repeatable: questionnaire.repeatable, onFail: questionnaire.onFail, content: questionnaire.content, files: questionnaire.files, }) } Loading @@ -67,6 +77,8 @@ const QuestionnaireForm: FC<{ repeatable: false, onFail: [], maxAttempts: 1, content: '', files: [], }) } }, [questionnaire, injectInfoId, state]) Loading @@ -93,6 +105,41 @@ const QuestionnaireForm: FC<{ </ShallowGetSet> </TooltipLabel> <TooltipLabel label={QUESTIONNAIRE_FORM.content}> <ShallowGetSet store={state} get={state => state.content} set={state => state.set} > {(value, setValue) => ( <TextArea value={value} className={css` resize: none !important; min-height: 5rem; `} autoResize fill placeholder='Input text' onChange={e => setValue('content', e.target.value)} /> )} </ShallowGetSet> </TooltipLabel> <ShallowGetSet store={state} get={({ files }) => files} set={({ set }) => set} > {(files, set) => ( <FileSelectorLabel label={QUESTIONNAIRE_FORM.file} selectedFiles={files} onChange={newFiles => set('files', newFiles)} /> )} </ShallowGetSet> <ShallowGetSet store={state} get={state => state.postExerciseSubmission} Loading
editor/src/components/InjectSpecification/store.ts +6 −0 Original line number Diff line number Diff line Loading @@ -157,6 +157,8 @@ export const initInjectSpecState = (type: InjectType) => ...overlayEmpty, ...connectionsEmpty, title: '', content: '', files: [], postExerciseSubmission: false, repeatable: false, onFail: [], Loading @@ -169,6 +171,8 @@ export const initInjectSpecState = (type: InjectType) => maxAttempts, repeatable, onFail, content, files, } = get() as State<InjectType.QUESTIONNAIRE> try { await updateQuestionnaire({ Loading @@ -178,6 +182,8 @@ export const initInjectSpecState = (type: InjectType) => repeatable, maxAttempts, onFail, content, files, }) await genericUpdate(injectInfoId) } catch (error) { Loading
editor/src/indexeddb/db.ts +1 −1 Original line number Diff line number Diff line Loading @@ -87,7 +87,7 @@ db.version(dbVersion).stores({ informationInjects: '&injectInfoId, content, files, informationChannelId', informationChannels: '++id, name', questionnaires: '&injectInfoId, &title, postExerciseSubmission, repeatable, maxAttempts, onFail', '&injectInfoId, &title, postExerciseSubmission, repeatable, maxAttempts, onFail, content, files', questionnaireQuestions: '++id, injectInfoId, text, type', questionnaireQuestionRadio: '[id+injectInfoId], correct, labels, labelsActivateControl, labelsDeactivateControl, max', Loading