Commit ad2036aa authored by Filip Šenk's avatar Filip Šenk Committed by Marek Veselý
Browse files

Editor - 0.20.1

parent fe3b00b2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
{
  "name": "@inject/editor",
  "version": "0.19.1",
  "version": "0.20.1",
  "description": "Editor module to Inject Exercise Platform",
  "main": "index.js",
  "license": "MIT",
+10 −0
Original line number Diff line number Diff line
@@ -144,4 +144,14 @@ export const QUESTIONNAIRE_QUESTION_FORM: Form = {
    tooltip: '',
    optional: true,
  },
  minimalLength: {
    label: 'Minimal answer length',
    tooltip: '',
    optional: true,
  },
  maximalLength: {
    label: 'Maximal answer length',
    tooltip: '',
    optional: true,
  },
}
+10 −0
Original line number Diff line number Diff line
@@ -24,6 +24,11 @@ export const TOOL_FORM: Form = {
    label: 'Default response',
    tooltip: '',
  },
  buttonCaption: {
    label: 'Button caption',
    tooltip: '',
    optional: true,
  },
}

export const TOOL_RESPONSE_FORM: Form = {
@@ -50,6 +55,11 @@ export const TOOL_RESPONSE_FORM: Form = {
    tooltip: '',
    optional: true,
  },
  buttonCaption: {
    label: 'Button caption',
    tooltip: '',
    optional: true,
  },
}

export const TOOL_RESPONSE_CONNECTIONS_FORM: Form = {
+24 −4
Original line number Diff line number Diff line
@@ -32,13 +32,14 @@ import type {
} from '../../../indexeddb/types'
import TooltipLabel from '../../Tooltips/TooltipLabel'
import TooltipSwitch from '../../Tooltips/TooltipSwitch'
import { MinMax } from './MinMax'
import QuestionnaireMilestoneForm from './QuestionnaireMilestoneForm'

interface QuestionnaireQuestionFormProps {
  questionnaireQuestion?: QuestionnaireQuestion
  autoFreeformQuestion?: QuestionnaireQuestionAutoFreeForm
  injectInfoId: number
  buttonProps: ButtonProps
  questionnaireQuestion?: QuestionnaireQuestion
  autoFreeformQuestion?: QuestionnaireQuestionAutoFreeForm
}

type State<
@@ -50,6 +51,8 @@ type State<
    update: (id?: number) => Promise<void>
    correctAnswer: string
    regex: boolean
    min?: number
    max?: number
  },
> = S & ZustandSetterSingle<S>

@@ -72,7 +75,7 @@ const AutoFreeformForm: FC<QuestionnaireQuestionFormProps> = ({
      })),
      set: (item, value) => set({ [item]: value }),
      update: async id => {
        const { multiline, text, note, correctAnswer, regex } = get()
        const { multiline, text, note, correctAnswer, regex, min, max } = get()

        const correctMilestones = (
          await db.questionnaireMilestones
@@ -110,6 +113,8 @@ const AutoFreeformForm: FC<QuestionnaireQuestionFormProps> = ({
            regex,
            correctMilestones,
            incorrectMilestones,
            min,
            max,
          }
        )

@@ -129,6 +134,8 @@ const AutoFreeformForm: FC<QuestionnaireQuestionFormProps> = ({
      note: questionnaireQuestion?.note,
      correctAnswer: autoFreeformQuestion?.correctAnswer,
      regex: autoFreeformQuestion?.regex,
      min: autoFreeformQuestion?.min,
      max: autoFreeformQuestion?.max,
    })
  }, [isOpen, state, questionnaireQuestion, autoFreeformQuestion])

@@ -233,7 +240,6 @@ const AutoFreeformForm: FC<QuestionnaireQuestionFormProps> = ({
              margin-block: 1rem !important;
            `}
          />

          <TooltipLabel label={QUESTIONNAIRE_QUESTION_FORM.note}>
            <ShallowGetSet
              store={state}
@@ -265,6 +271,20 @@ const AutoFreeformForm: FC<QuestionnaireQuestionFormProps> = ({
            title={QUESTIONNAIRE_QUESTION_FORM.incorrectMilestones.label}
            correct={false}
          />
          <ShallowGetSet
            store={state}
            get={({ min, max }) => [min, max]}
            set={({ set }) => set}
          >
            {([min, max], set) => (
              <MinMax
                min={min}
                max={max}
                onMinChange={value => set('min', value)}
                onMaxChange={value => set('max', value)}
              />
            )}
          </ShallowGetSet>
        </DialogBody>
        <DialogFooter
          actions={
+27 −3
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ import type {
} from '../../../indexeddb/types'
import TooltipLabel from '../../Tooltips/TooltipLabel'
import TooltipSwitch from '../../Tooltips/TooltipSwitch'
import { MinMax } from './MinMax'
import QuestionnaireMilestoneForm from './QuestionnaireMilestoneForm'

interface QuestionnaireQuestionFormProps {
@@ -45,6 +46,8 @@ type State<
    valid: boolean
    multiline: boolean
    note?: string
    min?: number
    max?: number
    update: (id?: number) => Promise<void>
  },
> = S & ZustandSetterSingle<S>
@@ -61,12 +64,16 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({
      text: '',
      multiline: false,
      note: '',
      min: undefined,
      max: undefined,
      ...compute(get, state => ({
        valid: state.text !== '',
        valid:
          state.text !== '' &&
          (!state.max || !state.min || state.min <= state.max),
      })),
      set: (item, value) => set({ [item]: value }),
      update: async id => {
        const { multiline, text, note } = get()
        const { multiline, text, note, min, max } = get()

        const relatedMilestones = (
          await db.questionnaireMilestones
@@ -85,6 +92,8 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({
          {
            multiline,
            relatedMilestones,
            min,
            max,
          }
        )

@@ -102,6 +111,8 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({
      text: questionnaireQuestion?.text ?? '',
      multiline: freeformQuestion?.multiline,
      note: questionnaireQuestion?.note ?? '',
      min: freeformQuestion?.min,
      max: freeformQuestion?.max,
    })
  }, [isOpen, state, questionnaireQuestion, freeformQuestion])

@@ -165,7 +176,6 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({
              />
            )}
          </ShallowGetSet>

          <QuestionnaireMilestoneForm
            questionId={freeformQuestion?.id}
            injectInfoId={injectInfoId}
@@ -186,6 +196,20 @@ const FreeformForm: FC<QuestionnaireQuestionFormProps> = ({
              )}
            </ShallowGetSet>
          </TooltipLabel>
          <ShallowGetSet
            store={state}
            get={({ min, max }) => [min, max]}
            set={({ set }) => set}
          >
            {([min, max], set) => (
              <MinMax
                min={min}
                max={max}
                onMinChange={value => set('min', value)}
                onMaxChange={value => set('max', value)}
              />
            )}
          </ShallowGetSet>
        </DialogBody>
        <DialogFooter
          actions={
Loading