server

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 License: MIT Imports: 14 Imported by: 0

README

logic_app_server

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadQueryFile

func ReadQueryFile(filename string) string

ReadQueryFile reads a SQL file and returns the contents as a string

Types

type Achievement

type Achievement struct {
	Name        string `json:"name"`
	Description string `json:"description"`
	Level       string `json:"level"`
	Achieved    bool   `json:"achieved"`
}

type Credentials

type Credentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type LeaderbordEntry

type LeaderbordEntry struct {
	Username   string  `json:"username"`
	Experience float64 `json:"experience"`
	Points     int     `json:"points"`
}

type LogicAppServer

type LogicAppServer struct {
	http.Handler
	// contains filtered or unexported fields
}

func NewLogicAppServer

func NewLogicAppServer(db *sql.DB) *LogicAppServer

type MyUserStore

type MyUserStore struct {
	DB *sql.DB
	// contains filtered or unexported fields
}

func NewMyUserStore

func NewMyUserStore(db *sql.DB) *MyUserStore

func (*MyUserStore) Achievements

func (us *MyUserStore) Achievements(user_id int) ([]Achievement, error)

func (*MyUserStore) CalculatePoints

func (us *MyUserStore) CalculatePoints(ss SolveSubmission) (int, error)

func (*MyUserStore) FindQuiz

func (us *MyUserStore) FindQuiz(user_id int, qc QuizProperties) (Quiz, error)

func (*MyUserStore) GetCompetitionQuiz

func (us *MyUserStore) GetCompetitionQuiz(user_id int) (Quiz, error)

func (*MyUserStore) Leaderboard

func (us *MyUserStore) Leaderboard() ([]LeaderbordEntry, error)

func (*MyUserStore) Login

func (us *MyUserStore) Login(credentials Credentials) (string, error)

func (*MyUserStore) Logout

func (us *MyUserStore) Logout(token string) error

func (*MyUserStore) ResetUser

func (us *MyUserStore) ResetUser(userId int) error

func (*MyUserStore) Signup

func (us *MyUserStore) Signup(credential Credentials) error

func (*MyUserStore) SolveQuiz

func (us *MyUserStore) SolveQuiz(userId int, ss SolveSubmission) (SolveSubmissionResponse, error)

func (*MyUserStore) UpdateAchievements

func (us *MyUserStore) UpdateAchievements(userId int) error

func (*MyUserStore) UserIdFromToken

func (us *MyUserStore) UserIdFromToken(token string) (int, error)

type PlayersHandler

type PlayersHandler struct {
	http.Handler
	// contains filtered or unexported fields
}

func NewPlayersHandler

func NewPlayersHandler(store UserStore) *PlayersHandler

func (*PlayersHandler) AchievementsHandler

func (uh *PlayersHandler) AchievementsHandler(w http.ResponseWriter, r *http.Request)

func (*PlayersHandler) LeaderboardHandler

func (uh *PlayersHandler) LeaderboardHandler(w http.ResponseWriter, r *http.Request)

type Quiz

type Quiz struct {
	QuizId    int      `json:"quizId"`
	Type      string   `json:"type"`
	TimeLimit float64  `json:"timeLimit"`
	Question  string   `json:"question"`
	Answers   []string `json:"answers"`
	Solutions []bool   `json:"solutions"`
}

type QuizHandler

type QuizHandler struct {
	http.Handler
	// contains filtered or unexported fields
}

func NewQuizHandler

func NewQuizHandler(store UserStore) *QuizHandler

func (*QuizHandler) CompetitionHandler

func (uh *QuizHandler) CompetitionHandler(w http.ResponseWriter, r *http.Request)

func (*QuizHandler) FindHandler

func (uh *QuizHandler) FindHandler(w http.ResponseWriter, r *http.Request)

func (*QuizHandler) SolveHandler

func (uh *QuizHandler) SolveHandler(w http.ResponseWriter, r *http.Request)

type QuizProperties

type QuizProperties struct {
	Type       string
	Difficulty string
	NumVars    int
	TimeLimit  int
}

func QuizPropertiesFromUrlQuery

func QuizPropertiesFromUrlQuery(queryParams url.Values) (QuizProperties, error)

type SolveSubmission

type SolveSubmission struct {
	QuizId    int     `json:"quizId"`
	IsCorrect bool    `json:"isCorrect"`
	Time      float64 `json:"time"`
}

type SolveSubmissionResponse

type SolveSubmissionResponse struct {
	Points int `json:"points"`
}

type UserHandler

type UserHandler struct {
	http.Handler
	// contains filtered or unexported fields
}

func NewUserHandler

func NewUserHandler(store UserStore) *UserHandler

func (*UserHandler) LoginHandler

func (uh *UserHandler) LoginHandler(w http.ResponseWriter, r *http.Request)

func (*UserHandler) LogoutHandler

func (uh *UserHandler) LogoutHandler(w http.ResponseWriter, r *http.Request)

func (*UserHandler) ResetHandler

func (uh *UserHandler) ResetHandler(w http.ResponseWriter, r *http.Request)

func (*UserHandler) SignupHandler

func (uh *UserHandler) SignupHandler(w http.ResponseWriter, r *http.Request)

type UserStore

type UserStore interface {
	Signup(c Credentials) error
	Login(c Credentials) (string, error)
	Logout(token string) error
	UserIdFromToken(token string) (int, error)
	ResetUser(userId int) error

	Achievements(user_id int) ([]Achievement, error)
	Leaderboard() ([]LeaderbordEntry, error)

	GetCompetitionQuiz(user_id int) (Quiz, error)
	FindQuiz(user_id int, qc QuizProperties) (Quiz, error)
	SolveQuiz(user_id int, ss SolveSubmission) (SolveSubmissionResponse, error)
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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