From a5a5b1f69f6ae3d446f3ed841eea22416f906afe Mon Sep 17 00:00:00 2001 From: SungHyun Do <52828205+glaxyt@users.noreply.github.com> Date: Sun, 24 Nov 2024 02:38:09 +0900 Subject: [PATCH] =?UTF-8?q?[BE=20-#106]=20=EC=8B=A4=EC=8B=9C=EA=B0=84=20?= =?UTF-8?q?=EC=86=8C=EC=BC=93=20=EC=84=9C=EB=B2=84=20=EC=86=A1=EC=88=98?= =?UTF-8?q?=EC=8B=A0=20=EB=8D=B0=EC=9D=B4=ED=84=B0=20=EC=9D=B8=ED=84=B0?= =?UTF-8?q?=ED=8E=98=EC=9D=B4=EC=8A=A4=20=EC=A0=95=EC=9D=98=20=20(#107)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: 실시간 소켓 서버 요청 데이터 인터페이스 코드 작성 * feat: 실시간 소켓 서버 응답 데이터 인터페이스 코드 작성 * feat: 실시간 소켓 서버 quiz, choice 데이터 인터페이스 코드 작성 * refactor: 타입 관리를 type -> interface로 변경함에 따라 폴더 삭제 * feat: 실시간 소켓 서버 요청 데이터 인터페이스 barrel 파일 작성 * feat: 실시간 소켓 서버 응답 데이터 인터페이스 barrel 파일 작성 * refactor: 인터페이스명 오타 수정 * refactor: 퀴즈 타입 as const로 상수 처리 * refactor: timeEnd -> isEnd로 오타 수정 --- packages/shared/interfaces/request/index.ts | 5 +++++ .../request/master-entry.request.interface.ts | 3 +++ .../interfaces/request/nickname.request.interface.ts | 3 +++ .../request/participant-entry.request.interface.ts | 4 ++++ .../request/show-quiz.request.interface.ts | 3 +++ .../request/start-quiz.request.interface.ts | 4 ++++ packages/shared/interfaces/response/index.ts | 10 ++++++++++ .../response/master-statistics.response.interface.ts | 8 ++++++++ .../response/nickname.response.interface.ts | 3 +++ .../participant-statistics.response.interface.ts | 6 ++++++ .../response/pincode.response.interface.ts | 3 +++ .../response/session.response.interface.ts | 3 +++ .../response/show-quiz.response.interface.ts | 6 ++++++ .../response/start-quiz.response.interface.ts | 3 +++ .../response/submit-answer.request.interface.ts | 6 ++++++ .../response/time-end.response.interface.ts | 3 +++ .../response/timer-tick.response.interface.ts | 5 +++++ packages/shared/interfaces/utils/choice.interface.ts | 7 +++++++ .../shared/interfaces/utils/quizdata.interface.ts | 12 ++++++++++++ packages/shared/types/a.ts | 1 - packages/shared/types/quiz.types.ts | 6 ++++++ 21 files changed, 103 insertions(+), 1 deletion(-) create mode 100644 packages/shared/interfaces/request/index.ts create mode 100644 packages/shared/interfaces/request/master-entry.request.interface.ts create mode 100644 packages/shared/interfaces/request/nickname.request.interface.ts create mode 100644 packages/shared/interfaces/request/participant-entry.request.interface.ts create mode 100644 packages/shared/interfaces/request/show-quiz.request.interface.ts create mode 100644 packages/shared/interfaces/request/start-quiz.request.interface.ts create mode 100644 packages/shared/interfaces/response/index.ts create mode 100644 packages/shared/interfaces/response/master-statistics.response.interface.ts create mode 100644 packages/shared/interfaces/response/nickname.response.interface.ts create mode 100644 packages/shared/interfaces/response/participant-statistics.response.interface.ts create mode 100644 packages/shared/interfaces/response/pincode.response.interface.ts create mode 100644 packages/shared/interfaces/response/session.response.interface.ts create mode 100644 packages/shared/interfaces/response/show-quiz.response.interface.ts create mode 100644 packages/shared/interfaces/response/start-quiz.response.interface.ts create mode 100644 packages/shared/interfaces/response/submit-answer.request.interface.ts create mode 100644 packages/shared/interfaces/response/time-end.response.interface.ts create mode 100644 packages/shared/interfaces/response/timer-tick.response.interface.ts create mode 100644 packages/shared/interfaces/utils/choice.interface.ts create mode 100644 packages/shared/interfaces/utils/quizdata.interface.ts delete mode 100644 packages/shared/types/a.ts create mode 100644 packages/shared/types/quiz.types.ts diff --git a/packages/shared/interfaces/request/index.ts b/packages/shared/interfaces/request/index.ts new file mode 100644 index 00000000..b8efb69b --- /dev/null +++ b/packages/shared/interfaces/request/index.ts @@ -0,0 +1,5 @@ +export * from './master-entry.request.interface'; +export * from './nickname.request.interface'; +export * from './participant-entry.request.interface'; +export * from './show-quiz.request.interface'; +export * from './start-quiz.request.interface'; diff --git a/packages/shared/interfaces/request/master-entry.request.interface.ts b/packages/shared/interfaces/request/master-entry.request.interface.ts new file mode 100644 index 00000000..ef36273a --- /dev/null +++ b/packages/shared/interfaces/request/master-entry.request.interface.ts @@ -0,0 +1,3 @@ +export interface MasterEntryRequest { + classId: number; +} diff --git a/packages/shared/interfaces/request/nickname.request.interface.ts b/packages/shared/interfaces/request/nickname.request.interface.ts new file mode 100644 index 00000000..ea452fc9 --- /dev/null +++ b/packages/shared/interfaces/request/nickname.request.interface.ts @@ -0,0 +1,3 @@ +export interface NicknameRequest { + pinCode: string; +} diff --git a/packages/shared/interfaces/request/participant-entry.request.interface.ts b/packages/shared/interfaces/request/participant-entry.request.interface.ts new file mode 100644 index 00000000..caf2b3f3 --- /dev/null +++ b/packages/shared/interfaces/request/participant-entry.request.interface.ts @@ -0,0 +1,4 @@ +export interface ParticipantEntryRequest { + pinCode: string; + nickname: string; +} diff --git a/packages/shared/interfaces/request/show-quiz.request.interface.ts b/packages/shared/interfaces/request/show-quiz.request.interface.ts new file mode 100644 index 00000000..5aeff60d --- /dev/null +++ b/packages/shared/interfaces/request/show-quiz.request.interface.ts @@ -0,0 +1,3 @@ +export interface ShowQuizRequest { + pinCode: string; +} diff --git a/packages/shared/interfaces/request/start-quiz.request.interface.ts b/packages/shared/interfaces/request/start-quiz.request.interface.ts new file mode 100644 index 00000000..3cfc4cef --- /dev/null +++ b/packages/shared/interfaces/request/start-quiz.request.interface.ts @@ -0,0 +1,4 @@ +export interface StartQuizRequest { + sid: string; + pinCode: string; +} diff --git a/packages/shared/interfaces/response/index.ts b/packages/shared/interfaces/response/index.ts new file mode 100644 index 00000000..4e5ff2e7 --- /dev/null +++ b/packages/shared/interfaces/response/index.ts @@ -0,0 +1,10 @@ +export * from './master-statistics.response.interface'; +export * from './participant-statistics.response.interface'; +export * from './time-end.response.interface'; +export * from './timer-tick.response.interface'; +export * from './pincode.response.interface'; +export * from './nickname.response.interface'; +export * from './session.response.interface'; +export * from './show-quiz.response.interface'; +export * from './start-quiz.response.interface'; +export * from './submit-answer.request.interface'; diff --git a/packages/shared/interfaces/response/master-statistics.response.interface.ts b/packages/shared/interfaces/response/master-statistics.response.interface.ts new file mode 100644 index 00000000..7b989b9c --- /dev/null +++ b/packages/shared/interfaces/response/master-statistics.response.interface.ts @@ -0,0 +1,8 @@ +export interface MasterStatisticsResponse { + totalSubmit: number; + solveRate: number; + averageTime: number; + participantRate: number; + choiceStatus: { [key: number]: number }; + submitHistory: [string, number][]; +} diff --git a/packages/shared/interfaces/response/nickname.response.interface.ts b/packages/shared/interfaces/response/nickname.response.interface.ts new file mode 100644 index 00000000..d4fa7207 --- /dev/null +++ b/packages/shared/interfaces/response/nickname.response.interface.ts @@ -0,0 +1,3 @@ +export interface NicknameResponse { + participantList: string[]; +} diff --git a/packages/shared/interfaces/response/participant-statistics.response.interface.ts b/packages/shared/interfaces/response/participant-statistics.response.interface.ts new file mode 100644 index 00000000..17791a64 --- /dev/null +++ b/packages/shared/interfaces/response/participant-statistics.response.interface.ts @@ -0,0 +1,6 @@ +export interface ParticipantStatisticsResponse { + totalSubmit: number; + solveRate: number; + averageTime: number; + participantRate: number; +} diff --git a/packages/shared/interfaces/response/pincode.response.interface.ts b/packages/shared/interfaces/response/pincode.response.interface.ts new file mode 100644 index 00000000..2a831f9e --- /dev/null +++ b/packages/shared/interfaces/response/pincode.response.interface.ts @@ -0,0 +1,3 @@ +export interface PincodeResponse { + pinCode: string; +} diff --git a/packages/shared/interfaces/response/session.response.interface.ts b/packages/shared/interfaces/response/session.response.interface.ts new file mode 100644 index 00000000..91a1c93a --- /dev/null +++ b/packages/shared/interfaces/response/session.response.interface.ts @@ -0,0 +1,3 @@ +export interface SessionResponse { + sid: string; +} diff --git a/packages/shared/interfaces/response/show-quiz.response.interface.ts b/packages/shared/interfaces/response/show-quiz.response.interface.ts new file mode 100644 index 00000000..9ac39eb6 --- /dev/null +++ b/packages/shared/interfaces/response/show-quiz.response.interface.ts @@ -0,0 +1,6 @@ +import { QuizData } from '../utils/quizdata.interface'; + +export interface ShowQuizResponse { + currentQuizData: QuizData; + isLast: boolean; +} diff --git a/packages/shared/interfaces/response/start-quiz.response.interface.ts b/packages/shared/interfaces/response/start-quiz.response.interface.ts new file mode 100644 index 00000000..eaa7938c --- /dev/null +++ b/packages/shared/interfaces/response/start-quiz.response.interface.ts @@ -0,0 +1,3 @@ +export interface StartQuizResponse { + isStarted: boolean; +} diff --git a/packages/shared/interfaces/response/submit-answer.request.interface.ts b/packages/shared/interfaces/response/submit-answer.request.interface.ts new file mode 100644 index 00000000..75315295 --- /dev/null +++ b/packages/shared/interfaces/response/submit-answer.request.interface.ts @@ -0,0 +1,6 @@ +export interface SubmitAnswerRequest { + pinCode: string; + sid: string; + selectedAnswer: number[]; + submitTime: number; +} diff --git a/packages/shared/interfaces/response/time-end.response.interface.ts b/packages/shared/interfaces/response/time-end.response.interface.ts new file mode 100644 index 00000000..0cf1533c --- /dev/null +++ b/packages/shared/interfaces/response/time-end.response.interface.ts @@ -0,0 +1,3 @@ +export interface TimeEndResponse { + isEnd: boolean; +} diff --git a/packages/shared/interfaces/response/timer-tick.response.interface.ts b/packages/shared/interfaces/response/timer-tick.response.interface.ts new file mode 100644 index 00000000..7e45a2f9 --- /dev/null +++ b/packages/shared/interfaces/response/timer-tick.response.interface.ts @@ -0,0 +1,5 @@ +export interface TimerTickResponse { + curretTime: number; + elaspedTime: number; + remainingTime: number; +} diff --git a/packages/shared/interfaces/utils/choice.interface.ts b/packages/shared/interfaces/utils/choice.interface.ts new file mode 100644 index 00000000..49a1c12d --- /dev/null +++ b/packages/shared/interfaces/utils/choice.interface.ts @@ -0,0 +1,7 @@ +export interface Choice { + id: number; + quizId: number; + content: string; + isCorrect: boolean; + position: number; +} diff --git a/packages/shared/interfaces/utils/quizdata.interface.ts b/packages/shared/interfaces/utils/quizdata.interface.ts new file mode 100644 index 00000000..d401549e --- /dev/null +++ b/packages/shared/interfaces/utils/quizdata.interface.ts @@ -0,0 +1,12 @@ +import { Choice } from './choice.interface'; +import { QuizType } from '../../types/quiz.types'; + +export interface QuizData { + id: number; + content: string; + quizType: QuizType; + timeLimit: number; + point: number; + position: number; + choices: Choice[]; +} diff --git a/packages/shared/types/a.ts b/packages/shared/types/a.ts deleted file mode 100644 index ef74d34b..00000000 --- a/packages/shared/types/a.ts +++ /dev/null @@ -1 +0,0 @@ -const a = 5; diff --git a/packages/shared/types/quiz.types.ts b/packages/shared/types/quiz.types.ts new file mode 100644 index 00000000..7eb776e4 --- /dev/null +++ b/packages/shared/types/quiz.types.ts @@ -0,0 +1,6 @@ +export const QUIZ_TYPES = { + MULTIPLE_CHOICE: 'MC', + TRUE_FALSE: 'TF', +} as const; + +export type QuizType = (typeof QUIZ_TYPES)[keyof typeof QUIZ_TYPES];