trainer

package
v0.0.0-...-de69bfc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 19, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Choice

type Choice struct {
	ID         int
	Option     string
	Text       string
	IsAnswer   bool
	IsSelected bool
}

type ChoiceDateV2

type ChoiceDateV2 struct {
	ID     int
	Option string
	Text   string
}

type ChoiceEntity

type ChoiceEntity struct {
	ID         int
	QuestionId int
	Option     string
	Text       string
	IsAnswer   bool
}

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

func NewController

func NewController(service Service, html fs.FS) *Controller

func (*Controller) Feedback

func (c *Controller) Feedback(w http.ResponseWriter, _ *http.Request)

func (*Controller) Health

func (c *Controller) Health(w http.ResponseWriter, r *http.Request)

func (*Controller) Home

func (c *Controller) Home(w http.ResponseWriter, r *http.Request)

func (*Controller) NewQuestion

func (c *Controller) NewQuestion(w http.ResponseWriter, r *http.Request)

func (*Controller) QuestionByID

func (c *Controller) QuestionByID(w http.ResponseWriter, r *http.Request)

func (*Controller) QuestionList

func (c *Controller) QuestionList(w http.ResponseWriter, r *http.Request)

func (*Controller) RandomQuestion

func (c *Controller) RandomQuestion(w http.ResponseWriter, _ *http.Request)

func (*Controller) Result

func (c *Controller) Result(w http.ResponseWriter, r *http.Request)

func (*Controller) SubmitFeedback

func (c *Controller) SubmitFeedback(w http.ResponseWriter, r *http.Request)

type Feedback

type Feedback struct {
	ID             int
	Name           string
	Email          string
	Topic          string
	Text           string
	IsAcknowledged bool
	IsCompleted    bool
}

type FeedbackEntity

type FeedbackEntity struct {
	ID             int
	Name           string
	Email          string
	Topic          string
	Text           string
	IsAcknowledged bool
	IsCompleted    bool
}

type LoadMoreParam

type LoadMoreParam struct {
	Search             string
	LastRuleSortOrder  int
	LastQuestionNumber int
	LastIndex          int
	Limit              int
}

type Question

type Question struct {
	ID                 int
	Text               string
	Rule               Rule
	QuestionNumber     int
	RuleQuestionNumber string
	Choices            []Choice
	References         []Reference
}

type QuestionData

type QuestionData struct {
	ID                 int
	RuleID             string
	RuleName           string
	RuleQuestionNumber string
	Text               string
}

type QuestionDataV2

type QuestionDataV2 struct {
	ID                 int
	CorrectChoices     string
	RuleQuestionNumber string
	Text               string
	Choices            []ChoiceDateV2
	QuestionNumber     int
	RuleName           string
}

type QuestionEntity

type QuestionEntity struct {
	ID             int
	Text           string
	RuleID         string
	QuestionNumber int
}

type QuestionListPageData

type QuestionListPageData struct {
	Questions     []QuestionData
	LoadMoreParam LoadMoreParam
}

type QuestionRepository

type QuestionRepository struct {
	// contains filtered or unexported fields
}

func NewRepository

func NewRepository(db *pgxpool.Pool) *QuestionRepository

func (*QuestionRepository) FindChoicesByQuestionIds

func (r *QuestionRepository) FindChoicesByQuestionIds(ctx context.Context, questionIds ...int) (map[int][]Choice, error)

FindChoicesByQuestionIds finds choices by question ids and returns a map of question id to choices

func (*QuestionRepository) FindRuleByID

func (r *QuestionRepository) FindRuleByID(ctx context.Context, ruleID string) (*Rule, error)

func (*QuestionRepository) FindRuleByIDs

func (r *QuestionRepository) FindRuleByIDs(ctx context.Context, ruleIDs ...string) (map[string]Rule, error)

FindRuleByIDs finds rules by rule ids and returns a map of rule id to rule

func (*QuestionRepository) GetAllDistinctRuleIDs

func (r *QuestionRepository) GetAllDistinctRuleIDs(ctx context.Context) ([]string, error)

func (*QuestionRepository) GetAllQuestions

func (r *QuestionRepository) GetAllQuestions(ctx context.Context) ([]Question, error)

func (*QuestionRepository) GetChoicesByQuestionID

func (r *QuestionRepository) GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error)

func (*QuestionRepository) GetQuestionByID

func (r *QuestionRepository) GetQuestionByID(ctx context.Context, id int) (*Question, error)

func (*QuestionRepository) GetRandomQuestion

func (r *QuestionRepository) GetRandomQuestion(ctx context.Context, rules []string) (*Question, error)

func (*QuestionRepository) InsertFeedback

func (r *QuestionRepository) InsertFeedback(ctx context.Context, feedback Feedback) error

func (*QuestionRepository) ListQuestions

func (r *QuestionRepository) ListQuestions(ctx context.Context, ruleIDs []string, search string, lastRuleSortOrder int, lastQuestionNumber int, limit int) ([]Question, error)

ListQuestions returns a list of questions supports pagination using the rule sort order and question number of the last question to offset

type QuestionService

type QuestionService struct {
	// contains filtered or unexported fields
}

func NewService

func NewService(repository Repository) *QuestionService

func (*QuestionService) GetAllQuestions

func (s *QuestionService) GetAllQuestions(ctx context.Context) ([]Question, error)

func (*QuestionService) GetChoicesByQuestionID

func (s *QuestionService) GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error)

func (*QuestionService) GetQuestionByID

func (s *QuestionService) GetQuestionByID(ctx context.Context, id int) (*Question, error)

func (*QuestionService) GetRandomQuestion

func (s *QuestionService) GetRandomQuestion(ctx context.Context, rules []string) (*Question, error)

func (*QuestionService) ListQuestions

func (s *QuestionService) ListQuestions(ctx context.Context, rules []string, search string, lastRuleSortOrder int, lastQuestionNumber int, limit int) ([]Question, error)

func (*QuestionService) SubmitFeedback

func (s *QuestionService) SubmitFeedback(ctx context.Context, feedback Feedback) error

type Reference

type Reference struct {
	ID   int
	Text string
}

type ReferenceEntity

type ReferenceEntity struct {
	ID         int
	QuestionId int
	Text       string
}

type Repository

type Repository interface {
	GetAllQuestions(ctx context.Context) ([]Question, error)
	GetQuestionByID(ctx context.Context, id int) (*Question, error)
	GetRandomQuestion(ctx context.Context, rules []string) (*Question, error)
	GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error)
	ListQuestions(ctx context.Context, rules []string, search string, lastRuleSortOrder int, lastQuestionNumber int, limit int) ([]Question, error)
	InsertFeedback(ctx context.Context, feedback Feedback) error
}

type Rule

type Rule struct {
	ID        string
	Name      string
	SortOrder int
}

type RuleEntity

type RuleEntity struct {
	ID        string
	Name      string
	SortOrder int
}

type Service

type Service interface {
	GetAllQuestions(ctx context.Context) ([]Question, error)
	GetQuestionByID(ctx context.Context, id int) (*Question, error)
	GetRandomQuestion(ctx context.Context, rules []string) (*Question, error)
	GetChoicesByQuestionID(ctx context.Context, questionID int) ([]Choice, error)
	ListQuestions(ctx context.Context, rules []string, search string, lastRuleSortOrder int, lastQuestionNumber int, limit int) ([]Question, error)
	SubmitFeedback(ctx context.Context, feedback Feedback) error
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL