Documentation
¶
Overview ¶
Package problems contains utilities useful for parsing, displaying, judging (a submission for) problems
Index ¶
- Variables
- func DeregisterConfigType(name string) error
- func RegisterConfigType(name string, parser ConfigParser, identifier ConfigIdentifier) error
- func Truncate(s string) string
- type Attachments
- type BytesData
- func (s BytesData) IsHTML() bool
- func (s BytesData) IsPDF() bool
- func (s BytesData) IsText() bool
- func (s BytesData) Locale() string
- func (s BytesData) Name() string
- func (s BytesData) String() string
- func (s BytesData) Type() string
- func (s BytesData) Value() ([]byte, error)
- func (s BytesData) ValueReader() (io.ReadCloser, error)
- type Checker
- type CompilationResult
- type CompilationStatus
- type Compiler
- type ConfigIdentifier
- type ConfigList
- type ConfigParser
- type ConfigStore
- type Contents
- type Data
- type EvaluationFile
- type EvaluationInfo
- type Evaluator
- type Executable
- type FeedbackType
- type FsStore
- func (s *FsStore) GetProblem(p string) (Problem, error)
- func (s *FsStore) HasProblem(p string) (bool, error)
- func (s *FsStore) ListProblems() ([]string, error)
- func (s *FsStore) MustGetProblem(p string) Problem
- func (s *FsStore) UpdateProblem(path string, name string) error
- func (s *FsStore) UpdateProblems() error
- type FsStoreOptions
- type Group
- func (g *Group) FirstNonAC() int
- func (g *Group) IsAC() bool
- func (g *Group) MaxMemoryUsage() memory.Amount
- func (g *Group) MaxScore() float64
- func (g *Group) MaxTimeSpent() time.Duration
- func (g *Group) Score() float64
- func (g *Group) SetMemoryLimit(ml memory.Amount)
- func (g *Group) SetTimeLimit(tl time.Duration)
- type LocalizedData
- type NamedData
- type NotFoundError
- type Problem
- type ProblemConfigType
- type ProblemParseError
- type ProblemWrapper
- type Runner
- type SafelyExecutable
- type ScoringType
- type Solution
- type Status
- type StatusUpdater
- type Store
- type TaskType
- type Testcase
- type Testset
- func (ts *Testset) FirstNonAC() int
- func (ts *Testset) IndexTestcase(ind int) *Testcase
- func (ts *Testset) IsAC() bool
- func (ts *Testset) MaxMemoryUsage() memory.Amount
- func (ts *Testset) MaxScore() (res float64)
- func (ts *Testset) MaxTimeSpent() time.Duration
- func (ts *Testset) Score() (res float64)
- func (ts *Testset) SetMemoryLimit(ml memory.Amount)
- func (ts *Testset) SetTimeLimit(tl time.Duration)
- func (ts *Testset) Testcases() (testcases []*Testcase)
- func (ts *Testset) Verdict() VerdictName
- type VerdictName
Constants ¶
This section is empty.
Variables ¶
var ( ErrorNameUsed = errors.New("config type name already in use") ErrorNoMatch = errors.New("parser can't decide config type, no match") )
var ( DataTypeText = "text/plain" DataTypeHTML = "text/html" DataTypePDF = "application/pdf" )
var ( FsStoreIgnoreFile = ".njudge_ignore" FsStorePrefixFile = ".njudge_prefix" )
var ErrorProblemNotFound = errors.New("problem not found")
var ErrorProblemParse = errors.New("can't parse problems")
Functions ¶
func DeregisterConfigType ¶
DeregisterConfigType unregisters a config type to the global ConfigStore
func RegisterConfigType ¶
func RegisterConfigType(name string, parser ConfigParser, identifier ConfigIdentifier) error
RegisterConfigType registers a config type to the global ConfigStore
Types ¶
type Attachments ¶
type Attachments []NamedData
type BytesData ¶
type BytesData struct { Loc string //Locale Val []byte //Value Typ string //Type (for example "text", "application/pdf", "text/html") Nam string //Name }
func (BytesData) ValueReader ¶
func (s BytesData) ValueReader() (io.ReadCloser, error)
type CompilationResult ¶ added in v0.4.0
type CompilationStatus ¶ added in v0.5.0
type CompilationStatus int
const ( BeforeCompilation CompilationStatus = 0 DuringCompilation CompilationStatus = 1 AfterCompilation CompilationStatus = 2 )
type ConfigIdentifier ¶
ConfigIdentifier is a function for some config type which takes a path and returns true if it thinks that its respective parser can parse it
type ConfigList ¶
type ConfigList struct {
ConfigTypes []ProblemConfigType
}
func NewConfigList ¶
func NewConfigList() *ConfigList
NewConfigList returns the default implementation of ConfigStore
func (*ConfigList) Deregister ¶
func (cs *ConfigList) Deregister(name string) error
func (*ConfigList) Register ¶
func (cs *ConfigList) Register(name string, parser ConfigParser, identifier ConfigIdentifier) error
type ConfigParser ¶
ConfigParser is a function for some config type which parses the problem from some path provided to it
type ConfigStore ¶
type ConfigStore interface { Register(string, ConfigParser, ConfigIdentifier) error Deregister(string) error Parse(afero.Fs, string) (Problem, error) }
ConfigStore is an interface with which you can register/deregister certain config types and parse a problem using these config types
type Contents ¶
type Contents []LocalizedData
func (Contents) FilterByLocale ¶
func (Contents) FilterByType ¶
type EvaluationFile ¶ added in v0.4.0
type EvaluationInfo ¶ added in v0.4.0
type Executable ¶ added in v0.4.0
type FeedbackType ¶
type FeedbackType string
FeedbackType is mainly for displaying to the end user. In FeedbackCF we actually output the contestant's output and the jury's output, too whereas in for example FeedbackACM we only use standard ACM feedback (just the verdict), in FeedbackIOI we display all testcases along information about groups.
const ( FeedbackUnknown FeedbackType = "" FeedbackCF FeedbackType = "FeedbackCF" FeedbackIOI FeedbackType = "FeedbackIOI" FeedbackACM FeedbackType = "FeedbackACM" FeedbackLazyIOI FeedbackType = "FeedbackLazyIOI" )
func FeedbackTypeFromShortString ¶ added in v0.4.0
func FeedbackTypeFromShortString(str string) FeedbackType
FeedbackTypeFromShortString parses a string into FeedbackType, the default is FEEDBACK_CF, "ioi" is for FeedbackIOI and "acm" is for FeedbackACM
func (*FeedbackType) UnmarshalJSON ¶ added in v0.4.0
func (f *FeedbackType) UnmarshalJSON(i []byte) error
type FsStore ¶
type FsStore struct { ByPath map[string]string sync.RWMutex // contains filtered or unexported fields }
func NewFsStore ¶
func NewFsStore(root string, options ...FsStoreOptions) *FsStore
func (*FsStore) GetProblem ¶ added in v0.4.0
func (*FsStore) ListProblems ¶ added in v0.4.0
func (*FsStore) MustGetProblem ¶ added in v0.4.0
func (*FsStore) UpdateProblems ¶ added in v0.4.0
type FsStoreOptions ¶
type FsStoreOptions func(*FsStore)
func FsStoreIgnorePrefix ¶
func FsStoreIgnorePrefix() FsStoreOptions
func FsStoreUseConfigStore ¶
func FsStoreUseConfigStore(cs ConfigStore) FsStoreOptions
func FsStoreUseFs ¶
func FsStoreUseFs(afs afero.Fs) FsStoreOptions
type Group ¶
type Group struct { Name string Scoring ScoringType Testcases []Testcase Dependencies []string }
A Group is named group of tests for which there is a scoring policy defined.
func (*Group) FirstNonAC ¶
func (*Group) MaxMemoryUsage ¶
func (*Group) MaxTimeSpent ¶
func (*Group) SetMemoryLimit ¶
func (*Group) SetTimeLimit ¶
type LocalizedData ¶
type NotFoundError ¶ added in v0.4.0
type NotFoundError struct {
Name string
}
func (NotFoundError) Error ¶ added in v0.4.0
func (err NotFoundError) Error() string
func (NotFoundError) Is ¶ added in v0.4.0
func (err NotFoundError) Is(target error) bool
type Problem ¶
type Problem interface { Name() string Titles() Contents Statements() Contents MemoryLimit() memory.Amount TimeLimit() int Attachments() Attachments Tags() []string EvaluationInfo }
type ProblemConfigType ¶
type ProblemConfigType struct { Name string Parser ConfigParser Identifier ConfigIdentifier }
type ProblemParseError ¶
func (ProblemParseError) Error ¶
func (err ProblemParseError) Error() string
func (ProblemParseError) Is ¶
func (ProblemParseError) Is(target error) bool
type ProblemWrapper ¶
func (ProblemWrapper) Name ¶
func (pw ProblemWrapper) Name() string
type SafelyExecutable ¶ added in v0.4.0
type ScoringType ¶
type ScoringType string
ScoringType represents the scoring of a group of tests,
- ScoringGroup means that if there's a non-accepted (or partially accepted) testcase in the group then the whole group scores 0 points,
- ScoringSum means that the score of the group is the sum of the scores.
- ScoringMin means that the score of the group is the minimum of the scores.
const ( ScoringUnknown ScoringType = "" ScoringGroup ScoringType = "ScoringGroup" ScoringSum ScoringType = "ScoringSum" ScoringMin ScoringType = "ScoringMin" )
func ScoringFromString ¶
func ScoringFromString(str string) ScoringType
func (*ScoringType) UnmarshalJSON ¶ added in v0.4.0
func (s *ScoringType) UnmarshalJSON(i []byte) error
type Status ¶
type Status struct { CompilationStatus CompilationStatus Compiled bool CompilerOutput string FeedbackType FeedbackType Feedback []Testset }
A Status represents the status of a submission after judging It contains the information about compilation and the feedback The main Testset is always the first one in Feedback.
type StatusUpdater ¶ added in v0.4.0
type Store ¶
type Store interface { ListProblems() ([]string, error) HasProblem(string) (bool, error) GetProblem(string) (Problem, error) MustGetProblem(string) Problem UpdateProblems() error UpdateProblem(path string, id string) error }
Store is an interface which is used to access a bunch of problems for example from the filesystem
type TaskType ¶
func NewTaskType ¶ added in v0.4.0
type Testcase ¶
type Testcase struct { Index int InputPath string OutputPath string AnswerPath string Testset string Group string VerdictName VerdictName Score float64 MaxScore float64 Output string ExpectedOutput string CheckerOutput string TimeSpent time.Duration MemoryUsed memory.Amount TimeLimit time.Duration MemoryLimit memory.Amount }
Testcase represents a testcase in the status of a submission.
type Testset ¶
Testset represents some set of tests, for example pretests and system tests should be testsets. They can also be used to seamlessly rejudge for contestants.
func (*Testset) FirstNonAC ¶
func (*Testset) IndexTestcase ¶
func (*Testset) MaxMemoryUsage ¶
func (*Testset) MaxTimeSpent ¶
func (*Testset) SetMemoryLimit ¶
func (*Testset) SetTimeLimit ¶
func (*Testset) Verdict ¶
func (ts *Testset) Verdict() VerdictName
type VerdictName ¶
type VerdictName string
VerdictName represents the verdict of a testcase i.e. the outcome which happened in result of running the testcase (or the lack of running it in the case of VerdictDR)
const ( VerdictUnknown VerdictName = "" VerdictAC VerdictName = "AC" VerdictWA VerdictName = "WA" VerdictRE VerdictName = "RE" VerdictTL VerdictName = "TL" VerdictML VerdictName = "ML" VerdictXX VerdictName = "XX" VerdictDR VerdictName = "DR" VerdictPC VerdictName = "PC" VerdictPE VerdictName = "PE" VerdictSK VerdictName = "SK" )
func (*VerdictName) UnmarshalJSON ¶ added in v0.4.0
func (v *VerdictName) UnmarshalJSON(i []byte) error