11package models
22
33import (
4+ "database/sql/driver"
5+ "encoding/json"
6+ "errors"
47 "gorm.io/gorm"
8+ "gorm.io/gorm/schema"
59 "testing_system/lib/customfields"
610)
711
812type ProblemType int
913
1014const (
11- ProblemType_ICPC ProblemType = iota + 1
12- ProblemType_IOI
15+ ProblemTypeICPC ProblemType = iota + 1
16+ ProblemTypeIOI
1317)
1418
19+ // TestGroupScoringType sets how should scheduler set points for a group
20+ type TestGroupScoringType int
21+
22+ const (
23+ // TestGroupScoringTypeComplete means that group costs TestGroup.GroupScore (all the tests should be OK)
24+ TestGroupScoringTypeComplete TestGroupScoringType = iota + 1
25+ // TestGroupScoringTypeEachTest means that group score = TestGroup.TestScore * (number of tests with OK)
26+ TestGroupScoringTypeEachTest
27+ // TestGroupScoringTypeMin means that group score = min(checker's scores among all the tests)
28+ TestGroupScoringTypeMin
29+ )
30+
31+ // TestGroupFeedbackType sets which info about tests in a group would be shown
32+ type TestGroupFeedbackType int
33+
34+ const (
35+ // TestGroupFeedbackTypeNone won't show anything
36+ TestGroupFeedbackTypeNone TestGroupFeedbackType = iota + 1
37+ // TestGroupFeedbackTypePoints will show points only
38+ TestGroupFeedbackTypePoints
39+ // TestGroupFeedbackTypeICPC will show verdict, time and memory usage for the first test with no OK
40+ TestGroupFeedbackTypeICPC
41+ // TestGroupFeedbackTypeComplete same as TestGroupFeedbackTypeICPC, but for every test
42+ TestGroupFeedbackTypeComplete
43+ // TestGroupFeedbackTypeFull same as TestGroupFeedbackTypeComplete, but with input, output, stderr, etc.
44+ TestGroupFeedbackTypeFull
45+ )
46+
47+ type TestGroup struct {
48+ Name string `json:"name" yaml:"name"`
49+ FirstTest uint64 `json:"FirstTest" yaml:"FirstTest"`
50+ LastTest uint64 `json:"LastTest" yaml:"LastTest"`
51+ // TestScore meaningful only in case of TestGroupScoringTypeEachTest
52+ TestScore * float64 `json:"TestScore" yaml:"TestScore"`
53+ // GroupScore meaningful only in case of TestGroupScoringTypeComplete
54+ GroupScore * float64 `json:"GroupScore" yaml:"GroupScore"`
55+ ScoringType TestGroupScoringType `json:"ScoringType" yaml:"ScoringType"`
56+ FeedbackType TestGroupFeedbackType `json:"FeedbackType" yaml:"FeedbackType"`
57+ RequiredGroupNames []string `json:"RequiredGroupNames" yaml:"RequiredGroupNames"`
58+ }
59+
60+ type TestGroups []TestGroup
61+
62+ func (t TestGroups ) Value () (driver.Value , error ) {
63+ return json .Marshal (t )
64+ }
65+
66+ func (t * TestGroups ) Scan (value interface {}) error {
67+ bytes , ok := value .([]byte )
68+ if ! ok {
69+ return errors .New ("type assertion to []byte failed while scanning TestGroups" )
70+ }
71+ return json .Unmarshal (bytes , t )
72+ }
73+
74+ func (t TestGroups ) GormDBDataType (db * gorm.DB , field * schema.Field ) string {
75+ switch db .Dialector .Name () {
76+ case "mysql" , "sqlite" :
77+ return "JSON"
78+ case "postgres" :
79+ return "JSONB"
80+ }
81+ return ""
82+ }
83+
1584type Problem struct {
1685 gorm.Model
1786
@@ -21,17 +90,19 @@ type Problem struct {
2190 MemoryLimit customfields.Memory `yaml:"MemoryLimit"`
2291
2392 TestsNumber uint64 `yaml:"TestsNumber"`
93+ // TestGroups ignored for ICPC problems
94+ TestGroups TestGroups `yaml:"TestGroups"`
2495
2596 // WallTimeLimit specifies maximum execution and wait time.
2697 // By default, it is max(5s, TimeLimit * 2)
2798 WallTimeLimit * customfields.Time `yaml:"WallTimeLimit,omitempty"`
2899
29- // MaxOpenFiles specifies maximum number of files, opened by testing system.
100+ // MaxOpenFiles specifies the maximum number of files, opened by testing system.
30101 // By default, it is 64
31102 MaxOpenFiles * uint64 `yaml:"MaxOpenFiles,omitempty"`
32103
33- // MaxThreads specifies maximum number of threads and/or processes
34- // By default, it is single thread
104+ // MaxThreads specifies the maximum number of threads and/or processes;
105+ // By default, it is a single thread
35106 // If MaxThreads equals to -1, any number of threads allowed
36107 MaxThreads * int64 `yaml:"MaxThreads,omitempty"`
37108
0 commit comments