JOJ3/internal/parser/resultstatus/parser.go
张泊明518370910136 6a7787a974
All checks were successful
submodules sync / sync (push) Successful in 42s
build / build (push) Successful in 1m26s
build / trigger-build-image (push) Successful in 7s
feat(parser/resultstatus): 0 score on non-accepted status
2024-11-01 03:08:20 -04:00

43 lines
846 B
Go

package resultstatus
import (
"fmt"
"github.com/criyle/go-judge/envexec"
"github.com/joint-online-judge/JOJ3/internal/stage"
)
type Conf struct {
Score int
Comment string
}
type ResultStatus struct{}
func (*ResultStatus) Run(results []stage.ExecutorResult, confAny any) (
[]stage.ParserResult, bool, error,
) {
conf, err := stage.DecodeConf[Conf](confAny)
if err != nil {
return nil, true, err
}
score := conf.Score
forceQuit := false
var res []stage.ParserResult
for _, result := range results {
comment := conf.Comment
if result.Status != stage.Status(envexec.StatusAccepted) {
score = 0
comment = fmt.Sprintf(
"Unexpected executor status: %s.", result.Status,
)
forceQuit = true
}
res = append(res, stage.ParserResult{
Score: score,
Comment: comment,
})
}
return res, forceQuit, nil
}