Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
students
survey
Commits
3e2be733
Commit
3e2be733
authored
Jul 09, 2022
by
Jiwon Yoon
Browse files
Merge branch 'DH1' into develop
parents
7cfe38be
9f2502d8
Changes
8
Hide whitespace changes
Inline
Side-by-side
frontend/src/CreateSurveyForm/QCheckbox.tsx
View file @
3e2be733
...
...
@@ -2,6 +2,7 @@ import React from "react";
import
{
CheckboxType
}
from
"
../types
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
Edit
}
from
"
./Edit
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
element
:
CheckboxType
;
...
...
@@ -21,22 +22,7 @@ export const QCheckbox = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
></
input
>
<
select
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
>
<
TypeChange
tt
=
"checkbox"
/>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
input
...
...
frontend/src/CreateSurveyForm/QDropdown.tsx
View file @
3e2be733
import
React
from
"
react
"
;
import
{
DropdownType
}
from
"
../types
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
element
:
DropdownType
;
...
...
@@ -19,22 +20,7 @@ export const QDropdown = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
></
input
>
<
select
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
>
<
TypeChange
tt
=
"dropdown"
/>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
input
...
...
frontend/src/CreateSurveyForm/QEssay.tsx
View file @
3e2be733
...
...
@@ -2,6 +2,7 @@ import React, { useState } from "react";
import
{
EssayType
}
from
"
../types
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
Edit
}
from
"
./Edit
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
element
:
EssayType
;
...
...
@@ -21,22 +22,8 @@ export const QEssay = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
></
input
>
<
select
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"
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
>
{
/* <TypeChange tt={"essay"} id={element._id} /> */
}
<
TypeChange
tt
=
{
"
essay
"
}
/>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
input
...
...
frontend/src/CreateSurveyForm/QFile.tsx
View file @
3e2be733
import
React
,
{
useState
}
from
"
react
"
;
import
{
FileType
}
from
"
../types
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
element
:
FileType
;
...
...
@@ -20,22 +21,7 @@ export const QFile = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
></
input
>
<
select
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
>
<
TypeChange
tt
=
"file"
/>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
input
...
...
frontend/src/CreateSurveyForm/QRadio.tsx
View file @
3e2be733
import
React
from
"
react
"
;
import
{
RadioType
}
from
"
../types
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
element
:
RadioType
;
...
...
@@ -19,21 +20,7 @@ export const QRadio = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
></
input
>
<
select
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
>
<
TypeChange
tt
=
"radio"
/>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
input
...
...
frontend/src/CreateSurveyForm/QRating.tsx
View file @
3e2be733
import
React
from
"
react
"
;
import
{
RatingType
}
from
"
../types
"
;
import
{
useQuestion
}
from
"
./question.context
"
;
import
{
TypeChange
}
from
"
./typeDD
"
;
type
Props
=
{
element
:
RatingType
;
...
...
@@ -21,22 +22,7 @@ export const QRating = ({ element }: Props) => {
placeholder
=
{
element
.
title
}
onChange
=
{
questionListChange
}
></
input
>
<
select
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
>
<
TypeChange
tt
=
"rating"
/>
</
div
>
<
div
className
=
"flex w-full justify-center"
>
<
input
...
...
frontend/src/CreateSurveyForm/question.context.tsx
View file @
3e2be733
...
...
@@ -17,6 +17,7 @@ interface IQuestionContext {
editCompleteClick
:
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
void
;
currentId
:
string
;
addQuestion
:
(
e
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
=>
Promise
<
void
>
;
questionTypeChange
:
(
e
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
void
;
}
const
QuestionContext
=
createContext
<
IQuestionContext
>
({
...
...
@@ -28,6 +29,7 @@ const QuestionContext = createContext<IQuestionContext>({
editCompleteClick
:
()
=>
{},
currentId
:
""
,
addQuestion
:
async
()
=>
{},
questionTypeChange
:
()
=>
{},
});
export
const
QuestionProvider
:
FC
<
{
children
:
ReactNode
}
>
=
({
children
})
=>
{
...
...
@@ -73,6 +75,13 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
obj
[
targetKey
]
=
e
.
target
.
value
;
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
()
{
try
{
...
...
@@ -106,6 +115,7 @@ export const QuestionProvider: FC<{ children: ReactNode }> = ({ children }) => {
editClick
,
editCompleteClick
,
currentId
,
questionTypeChange
,
}
}
>
{
children
}
...
...
frontend/src/CreateSurveyForm/typeDD.tsx
0 → 100644
View file @
3e2be733
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
:
React
.
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