diff --git a/src/components/Survey/Editors/SelectItemCondition.tsx b/src/components/Survey/Editors/SelectItemCondition.tsx index d6bd0f5..1de96f0 100644 --- a/src/components/Survey/Editors/SelectItemCondition.tsx +++ b/src/components/Survey/Editors/SelectItemCondition.tsx @@ -25,14 +25,14 @@ export const SelectCondition: React.FC> = ) { return } - sItem.answerSpec.options.map((option) => { + sItem.answer.options.map((option) => { const condition: SurveyItemCondition = { questionLabel: sItem.question.questionLabel, triggeringOption: option, } possibleItems.push(condition) }) - sItem.answerSpec.factorialOptions?.map((option) => { + sItem.answer.factorialOptions?.map((option) => { const condition: SurveyItemCondition = { questionLabel: sItem.question.questionLabel, triggeringOption: option.name, diff --git a/src/components/Survey/Editors/SurveyEditor.tsx b/src/components/Survey/Editors/SurveyEditor.tsx index 1be95b1..59d221b 100644 --- a/src/components/Survey/Editors/SurveyEditor.tsx +++ b/src/components/Survey/Editors/SurveyEditor.tsx @@ -7,7 +7,7 @@ import CheckBox from "../../../shared-module/components/InputFields/CheckBox" import TextField from "../../../shared-module/components/InputFields/TextField" import { baseTheme, primaryFont } from "../../../shared-module/styles" import { - AnswerSpec, + Answer, AnswerType, SumFactor, Survey, @@ -91,7 +91,7 @@ const SurveyEditor: React.FC> = ({ state, setStat ...quest, id: v4(), question: { question: "", questionLabel: "", id: v4() }, - answer: { ...quest.answerSpec, id: v4() }, + answer: { ...quest.answer, id: v4() }, } const currentIndex = state.content.indexOf(quest) const newContent = state.content @@ -140,14 +140,14 @@ const SurveyEditor: React.FC> = ({ state, setStat if (typeof newState.content === "undefined") { newState.content = [] } - const answerObject: AnswerSpec = { + const answerObject: Answer = { type: AnswerType.None, options: [], } newState.content.push({ id: v4(), question: { id: v4(), question: "", questionLabel: "" }, - answerSpec: answerObject, + answer: answerObject, conditional: false, }) setState({ view_type: "exercise-editor", private_spec: newState }) @@ -168,14 +168,14 @@ const SurveyEditor: React.FC> = ({ state, setStat if (!e) { return } - const answerObject: AnswerSpec = { + const answerObject: Answer = { type: AnswerType.None, options: [], } newContent.push({ id: v4(), question: { id: v4(), questionLabel: e[0], question: e[1] }, - answerSpec: answerObject, + answer: answerObject, conditional: false, }) }) diff --git a/src/components/Survey/Editors/SurveyItemEditor.tsx b/src/components/Survey/Editors/SurveyItemEditor.tsx index e4024b8..c5768f5 100644 --- a/src/components/Survey/Editors/SurveyItemEditor.tsx +++ b/src/components/Survey/Editors/SurveyItemEditor.tsx @@ -5,7 +5,7 @@ import CheckBox from "../../../shared-module/components/InputFields/CheckBox" import TextArea from "../../../shared-module/components/InputFields/TextAreaField" import { baseTheme, primaryFont } from "../../../shared-module/styles" import { respondToOrLarger } from "../../../shared-module/styles/respond" -import { AnswerSpec, AnswerType, Survey, SurveyItem } from "../../../util/spec-types/privateSpec" +import { Answer, AnswerType, Survey, SurveyItem } from "../../../util/spec-types/privateSpec" import { insertVariablesToText, parseLabelQuestion, @@ -107,23 +107,23 @@ const SurveyItemEditor: React.FC> = ({ }, } if (newItem.question.questionLabel === "info") { - newItem.answerSpec.type = AnswerType.None - newItem.answerSpec.options = [] + newItem.answer.type = AnswerType.None + newItem.answer.options = [] delete newItem.globalVariable delete newItem.question.mandatory } if (newItem.question.questionLabel === "info-header") { - newItem.answerSpec.type = AnswerType.ConsentCheckbox - newItem.answerSpec.options = [] + newItem.answer.type = AnswerType.ConsentCheckbox + newItem.answer.options = [] delete newItem.globalVariable delete newItem.question.mandatory } if ( - newItem.answerSpec.type === AnswerType.ConsentCheckbox && + newItem.answer.type === AnswerType.ConsentCheckbox && newItem.question.questionLabel !== "info-header" ) { - newItem.answerSpec.type = AnswerType.None - newItem.answerSpec.options = [] + newItem.answer.type = AnswerType.None + newItem.answer.options = [] } onChangeSurveyItem(newItem) }} @@ -146,22 +146,22 @@ const SurveyItemEditor: React.FC> = ({ /> {item.question.questionLabel && item.question.questionLabel !== "info" && ( )} - {(item.answerSpec?.type === AnswerType.MultiChoice || - item.answerSpec?.type === AnswerType.RadioGroup || - item.answerSpec?.type === AnswerType.Dropdown || - item.answerSpec?.type === AnswerType.AdvancedDropdown) && ( + {(item.answer?.type === AnswerType.MultiChoice || + item.answer?.type === AnswerType.RadioGroup || + item.answer?.type === AnswerType.Dropdown || + item.answer?.type === AnswerType.AdvancedDropdown) && (
- {item.answerSpec.options.length > 0 && ( + {item.answer.options.length > 0 && (
    > = ({ border-spacing: 0; `} > - {item.answerSpec.options.map((o, o_idx) => { + {item.answer.options.map((o, o_idx) => { return (
  1. @@ -228,18 +228,18 @@ const SurveyItemEditor: React.FC> = ({ value={o as string} type="text" onChange={(e) => { - const newAnswerSpec = item.answerSpec - newAnswerSpec.options[o_idx] = e.target.value - onChangeSurveyItem({ ...item, answerSpec: newAnswerSpec }) + const newAnswer = item.answer + newAnswer.options[o_idx] = e.target.value + onChangeSurveyItem({ ...item, answer: newAnswer }) }} /> { const newAnswer = { - ...item.answerSpec, - options: (item.answerSpec.options as string[]).filter((e) => o !== e), + ...item.answer, + options: (item.answer.options as string[]).filter((e) => o !== e), } - onChangeSurveyItem({ ...item, answerSpec: newAnswer }) + onChangeSurveyItem({ ...item, answer: newAnswer }) }} > {"x"} @@ -253,8 +253,8 @@ const SurveyItemEditor: React.FC> = ({
)} - {item.answerSpec.type === AnswerType.WeightedRadioGroup && ( + {item.answer.type === AnswerType.WeightedRadioGroup && ( <>
    - {item.answerSpec.factorialOptions?.map((fop, idx) => { + {item.answer.factorialOptions?.map((fop, idx) => { return (
  1. > = ({ idx={idx + 1} item={fop} onDelete={() => { - const newOptions = item.answerSpec.factorialOptions?.filter( + const newOptions = item.answer.factorialOptions?.filter( (e) => e.id !== fop.id, ) onChangeSurveyItem({ ...item, - answerSpec: { ...item.answerSpec, factorialOptions: newOptions }, + answer: { ...item.answer, factorialOptions: newOptions }, }) }} onChange={(op) => { - const newOptions = item.answerSpec.factorialOptions?.map((option) => { + const newOptions = item.answer.factorialOptions?.map((option) => { if (option.id !== fop.id) { return option } @@ -308,7 +308,7 @@ const SurveyItemEditor: React.FC> = ({ }) onChangeSurveyItem({ ...item, - answerSpec: { ...item.answerSpec, factorialOptions: newOptions }, + answer: { ...item.answer, factorialOptions: newOptions }, }) }} /> @@ -319,10 +319,10 @@ const SurveyItemEditor: React.FC> = ({ )} - {item.answerSpec?.type === AnswerType.ConsentCheckbox && ( + {item.answer?.type === AnswerType.ConsentCheckbox && (