package assessment import ( "Yimaru-Backend/internal/domain" "context" "errors" "strings" "github.com/jackc/pgx/v5" ) // CreateQuestion creates a question in the unified questions system. // Initial assessment questions should be created through the unified questions API // and then linked to the initial assessment question set. func (s *Service) CreateQuestion( ctx context.Context, input domain.CreateQuestionInput, ) (domain.Question, error) { return s.questionStore.CreateQuestion(ctx, input) } // ListQuestions returns published questions for a CEFR placement level set. // When level is empty, defaults to A1 for backward compatibility. func (s *Service) ListQuestions(ctx context.Context, level string) ([]domain.QuestionWithDetails, error) { if strings.TrimSpace(level) == "" { level = "A1" } normalized, err := domain.NormalizeCEFRLevel(level) if err != nil { return nil, err } _, questions, err := s.loadPublishedLevelQuestions(ctx, normalized) if err != nil { if errors.Is(err, ErrPlacementSetNotFound) || errors.Is(err, pgx.ErrNoRows) { return nil, ErrPlacementSetNotFound } return nil, err } return questions, nil } // GetQuestionByID returns a question with full details. func (s *Service) GetQuestionByID(ctx context.Context, id int64) (domain.QuestionWithDetails, error) { return s.questionStore.GetQuestionWithDetails(ctx, id) }