add qid to excel file answer path

This commit is contained in:
skeris 2024-07-19 15:46:40 +03:00
parent cf974729bd
commit 6f55c35b7b
2 changed files with 7 additions and 1 deletions

@ -22,6 +22,7 @@ services:
TRASH_LOG_HOST: "10.8.0.15:7113"
MODULE_LOGGER: "quiz-core-main"
CLICK_HOUSE_CRED: "clickhouse://10.8.0.15:9000/default?sslmode=disable"
S3_PREFIX: "https://s3.timeweb.cloud/3c580be9-cf31f296-d055-49cf-b39e-30c7959dc17b/squizimages/"
ports:
- 10.8.0.9:1488:1488
- 10.8.0.9:9000:9000

@ -159,6 +159,11 @@ func (s *Service) ExportResultsToCSV(ctx *fiber.Ctx) error {
}
}
quiz, err := s.dal.QuizRepo.GetQuizById(ctx.Context(), accountID, quizID)
if err != nil {
return ctx.Status(fiber.StatusInternalServerError).SendString("failed to get quiz")
}
questions, err := s.dal.ResultRepo.GetQuestions(ctx.Context(), quizID)
if err != nil {
return ctx.Status(fiber.StatusInternalServerError).SendString("failed to get questions")
@ -177,7 +182,7 @@ func (s *Service) ExportResultsToCSV(ctx *fiber.Ctx) error {
buffer := new(bytes.Buffer)
if err := tools.WriteDataToExcel(buffer, questions, answers, s.s3Prefix); err != nil {
if err := tools.WriteDataToExcel(buffer, questions, answers, s.s3Prefix + quiz.Qid + "/"); err != nil {
return ctx.Status(fiber.StatusInternalServerError).SendString("failed to write data to Excel")
}