This commit is contained in:
2026-10-11 16:00:18 +07:00
parent 504b49f7cc
commit 030ca56900
77 changed files with 793 additions and 638 deletions
+8 -8
View File
@@ -49,7 +49,7 @@ var (
ErrOfflineAnswers = errors.New("в offline-игре ответы через сайт недоступны")
)
func (s *AnswerService) getTeamAndGame(ctx context.Context, teamID int, password string) (*repos.Team, *repos.Game, error) {
func (s *AnswerService) getTeamAndGame(ctx context.Context, teamID string, password string) (*repos.Team, *repos.Game, error) {
team, err := s.teamsRepo.GetTeamByID(ctx, teamID)
if err != nil {
if errors.Is(err, teams_repo.ErrTeamNotFound) {
@@ -82,7 +82,7 @@ func (s *AnswerService) getScenarioQuestionsByCode(ctx context.Context, scenario
return scenario.Story.Questions, byCode, nil
}
func (s *AnswerService) GetTeamAnswers(ctx context.Context, teamID int, password string) ([]Answer, error) {
func (s *AnswerService) GetTeamAnswers(ctx context.Context, teamID string, password string) ([]Answer, error) {
_, game, err := s.getTeamAndGame(ctx, teamID, password)
if err != nil {
return nil, err
@@ -111,7 +111,7 @@ func (s *AnswerService) GetTeamAnswers(ctx context.Context, teamID int, password
return answers, nil
}
func (s *AnswerService) SubmitTeamAnswers(ctx context.Context, teamID int, password string, answers []Answer) error {
func (s *AnswerService) SubmitTeamAnswers(ctx context.Context, teamID string, password string, answers []Answer) error {
_, game, err := s.getTeamAndGame(ctx, teamID, password)
if err != nil {
return err
@@ -157,7 +157,7 @@ func (s *AnswerService) GetGameAnswers(ctx context.Context, gameID int) (*GameAn
if err != nil {
return nil, err
}
teamIDs := make([]int, 0, len(teams))
teamIDs := make([]string, 0, len(teams))
for _, team := range teams {
teamIDs = append(teamIDs, team.ID)
}
@@ -169,7 +169,7 @@ func (s *AnswerService) GetGameAnswers(ctx context.Context, gameID int) (*GameAn
if err != nil {
return nil, err
}
answerByTeamAndCode := make(map[int]map[string]AnswerScore, len(teams))
answerByTeamAndCode := make(map[string]map[string]AnswerScore, len(teams))
for _, row := range rows {
if _, ok := byCode[row.QuestionCode]; !ok {
continue
@@ -208,7 +208,7 @@ func (s *AnswerService) GetGameAnswers(ctx context.Context, gameID int) (*GameAn
}, nil
}
func (s *AnswerService) SetTeamAnswerScore(ctx context.Context, teamID int, questionCode string, score *int) error {
func (s *AnswerService) SetTeamAnswerScore(ctx context.Context, teamID string, questionCode string, score *int) error {
team, err := s.teamsRepo.GetTeamByID(ctx, teamID)
if err != nil {
return mapAnswerError(err)
@@ -243,7 +243,7 @@ func (s *AnswerService) GetGameResults(ctx context.Context, gameID int) (*GameRe
if err != nil {
return nil, err
}
teamIDs := make([]int, 0, len(teams))
teamIDs := make([]string, 0, len(teams))
for _, team := range teams {
teamIDs = append(teamIDs, team.ID)
}
@@ -255,7 +255,7 @@ func (s *AnswerService) GetGameResults(ctx context.Context, gameID int) (*GameRe
if err != nil {
return nil, err
}
answerByTeamAndCode := make(map[int]map[string]AnswerScore, len(teams))
answerByTeamAndCode := make(map[string]map[string]AnswerScore, len(teams))
for _, row := range rows {
if _, ok := byCode[row.QuestionCode]; !ok {
continue