Yimaru-BackEnd/internal/domain/questions.go
Yared Yemane 2605877f12 Resolve question-set question-types to builder definitions.
Map legacy runtime types like AUDIO to catalog keys (e.g. audio_conversation_type) so the endpoint matches type-definitions API output.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 06:46:54 -07:00

215 lines
5.6 KiB
Go

package domain
import "time"
type QuestionType string
const (
QuestionTypeMCQ QuestionType = "MCQ"
QuestionTypeTrueFalse QuestionType = "TRUE_FALSE"
QuestionTypeShortAnswer QuestionType = "SHORT_ANSWER"
QuestionTypeAudio QuestionType = "AUDIO"
)
type DifficultyLevel string
const (
DifficultyEasy DifficultyLevel = "EASY"
DifficultyMedium DifficultyLevel = "MEDIUM"
DifficultyHard DifficultyLevel = "HARD"
)
type QuestionSetType string
const (
QuestionSetTypePractice QuestionSetType = "PRACTICE"
QuestionSetTypeInitialAssessment QuestionSetType = "INITIAL_ASSESSMENT"
QuestionSetTypeQuiz QuestionSetType = "QUIZ"
QuestionSetTypeExam QuestionSetType = "EXAM"
QuestionSetTypeSurvey QuestionSetType = "SURVEY"
QuestionSetTypeCapstone QuestionSetType = "CAPSTONE"
)
type PracticeAccessBlock struct {
QuestionSetID int64
Title string
DisplayOrder int32
}
type MatchType string
const (
MatchTypeExact MatchType = "EXACT"
MatchTypeContains MatchType = "CONTAINS"
MatchTypeCaseInsensitive MatchType = "CASE_INSENSITIVE"
)
type Question struct {
ID int64
QuestionText string
QuestionType string
QuestionTypeDefinitionID *int64
DynamicPayload *DynamicQuestionPayload
DifficultyLevel *string
Points int32
Explanation *string
Tips *string
VoicePrompt *string
SampleAnswerVoicePrompt *string
ImageURL *string
Status string
CreatedAt time.Time
UpdatedAt *time.Time
}
type QuestionAudioAnswer struct {
ID int64
QuestionID int64
CorrectAnswerText string
CreatedAt time.Time
}
type QuestionWithDetails struct {
Question
Options []QuestionOption
ShortAnswers []QuestionShortAnswer
AudioAnswer *QuestionAudioAnswer
}
type QuestionOption struct {
ID int64
QuestionID int64
OptionText string
OptionOrder int32
IsCorrect bool
CreatedAt time.Time
}
type QuestionShortAnswer struct {
ID int64
QuestionID int64
AcceptableAnswer string
MatchType string
CreatedAt time.Time
}
type QuestionSet struct {
ID int64
Title string
Description *string
SetType string
OwnerType *string
OwnerID *int64
BannerImage *string
Persona *string
TimeLimitMinutes *int32
PassingScore *int32
ShuffleQuestions bool
Status string
IntroVideoURL *string
UserPersonas []UserPersona
CreatedAt time.Time
UpdatedAt *time.Time
}
type QuestionSetItem struct {
ID int64
SetID int64
QuestionID int64
DisplayOrder int32
CreatedAt time.Time
}
// QuestionSetQuestionTypeGroup is a raw DB aggregate before resolving builder definitions.
type QuestionSetQuestionTypeGroup struct {
QuestionTypeDefinitionID *int64
QuestionType string
Count int64
}
// QuestionSetQuestionTypeCount is one builder question type present in a set with how many questions use it.
type QuestionSetQuestionTypeCount struct {
QuestionTypeDefinitionID *int64 `json:"question_type_definition_id,omitempty"`
Key string `json:"key"`
DisplayName string `json:"display_name"`
Count int64 `json:"count"`
}
// QuestionSetQuestionTypesSummary summarizes distinct question types in a question set (e.g. linked practice).
type QuestionSetQuestionTypesSummary struct {
QuestionSetID int64 `json:"question_set_id"`
QuestionTypes []QuestionSetQuestionTypeCount `json:"question_types"`
TotalQuestions int64 `json:"total_questions"`
}
type QuestionSetItemWithQuestion struct {
QuestionSetItem
QuestionText string
QuestionType string
DynamicPayload *DynamicQuestionPayload
DifficultyLevel *string
Points int32
Explanation *string
Tips *string
VoicePrompt *string
SampleAnswerVoicePrompt *string
ImageURL *string
AudioCorrectAnswerText *string
QuestionStatus string
}
type CreateQuestionInput struct {
QuestionText string
QuestionType string
QuestionTypeDefinitionID *int64
DynamicPayload *DynamicQuestionPayload
DifficultyLevel *string
Points *int32
Explanation *string
Tips *string
VoicePrompt *string
SampleAnswerVoicePrompt *string
ImageURL *string
Status *string
Options []CreateQuestionOptionInput
ShortAnswers []CreateShortAnswerInput
AudioCorrectAnswerText *string
}
type CreateQuestionOptionInput struct {
OptionText string
OptionOrder *int32
IsCorrect bool
}
type CreateShortAnswerInput struct {
AcceptableAnswer string
MatchType *string
}
type CreateQuestionSetInput struct {
Title string
Description *string
SetType string
OwnerType *string
OwnerID *int64
BannerImage *string
Persona *string
TimeLimitMinutes *int32
PassingScore *int32
ShuffleQuestions *bool
Status *string
IntroVideoURL *string
}
// UserPersona represents a user acting as a persona in a practice session
type UserPersona struct {
ID int64
FirstName *string
LastName *string
NickName *string
ProfilePictureURL *string
Role string
DisplayOrder int32
}