internal

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package internal contains internal logic of the application.

Package internal contains internal logic of the application.

Package internal contains internal logic of the application.

Package internal contains internal logic of the application.

Package internal contains internal logic of the application.

Index

Constants

View Source
const (
	NONE = TestResult(iota)
	OK
	CE
	RE
	TL
	ML
	WA
	EOC
)

Enum values

Variables

This section is empty.

Functions

func AddRun

func AddRun(contest *ContestInfo, run *RunInfo)

AddRun adds new run for the current contest

func GenerateContestInfo

func GenerateContestInfo(config *config.Config) error

GenerateContestInfo generates default contest info json file with the specified config

func RejudgeRun

func RejudgeRun(run *RunInfo) error

RejudgeRun rejudges the specfied RunInfo

func RemoveFile

func RemoveFile(path string)

RemoveFile removes the file with the specified path

func UpdateContestInfo

func UpdateContestInfo(config *config.Config, contest **ContestInfo)

UpdateContestInfo updates info about the current contest and writes it to the specified json file

Types

type CodeRunnerContext

type CodeRunnerContext struct {
	// contains filtered or unexported fields
}

CodeRunnerContext is a struct that contains all necessary information for running tests.

func NewCodeRunnerContext

func NewCodeRunnerContext(filePath, executablePath, language string) *CodeRunnerContext

NewCodeRunnerContext creates new COdeRunnerContext with giving parameters.

func (*CodeRunnerContext) Test

func (ctx *CodeRunnerContext) Test(
	directoryWithTests string,
	testsCount int,
) (TestingResult, error)

Test tests program on given tests and returns result of testing

type ContestInfo

type ContestInfo struct {
	Problems    []ProblemInfo              `json:"problems"`
	Contestants map[string]*ContestantInfo `json:"contestants"`
	StartTime   time.Time                  `json:"startTime"`
}

ContestInfo represents information about contest such as Problems names, Contestants information and StartTime of the contest

var Contest *ContestInfo

func NewContestInfo

func NewContestInfo(
	problems []ProblemInfo,
	contestants map[string]*ContestantInfo,
	startTime time.Time,
) *ContestInfo

NewContestInfo creates pointer of type ContestInfo

type ContestantInfo

type ContestantInfo struct {
	Id                string                  `json:"id"`
	Name              string                  `json:"name"`
	Points            int                     `json:"points"`
	Penalty           int64                   `json:"penalty"`
	Runs              []RunInfo               `json:"runs"`
	Results           map[ProblemInfo]RunInfo `json:"results"`
	AdditionalPenalty map[ProblemInfo]int64   `json:"additionalPenalty"`
	// contains filtered or unexported fields
}

ContestantInfo represents information about the contestant such as Name, Points, Penalty and information about his Runs.

func NewContestantInfo

func NewContestantInfo(id, name string) *ContestantInfo

NewContestantInfo creates pointer of type ContestantInfo

type ProblemInfo

type ProblemInfo = string

ProblemInfo represents number of the task

type Run

type Run struct {
	// contains filtered or unexported fields
}

Run represents information that need to execute program on the specified tests

func NewRun

func NewRun(fileName, language, problem, username string) *Run

NewRun creates Run

func (*Run) RunTests

func (ts *Run) RunTests() (TestingResult, error)

RunTests runs tests and return the result of testing

type RunInfo

type RunInfo struct {
	Id       string        `json:"id"`
	Problem  ProblemInfo   `json:"problem"`
	Result   TestingResult `json:"result"`
	Time     int64         `json:"time"`
	FileName string        `json:"fileName"`
	Language string        `json:"language"`
}

RunInfo represents information about the run such as Id, Problem, Result, Time and FileName

func NewRunInfo

func NewRunInfo(id, problem string, result TestingResult, t int64, fileName, language string) *RunInfo

NewRunInfo creates pointer of type RunInfo with given RunInfo.Result and RunInfo.Time

type TestResult

type TestResult int

TestResult type of the enum

func (*TestResult) GetString

func (t *TestResult) GetString() string

GetString returns string representation of the test result

type TestingResult

type TestingResult struct {
	Number int        `json:"number"`
	Result TestResult `json:"result"`
}

TestingResult is a struct that contains information about test result.

func (*TestingResult) String

func (t *TestingResult) String() string

String return string representation of TestingResult.

Jump to

Keyboard shortcuts

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