Commit 72abe1cb authored by Jiwon Yoon's avatar Jiwon Yoon
Browse files

Questions(파일이름변경), 객관식 content choices로 통일

parent 37cfe93b
import React, { useState } from "react"; import React, { useState } from "react";
import { Question } from "./Question"; import { Questions } from "./Questions";
import { QuestionProvider } from "./question.context"; import { QuestionProvider } from "./question.context";
export interface BasicQuestionType {
type: string;
_id: string;
title: string;
isRequired: boolean;
comment: string;
content: any;
[key: string]: string | number | boolean | any;
}
export interface EssayType extends BasicQuestionType {}
export interface RadioType extends BasicQuestionType {
content: {
hasOther: boolean;
choices: string[];
otherText: string;
};
}
export interface CheckboxType extends BasicQuestionType {
content: {
choices: string[];
maxCount: number;
};
}
export interface DropdownType extends BasicQuestionType {
content: {
choices: string[];
hasNone: boolean;
};
}
export interface FileType extends BasicQuestionType {
content: {
filename: string;
value: string;
};
}
export interface RatingType extends BasicQuestionType {
content: {
rateValues: {
value: number;
text: string;
}[];
minRateDescription: string;
maxRateDescription: string;
};
}
const EssayQ: EssayType = {
type: "essay",
_id: "000000000000",
title: "Question Title",
isRequired: false,
comment: "질문에 대한 설명을 입력해주세요",
content: null,
};
const RadioQ: RadioType = {
type: "radio",
_id: "000000000001",
title: "Question Title",
isRequired: false,
comment: "질문에 대한 설명을 입력해주세요",
content: {
hasOther: false,
otherText: "",
choices: ["radio1", "radio2", "radio3"],
},
};
const CheckboxQ: CheckboxType = {
type: "checkbox",
_id: "000000000002",
title: "Question Title",
isRequired: false,
comment: "질문에 대한 설명을 입력해주세요",
content: {
choices: ["check1", "check2", "check3"],
maxCount: 2,
},
};
const DropdownQ: DropdownType = {
type: "dropdown",
_id: "000000000003",
title: "Question Title",
isRequired: false,
comment: "질문에 대한 설명을 입력해주세요",
content: {
choices: ["drop1", "drop2", "drop3"],
hasNone: false,
},
};
const FileQ: FileType = {
type: "file",
_id: "000000000004",
title: "Question Title",
isRequired: false,
comment: "질문에 대한 설명을 입력해주세요",
content: {
filename: "",
value: "",
},
};
const RatingQ: RatingType = {
type: "rating",
_id: "000000000005",
title: "Question Title",
isRequired: false,
comment: "질문에 대한 설명을 입력해주세요",
content: {
rateValues: [
{ value: 1, text: "1" },
{ value: 2, text: "2" },
{ value: 3, text: "3" },
],
minRateDescription: "가장 낮음",
maxRateDescription: "가장 높음",
},
};
export const CreateSurveyForm = () => { export const CreateSurveyForm = () => {
const [survey, setSurvey] = useState(); const [survey, setSurvey] = useState();
const [error, setError] = useState(""); const [error, setError] = useState("");
...@@ -141,7 +25,7 @@ export const CreateSurveyForm = () => { ...@@ -141,7 +25,7 @@ export const CreateSurveyForm = () => {
cols={60} cols={60}
></textarea> ></textarea>
</div> </div>
<Question /> <Questions />
<div> <div>
<button className="border bg-themeColor my-5 py-2 px-3 font-bold text-white"> <button className="border bg-themeColor my-5 py-2 px-3 font-bold text-white">
설문조사 생성 설문조사 생성
......
import React from "react"; import React from "react";
import { CheckboxType } from "./CreateSurveyFormPage"; import { CheckboxType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { Edit } from "./Edit"; import { Edit } from "./Edit";
...@@ -49,13 +49,13 @@ export const QCheckbox = ({ element }: Props) => { ...@@ -49,13 +49,13 @@ export const QCheckbox = ({ element }: Props) => {
></input> ></input>
</div> </div>
<div id="commentarea" className="flex mt-4"> <div id="commentarea" className="flex mt-4">
{element.content.choices.map((e: string) => ( {element.content.choices.map((e: any) => (
<div> <div>
<input type="checkbox" checked={false}></input> <input type="checkbox" checked={false}></input>
<input <input
type="text" type="text"
className="mx-2 border-b-2" className="mx-2 border-b-2"
placeholder={e} placeholder={e.text}
></input> ></input>
</div> </div>
))} ))}
......
import React from "react"; import React from "react";
import { DropdownType } from "./CreateSurveyFormPage"; import { DropdownType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
type Props = { type Props = {
...@@ -47,13 +47,13 @@ export const QDropdown = ({ element }: Props) => { ...@@ -47,13 +47,13 @@ export const QDropdown = ({ element }: Props) => {
></input> ></input>
</div> </div>
<div id="commentarea" className="flex mt-4"> <div id="commentarea" className="flex mt-4">
{element.content.choices.map((e: string) => ( {element.content.choices.map((e: any) => (
<div> <div>
<input type="checkbox" checked={false}></input> <input type="checkbox" checked={false}></input>
<input <input
type="text" type="text"
className="mx-2 border-b-2" className="mx-2 border-b-2"
placeholder={e} placeholder={e.text}
></input> ></input>
</div> </div>
))} ))}
......
import React, { useState } from "react"; import React, { useState } from "react";
import { EssayType } from "./CreateSurveyFormPage"; import { EssayType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
import { Edit } from "./Edit"; import { Edit } from "./Edit";
......
import React, { useState } from "react"; import React, { useState } from "react";
import { FileType } from "./CreateSurveyFormPage"; import { FileType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
type Props = { type Props = {
......
import React from "react"; import React from "react";
import { RadioType } from "./CreateSurveyFormPage"; import { RadioType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
type Props = { type Props = {
...@@ -46,21 +46,21 @@ export const QRadio = ({ element }: Props) => { ...@@ -46,21 +46,21 @@ export const QRadio = ({ element }: Props) => {
></input> ></input>
</div> </div>
<div className="flex mt-4"> <div className="flex mt-4">
{element.content.choices.map((e: string, index: number) => ( {element.content.choices.map((e: any) => (
<div> <div>
<input <input
type="radio" type="radio"
id={element._id} id={element._id}
name="choice" name="choice"
value={e} value={e.text}
disabled disabled
/> />
<input <input
type="text" type="text"
name={"choice" + `${index}`} name={"choice"}
// key={`${index}`} // key={`${index}`}
className="mx-2 border-b-2" className="mx-2 border-b-2"
placeholder={e} placeholder={e.text}
onChange={questionListChange} onChange={questionListChange}
></input> ></input>
<button></button> <button></button>
......
import React from "react"; import React from "react";
import { RatingType } from "./CreateSurveyFormPage"; import { RatingType } from "../types";
import { useQuestion } from "./question.context"; import { useQuestion } from "./question.context";
type Props = { type Props = {
...@@ -56,7 +56,7 @@ export const QRating = ({ element }: Props) => { ...@@ -56,7 +56,7 @@ export const QRating = ({ element }: Props) => {
size={10} size={10}
placeholder={element.content.minRateDescription} placeholder={element.content.minRateDescription}
></input> ></input>
{element.content.rateValues.map((e) => ( {element.content.choices.map((e) => (
<input <input
name="text" name="text"
id={element._id} id={element._id}
......
...@@ -9,7 +9,7 @@ import { useQuestion } from "./question.context"; ...@@ -9,7 +9,7 @@ import { useQuestion } from "./question.context";
type Props = {}; type Props = {};
export const Question = ({}: Props) => { export const Questions = ({}: Props) => {
const { addQuestion, questionList, currentId } = useQuestion(); const { addQuestion, questionList, currentId } = useQuestion();
return ( return (
......
export { CreateSurveyForm } from "./CreateSurveyFormPage"; export { CreateSurveyForm } from "./CreateSurveyFormPage";
export { Question } from "./Question"; export { Questions } from "./Questions";
...@@ -6,7 +6,7 @@ import React, { ...@@ -6,7 +6,7 @@ import React, {
useState, useState,
} from "react"; } from "react";
import axios from "axios"; import axios from "axios";
import { BasicQuestionType } from "./CreateSurveyFormPage"; import { BasicQuestionType } from "../types";
interface IQuestionContext { interface IQuestionContext {
questionListChange: (e: React.ChangeEvent<HTMLInputElement>) => void; questionListChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
......
...@@ -9,3 +9,64 @@ export interface SignupUser { ...@@ -9,3 +9,64 @@ export interface SignupUser {
name: string; name: string;
password: string; password: string;
} }
export interface BasicQuestionType {
type: string;
_id: string;
title: string;
isRequired: boolean;
comment: string;
content: any;
[key: string]: string | number | boolean | any;
}
export interface EssayType extends BasicQuestionType {}
export interface RadioType extends BasicQuestionType {
content: {
choices: {
value: number;
text: string;
}[];
hasOther: boolean;
otherText: string;
};
}
export interface CheckboxType extends BasicQuestionType {
content: {
choices: {
value: number;
text: string;
}[];
maxCount: number;
};
}
export interface DropdownType extends BasicQuestionType {
content: {
choices: {
value: number;
text: string;
}[];
hasNone: boolean;
};
}
export interface FileType extends BasicQuestionType {
content: {
filename: string;
value: string;
};
}
export interface RatingType extends BasicQuestionType {
content: {
choices: {
value: number;
text: string;
}[];
minRateDescription: string;
maxRateDescription: string;
};
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment