Skip to content

Commit

Permalink
Merge pull request #92 from boostcampwm-2022/Refactor/User/Logout
Browse files Browse the repository at this point in the history
Refactor/user/logout
  • Loading branch information
ekek54 authored Dec 15, 2022
2 parents bff7994 + 7b555c9 commit a38347f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 28 deletions.
Binary file added client/public/favicon.ico
Binary file not shown.
2 changes: 2 additions & 0 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
<link rel="icon" href="./favicon.ico" type="image/x-icon" />
<title>BoostForm</title>
</head>
<body>
Expand Down
3 changes: 3 additions & 0 deletions server/src/Form/Form.Service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`,
Expand Down
10 changes: 7 additions & 3 deletions server/src/Result/Result.Service.ts
Original file line number Diff line number Diff line change
@@ -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<any>;
private responseList: Array<any>;

result: FormResult;

Expand All @@ -22,6 +21,7 @@ export default class ResultService {
};
}

// formId에 해당하는 설문지와 응답들을 불러온다.
public async init(formId: string) {
this.form = undefined;
this.responseList = [];
Expand Down Expand Up @@ -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;
Expand Down
49 changes: 24 additions & 25 deletions server/src/Result/Result.Test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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,
},
},
},
Expand Down

0 comments on commit a38347f

Please sign in to comment.