From 75080c29bb5072c444d559478f636e744c36e016 Mon Sep 17 00:00:00 2001 From: Kirill Ivlev Date: Thu, 31 Oct 2024 01:32:02 +0400 Subject: [PATCH] results page --- src/game/game.service.ts | 3 ++- src/messaging/quiz-messaging.controller.ts | 1 + src/quiz/quiz.controller.ts | 5 +++++ src/quiz/quiz.service.ts | 6 +++++- 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/game/game.service.ts b/src/game/game.service.ts index 4f8e43b..75c49ca 100644 --- a/src/game/game.service.ts +++ b/src/game/game.service.ts @@ -63,9 +63,10 @@ export class GameService implements OnApplicationBootstrap{ } else { qItem = await this.gameQueueModel.findById(id).exec(); } - this.logger.verbose(`Set ${id} in queue as completed`); + this.logger.verbose(`Set ${qItem.id} in queue as completed`); if (!qItem) { throw new InternalServerErrorException('no such item'); + } qItem.completed = true; await qItem.save(); diff --git a/src/messaging/quiz-messaging.controller.ts b/src/messaging/quiz-messaging.controller.ts index 71b9b8c..964adc2 100644 --- a/src/messaging/quiz-messaging.controller.ts +++ b/src/messaging/quiz-messaging.controller.ts @@ -30,6 +30,7 @@ export class QuizMessagingController { async completeQueueItem(@Payload() data: any) { this.logger.verbose(`complete item`) await this.gameService.markQueueAsCompleted(null); + //await this.quizService.proceedWithGame(); } @MessagePattern({ cmd: CommandsConsts.GetCards}) diff --git a/src/quiz/quiz.controller.ts b/src/quiz/quiz.controller.ts index eb16946..17980e6 100644 --- a/src/quiz/quiz.controller.ts +++ b/src/quiz/quiz.controller.ts @@ -16,6 +16,11 @@ export class QuizController { return await this.quizService.setQuestion(qustionDto); } + @Get('question-results') + async GetQuestionResults() { + return await this.quizService.getQuestionResults(); + } + @Post('proceed') async Get() { console.log('proceed with game') diff --git a/src/quiz/quiz.service.ts b/src/quiz/quiz.service.ts index 573b232..0178dea 100644 --- a/src/quiz/quiz.service.ts +++ b/src/quiz/quiz.service.ts @@ -122,7 +122,6 @@ export class QuizService { async proceedWithGame() { this.logger.verbose(`[proceedWithGame] Executing proceed with game`); await this.calculateScore(); - //this.sharedService.sendSocketNotificationToAllClients(SocketEvents.GameQueueItem, {}); await this.commandBus.execute(new ProceedGameQueueCommand()); return Promise.resolve(true); } @@ -264,4 +263,9 @@ export class QuizService { await newQuestion.save(); } } + + async getQuestionResults() { + const question = await this.get(); + return question.userAnswers; + } }