diff --git a/client/public/favicon.ico b/client/public/favicon.ico
new file mode 100644
index 0000000..f6f66f8
Binary files /dev/null and b/client/public/favicon.ico differ
diff --git a/client/public/index.html b/client/public/index.html
index 068ad2b..b417708 100644
--- a/client/public/index.html
+++ b/client/public/index.html
@@ -5,6 +5,8 @@
+
+
BoostForm
diff --git a/server/src/Form/Form.Service.ts b/server/src/Form/Form.Service.ts
index 2164ca3..9b16527 100644
--- a/server/src/Form/Form.Service.ts
+++ b/server/src/Form/Form.Service.ts
@@ -34,6 +34,9 @@ class FormService {
.catch(() => {
throw new NotFoundException();
});
+ if (!rawFormList) {
+ throw new NotFoundException();
+ }
const formList = rawFormList.map((form: any) => {
return {
_id: `${form._id}`,
diff --git a/server/src/Result/Result.Service.ts b/server/src/Result/Result.Service.ts
index 98e1c6a..02f1270 100644
--- a/server/src/Result/Result.Service.ts
+++ b/server/src/Result/Result.Service.ts
@@ -1,13 +1,12 @@
-import { format } from "path";
import { Response, FormResult, Answer } from "./types/Result.Interface";
import Form from "../Form/Form.Model";
import FormResponse from "../Response/Response.Model";
import BadRequestException from "../Common/Exceptions/BadRequest.Exception";
export default class ResultService {
- form: any;
+ private form: any;
- responseList: Array;
+ private responseList: Array;
result: FormResult;
@@ -22,6 +21,7 @@ export default class ResultService {
};
}
+ // formId에 해당하는 설문지와 응답들을 불러온다.
public async init(formId: string) {
this.form = undefined;
this.responseList = [];
@@ -65,21 +65,25 @@ export default class ResultService {
return resultDict;
}
+ // 설문 응답 리스트를 순회하며 결과를 집계한다
formResult(): FormResult {
this.responseList.forEach((response) => this.aggregateResponse(response));
return this.result;
}
+ // 설문 응답내의 문제 리스트를 순회하며 결과를 집계한다.
aggregateResponse(response: Response) {
response.answer_list.forEach((answer: Answer) => this.aggregateAnswer(answer));
}
+ // 문제 별 응답개수를 카운트하고 문제 내의 지문들을 순회화며 결과를 집계한다.
aggregateAnswer(answer: Answer) {
if (!((answer.question_id as number) in this.result.questionResultDict)) return;
this.result.questionResultDict[answer.question_id].responseCount += 1;
answer.answer.forEach((option: string) => this.countOptionSelected(option, answer.question_id));
}
+ // 지문 별 응답개수를 카운트한다.
countOptionSelected(option: string, questionId: number) {
if (option in this.result.questionResultDict[questionId].answerTotal) {
this.result.questionResultDict[questionId].answerTotal[option] += 1;
diff --git a/server/src/Result/Result.Test.ts b/server/src/Result/Result.Test.ts
index 9ffe05c..4f96f40 100644
--- a/server/src/Result/Result.Test.ts
+++ b/server/src/Result/Result.Test.ts
@@ -1,3 +1,4 @@
+// eslint-disable-next-line import/no-extraneous-dependencies
import request from "supertest";
import * as dotenv from "dotenv";
import { BeforeRecover } from "typeorm";
@@ -9,47 +10,45 @@ beforeAll(async () => {
await connectMongoDB();
});
describe("GET api/results/:formId", () => {
- const testFormId = "6396ab6baa73534ba0a86b12";
+ const testFormId = "637e2d875d07882cfce8a076";
const testResult = {
- formTitle: "TEST",
- totalResponseCount: 9,
+ formTitle: "Form Mock Data",
+ totalResponseCount: 28363,
acceptResponse: true,
questionResultDict: {
"1": {
type: "checkbox",
- questionTitle: "q1",
- responseCount: 9,
+ questionTitle: "좋아하는 동물",
+ responseCount: 12389,
answerTotal: {
- a1: 2,
- a2: 1,
- a3: 1,
- a4: 2,
- a5: 3,
+ dog: 3114,
+ cat: 3059,
+ rabbit: 3163,
+ question1: 3053,
},
},
"2": {
type: "multiple",
- questionTitle: "q2",
- responseCount: 9,
+ questionTitle: "좋아하는 음식",
+ responseCount: 12389,
answerTotal: {
- a1: 6,
- a2: 9,
- a3: 9,
- a4: 9,
- a5: 9,
+ pizza: 3114,
+ chicken: 3059,
+ kimbap: 3163,
+ bread: 0,
+ question2: 3053,
},
},
"3": {
type: "paragraph",
- questionTitle: "q3",
- responseCount: 9,
+ questionTitle: "의견을 남겨주세요",
+ responseCount: 12389,
answerTotal: {
- "2": 1,
- "3": 2,
- "4": 1,
- "5": 2,
- "6": 2,
- a1: 1,
+ answer1: 3110,
+ answer2: 3059,
+ answer3: 3163,
+ question3: 3053,
+ 의견1: 4,
},
},
},