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
f8d845da
Commit
f8d845da
authored
Jul 23, 2022
by
Yoon, Daeki
😅
Browse files
Merge branch 'answer-structure' into main-answer-structure
parents
6442aa99
ab4ecce7
Changes
17
Show whitespace changes
Inline
Side-by-side
docs/overview.drawio
0 → 100644
View file @
f8d845da
<mxfile host="65bd71144e">
<diagram id="4_LKa-YRAXo4FlEpOd_K" name="페이지-1">
<mxGraphModel dx="1549" dy="312" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0"/>
<mxCell id="1" parent="0"/>
<mxCell id="33" value="Frontend" style="swimlane;" vertex="1" parent="1">
<mxGeometry x="-180" y="40" width="1080" height="800" as="geometry">
<mxRectangle x="-20" y="40" width="80" height="23" as="alternateBounds"/>
</mxGeometry>
</mxCell>
<mxCell id="2" value="Routes" style="whiteSpace=wrap;html=1;" vertex="1" parent="33">
<mxGeometry x="185" y="40" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="3" value="/surveys/edit/:surveyId" style="whiteSpace=wrap;html=1;" vertex="1" parent="33">
<mxGeometry x="320" y="130" width="120" height="60" as="geometry"/>
</mxCell>
<mxCell id="4" value="" style="edgeStyle=none;html=1;" edge="1" parent="33" source="2" target="3">
<mxGeometry relative="1" as="geometry"/>
</mxCell>
<mxCell id="29" value="<p style="margin: 0px ; margin-top: 4px ; text-align: center ; text-decoration: underline"><b>EditSurvey: 설문조사 수정</b></p><hr><p style="margin: 0px ; margin-left: 8px">surveyId = useParams()</p><p style="margin: 0px ; margin-left: 8px">useEffect(<span>surveyApi.getSurvey(surveyId))</span></p><p style="margin: 0px ; margin-left: 8px"><span><br></span></p><p style="margin: 0px ; margin-left: 8px"><span>- 질문 추가: addQuestion()</span></p><p style="margin: 0px ; margin-left: 8px"><span>- 질문 삭제: deleteQuestion()</span></p><p style="margin: 0px ; margin-left: 8px"><br></p><p style="margin: 0px ; margin-left: 8px"><span>- 설문 수정: updateSurvey: await surveyApi.update()</span></p>" style="verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;" vertex="1" parent="33">
<mxGeometry x="97.5" y="250" width="295" height="170" as="geometry"/>
</mxCell>
<mxCell id="6" value="<span style="font-size: 12px">/surveys/edit/:surveyId<br></span>" style="edgeStyle=none;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;exitX=0.5;exitY=1;exitDx=0;exitDy=0;" edge="1" parent="33" source="2" target="29">
<mxGeometry relative="1" as="geometry">
<mxPoint x="340" y="450" as="targetPoint"/>
</mxGeometry>
</mxCell>
<mxCell id="30" value="<p style="margin: 0px ; margin-top: 4px ; text-align: center ; text-decoration: underline"><b>survey.api</b></p><hr><p style="margin: 0px ; margin-left: 8px">getSuvey()<br>field2 = value2<br>field3 = value3</p>" style="verticalAlign=top;align=left;overflow=fill;fontSize=12;fontFamily=Helvetica;html=1;" vertex="1" parent="33">
<mxGeometry x="460" y="40" width="160" height="90" as="geometry"/>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>
\ No newline at end of file
frontend/src/SurveyRouter.tsx
View file @
f8d845da
...
...
@@ -3,7 +3,7 @@ import { BrowserRouter, Route, Routes } from "react-router-dom";
import
App
from
"
./App
"
;
import
{
Login
,
SignUp
}
from
"
./auth
"
;
import
{
RequireAuth
}
from
"
./auth/RequireAuth
"
;
import
{
SurveyForm
}
from
"
./
common
s
"
;
import
{
Answer
SurveyForm
}
from
"
./
answer
s
"
;
import
{
Home
}
from
"
./home
"
;
import
{
Profile
}
from
"
./profile
"
;
import
{
EditResultButton
}
from
"
./survey
"
;
...
...
@@ -22,7 +22,7 @@ export const SurveyRouter = () => {
<
Route
path
=
":surveyId"
element
=
{
<
EditSurvey
/>
}
/>
<
Route
path
=
":surveyId/result"
element
=
{
<
ResultSurvey
/>
}
/>
</
Route
>
<
Route
path
=
"surveys/:surveyId"
element
=
{
<
SurveyForm
/>
}
/>
<
Route
path
=
"surveys/:surveyId"
element
=
{
<
Answer
SurveyForm
/>
}
/>
<
Route
path
=
"profile"
element
=
{
...
...
frontend/src/
common
s/ACheckboxForm.tsx
→
frontend/src/
answer
s/ACheckboxForm.tsx
View file @
f8d845da
import
React
,
{
useState
}
from
"
react
"
;
import
{
CheckboxType
,
AnswersType
}
from
"
../types
"
;
import
{
CheckboxType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
type
Props
=
{
interface
Props
extends
Answer
Props
{
element
:
CheckboxType
;
answerQuestion
:
any
|
undefined
;
}
;
}
export
const
ACheckboxForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
...
...
frontend/src/
common
s/ADateForm.tsx
→
frontend/src/
answer
s/ADateForm.tsx
View file @
f8d845da
File moved
frontend/src/
common
s/ADropdownForm.tsx
→
frontend/src/
answer
s/ADropdownForm.tsx
View file @
f8d845da
import
React
,
{
useState
}
from
"
react
"
;
import
{
DropdownType
,
Answer
sType
}
from
"
../types
"
;
import
{
DropdownType
,
Answer
Props
}
from
"
../types
"
;
type
Props
=
{
interface
Props
extends
Answer
Props
{
element
:
DropdownType
;
answerQuestion
:
any
|
undefined
;
}
;
}
export
const
ADropdownForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
...
...
frontend/src/
common
s/AEssayForm.tsx
→
frontend/src/
answer
s/AEssayForm.tsx
View file @
f8d845da
import
React
,
{
useState
}
from
"
react
"
;
import
{
EssayType
,
Answers
Type
}
from
"
../types
"
;
import
{
AnswerProps
,
Essay
Type
}
from
"
../types
"
;
type
Props
=
{
element
:
EssayType
;
...
...
frontend/src/
common
s/AFileForm.tsx
→
frontend/src/
answer
s/AFileForm.tsx
View file @
f8d845da
import
React
,
{
useState
}
from
"
react
"
;
import
{
FileType
,
AnswersType
}
from
"
../types
"
;
import
{
FileType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
type
Props
=
{
interface
Props
extends
Answer
Props
{
element
:
FileType
;
answerQuestion
:
any
|
undefined
;
addFiles
:
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
void
;
}
;
}
export
const
AFileForm
=
({
element
,
answerQuestion
,
addFiles
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
...
...
frontend/src/
common
s/AQuestion.tsx
→
frontend/src/
answer
s/AQuestion.tsx
View file @
f8d845da
File moved
frontend/src/
common
s/ARadioForm.tsx
→
frontend/src/
answer
s/ARadioForm.tsx
View file @
f8d845da
import
React
,
{
useState
}
from
"
react
"
;
import
{
RadioType
,
AnswersType
}
from
"
../types
"
;
import
{
RadioType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
type
Props
=
{
interface
Props
extends
Answer
Props
{
element
:
RadioType
;
answerQuestion
:
any
|
undefined
;
}
;
}
export
const
ARadioForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
...
...
@@ -23,7 +23,7 @@ export const ARadioForm = ({ element, answerQuestion }: Props) => {
return
(
<
div
className
=
"flex w-full gap-2 justify-around my-3"
>
{
element
.
content
.
choices
.
map
((
choice
)
=>
(
<
div
>
<
div
key
=
{
choice
.
text
}
>
<
input
className
=
"mr-2"
type
=
"radio"
...
...
frontend/src/
common
s/ARatingForm.tsx
→
frontend/src/
answer
s/ARatingForm.tsx
View file @
f8d845da
import
React
,
{
useState
}
from
"
react
"
;
import
{
RatingType
,
AnswersType
}
from
"
../types
"
;
import
{
RatingType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
type
Props
=
{
interface
Props
extends
Answer
Props
{
element
:
RatingType
;
answerQuestion
:
any
|
undefined
;
}
;
}
export
const
ARatingForm
=
({
element
,
answerQuestion
}:
Props
)
=>
{
const
[
selectedchoice
,
setSelectedchoice
]
=
useState
(
""
);
...
...
frontend/src/
commons/
SurveyForm.tsx
→
frontend/src/
answers/Answer
SurveyForm.tsx
View file @
f8d845da
...
...
@@ -7,7 +7,7 @@ import { Question } from "../questions";
import
{
AnswerType
,
SurveyType
}
from
"
../types
"
;
import
{
AQuestion
}
from
"
./AQuestion
"
;
export
const
SurveyForm
=
()
=>
{
export
const
Answer
SurveyForm
=
()
=>
{
let
{
surveyId
}
=
useParams
<
{
surveyId
:
string
}
>
();
const
[
files
,
setFiles
]
=
useState
<
{
questionId
:
string
;
file
:
File
}[]
>
([]);
const
[
requiredErrorMessage
,
setRequiredErrorMessage
]
=
useState
(
""
);
...
...
frontend/src/answers/index.tsx
0 → 100644
View file @
f8d845da
export
{
AnswerSurveyForm
}
from
"
./AnswerSurveyForm
"
;
frontend/src/commons/constants.ts
0 → 100644
View file @
f8d845da
export
const
QUESTION_TYPES
=
new
Map
([
[
"
essay
"
,
"
주관식
"
],
[
"
radio
"
,
"
객관식
"
],
[
"
dropdown
"
,
"
드롭다운
"
],
[
"
checkbox
"
,
"
체크박스
"
],
[
"
file
"
,
"
파일
"
],
[
"
rating
"
,
"
선형
"
],
[
"
grid
"
,
"
그리드
"
],
[
"
date
"
,
"
날짜
"
],
]);
frontend/src/commons/index.tsx
View file @
f8d845da
export
{
Header
}
from
"
./Header
"
;
export
{
SurveyForm
}
from
"
./SurveyForm
"
;
\ No newline at end of file
export
{
QUESTION_TYPES
}
from
"
./constants
"
;
frontend/src/questions/Question.tsx
View file @
f8d845da
import
React
,
{
useState
,
Dispatch
,
SetStateAction
}
from
"
react
"
;
import
{
BasicQuestionType
,
EssayType
}
from
"
../types
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
BasicQuestionType
}
from
"
../types
"
;
import
{
questionApi
}
from
"
../apis
"
;
import
{
EssayForm
}
from
"
./EssayForm
"
;
import
{
CheckboxForm
}
from
"
./CheckboxForm
"
;
...
...
@@ -8,6 +8,7 @@ import { DropdownForm } from "./DropdownForm";
import
{
FileForm
}
from
"
./FileForm
"
;
import
{
RatingForm
}
from
"
./RatingForm
"
;
import
{
DateForm
}
from
"
./DateForm
"
;
import
{
QUESTION_TYPES
}
from
"
../commons
"
;
type
Props
=
{
element
:
BasicQuestionType
;
...
...
@@ -16,17 +17,6 @@ type Props = {
isSave
:
boolean
;
};
const
typeDropDown
=
new
Map
([
[
"
essay
"
,
"
주관식
"
],
[
"
radio
"
,
"
객관식
"
],
[
"
dropdown
"
,
"
드롭다운
"
],
[
"
checkbox
"
,
"
체크박스
"
],
[
"
file
"
,
"
파일
"
],
[
"
rating
"
,
"
선형
"
],
[
"
grid
"
,
"
그리드
"
],
[
"
date
"
,
"
날짜
"
],
]);
export
const
Question
=
({
element
,
handleQuestion
,
...
...
@@ -165,13 +155,15 @@ export const Question = ({
name
=
"type"
onChange
=
{
handleSelect
}
disabled
=
{
save
}
value
=
{
element
.
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"
>
{
Array
.
from
(
typeDropDown
.
entries
()).
map
(([
key
,
value
])
=>
(
{
Array
.
from
(
QUESTION_TYPES
.
entries
()).
map
(([
key
,
value
])
=>
(
<
option
key
=
{
key
}
id
=
{
element
.
_id
}
value
=
{
key
}
selected
=
{
key
===
element
.
type
}
//
selected={key === element.type}
>
{
value
}
</
option
>
...
...
frontend/src/survey/EditSurvey.tsx
View file @
f8d845da
...
...
@@ -139,6 +139,7 @@ export const EditSurvey = () => {
</
div
>
{
questions
.
map
((
question
)
=>
(
<
Question
key
=
{
question
.
_id
}
element
=
{
question
}
isSave
=
{
state
?
true
:
false
}
handleQuestion
=
{
handleQuestion
}
...
...
frontend/src/types/index.ts
View file @
f8d845da
...
...
@@ -44,22 +44,21 @@ export interface RadioType extends BasicQuestionType {
};
}
export
interface
CheckboxType
extends
BasicQuestionType
{
content
:
{
choices
:
{
interface
IChoices
{
value
:
number
;
text
:
string
;
}[];
}
export
interface
CheckboxType
extends
BasicQuestionType
{
content
:
{
choices
:
IChoices
[];
maxCount
:
number
;
};
}
export
interface
DropdownType
extends
BasicQuestionType
{
content
:
{
choices
:
{
value
:
number
;
text
:
string
;
}[];
choices
:
IChoices
[];
hasNone
:
boolean
;
};
}
...
...
@@ -93,3 +92,9 @@ export interface AnswerType {
guestId
:
string
;
answers
:
AnswersType
[];
}
export
interface
AnswerProps
{
element
:
BasicQuestionType
;
// answers: AnswersType | undefined;
// handleAnswer: () => void;
}
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