Documentation ¶
Overview ¶
Package models defines all the data models used in the database, as well as methods to acquire and modify them.
Index ¶
- func BatchInsertJobs(db db.DBContext, jobs ...*Job) error
- func CollectUserProblemResults(db db.DBContext, userID string, problems []*Problem) (map[int]*ProblemResult, error)
- func GetProblemByName(db db.DBContext, contestID int, name string) (*Problem, error)
- func (r *TestGroup) Hidden() bool
- func RejudgeCompile(db db.DBContext, subIDs ...int) error
- func RejudgeRun(db db.DBContext, subIDs ...int) error
- func RejudgeScore(db db.DBContext, subIDs ...int) error
- func (r *TestGroup) Verify() error
- func (p *Problem) WriteFiles(db db.DBContext, files []*File) error
- func (r *TestGroup) WriteTests(db db.DBContext, tests []*Test, override bool) error
- type Config
- type ContestType
- type JobType
- type Language
- type PenaltyPolicy
- type ProblemWithTestGroups
- type QueueOverview
- type ScoringMode
- type TestGroupWithTests
- type TestScoringMode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BatchInsertJobs ¶
BatchInsertJobs try to insert all given jobs.
func CollectUserProblemResults ¶
func CollectUserProblemResults(db db.DBContext, userID string, problems []*Problem) (map[int]*ProblemResult, error)
CollectProblemResults collects an user's problem results for a contest. The result map's key is the problem ID.
func GetProblemByName ¶
GetProblemByName gets a Problem from the Database by its name and contest.
func (*TestGroup) Hidden ¶
func (r *TestGroup) Hidden() bool
Hidden returns whether the test group is hidden.
func RejudgeCompile ¶
RejudgeCompile re-compiles all submissions given.
func RejudgeRun ¶
RejudgeRun re-runs all tests for the submissions given.
func RejudgeScore ¶
RejudgeScore re-scores all submissions given.
func (*Problem) WriteFiles ¶
WriteFiles writes the given files as brand new, overwritting the old ones. Note that because of overwritting behaviour, we cannot ensure the validity of the indicies, hence they are not reflected into the *Files.
Types ¶
type Config ¶
type Config struct { SessionKey []byte `db:"session_key"` EnableRegistration bool `db:"enable_registration"` }
Config is the configuation of the server.
func GenerateConfig ¶
GenerateConfig generates a random configuration.
type ContestType ¶
type ContestType string
ContestType is the enum representing the contest type. The contest type determines ONLY how the scoreboard is rendered.
const ( // The contestants are sorted by number of "solved" problems, then by total penalty. ContestTypeUnweighted ContestType = "unweighted" // Problems each have different scores, and penalty only serves as tiebreakers. ContestTypeWeighted ContestType = "weighted" )
type JobType ¶
type JobType string
JobType determines the type of the job. This can be: - Compile: highest priority. Compiles a submission into executable bytecode. - Test: run a test. - Score: recalculate the score.
type Language ¶
type Language string
Language represents the language of the submission. The available values depend on the machine the judge is run on.
func LanguageByExt ¶
LanguageByExt returns a language based on the file extension.
type PenaltyPolicy ¶
type PenaltyPolicy string
PenaltyPolicy dictates how the penalty is calculated. There are: - None: no penalty at all (IOI - like). - SubmitTime: minutes passed from the start of the contest, of the submission time. - ICPC: SubmitTime + 20 * (# of past submissions)
const ( PenaltyPolicyNone PenaltyPolicy = "none" PenaltyPolicySubmitTime PenaltyPolicy = "submit_time" PenaltyPolicyICPC PenaltyPolicy = "icpc" )
Defined values for PenaltyPolicy.
type ProblemWithTestGroups ¶
type ProblemWithTestGroups struct { *Problem TestGroups []*TestGroup }
ProblemWithTestGroups is a problem with attached test groups, that will provide score-related statistics.
func CollectTestGroups ¶
func CollectTestGroups(db db.DBContext, problems []*Problem, private bool) ([]*ProblemWithTestGroups, error)
CollectTestGroups collects the test groups for a list of problems.
func (*ProblemWithTestGroups) SubtaskScores ¶
func (p *ProblemWithTestGroups) SubtaskScores() string
SubtaskScores returns the problem's test group scores as a list seperated by forward slash.
func (*ProblemWithTestGroups) TotalScore ¶
func (p *ProblemWithTestGroups) TotalScore() float64
TotalScore returns the problem's maximal total score.
type QueueOverview ¶
QueueOverview gives overview information about the queue of jobs.
func GetQueueOverview ¶
func GetQueueOverview(db db.DBContext) (*QueueOverview, error)
GetQueueOverview gets the current queue overview.
func (*QueueOverview) Total ¶
func (q *QueueOverview) Total() int
Total returns the sum of all queue counts.
type ScoringMode ¶
type ScoringMode string
ScoringMode dictates how the best submission is chosen. There are: - Best: The submission with the highest score is chosen. If on a tie, choose the one with largest penalty. - Once: The first (successfully compiled) submission is the best one. - Last: The last submission is the best one. - Decay: The last submission is the best one. The score is modified by the number of submissions before it (0.1 * count), and the time passed (0.7 * time passed in %), to a minimum of 0.3 times the original.
const ( ScoringModeBest ScoringMode = "best" ScoringModeOnce ScoringMode = "once" ScoringModeLast ScoringMode = "last" ScoringModeDecay ScoringMode = "decay" )
Defined values for ScoringMode.
type TestGroupWithTests ¶
type TestGroupWithTests struct { *TestGroup Tests []*Test }
TestGroupWithTests are wrapped test groups with tests included.
func GetProblemTests ¶
func GetProblemTests(db db.DBContext, problemID int) ([]*TestGroupWithTests, error)
GetProblemTests collects test groups and tests from a problem.
func GetProblemTestsMeta ¶
func GetProblemTestsMeta(db db.DBContext, problemID int) ([]*TestGroupWithTests, error)
GetProblemTestsMeta is like GetProblemTests, but inputs and outputs are not included.
func (*TestGroupWithTests) ComputeScore ¶
func (tg *TestGroupWithTests) ComputeScore(results map[int]*TestResult) float64
ComputeScore returns the score of a test group (with tests), given the test results.
type TestScoringMode ¶
type TestScoringMode string
TestScoringMode determines how the score of each test in the group adds up to the total of the group. The schemes are: - Sum: Each test has an equal weight and the score of the group is (sum of test scores / # of tests) * (group score) - Min: The score of the group = min(score of each test) * (group score) - Product: Score of the group = product(score of each test) * (group score)
const ( TestScoringModeSum TestScoringMode = "sum" TestScoringModeMin TestScoringMode = "min" TestScoringModeProduct TestScoringMode = "product" )
All possible values of TestScoringMode.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Command "generate-models" reads the model information from the "models/models.json" file, and generate the relevant "models/generated.go" file.
|
Command "generate-models" reads the model information from the "models/models.json" file, and generate the relevant "models/generated.go" file. |
Package verify implements certain verification methods for simple data structures.
|
Package verify implements certain verification methods for simple data structures. |