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
4d2e3d2b
Commit
4d2e3d2b
authored
Jul 23, 2022
by
Yoon, Daeki
😅
Browse files
설문 응답 폴더 구조 변경
parent
719a7a2b
Changes
13
Show whitespace changes
Inline
Side-by-side
frontend/src/
common
s/ACheckboxForm.tsx
→
frontend/src/
answer
s/ACheckboxForm.tsx
View file @
4d2e3d2b
import
React
,
{
useState
}
from
"
react
"
;
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
;
element
:
CheckboxType
;
answers
:
AnswersType
|
undefined
;
}
handleAnswer
:
()
=>
void
;
};
export
const
ACheckboxForm
=
({
element
,
answers
,
handleAnswer
}:
Props
)
=>
{
export
const
ACheckboxForm
=
({
element
,
answers
,
handleAnswer
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
{
value
}
=
event
.
currentTarget
;
const
{
value
}
=
event
.
currentTarget
;
// response.answers.map((a) => {
// if (a.questionId === element._id) {
// a.answer = value;
// }
// });
answers
&&
(
answers
.
answer
=
value
);
answers
&&
(
answers
.
answer
=
value
);
setAnswer
(
value
);
setAnswer
(
value
);
handleAnswer
();
handleAnswer
();
...
...
frontend/src/
common
s/ADateForm.tsx
→
frontend/src/
answer
s/ADateForm.tsx
View file @
4d2e3d2b
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
DateType
,
AnswersType
}
from
"
../types
"
;
import
{
AnswerProps
}
from
"
../types
"
;
type
Props
=
{
element
:
DateType
;
export
const
ADateForm
=
({
element
,
answers
,
handleAnswer
}:
AnswerProps
)
=>
{
answers
:
AnswersType
|
undefined
;
handleAnswer
:
()
=>
void
;
};
export
const
ADateForm
=
({
element
,
answers
,
handleAnswer
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
{
value
}
=
event
.
currentTarget
;
const
{
value
}
=
event
.
currentTarget
;
...
...
frontend/src/
common
s/ADropdownForm.tsx
→
frontend/src/
answer
s/ADropdownForm.tsx
View file @
4d2e3d2b
import
React
,
{
useState
}
from
"
react
"
;
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
;
element
:
DropdownType
;
answers
:
AnswersType
|
undefined
;
}
handleAnswer
:
()
=>
void
;
};
export
const
ADropdownForm
=
({
element
,
handleAnswer
,
answers
}:
Props
)
=>
{
export
const
ADropdownForm
=
({
element
,
handleAnswer
,
answers
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLSelectElement
>
)
=>
{
const
{
value
}
=
event
.
currentTarget
;
const
{
value
}
=
event
.
currentTarget
;
// response.answers.map((a) => {
// if (a.questionId === element._id) {
// a.answer = value;
// }
// });
answers
&&
(
answers
.
answer
=
value
);
answers
&&
(
answers
.
answer
=
value
);
setAnswer
(
value
);
setAnswer
(
value
);
handleAnswer
();
handleAnswer
();
...
...
frontend/src/
common
s/AEssayForm.tsx
→
frontend/src/
answer
s/AEssayForm.tsx
View file @
4d2e3d2b
import
React
,
{
useState
}
from
"
react
"
;
import
React
,
{
useState
}
from
"
react
"
;
import
{
EssayType
,
Answer
sType
}
from
"
../types
"
;
import
{
Answer
Props
}
from
"
../types
"
;
type
Props
=
{
export
const
AEssayForm
=
({
element
,
handleAnswer
,
answers
}:
AnswerProps
)
=>
{
element
:
EssayType
;
answers
:
AnswersType
|
undefined
;
handleAnswer
:
()
=>
void
;
};
export
const
AEssayForm
=
({
element
,
handleAnswer
,
answers
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
{
value
}
=
event
.
currentTarget
;
const
{
value
}
=
event
.
currentTarget
;
// response.answers.map((a) => {
// if (a.questionId === element._id) {
// a.answer = value;
// }
// });
answers
&&
(
answers
.
answer
=
value
);
answers
&&
(
answers
.
answer
=
value
);
setAnswer
(
value
);
setAnswer
(
value
);
handleAnswer
();
handleAnswer
();
...
...
frontend/src/
common
s/AFileForm.tsx
→
frontend/src/
answer
s/AFileForm.tsx
View file @
4d2e3d2b
import
React
,
{
useState
}
from
"
react
"
;
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
;
element
:
FileType
;
answers
:
AnswersType
|
undefined
;
handleAnswer
:
()
=>
void
;
addFiles
:
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
void
;
addFiles
:
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
void
;
}
;
}
export
const
AFileForm
=
({
export
const
AFileForm
=
({
element
,
element
,
...
@@ -18,11 +16,6 @@ export const AFileForm = ({
...
@@ -18,11 +16,6 @@ export const AFileForm = ({
if
(
event
.
currentTarget
.
files
)
{
if
(
event
.
currentTarget
.
files
)
{
const
uploadFile
=
event
.
currentTarget
.
files
[
0
];
const
uploadFile
=
event
.
currentTarget
.
files
[
0
];
addFiles
({
questionId
:
element
.
_id
,
file
:
uploadFile
});
addFiles
({
questionId
:
element
.
_id
,
file
:
uploadFile
});
// response.answers.map((a) => {
// if (a.questionId === element._id) {
// a.answer = uploadFile.name;
// }
// });
answers
&&
(
answers
.
answer
=
uploadFile
.
name
);
answers
&&
(
answers
.
answer
=
uploadFile
.
name
);
handleAnswer
();
handleAnswer
();
}
}
...
...
frontend/src/
common
s/AQuestion.tsx
→
frontend/src/
answer
s/AQuestion.tsx
View file @
4d2e3d2b
import
React
from
"
react
"
;
import
React
from
"
react
"
;
import
{
BasicQuestionType
,
AnswersType
}
from
"
../types
"
;
import
{
BasicQuestionType
,
AnswersType
,
AnswerProps
}
from
"
../types
"
;
import
{
ACheckboxForm
}
from
"
./ACheckboxForm
"
;
import
{
ACheckboxForm
}
from
"
./ACheckboxForm
"
;
import
{
ADateForm
}
from
"
./ADateForm
"
;
import
{
ADateForm
}
from
"
./ADateForm
"
;
import
{
ADropdownForm
}
from
"
./ADropdownForm
"
;
import
{
ADropdownForm
}
from
"
./ADropdownForm
"
;
...
@@ -8,16 +8,14 @@ import { AFileForm } from "./AFileForm";
...
@@ -8,16 +8,14 @@ import { AFileForm } from "./AFileForm";
import
{
ARadioForm
}
from
"
./ARadioForm
"
;
import
{
ARadioForm
}
from
"
./ARadioForm
"
;
import
{
ARatingForm
}
from
"
./ARatingForm
"
;
import
{
ARatingForm
}
from
"
./ARatingForm
"
;
type
Props
=
{
interface
Props
extends
AnswerProps
{
question
:
BasicQuestionType
;
answer
:
AnswersType
|
undefined
;
handleAnswer
:
()
=>
void
;
addFiles
:
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
void
;
addFiles
:
(
oneFile
:
{
questionId
:
string
;
file
:
File
})
=>
void
;
};
}
export
const
AQuestion
=
({
export
const
AQuestion
=
({
question
,
element
,
handleAnswer
,
handleAnswer
,
answer
,
answer
s
,
addFiles
,
addFiles
,
}:
Props
)
=>
{
}:
Props
)
=>
{
function
getContent
(
question
:
BasicQuestionType
)
{
function
getContent
(
question
:
BasicQuestionType
)
{
...
@@ -26,7 +24,7 @@ export const AQuestion = ({
...
@@ -26,7 +24,7 @@ export const AQuestion = ({
return
(
return
(
<
AEssayForm
<
AEssayForm
element
=
{
question
}
element
=
{
question
}
answers
=
{
answer
}
answers
=
{
answer
s
}
handleAnswer
=
{
handleAnswer
}
handleAnswer
=
{
handleAnswer
}
/>
/>
);
);
...
@@ -34,7 +32,7 @@ export const AQuestion = ({
...
@@ -34,7 +32,7 @@ export const AQuestion = ({
return
(
return
(
<
ARadioForm
<
ARadioForm
element
=
{
question
}
element
=
{
question
}
answers
=
{
answer
}
answers
=
{
answer
s
}
handleAnswer
=
{
handleAnswer
}
handleAnswer
=
{
handleAnswer
}
/>
/>
);
);
...
@@ -42,7 +40,7 @@ export const AQuestion = ({
...
@@ -42,7 +40,7 @@ export const AQuestion = ({
return
(
return
(
<
ACheckboxForm
<
ACheckboxForm
element
=
{
question
}
element
=
{
question
}
answers
=
{
answer
}
answers
=
{
answer
s
}
handleAnswer
=
{
handleAnswer
}
handleAnswer
=
{
handleAnswer
}
/>
/>
);
);
...
@@ -50,7 +48,7 @@ export const AQuestion = ({
...
@@ -50,7 +48,7 @@ export const AQuestion = ({
return
(
return
(
<
ADropdownForm
<
ADropdownForm
element
=
{
question
}
element
=
{
question
}
answers
=
{
answer
}
answers
=
{
answer
s
}
handleAnswer
=
{
handleAnswer
}
handleAnswer
=
{
handleAnswer
}
/>
/>
);
);
...
@@ -58,7 +56,7 @@ export const AQuestion = ({
...
@@ -58,7 +56,7 @@ export const AQuestion = ({
return
(
return
(
<
AFileForm
<
AFileForm
element
=
{
question
}
element
=
{
question
}
answers
=
{
answer
}
answers
=
{
answer
s
}
handleAnswer
=
{
handleAnswer
}
handleAnswer
=
{
handleAnswer
}
addFiles
=
{
addFiles
}
addFiles
=
{
addFiles
}
/>
/>
...
@@ -67,7 +65,7 @@ export const AQuestion = ({
...
@@ -67,7 +65,7 @@ export const AQuestion = ({
return
(
return
(
<
ARatingForm
<
ARatingForm
element
=
{
question
}
element
=
{
question
}
answers
=
{
answer
}
answers
=
{
answer
s
}
handleAnswer
=
{
handleAnswer
}
handleAnswer
=
{
handleAnswer
}
/>
/>
);
);
...
@@ -75,7 +73,7 @@ export const AQuestion = ({
...
@@ -75,7 +73,7 @@ export const AQuestion = ({
return
(
return
(
<
ADateForm
<
ADateForm
element
=
{
question
}
element
=
{
question
}
answers
=
{
answer
}
answers
=
{
answer
s
}
handleAnswer
=
{
handleAnswer
}
handleAnswer
=
{
handleAnswer
}
/>
/>
);
);
...
@@ -87,10 +85,10 @@ export const AQuestion = ({
...
@@ -87,10 +85,10 @@ export const AQuestion = ({
return
(
return
(
<
div
className
=
"flex flex-col container w-4/5 h-auto border-2 border-themeColor items-center m-3 py-4"
>
<
div
className
=
"flex flex-col container w-4/5 h-auto border-2 border-themeColor items-center m-3 py-4"
>
<
div
className
=
"flex flexgi-row my-1 w-11/12 place-content-between items-center"
>
<
div
className
=
"flex flexgi-row my-1 w-11/12 place-content-between items-center"
>
<
div
className
=
"text-xl font-bold"
>
{
question
.
title
}
</
div
>
<
div
className
=
"text-xl font-bold"
>
{
element
.
title
}
</
div
>
</
div
>
</
div
>
<
div
className
=
"w-11/12 text-slate-500"
>
{
question
.
comment
}
</
div
>
<
div
className
=
"w-11/12 text-slate-500"
>
{
element
.
comment
}
</
div
>
{
getContent
(
question
)
}
{
getContent
(
element
)
}
</
div
>
</
div
>
);
);
};
};
frontend/src/
common
s/ARadioForm.tsx
→
frontend/src/
answer
s/ARadioForm.tsx
View file @
4d2e3d2b
import
React
,
{
useState
}
from
"
react
"
;
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
;
element
:
RadioType
;
answers
:
AnswersType
|
undefined
;
}
handleAnswer
:
()
=>
void
;
};
export
const
ARadioForm
=
({
element
,
answers
,
handleAnswer
}:
Props
)
=>
{
export
const
ARadioForm
=
({
element
,
answers
,
handleAnswer
}:
Props
)
=>
{
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
[
answer
,
setAnswer
]
=
useState
(
""
);
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
handleChange
=
(
event
:
React
.
ChangeEvent
<
HTMLInputElement
>
)
=>
{
const
{
value
}
=
event
.
currentTarget
;
const
{
value
}
=
event
.
currentTarget
;
// response.answers.map((a) => {
// if (a.questionId === element._id) {
// a.answer = value;
// }
// });
answers
&&
(
answers
.
answer
=
value
);
answers
&&
(
answers
.
answer
=
value
);
setAnswer
(
value
);
setAnswer
(
value
);
handleAnswer
();
handleAnswer
();
...
@@ -24,7 +17,7 @@ export const ARadioForm = ({ element, answers, handleAnswer }: Props) => {
...
@@ -24,7 +17,7 @@ export const ARadioForm = ({ element, answers, handleAnswer }: Props) => {
return
(
return
(
<
div
className
=
"flex w-full gap-2 justify-around my-3"
>
<
div
className
=
"flex w-full gap-2 justify-around my-3"
>
{
element
.
content
.
choices
.
map
((
choice
)
=>
(
{
element
.
content
.
choices
.
map
((
choice
)
=>
(
<
div
>
<
div
key
=
{
choice
.
text
}
>
<
input
<
input
className
=
"mr-2"
className
=
"mr-2"
type
=
"radio"
type
=
"radio"
...
...
frontend/src/
common
s/ARatingForm.tsx
→
frontend/src/
answer
s/ARatingForm.tsx
View file @
4d2e3d2b
import
React
,
{
useState
}
from
"
react
"
;
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
;
element
:
RatingType
;
answers
:
AnswersType
|
undefined
;
}
handleAnswer
:
()
=>
void
;
};
export
const
ARatingForm
=
({
element
,
answers
,
handleAnswer
}:
Props
)
=>
{
export
const
ARatingForm
=
({
element
,
answers
,
handleAnswer
}:
Props
)
=>
{
const
[
selectedchoice
,
setSelectedchoice
]
=
useState
(
""
);
const
[
selectedchoice
,
setSelectedchoice
]
=
useState
(
""
);
...
@@ -14,11 +12,6 @@ export const ARatingForm = ({ element, answers, handleAnswer }: Props) => {
...
@@ -14,11 +12,6 @@ export const ARatingForm = ({ element, answers, handleAnswer }: Props) => {
function
buttonClick
(
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
{
function
buttonClick
(
event
:
React
.
MouseEvent
<
HTMLButtonElement
>
)
{
event
.
preventDefault
();
event
.
preventDefault
();
const
{
name
}
=
event
.
currentTarget
;
const
{
name
}
=
event
.
currentTarget
;
// response.answers.map((a) => {
// if (a.questionId === element._id) {
// a.answer = name;
// }
// });
answers
&&
(
answers
.
answer
=
name
);
answers
&&
(
answers
.
answer
=
name
);
setAnswer
(
name
);
setAnswer
(
name
);
setSelectedchoice
(
event
.
currentTarget
.
name
);
setSelectedchoice
(
event
.
currentTarget
.
name
);
...
...
frontend/src/
commons/
SurveyForm.tsx
→
frontend/src/
answers/Answer
SurveyForm.tsx
View file @
4d2e3d2b
...
@@ -5,7 +5,7 @@ import { catchErrors } from "../helpers";
...
@@ -5,7 +5,7 @@ import { catchErrors } from "../helpers";
import
{
AnswerType
,
SurveyType
}
from
"
../types
"
;
import
{
AnswerType
,
SurveyType
}
from
"
../types
"
;
import
{
AQuestion
}
from
"
./AQuestion
"
;
import
{
AQuestion
}
from
"
./AQuestion
"
;
export
const
SurveyForm
=
()
=>
{
export
const
Answer
SurveyForm
=
()
=>
{
let
{
surveyId
}
=
useParams
<
{
surveyId
:
string
}
>
();
let
{
surveyId
}
=
useParams
<
{
surveyId
:
string
}
>
();
const
[
files
,
setFiles
]
=
useState
<
{
questionId
:
string
;
file
:
File
}[]
>
([]);
const
[
files
,
setFiles
]
=
useState
<
{
questionId
:
string
;
file
:
File
}[]
>
([]);
const
[
error
,
setError
]
=
useState
(
""
);
const
[
error
,
setError
]
=
useState
(
""
);
...
@@ -41,11 +41,6 @@ export const SurveyForm = () => {
...
@@ -41,11 +41,6 @@ export const SurveyForm = () => {
});
});
console
.
log
(
questionIds
);
console
.
log
(
questionIds
);
if
(
answersurvey
)
{
if
(
answersurvey
)
{
// setResponse({
// ...answer,
// surveyId: answersurvey._id,
// answers: questionIds,
// });
answer
.
current
.
surveyId
=
answersurvey
.
_id
;
answer
.
current
.
surveyId
=
answersurvey
.
_id
;
answer
.
current
.
guestId
=
answersurvey
.
guestId
;
answer
.
current
.
guestId
=
answersurvey
.
guestId
;
answer
.
current
.
answers
=
questionIds
;
answer
.
current
.
answers
=
questionIds
;
...
@@ -108,8 +103,9 @@ export const SurveyForm = () => {
...
@@ -108,8 +103,9 @@ export const SurveyForm = () => {
{
survey
.
questions
.
map
((
question
)
=>
{
{
survey
.
questions
.
map
((
question
)
=>
{
return
(
return
(
<
AQuestion
<
AQuestion
question
=
{
question
}
key
=
{
question
.
_id
}
answer
=
{
answer
.
current
.
answers
.
find
(
element
=
{
question
}
answers
=
{
answer
.
current
.
answers
.
find
(
(
ans
)
=>
ans
.
questionId
===
question
.
_id
(
ans
)
=>
ans
.
questionId
===
question
.
_id
)
}
)
}
addFiles
=
{
addFiles
}
addFiles
=
{
addFiles
}
...
...
frontend/src/answers/index.tsx
0 → 100644
View file @
4d2e3d2b
export
{
AnswerSurveyForm
}
from
"
./AnswerSurveyForm
"
;
frontend/src/commons/index.tsx
View file @
4d2e3d2b
export
{
Header
}
from
"
./Header
"
;
export
{
Header
}
from
"
./Header
"
;
export
{
SurveyForm
}
from
"
./SurveyForm
"
;
\ No newline at end of file
frontend/src/questions/Question.tsx
View file @
4d2e3d2b
...
@@ -167,6 +167,7 @@ export const Question = ({
...
@@ -167,6 +167,7 @@ export const Question = ({
>
>
{
Array
.
from
(
typeDropDown
.
entries
()).
map
(([
key
,
value
])
=>
(
{
Array
.
from
(
typeDropDown
.
entries
()).
map
(([
key
,
value
])
=>
(
<
option
<
option
key
=
{
key
}
id
=
{
element
.
_id
}
id
=
{
element
.
_id
}
value
=
{
key
}
value
=
{
key
}
selected
=
{
key
===
element
.
type
}
selected
=
{
key
===
element
.
type
}
...
...
frontend/src/types/index.ts
View file @
4d2e3d2b
...
@@ -44,22 +44,21 @@ export interface RadioType extends BasicQuestionType {
...
@@ -44,22 +44,21 @@ export interface RadioType extends BasicQuestionType {
};
};
}
}
export
interface
CheckboxType
extends
BasicQuestionType
{
interface
IChoices
{
content
:
{
choices
:
{
value
:
number
;
value
:
number
;
text
:
string
;
text
:
string
;
}[];
}
export
interface
CheckboxType
extends
BasicQuestionType
{
content
:
{
choices
:
IChoices
[];
maxCount
:
number
;
maxCount
:
number
;
};
};
}
}
export
interface
DropdownType
extends
BasicQuestionType
{
export
interface
DropdownType
extends
BasicQuestionType
{
content
:
{
content
:
{
choices
:
{
choices
:
IChoices
[];
value
:
number
;
text
:
string
;
}[];
hasNone
:
boolean
;
hasNone
:
boolean
;
};
};
}
}
...
@@ -93,3 +92,9 @@ export interface AnswerType {
...
@@ -93,3 +92,9 @@ export interface AnswerType {
guestId
:
string
;
guestId
:
string
;
answers
:
AnswersType
[];
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