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
7275ba42
"frontend/src/vscode:/vscode.git/clone" did not exist on "09cfa64e2000de0a30642044e66582b84f6e432d"
Commit
7275ba42
authored
Aug 20, 2022
by
Jiwon Yoon
Browse files
result에 맞게 다시 수정
parent
10f7f53d
Changes
11
Show whitespace changes
Inline
Side-by-side
frontend/src/forms/RCheckbox.tsx
View file @
7275ba42
...
...
@@ -3,11 +3,10 @@ import { IQuestionData } from "../types";
type
Props
=
{
question
:
IQuestionData
;
answers
:
any
;
};
export
const
RCheckbox
=
({
question
,
answers
}:
Props
)
=>
{
const
result
=
answers
.
flat
().
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
export
const
RCheckbox
=
({
question
}:
Props
)
=>
{
const
result
=
question
.
answers
.
flat
().
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
acc
[
cur
]
=
(
acc
[
cur
]
||
0
)
+
1
;
return
acc
;
},
{});
...
...
frontend/src/forms/RDate.tsx
View file @
7275ba42
...
...
@@ -3,13 +3,12 @@ import { IQuestionData } from "../types";
type
Props
=
{
question
:
IQuestionData
;
answers
:
any
;
};
export
const
RDate
=
({
question
,
answers
}:
Props
)
=>
{
export
const
RDate
=
({
question
}:
Props
)
=>
{
return
(
<
div
className
=
"m-5"
>
{
answers
.
map
((
answer
:
any
)
=>
(
{
question
.
answers
.
map
((
answer
:
any
)
=>
(
<
div
key
=
{
answer
}
className
=
"font-bold"
>
{
answer
}
</
div
>
...
...
frontend/src/forms/RDropdown.tsx
View file @
7275ba42
...
...
@@ -3,11 +3,10 @@ import { IQuestionData } from "../types";
type
Props
=
{
question
:
IQuestionData
;
answers
:
any
;
};
export
const
RDropdown
=
({
question
,
answers
}:
Props
)
=>
{
const
result
=
answers
.
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
export
const
RDropdown
=
({
question
}:
Props
)
=>
{
const
result
=
question
.
answers
.
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
acc
[
cur
]
=
(
acc
[
cur
]
||
0
)
+
1
;
return
acc
;
},
{});
...
...
frontend/src/forms/REssay.tsx
View file @
7275ba42
...
...
@@ -3,13 +3,12 @@ import { IQuestionData } from "../types";
type
Props
=
{
question
:
IQuestionData
;
answers
:
any
;
};
export
const
REssay
=
({
question
,
answers
}:
Props
)
=>
{
export
const
REssay
=
({
question
}:
Props
)
=>
{
return
(
<
div
className
=
"m-5"
>
{
answers
.
map
((
answer
:
any
,
index
:
number
)
=>
(
{
question
.
answers
.
map
((
answer
:
any
,
index
:
number
)
=>
(
<
div
key
=
{
index
}
className
=
"font-bold"
>
{
answer
}
</
div
>
...
...
frontend/src/forms/RFile.tsx
View file @
7275ba42
...
...
@@ -3,14 +3,13 @@ import { baseImageUrl } from "../apis";
type
Props
=
{
question
:
any
;
answers
:
any
;
};
export
const
RFile
=
({
question
,
answers
}:
Props
)
=>
{
export
const
RFile
=
({
question
}:
Props
)
=>
{
console
.
log
(
"
question
"
,
question
);
return
(
<
div
className
=
"m-5 flex justify-start items-center"
>
{
answers
.
map
((
answer
:
any
,
index
:
number
)
=>
(
{
question
.
answers
.
map
((
answer
:
any
,
index
:
number
)
=>
(
<
Fragment
key
=
{
index
}
>
<
img
className
=
"h-14"
...
...
frontend/src/forms/RRadio.tsx
View file @
7275ba42
...
...
@@ -3,11 +3,10 @@ import { IQuestionData } from "../types";
type
Props
=
{
question
:
IQuestionData
;
answers
:
any
;
};
export
const
RRadio
=
({
question
,
answers
}:
Props
)
=>
{
const
result
=
answers
.
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
export
const
RRadio
=
({
question
}:
Props
)
=>
{
const
result
=
question
.
answers
.
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
acc
[
cur
]
=
(
acc
[
cur
]
||
0
)
+
1
;
return
acc
;
},
{});
...
...
frontend/src/forms/RRating.tsx
View file @
7275ba42
...
...
@@ -3,11 +3,10 @@ import { IQuestionData } from "../types";
type
Props
=
{
question
:
IQuestionData
;
answers
:
any
;
};
export
const
RRating
=
({
question
,
answers
}:
Props
)
=>
{
const
result
=
answers
.
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
export
const
RRating
=
({
question
}:
Props
)
=>
{
const
result
=
question
.
answers
.
reduce
((
acc
:
any
,
cur
:
any
)
=>
{
acc
[
cur
]
=
(
acc
[
cur
]
||
0
)
+
1
;
return
acc
;
},
{});
...
...
frontend/src/helpers/question.helper.tsx
View file @
7275ba42
...
...
@@ -109,25 +109,22 @@ export const getAnswerElementByType = (
}
};
export
const
getResultElementByType
=
(
question
:
IQuestionData
,
answers
:
any
)
=>
{
export
const
getResultElementByType
=
(
question
:
IQuestionData
)
=>
{
switch
(
question
.
type
)
{
case
"
singletext
"
:
return
<
REssay
question
=
{
question
}
answers
=
{
answers
}
/>;
return
<
REssay
question
=
{
question
}
/>;
case
"
radio
"
:
return
<
RRadio
question
=
{
question
}
answers
=
{
answers
}
/>;
return
<
RRadio
question
=
{
question
}
/>;
case
"
checkbox
"
:
return
<
RCheckbox
question
=
{
question
}
answers
=
{
answers
}
/>;
return
<
RCheckbox
question
=
{
question
}
/>;
case
"
dropdown
"
:
return
<
RDropdown
question
=
{
question
}
answers
=
{
answers
}
/>;
return
<
RDropdown
question
=
{
question
}
/>;
case
"
file
"
:
return
<
RFile
question
=
{
question
}
answers
=
{
answers
}
/>;
return
<
RFile
question
=
{
question
}
/>;
case
"
rating
"
:
return
<
RRating
question
=
{
question
}
answers
=
{
answers
}
/>;
return
<
RRating
question
=
{
question
}
/>;
case
"
date
"
:
return
<
RDate
question
=
{
question
}
answers
=
{
answers
}
/>;
return
<
RDate
question
=
{
question
}
/>;
default
:
return
<></>;
}
...
...
frontend/src/surveys/Accordion.tsx
View file @
7275ba42
...
...
@@ -4,10 +4,9 @@ import { getResultElementByType } from "../helpers/question.helper";
type
AccordionProps
=
{
question
:
IQuestionData
;
answers
:
any
;
};
export
const
Accordion
=
({
question
,
answers
}:
AccordionProps
)
=>
{
export
const
Accordion
=
({
question
}:
AccordionProps
)
=>
{
const
[
isOpened
,
setOpened
]
=
useState
<
boolean
>
(
false
);
const
[
height
,
setHeight
]
=
useState
<
string
>
(
"
0px
"
);
const
contentElement
=
useRef
<
HTMLDivElement
>
(
null
);
...
...
@@ -33,7 +32,7 @@ export const Accordion = ({ question, answers }: AccordionProps) => {
style
=
{
{
height
:
height
}
}
className
=
"bg-gray-100 overflow-hidden transition-all duration-300"
>
{
answers
&&
getResultElementByType
(
question
,
answers
)
}
{
question
.
answers
&&
getResultElementByType
(
question
)
}
</
div
>
</
div
>
</
div
>
...
...
frontend/src/surveys/ResultSurvey.tsx
View file @
7275ba42
...
...
@@ -51,11 +51,7 @@ export const ResultSurvey = () => {
<
div
className
=
"container w-11/12 place-self-center"
>
{
survey
.
questions
.
map
((
question
)
=>
(
<
Accordion
key
=
{
question
.
_id
}
question
=
{
question
.
questionInfo
}
answers
=
{
question
.
answers
}
/>
<
Accordion
key
=
{
question
.
_id
}
question
=
{
question
}
/>
))
}
</
div
>
</
div
>
...
...
src/db/answer.db.ts
View file @
7275ba42
...
...
@@ -34,6 +34,9 @@ export const getAnswers = async (surveyId: string) => {
$unwind
:
"
$questionInfo
"
,
},
{
$set
:
{
"
questionInfo.answers
"
:
"
$answers
"
}
},
{
$unset
:
"
answers
"
},
// 질문 순서대로 정렬
{
$sort
:
{
"
questionInfo.order
"
:
1
}
},
...
...
@@ -42,7 +45,7 @@ export const getAnswers = async (surveyId: string) => {
$group
:
{
_id
:
"
$surveyId
"
,
questions
:
{
$push
:
{
questionInfo
:
"
$questionInfo
"
,
answers
:
"
$answers
"
}
,
$push
:
"
$questionInfo
"
,
},
},
},
...
...
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