Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
survey
Commits
7035f39e
Commit
7035f39e
authored
Jul 08, 2022
by
jang dong hyeok
Browse files
changeDD함수로 questionList접근해서 type바꾸기
parent
37cfe93b
Changes
8
Show whitespace changes
Inline
Side-by-side
frontend/src/CreateSurveyForm/QCheckbox.tsx
View file @
7035f39e
...
@@ -2,6 +2,7 @@ import React from "react";
...
@@ -2,6 +2,7 @@ import React from "react";
import
{
CheckboxType
}
from
"
./CreateSurveyFormPage
"
;
import
{
CheckboxType
}
from
"
./CreateSurveyFormPage
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
Edit
}
from
"
./Edit
"
;
import
{
Edit
}
from
"
./Edit
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
type
Props
=
{
element
:
CheckboxType
;
element
:
CheckboxType
;
...
@@ -21,22 +22,7 @@ export const QCheckbox = ({ element }: Props) => {
...
@@ -21,22 +22,7 @@ export const QCheckbox = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
onChange
=
{
questionListChange
}
></
input
>
></
input
>
<
select
<
TypeChange
tt
=
"checkbox"
/>
id
=
"Questions"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<
option
>
질문종류
</
option
>
<
option
value
=
"essay"
>
주관식
</
option
>
<
option
value
=
"radio"
>
객관식
</
option
>
<
option
value
=
"dropdown"
>
드롭다운(객관식)
</
option
>
<
option
value
=
"checkbox"
selected
>
체크박스(객관식)
</
option
>
<
option
value
=
"file"
>
파일업로드
</
option
>
<
option
value
=
"rating"
>
선형
</
option
>
<
option
value
=
"grid"
>
그리드
</
option
>
<
option
value
=
"date"
>
날짜
</
option
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
div
className
=
"flex w-full justify-center"
>
<
input
<
input
...
...
frontend/src/CreateSurveyForm/QDropdown.tsx
View file @
7035f39e
import
React
from
"
react
"
;
import
React
from
"
react
"
;
import
{
DropdownType
}
from
"
./CreateSurveyFormPage
"
;
import
{
DropdownType
}
from
"
./CreateSurveyFormPage
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
type
Props
=
{
element
:
DropdownType
;
element
:
DropdownType
;
...
@@ -19,22 +20,7 @@ export const QDropdown = ({ element }: Props) => {
...
@@ -19,22 +20,7 @@ export const QDropdown = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
onChange
=
{
questionListChange
}
></
input
>
></
input
>
<
select
<
TypeChange
tt
=
"dropdown"
/>
id
=
"Questions"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<
option
>
질문종류
</
option
>
<
option
value
=
"essay"
>
주관식
</
option
>
<
option
value
=
"radio"
>
객관식
</
option
>
<
option
value
=
"dropdown"
selected
>
드롭다운(객관식)
</
option
>
<
option
value
=
"checkbox"
>
체크박스(객관식)
</
option
>
<
option
value
=
"file"
>
파일업로드
</
option
>
<
option
value
=
"rating"
>
선형
</
option
>
<
option
value
=
"grid"
>
그리드
</
option
>
<
option
value
=
"date"
>
날짜
</
option
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
div
className
=
"flex w-full justify-center"
>
<
input
<
input
...
...
frontend/src/CreateSurveyForm/QEssay.tsx
View file @
7035f39e
...
@@ -2,6 +2,7 @@ import React, { useState } from "react";
...
@@ -2,6 +2,7 @@ import React, { useState } from "react";
import
{
EssayType
}
from
"
./CreateSurveyFormPage
"
;
import
{
EssayType
}
from
"
./CreateSurveyFormPage
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
Edit
}
from
"
./Edit
"
;
import
{
Edit
}
from
"
./Edit
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
type
Props
=
{
element
:
EssayType
;
element
:
EssayType
;
...
@@ -21,22 +22,8 @@ export const QEssay = ({ element }: Props) => {
...
@@ -21,22 +22,8 @@ export const QEssay = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
onChange
=
{
questionListChange
}
></
input
>
></
input
>
<
select
{
/* <TypeChange tt={"essay"} id={element._id} /> */
}
id
=
"Questions"
<
TypeChange
tt
=
{
"
essay
"
}
/>
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<
option
>
질문종류
</
option
>
<
option
value
=
"essay"
selected
>
주관식
</
option
>
<
option
value
=
"radio"
>
객관식
</
option
>
<
option
value
=
"dropdown"
>
드롭다운(객관식)
</
option
>
<
option
value
=
"checkbox"
>
체크박스(객관식)
</
option
>
<
option
value
=
"file"
>
파일업로드
</
option
>
<
option
value
=
"rating"
>
선형
</
option
>
<
option
value
=
"grid"
>
그리드
</
option
>
<
option
value
=
"date"
>
날짜
</
option
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
div
className
=
"flex w-full justify-center"
>
<
input
<
input
...
...
frontend/src/CreateSurveyForm/QFile.tsx
View file @
7035f39e
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
FileType
}
from
"
./CreateSurveyFormPage
"
;
import
{
FileType
}
from
"
./CreateSurveyFormPage
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
type
Props
=
{
element
:
FileType
;
element
:
FileType
;
...
@@ -20,22 +21,7 @@ export const QFile = ({ element }: Props) => {
...
@@ -20,22 +21,7 @@ export const QFile = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
onChange
=
{
questionListChange
}
></
input
>
></
input
>
<
select
<
TypeChange
tt
=
"file"
/>
id
=
"Questions"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<
option
>
질문종류
</
option
>
<
option
value
=
"essay"
>
주관식
</
option
>
<
option
value
=
"radio"
>
객관식
</
option
>
<
option
value
=
"dropdown"
>
드롭다운(객관식)
</
option
>
<
option
value
=
"checkbox"
>
체크박스(객관식)
</
option
>
<
option
value
=
"file"
selected
>
파일업로드
</
option
>
<
option
value
=
"rating"
>
선형
</
option
>
<
option
value
=
"grid"
>
그리드
</
option
>
<
option
value
=
"date"
>
날짜
</
option
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
div
className
=
"flex w-full justify-center"
>
<
input
<
input
...
...
frontend/src/CreateSurveyForm/QRadio.tsx
View file @
7035f39e
import
React
from
"
react
"
;
import
React
from
"
react
"
;
import
{
RadioType
}
from
"
./CreateSurveyFormPage
"
;
import
{
RadioType
}
from
"
./CreateSurveyFormPage
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
type
Props
=
{
element
:
RadioType
;
element
:
RadioType
;
...
@@ -19,21 +20,7 @@ export const QRadio = ({ element }: Props) => {
...
@@ -19,21 +20,7 @@ export const QRadio = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
onChange
=
{
questionListChange
}
></
input
>
></
input
>
<
select
<
TypeChange
tt
=
"radio"
/>
id
=
"Questions"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor focus:themeColor block w-full mr-3 p-2.5"
>
<
option
>
질문종류
</
option
>
<
option
value
=
"Essay"
>
주관식
</
option
>
<
option
value
=
"MultipleChoice"
selected
>
객관식
</
option
>
<
option
value
=
"Dropdown"
>
드롭다운(객관식)
</
option
>
<
option
value
=
"CheckBox"
>
체크박스(객관식)
</
option
>
<
option
value
=
"Rating"
>
선형
</
option
>
<
option
value
=
"Grid"
>
그리드
</
option
>
<
option
value
=
"Date"
>
날짜
</
option
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
div
className
=
"flex w-full justify-center"
>
<
input
<
input
...
...
frontend/src/CreateSurveyForm/QRating.tsx
View file @
7035f39e
import
React
from
"
react
"
;
import
React
from
"
react
"
;
import
{
RatingType
}
from
"
./CreateSurveyFormPage
"
;
import
{
RatingType
}
from
"
./CreateSurveyFormPage
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
type
Props
=
{
element
:
RatingType
;
element
:
RatingType
;
...
@@ -21,22 +22,7 @@ export const QRating = ({ element }: Props) => {
...
@@ -21,22 +22,7 @@ export const QRating = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
onChange
=
{
questionListChange
}
></
input
>
></
input
>
<
select
<
TypeChange
tt
=
"rating"
/>
id
=
{
element
.
_id
}
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
>
<
option
>
질문종류
</
option
>
<
option
value
=
"essay"
>
주관식
</
option
>
<
option
value
=
"radio"
>
객관식
</
option
>
<
option
value
=
"dropdown"
>
드롭다운(객관식)
</
option
>
<
option
value
=
"checkbox"
>
체크박스(객관식)
</
option
>
<
option
value
=
"file"
>
파일업로드
</
option
>
<
option
value
=
"rating"
selected
>
선형
</
option
>
<
option
value
=
"grid"
>
그리드
</
option
>
<
option
value
=
"date"
>
날짜
</
option
>
</
select
>
</
div
>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
div
className
=
"flex w-full justify-center"
>
<
input
<
input
...
...
frontend/src/CreateSurveyForm/question.context.tsx
View file @
7035f39e
...
@@ -7,6 +7,7 @@ import React, {
...
@@ -7,6 +7,7 @@ import React, {
}
from
"
react
"
;
}
from
"
react
"
;
import
axios
from
"
axios
"
;
import
axios
from
"
axios
"
;
import
{
BasicQuestionType
}
from
"
./CreateSurveyFormPage
"
;
import
{
BasicQuestionType
}
from
"
./CreateSurveyFormPage
"
;
import
e
from
"
express
"
;
interface
IQuestionContext
{
interface
IQuestionContext
{
questionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
questionListChange
:
(
e
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
void
;
...
@@ -14,6 +15,7 @@ interface IQuestionContext {
...
@@ -14,6 +15,7 @@ interface IQuestionContext {
editClick
:
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
void
;
editClick
:
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
void
;
currentId
:
string
;
currentId
:
string
;
addQuestion
:
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
Promise
<
void
>
;
addQuestion
:
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
Promise
<
void
>
;
questionTypeChange
:
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
void
;
}
}
const
QuestionContext
=
createContext
<
IQuestionContext
>
({
const
QuestionContext
=
createContext
<
IQuestionContext
>
({
...
@@ -22,6 +24,7 @@ const QuestionContext = createContext<IQuestionContext>({
...
@@ -22,6 +24,7 @@ const QuestionContext = createContext<IQuestionContext>({
editClick
:
()
=>
{},
editClick
:
()
=>
{},
currentId
:
""
,
currentId
:
""
,
addQuestion
:
async
()
=>
{},
addQuestion
:
async
()
=>
{},
questionTypeChange
:
()
=>
{},
});
});
export
const
QuestionProvider
:
FC
<
{
children
:
ReactNode
}
>
=
({
children
})
=>
{
export
const
QuestionProvider
:
FC
<
{
children
:
ReactNode
}
>
=
({
children
})
=>
{
...
@@ -37,6 +40,13 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
...
@@ -37,6 +40,13 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
obj
[
targetKey
]
=
e
.
target
.
value
;
obj
[
targetKey
]
=
e
.
target
.
value
;
setQuestionList
(
newList
);
setQuestionList
(
newList
);
}
}
function
questionTypeChange
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
):
void
{
const
newType
:
BasicQuestionType
[]
=
[...
questionList
];
const
objType
:
any
=
newType
.
find
((
t
)
=>
t
.
_id
===
e
.
target
.
id
);
const
targetType
:
string
=
e
.
target
.
name
;
objType
[
targetType
]
=
e
.
target
.
value
;
setQuestionList
(
newType
);
}
async
function
addQuestion
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
{
async
function
addQuestion
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
{
try
{
try
{
...
@@ -71,6 +81,7 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
...
@@ -71,6 +81,7 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
questionList
,
questionList
,
editClick
,
editClick
,
currentId
,
currentId
,
questionTypeChange
,
}
}
}
}
>
>
{
children
}
{
children
}
...
...
frontend/src/CreateSurveyForm/typeDD.tsx
0 → 100644
View file @
7035f39e
import
React
,
{
ChangeEvent
,
useState
}
from
"
react
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
type
typeChangeProps
=
{
tt
:
string
;
};
export
function
TypeChange
({
tt
}:
typeChangeProps
)
{
const
{
questionTypeChange
}
=
useQuestion
();
const
typeDD
=
new
Map
([
[
"
essay
"
,
"
주관식
"
],
[
"
radio
"
,
"
객관식
"
],
[
"
dropdown
"
,
"
드롭다운(객관식)
"
],
[
"
checkbox
"
,
"
체크박스
"
],
[
"
file
"
,
"
파일
"
],
[
"
rating
"
,
"
선형
"
],
[
"
grid
"
,
"
그리드
"
],
[
"
date
"
,
"
날짜
"
],
]);
function
changeDD
(
e
:
ChangeEvent
<
HTMLSelectElement
>
)
{
const
tt
=
e
.
target
.
value
;
questionTypeChange
(
e
);
console
.
log
(
tt
);
//if문으로 type별로 content 바뀌게 해보기
}
return
(
<
select
id
=
"Questions"
name
=
"type"
className
=
"w-36 bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-themeColor w-full mr-3 p-2.5"
defaultValue
=
{
tt
}
onChange
=
{
changeDD
}
>
{
Array
.
from
(
typeDD
.
entries
()).
map
(([
k
,
v
])
=>
(
<
option
value
=
{
k
}
>
{
v
}
</
option
>
))
}
</
select
>
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment