package ports

import (
	"Yimaru-Backend/internal/domain"
	"context"
)

type QuestionStore interface {
	// Questions
	CreateQuestion(ctx context.Context, input domain.CreateQuestionInput) (domain.Question, error)
	GetQuestionByID(ctx context.Context, id int64) (domain.Question, error)
	GetQuestionWithDetails(ctx context.Context, id int64) (domain.QuestionWithDetails, error)
	ListQuestions(ctx context.Context, questionType, difficulty, status *string, limit, offset int32) ([]domain.Question, int64, error)
	SearchQuestions(ctx context.Context, query string, limit, offset int32) ([]domain.Question, int64, error)
	UpdateQuestion(ctx context.Context, id int64, input domain.CreateQuestionInput) error
	ArchiveQuestion(ctx context.Context, id int64) error
	DeleteQuestion(ctx context.Context, id int64) error

	// Question Options
	CreateQuestionOption(ctx context.Context, questionID int64, optionText string, optionOrder *int32, isCorrect bool) (domain.QuestionOption, error)
	GetOptionsByQuestionID(ctx context.Context, questionID int64) ([]domain.QuestionOption, error)
	UpdateQuestionOption(ctx context.Context, id int64, optionText *string, optionOrder *int32, isCorrect *bool) error
	DeleteQuestionOption(ctx context.Context, id int64) error
	DeleteOptionsByQuestionID(ctx context.Context, questionID int64) error

	// Question Short Answers
	CreateQuestionShortAnswer(ctx context.Context, questionID int64, acceptableAnswer string, matchType *string) (domain.QuestionShortAnswer, error)
	GetShortAnswersByQuestionID(ctx context.Context, questionID int64) ([]domain.QuestionShortAnswer, error)
	UpdateQuestionShortAnswer(ctx context.Context, id int64, acceptableAnswer, matchType *string) error
	DeleteQuestionShortAnswer(ctx context.Context, id int64) error
	DeleteShortAnswersByQuestionID(ctx context.Context, questionID int64) error

	// Question Sets
	CreateQuestionSet(ctx context.Context, input domain.CreateQuestionSetInput) (domain.QuestionSet, error)
	GetQuestionSetByID(ctx context.Context, id int64) (domain.QuestionSet, error)
	GetQuestionSetsByOwner(ctx context.Context, ownerType string, ownerID int64) ([]domain.QuestionSet, error)
	GetQuestionSetsByType(ctx context.Context, setType string, limit, offset int32) ([]domain.QuestionSet, int64, error)
	GetPublishedQuestionSetsByOwner(ctx context.Context, ownerType string, ownerID int64) ([]domain.QuestionSet, error)
	GetInitialAssessmentSet(ctx context.Context) (domain.QuestionSet, error)
	UpdateQuestionSet(ctx context.Context, id int64, input domain.CreateQuestionSetInput) error
	ArchiveQuestionSet(ctx context.Context, id int64) error
	DeleteQuestionSet(ctx context.Context, id int64) error

	// Question Set Items
	AddQuestionToSet(ctx context.Context, setID, questionID int64, displayOrder *int32) (domain.QuestionSetItem, error)
	GetQuestionSetItems(ctx context.Context, setID int64) ([]domain.QuestionSetItemWithQuestion, error)
	GetPublishedQuestionsInSet(ctx context.Context, setID int64) ([]domain.QuestionSetItemWithQuestion, error)
	RemoveQuestionFromSet(ctx context.Context, setID, questionID int64) error
	UpdateQuestionOrder(ctx context.Context, setID, questionID int64, displayOrder int32) error
	CountQuestionsInSet(ctx context.Context, setID int64) (int64, error)
	GetQuestionSetsContainingQuestion(ctx context.Context, questionID int64) ([]domain.QuestionSet, error)

	// User Personas in Question Sets
	AddUserPersonaToQuestionSet(ctx context.Context, questionSetID, userID int64, displayOrder int32) error
	RemoveUserPersonaFromQuestionSet(ctx context.Context, questionSetID, userID int64) error
	GetUserPersonasByQuestionSetID(ctx context.Context, questionSetID int64) ([]domain.UserPersona, error)
}
