Yimaru-BackEnd/internal/services/assessment/initial_assessment.go

49 lines
1.4 KiB
Go

package assessment
import (
"Yimaru-Backend/internal/domain"
"context"
)
// 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 questions from the initial assessment set.
func (s *Service) ListQuestions(ctx context.Context) ([]domain.QuestionWithDetails, error) {
// Get the initial assessment set
set, err := s.questionStore.GetInitialAssessmentSet(ctx)
if err != nil {
return nil, err
}
// Get all questions in the set
items, err := s.questionStore.GetPublishedQuestionsInSet(ctx, set.ID)
if err != nil {
return nil, err
}
// Build the full question details
result := make([]domain.QuestionWithDetails, 0, len(items))
for _, item := range items {
qwd, err := s.questionStore.GetQuestionWithDetails(ctx, item.QuestionID)
if err != nil {
continue // Skip if we can't get details
}
result = append(result, qwd)
}
return result, 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)
}