contests

package
v0.0.0-...-7466d73 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Auth

func Auth(contest string, username string, password string) *http.Cookie

Auth authenticates an user

func ContestHandler

func ContestHandler(w http.ResponseWriter, r *http.Request)

ContestHandler ... Nothing to see here

func ContestHandlerInit

func ContestHandlerInit()

ContestHandlerInit ... Function that initializes the contest handler.

func OpenDB

func OpenDB() *sql.DB

OpenDB opens a connection to the database

func ReadContestInit

func ReadContestInit()

ReadContestInit prepares for reading contests from json and caching

func SaveSubmission

func SaveSubmission(contest Contest, contestant Contestant, submissionFn string) int

SaveSubmission saves the submission to the database and returns the id

func ValidateTaskSubmit

func ValidateTaskSubmit(t Task, r *http.Request) bool

ValidateTaskSubmit validates a submit request (/contest/.../submit/...)

Types

type Admin

type Admin struct {
	Name     string
	UserName string
	Password string
	DbID     int
}

Admin the admin type

type Contest

type Contest struct {
	ContestName      string
	RealName         string
	ID               int
	Contestants      []Contestant
	Tasks            []Task
	Admins           []Admin
	StartTime        time.Time
	EndTime          time.Time
	ContestEnded     bool
	SubmissionsCount int
}

Contest The contest type, as parsed from the contest.json

func ReadContest

func ReadContest(name string) (Contest, error)

ReadContest ... Nothing to see here

func ReadContestFromDb

func ReadContestFromDb(name string) Contest

ReadContestFromDb reads the contest from the database

type Contestant

type Contestant struct {
	Name     string
	UserName string
	Password string
	DbID     int
}

Contestant The contestant type, from the table contestants

type List

type List struct {
	Contests []Contest
}

List is a list of contests stored as an array

type Manager

type Manager struct {
	ManagerName string
	ForLang     []string
	DbID        int
}

Manager the task manager and judge

type Session

type Session struct {
	LoginName  string
	Contest    string
	Contestant Contestant
}

Session is a session like in PHP, kind of

func Validate

func Validate(r *http.Request, contestName string) (bool, Session)

Validate validates a previous authentication and returns true if it is valid

type Task

type Task struct {
	TaskName          string
	FullTaskName      string
	TaskStatementFile string
	Manager           Manager
	DbID              int
}

Task The task type

Jump to

Keyboard shortcuts

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