model

package
v0.0.0-...-5805fc1 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2015 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package model groups a lot of types that model the data that drives Coduno.

It is designed for Google Datastore, but switching to other BigTable implementations is not inconceivable (though it might require some more work).

Not all exported types directly translate to entities that are persisted, but most of them do.

Index

Constants

View Source
const (
	Move        RobotEvent = RobotEvent("MOVE")
	OutOfBounds            = RobotEvent("OUT_OF_BOUNDS")
	Obstacle               = RobotEvent("HIT_OBSTACLE")
	MissedCoin             = RobotEvent("MISSED_COIN")
	WrongPick              = RobotEvent("WRONG_PICK")
	Picked                 = RobotEvent("PICKED")
)
View Source
const ChallengeKind = "Challenge"

ChallengeKind is the kind used in Datastore to store entities Challenge entities.

View Source
const CoderJunitTestResultKind = "CoderJunitTestResult"

CoderJunitTestResultKind is the kind used in Datastore to store entities CoderJunitTestResult entities.

View Source
const CompanyKind = "Company"

CompanyKind is the kind used in Datastore to store entities Company entities.

View Source
const DiffTestResultKind = "DiffTestResult"

DiffTestResultKind is the kind used in Datastore to store entities DiffTestResult entities.

View Source
const InvitationKind = "Invitation"

InvitationKind is the kind used in Datastore to store entities Invitation entities.

View Source
const JunitTestResultKind = "JunitTestResult"

JunitTestResultKind is the kind used in Datastore to store entities JunitTestResult entities.

View Source
const ProfileKind = "Profile"

ProfileKind is the kind used in Datastore to store entities Profile entities.

View Source
const ResultKind = "Result"

ResultKind is the kind used in Datastore to store entities Result entities.

View Source
const RobotTestResultsKind = "RobotTestResults"

RobotTestResultsKind is the kind used in Datastore to store entities RobotTestResults entities.

View Source
const SubmissionKind = "Submission"

SubmissionKind is the kind used in Datastore to store entities Submission entities.

View Source
const TaskKind = "Task"

TaskKind is the kind used in Datastore to store entities Task entities.

View Source
const TemplateKind = "Template"

TemplateKind is the kind used in Datastore to store entities Template entities.

View Source
const TestKind = "Test"

TestKind is the kind used in Datastore to store entities Test entities.

View Source
const TokenKind = "Token"

TokenKind is the kind used in Datastore to store entities Token entities.

View Source
const UserKind = "User"

UserKind is the kind used in Datastore to store entities User entities.

Variables

This section is empty.

Functions

func NewQueryForChallenge

func NewQueryForChallenge() *datastore.Query

NewQueryForChallenge prepares a datastore.Query that can be used to query entities of type Challenge.

func NewQueryForCoderJunitTestResult

func NewQueryForCoderJunitTestResult() *datastore.Query

NewQueryForCoderJunitTestResult prepares a datastore.Query that can be used to query entities of type CoderJunitTestResult.

func NewQueryForCompany

func NewQueryForCompany() *datastore.Query

NewQueryForCompany prepares a datastore.Query that can be used to query entities of type Company.

func NewQueryForDiffTestResult

func NewQueryForDiffTestResult() *datastore.Query

NewQueryForDiffTestResult prepares a datastore.Query that can be used to query entities of type DiffTestResult.

func NewQueryForInvitation

func NewQueryForInvitation() *datastore.Query

NewQueryForInvitation prepares a datastore.Query that can be used to query entities of type Invitation.

func NewQueryForJunitTestResult

func NewQueryForJunitTestResult() *datastore.Query

NewQueryForJunitTestResult prepares a datastore.Query that can be used to query entities of type JunitTestResult.

func NewQueryForProfile

func NewQueryForProfile() *datastore.Query

NewQueryForProfile prepares a datastore.Query that can be used to query entities of type Profile.

func NewQueryForResult

func NewQueryForResult() *datastore.Query

NewQueryForResult prepares a datastore.Query that can be used to query entities of type Result.

func NewQueryForRobotTestResults

func NewQueryForRobotTestResults() *datastore.Query

NewQueryForRobotTestResults prepares a datastore.Query that can be used to query entities of type RobotTestResults.

func NewQueryForSubmission

func NewQueryForSubmission() *datastore.Query

NewQueryForSubmission prepares a datastore.Query that can be used to query entities of type Submission.

func NewQueryForTask

func NewQueryForTask() *datastore.Query

NewQueryForTask prepares a datastore.Query that can be used to query entities of type Task.

func NewQueryForTemplate

func NewQueryForTemplate() *datastore.Query

NewQueryForTemplate prepares a datastore.Query that can be used to query entities of type Template.

func NewQueryForTest

func NewQueryForTest() *datastore.Query

NewQueryForTest prepares a datastore.Query that can be used to query entities of type Test.

func NewQueryForToken

func NewQueryForToken() *datastore.Query

NewQueryForToken prepares a datastore.Query that can be used to query entities of type Token.

func NewQueryForUser

func NewQueryForUser() *datastore.Query

NewQueryForUser prepares a datastore.Query that can be used to query entities of type User.

Types

type Assignment

type Assignment struct {
	// Name should give a very brief and memorable
	// description and classification of the assignment.
	Name string `datastore:",index",json:",omitempty"`

	// Description should detail what this assignment is
	// about and why it makes sense.
	//
	// TODO(victorbalan): Improve documentation.
	Description string `datastore:",noindex",json:",omitempty"`

	// Instructions should make clear how the assignment
	// is to be carried out (e.g. a step-by-step guide).
	//
	// NOTE(flowlo, victorbalan): Instructions is not guaranteed
	// to be backwards-compatible. In the future it may
	// be an URL pointing at the source of the instructions.
	Instructions string `datastore:",noindex",json:",omitempty"`

	// Expected time to complete the assignment. Can serve
	// as deadline.
	Duration time.Duration `datastore:",index",json:",omitempty"`

	// Where to deliver results as part of carrying out the
	// assignment.
	Endpoints Endpoints `datastore:",noindex",json:",omitempty"`
}

Assignment conveys the specification of what a User must do in order to fulfill a Task or Challenge.

type Challenge

type Challenge struct {
	Assignment

	// The tasks that have to be fulfilled in order
	// to successfully complete the Challenge.
	//
	// Result.StartTimes and Result.FinalSubmissions
	// depend on the ordering of this slice. Also it
	// affects the rendering of this Challenge with
	// respect to the user. Therefore it must be
	// guaranteed to be stable.
	Tasks []*datastore.Key `datastore:",noindex",json:",omitempty"`

	// The Resulter to use to compute skills (and
	// therefore a Result) from the outcome of
	// the Submissions to Tasks.
	Resulter int64 `datastore:",noindex",json:",omitempty"`
}

Challenge is an abstract piece of work that can consist of many different Tasks.

Saved in Datastore, Challenge will be a child entity to Company, so keys pointing to a Challenge can be used to obtain the Company that owns it.

func (*Challenge) Key

func (ƨ *Challenge) Key(key *datastore.Key) *KeyedChallenge

Key is a shorthand to fill a KeyedChallenge with an entity and it's key.

func (Challenge) Put

func (ƨ Challenge) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Challenge into Datastore using the given key.

func (Challenge) PutWithParent

func (ƨ Challenge) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Challenge as child of another entity. This will error if parent == nil.

type Challenges

type Challenges []Challenge

Challenges is just a slice of Challenge.

func (Challenges) Key

func (ƨ Challenges) Key(keys []*datastore.Key) (keyed []KeyedChallenge)

Key is a shorthand to fill a slice of KeyedChallenge with some entities alongside their keys.

type CoderJunitTestResult

type CoderJunitTestResult struct {
	JunitTestResult
	ShouldFail bool
}

CoderJunitTestResult is the result of a set of JUnit tests written by the coder for some specs ran against code written by the coduno team for said specs. Besides the results of the test, it also encapsulates wether it was supposed to fail in order to assess the correctness of the unit tests.

func (*CoderJunitTestResult) Key

Key is a shorthand to fill a KeyedCoderJunitTestResult with an entity and it's key.

func (CoderJunitTestResult) Put

Put will put this CoderJunitTestResult into Datastore using the given key.

func (CoderJunitTestResult) PutWithParent

func (ƨ CoderJunitTestResult) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this CoderJunitTestResult as child of another entity. This will error if parent == nil.

type CoderJunitTestResults

type CoderJunitTestResults []CoderJunitTestResult

CoderJunitTestResults is just a slice of CoderJunitTestResult.

func (CoderJunitTestResults) Key

Key is a shorthand to fill a slice of KeyedCoderJunitTestResult with some entities alongside their keys.

type Company

type Company struct {
	mail.Address `datastore:",index",json:",omitempty"`

	// Unique name for this user, like analogous to @google
	// on GitHub/Twitter/...
	Nick string `datastore:",index",json:",omitempty"`
}

Company contains the data related to a company.

TODO(flowlo, victorbalan): In the future, the company may point at Users to enable role based authentication.

func (*Company) Key

func (ƨ *Company) Key(key *datastore.Key) *KeyedCompany

Key is a shorthand to fill a KeyedCompany with an entity and it's key.

func (Company) Put

func (ƨ Company) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Company into Datastore using the given key.

func (Company) PutWithParent

func (ƨ Company) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Company as child of another entity. This will error if parent == nil.

type Companys

type Companys []Company

Companys is just a slice of Company.

func (Companys) Key

func (ƨ Companys) Key(keys []*datastore.Key) (keyed []KeyedCompany)

Key is a shorthand to fill a slice of KeyedCompany with some entities alongside their keys.

type DiffTestResult

type DiffTestResult struct {
	SimpleTestResult

	DiffLines []int `datastore:",noindex"`
	Endpoint  string
	Failed    bool
}

DiffTestResult holds the result of an outputtest.

func (*DiffTestResult) Key

Key is a shorthand to fill a KeyedDiffTestResult with an entity and it's key.

func (DiffTestResult) Put

func (ƨ DiffTestResult) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this DiffTestResult into Datastore using the given key.

func (DiffTestResult) PutWithParent

func (ƨ DiffTestResult) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this DiffTestResult as child of another entity. This will error if parent == nil.

type DiffTestResults

type DiffTestResults []DiffTestResult

DiffTestResults is just a slice of DiffTestResult.

func (DiffTestResults) Key

func (ƨ DiffTestResults) Key(keys []*datastore.Key) (keyed []KeyedDiffTestResult)

Key is a shorthand to fill a slice of KeyedDiffTestResult with some entities alongside their keys.

type Endpoints

type Endpoints struct {
	// Name of the WebComponent used to render
	// the assignment accordingly.
	WebInterface string `datastore:",noindex",json:",omitempty"`

	// URL of the remote that should be pushed
	// to.
	//
	// NOTE(flowlo): No backwards-compatibility
	// guarantee on this.
	//
	// TODO(flowlo): Investigate why we can not use
	// url.URL
	GitRepository string `datastore:",noindex",json:",omitempty"`
}

Endpoints encapsulates two possible ways to deliver the outcome of trying to fulfill an assignment.

type Failure

type Failure struct {
	Message string `xml:"message,attr"`
}

Failure holds a failure created by JUnit.

type Invitation

type Invitation struct {
	User *datastore.Key `datastore:",index",json:",omitempty"`
	Sent time.Time      `datastore:",index",json:",omitempty"`
}

Invitation represents the message sent by a company to a User in order to ask them to do a Challenge.

func (*Invitation) Key

func (ƨ *Invitation) Key(key *datastore.Key) *KeyedInvitation

Key is a shorthand to fill a KeyedInvitation with an entity and it's key.

func (Invitation) Put

func (ƨ Invitation) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Invitation into Datastore using the given key.

func (Invitation) PutWithParent

func (ƨ Invitation) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Invitation as child of another entity. This will error if parent == nil.

type Invitations

type Invitations []Invitation

Invitations is just a slice of Invitation.

func (Invitations) Key

func (ƨ Invitations) Key(keys []*datastore.Key) (keyed []KeyedInvitation)

Key is a shorthand to fill a slice of KeyedInvitation with some entities alongside their keys.

type JunitTestResult

type JunitTestResult struct {
	Stdout string `datastore:",noindex"`
	Stderr string `datastore:",noindex"`
	Exit   string `datastore:",noindex"`

	Start time.Time `datastore:",index"`
	End   time.Time `datastore:",index"`

	Results  UnitTestResults `datastore:",noindex"`
	Endpoint string
}

JunitTestResult is a submission to a set of JUnit test cases. Besides the uploaded code, it also encapsulates more detailed results generated by JUnit.

func (*JunitTestResult) Key

Key is a shorthand to fill a KeyedJunitTestResult with an entity and it's key.

func (JunitTestResult) Put

Put will put this JunitTestResult into Datastore using the given key.

func (JunitTestResult) PutWithParent

func (ƨ JunitTestResult) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this JunitTestResult as child of another entity. This will error if parent == nil.

type JunitTestResults

type JunitTestResults []JunitTestResult

JunitTestResults is just a slice of JunitTestResult.

func (JunitTestResults) Key

func (ƨ JunitTestResults) Key(keys []*datastore.Key) (keyed []KeyedJunitTestResult)

Key is a shorthand to fill a slice of KeyedJunitTestResult with some entities alongside their keys.

type KeyedChallenge

type KeyedChallenge struct {
	*Challenge
	Key *datastore.Key
}

KeyedChallenge is a struct that embeds Challenge and also contains a Key, mainly used for encoding to JSON.

type KeyedCoderJunitTestResult

type KeyedCoderJunitTestResult struct {
	*CoderJunitTestResult
	Key *datastore.Key
}

KeyedCoderJunitTestResult is a struct that embeds CoderJunitTestResult and also contains a Key, mainly used for encoding to JSON.

type KeyedCompany

type KeyedCompany struct {
	*Company
	Key *datastore.Key
}

KeyedCompany is a struct that embeds Company and also contains a Key, mainly used for encoding to JSON.

type KeyedDiffTestResult

type KeyedDiffTestResult struct {
	*DiffTestResult
	Key *datastore.Key
}

KeyedDiffTestResult is a struct that embeds DiffTestResult and also contains a Key, mainly used for encoding to JSON.

type KeyedInvitation

type KeyedInvitation struct {
	*Invitation
	Key *datastore.Key
}

KeyedInvitation is a struct that embeds Invitation and also contains a Key, mainly used for encoding to JSON.

type KeyedJunitTestResult

type KeyedJunitTestResult struct {
	*JunitTestResult
	Key *datastore.Key
}

KeyedJunitTestResult is a struct that embeds JunitTestResult and also contains a Key, mainly used for encoding to JSON.

type KeyedProfile

type KeyedProfile struct {
	*Profile
	Key *datastore.Key
}

KeyedProfile is a struct that embeds Profile and also contains a Key, mainly used for encoding to JSON.

type KeyedResult

type KeyedResult struct {
	*Result
	Key *datastore.Key
}

KeyedResult is a struct that embeds Result and also contains a Key, mainly used for encoding to JSON.

type KeyedRobotTestResults

type KeyedRobotTestResults struct {
	*RobotTestResults
	Key *datastore.Key
}

KeyedRobotTestResults is a struct that embeds RobotTestResults and also contains a Key, mainly used for encoding to JSON.

type KeyedSubmission

type KeyedSubmission struct {
	*Submission
	Key *datastore.Key
}

KeyedSubmission is a struct that embeds Submission and also contains a Key, mainly used for encoding to JSON.

type KeyedTask

type KeyedTask struct {
	*Task
	Key *datastore.Key
}

KeyedTask is a struct that embeds Task and also contains a Key, mainly used for encoding to JSON.

type KeyedTemplate

type KeyedTemplate struct {
	*Template
	Key *datastore.Key
}

KeyedTemplate is a struct that embeds Template and also contains a Key, mainly used for encoding to JSON.

type KeyedTest

type KeyedTest struct {
	*Test
	Key *datastore.Key
}

KeyedTest is a struct that embeds Test and also contains a Key, mainly used for encoding to JSON.

type KeyedToken

type KeyedToken struct {
	*Token
	Key *datastore.Key
}

KeyedToken is a struct that embeds Token and also contains a Key, mainly used for encoding to JSON.

type KeyedUser

type KeyedUser struct {
	*User
	Key *datastore.Key
}

KeyedUser is a struct that embeds User and also contains a Key, mainly used for encoding to JSON.

type Map

type Map struct {
	Start, Finish, Max Position
	Coins, Obstacles   []Position
}

func (Map) CoinAt

func (m Map) CoinAt(p Position) bool

type Position

type Position struct {
	X,
	Y int
}

type Profile

type Profile struct {
	Skills     `datastore:",index",json:",omitempty"`
	LastUpdate time.Time `datastore:",index",json:",omitempty"`
}

Profile is the current rating of a User. It can vary over times as new Results come in and will be recomputed as needed. It is there to give a quick overview over the skills/performance of an individual user.

For short-timed challenges, the Profile should not be updated, but only when a final result was produced.

Long-term challenges may decide to refresh the competing user's Profile as pleased, but should not do so more than once a day.

Saved in Datastore, Profile will be a child entity to User, so keys pointing to a Profile can be used to obtain the user they represent.

func (*Profile) Key

func (ƨ *Profile) Key(key *datastore.Key) *KeyedProfile

Key is a shorthand to fill a KeyedProfile with an entity and it's key.

func (Profile) Put

func (ƨ Profile) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Profile into Datastore using the given key.

func (Profile) PutWithParent

func (ƨ Profile) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Profile as child of another entity. This will error if parent == nil.

type Profiles

type Profiles []Profile

Profiles is just a slice of Profile.

func (Profiles) Key

func (ƨ Profiles) Key(keys []*datastore.Key) (keyed []KeyedProfile)

Key is a shorthand to fill a slice of KeyedProfile with some entities alongside their keys.

type Result

type Result struct {
	// Calculated by logic from the Challenge. If
	// it is missing an average over all FinalSubmissions
	// will be computed at best effort.
	Skills Skills `datastore:",index",json:",omitempty"`

	// Challenge refers to the challenge that this
	// result provides data for.
	Challenge *datastore.Key `datastore:",index",json:",omitempty"`

	// Indicates when the user has started to work on
	// a Task (meaning as soon as the Task
	// is served to the user).
	//
	// In case all Tasks are available to the
	// user in parallel, it is possible that every
	// element of this slice holds the same value.
	// Anyway, the Challenge logic has to make sense
	// of this property and how to interpret it.
	//
	// Indexed the same as Challenge.Tasks.
	StartTimes []time.Time `datastore:",noindex",json:",omitempty"`

	// Points to the last submission to the
	// corresponding Task.
	//
	// Indexed the same as Challenge.Tasks.
	FinalSubmissions []*datastore.Key `datastore:",noindex",json:",omitempty"`

	// The time when the coder started the Challenge.
	Started time.Time `datastore:",index",json:",omitempty"`

	// The time when the coder finished the Challenge.
	Finished time.Time `datastore:",index",json:",omitempty"`

	// When this result was last (re)computed by the
	// Resulter in Challenge.
	Computed time.Time `datastore:",index",json:",omitempty"`
}

Result holds the performance of an User for some Challenge. It is fixed once the user has completed the Challenge or timed out. After that, only Skills are to be modified in case the logic in Challenge changes.

Saved in Datastore, Result will be a child entity to Profile, so keys pointing to a Result can be used to obtain the Profile they influence.

func (*Result) Key

func (ƨ *Result) Key(key *datastore.Key) *KeyedResult

Key is a shorthand to fill a KeyedResult with an entity and it's key.

func (Result) Put

func (ƨ Result) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Result into Datastore using the given key.

func (Result) PutWithParent

func (ƨ Result) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Result as child of another entity. This will error if parent == nil.

type Results

type Results []Result

Results is just a slice of Result.

func (Results) Key

func (ƨ Results) Key(keys []*datastore.Key) (keyed []KeyedResult)

Key is a shorthand to fill a slice of KeyedResult with some entities alongside their keys.

type RobotDirection

type RobotDirection int
const (
	Up RobotDirection = iota
	Right
	Down
	Left
)

type RobotEvent

type RobotEvent string

type RobotLogEntry

type RobotLogEntry struct {
	Position
	Event RobotEvent
}

func (RobotLogEntry) Move

func (*RobotLogEntry) Validate

func (p *RobotLogEntry) Validate(m *Map) bool

type RobotTestResults

type RobotTestResults struct {
	Failed        bool
	ReachedFinish bool
	Moves         []RobotLogEntry
}

func (*RobotTestResults) Key

Key is a shorthand to fill a KeyedRobotTestResults with an entity and it's key.

func (RobotTestResults) Put

Put will put this RobotTestResults into Datastore using the given key.

func (RobotTestResults) PutWithParent

func (ƨ RobotTestResults) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this RobotTestResults as child of another entity. This will error if parent == nil.

type RobotTestResultss

type RobotTestResultss []RobotTestResults

RobotTestResultss is just a slice of RobotTestResults.

func (RobotTestResultss) Key

func (ƨ RobotTestResultss) Key(keys []*datastore.Key) (keyed []KeyedRobotTestResults)

Key is a shorthand to fill a slice of KeyedRobotTestResults with some entities alongside their keys.

type Rusage

type Rusage struct {
	Utime,
	Stime syscall.Timeval
	Maxrss,
	Ixrss,
	Idrss,
	Isrss,
	Minflt,
	Majflt,
	Nswap,
	Inblock,
	Oublock,
	Msgsnd,
	Msgrcv,
	Nsignals,
	Nvcsw,
	Nivcsw int64 `json:",omitempty"`
}

Rusage is is a copy of syscall.Rusage for Linux. It is needed as syscall.Rusage built on Windows cannot be saved in Datastore because it holds unsigned integers. Runs are executed inside Docker and therefore will always generate this version of syscall.Rusage. See https://godoc.org/google.golang.org/cloud/datastore#Property See https://golang.org/src/syscall/syscall_windows.go See https://golang.org/src/syscall/ztypes_linux_amd64.go

type SimpleTestResult

type SimpleTestResult struct {
	Stdout  string `datastore:",noindex",json:",omitempty"`
	Stderr  string `datastore:",noindex",json:",omitempty"`
	Exit    string `datastore:",noindex",json:",omitempty"`
	Prepare string `datastore:",noindex",json:",omitempty"`

	Rusage Rusage    `datastore:",noindex",json:",omitempty"`
	Start  time.Time `datastore:",index",json:",omitempty"`
	End    time.Time `datastore:",index",json:",omitempty"`
}

type SkillWeights

type SkillWeights Skills

SkillWeights can be used to express what impact or rating a Task has on a set of Skills.

type Skills

type Skills struct {
	Readability,
	Security,
	CodingSpeed,
	Algorithmics float64 `json:",omitempty"`
}

Skills we assess.

TODO(flowlo, victorbalan): Add further categories of assessment.

func (Skills) Add

func (s Skills) Add(skills Skills) Skills

func (Skills) Div

func (s Skills) Div(skills Skills) Skills

func (Skills) DivBy

func (s Skills) DivBy(v float64) Skills

func (Skills) Mul

func (s Skills) Mul(skills Skills) Skills

type StoredObject

type StoredObject struct {
	// The bucket the object resides in.
	Bucket string

	// Name of the object inside the bucket.
	Name string
}

StoredObject refers to an object stored in Google Cloud Storage.

See https://cloud.google.com/storage/docs/concepts-techniques#concepts

type Submission

type Submission struct {
	Time     time.Time
	Task     *datastore.Key
	Code     StoredObject
	Language string
}

Submission is a form of result for some Task.

TODO(flowlo): As soon as we also store other submissions, implement a PropertyLoadSaver similar to this:

func (s *Submission) Load(ps []datastore.Property) error {
	return datastore.LoadStruct(s, ps)
}

func (s *Submission) Save() ([]datastore.Property, error) {
	if s.Code.Name != "" && s.Answers != nil {
		return nil, errors.New("cannot save Code and Answers in one Submission")
	}
	return ...
}

func (*Submission) Key

func (ƨ *Submission) Key(key *datastore.Key) *KeyedSubmission

Key is a shorthand to fill a KeyedSubmission with an entity and it's key.

func (Submission) Put

func (ƨ Submission) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Submission into Datastore using the given key.

func (Submission) PutWithParent

func (ƨ Submission) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Submission as child of another entity. This will error if parent == nil.

type Submissions

type Submissions []Submission

Submissions is just a slice of Submission.

func (Submissions) Key

func (ƨ Submissions) Key(keys []*datastore.Key) (keyed []KeyedSubmission)

Key is a shorthand to fill a slice of KeyedSubmission with some entities alongside their keys.

type Task

type Task struct {
	// Returns details on the assignment that is covered by this task.
	Assignment Assignment

	// Says what skills are needed/exercised to complete
	// the Task.
	SkillWeights SkillWeights

	// Refers to some logic that looks at the Submissions
	// of this task and produces a set of skills that
	// represent how well the user did in doing this Task.
	// It is to be weighted by SkillWeights.
	Tasker    int64                     `json:"-"`
	Templates map[string][]StoredObject `json:"-"`
	Languages []string                  `json:",omitempty"`
}

Task is a concrete piece of work that cannot be split any further.

This type is very general and can be implemented in vrious ways, accordingly implementing logic to make this Task comparable to others with respect to it's SkillWeights.

func (*Task) Key

func (ƨ *Task) Key(key *datastore.Key) *KeyedTask

Key is a shorthand to fill a KeyedTask with an entity and it's key.

func (*Task) Load

func (t *Task) Load(ps []datastore.Property) error

func (Task) Put

func (ƨ Task) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Task into Datastore using the given key.

func (Task) PutWithParent

func (ƨ Task) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Task as child of another entity. This will error if parent == nil.

func (*Task) Save

func (t *Task) Save() ([]datastore.Property, error)

type Tasks

type Tasks []Task

Tasks is just a slice of Task.

func (Tasks) Key

func (ƨ Tasks) Key(keys []*datastore.Key) (keyed []KeyedTask)

Key is a shorthand to fill a slice of KeyedTask with some entities alongside their keys.

type Template

type Template struct {
	Language  string         `datastore:",index"`
	Path      string         `datastore:",noindex"`
	Challenge *datastore.Key `datastore:",index"`
}

Template contains data about a code template assigned to a Task

func (*Template) Key

func (ƨ *Template) Key(key *datastore.Key) *KeyedTemplate

Key is a shorthand to fill a KeyedTemplate with an entity and it's key.

func (Template) Put

func (ƨ Template) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Template into Datastore using the given key.

func (Template) PutWithParent

func (ƨ Template) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Template as child of another entity. This will error if parent == nil.

type Templates

type Templates []Template

Templates is just a slice of Template.

func (Templates) Key

func (ƨ Templates) Key(keys []*datastore.Key) (keyed []KeyedTemplate)

Key is a shorthand to fill a slice of KeyedTemplate with some entities alongside their keys.

type Test

type Test struct {
	Tester int64
	Name   string
	Params map[string]string
}

func (*Test) Key

func (ƨ *Test) Key(key *datastore.Key) *KeyedTest

Key is a shorthand to fill a KeyedTest with an entity and it's key.

func (*Test) Load

func (t *Test) Load(ps []datastore.Property) error

func (Test) Put

func (ƨ Test) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Test into Datastore using the given key.

func (Test) PutWithParent

func (ƨ Test) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Test as child of another entity. This will error if parent == nil.

func (*Test) Save

func (t *Test) Save() ([]datastore.Property, error)

type TestCase

type TestCase struct {
	Name     string        `xml:"name,attr"`
	Duration time.Duration `xml:"time,attr"`
	Failure  Failure       `xml:"failure"`
}

TestCase holds a test case created by JUnit.

type TestResult

type TestResult struct{}

type TestStats

type TestStats struct {
	Stdout,
	Stderr string
	Test   *datastore.Key
	Failed bool
}

type Tests

type Tests []Test

Tests is just a slice of Test.

func (Tests) Key

func (ƨ Tests) Key(keys []*datastore.Key) (keyed []KeyedTest)

Key is a shorthand to fill a slice of KeyedTest with some entities alongside their keys.

type Token

type Token struct {
	// Corresponds to the crypto.Hash that was used to hash the value
	// of this Token.
	// It is an int and not a crypto.Hash because the base type of
	// crypto.Hash is uint (go1) and unsigned types cannot be stored by
	// Datastore.
	// A conversion is needed at runtime:
	//
	//	hash := crypto.Hash(Token.Hash)
	//
	Hash int `datastore:",noindex",json:",omitempty"`

	// The digest of this Token after hashing with above hash.
	Digest []byte `datastore:",noindex",json:",omitempty"`

	// If a User is authenticated using an Token, authorization
	// can be granted to only a subset of possible actions. This slice
	// acts as a filter and should list allowed scopes, i.e. permissions.
	Scopes []string `datastore:",noindex",json:",omitempty"`

	// Arbitrary string describing the use of this token. It can be
	// automatically generated or set by the user.
	Description string `datastore:",noindex",json:",omitempty"`

	// Time of creation.
	Creation time.Time `datastore:",noindex",json:",omitempty"`

	// If an Token is seen after Expiry, it is to be deleted. This property
	// is indexed to enable for grabage collection of expired Tokens.
	Expiry time.Time `datastore:",index",json:",omitempty"`

	// Address of the client that created this Token.
	RemoteAddr string `datastore:",noindex",json:",omitempty"`
}

Token encapsulates a digest of a secret that can be used to authenticate a User. The entity only holds a digest to prevent impersonation of a user in case it is leaked.

When requests arrive, the correct Token is queried by key, therefore these entities use indexes vary sparingly.

Tokens reside in an entity group rooted at a User. As Tokens cannot be altered by the user, writes are only done at creation and deletion and are therefore neglegible.

func (*Token) Key

func (ƨ *Token) Key(key *datastore.Key) *KeyedToken

Key is a shorthand to fill a KeyedToken with an entity and it's key.

func (Token) Put

func (ƨ Token) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this Token into Datastore using the given key.

func (Token) PutWithParent

func (ƨ Token) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this Token as child of another entity. This will error if parent == nil.

type Tokens

type Tokens []Token

Tokens is just a slice of Token.

func (Tokens) Key

func (ƨ Tokens) Key(keys []*datastore.Key) (keyed []KeyedToken)

Key is a shorthand to fill a slice of KeyedToken with some entities alongside their keys.

type UnitTestResults

type UnitTestResults struct {
	Tests    int        `xml:"tests,attr"`
	Failures int        `xml:"failures,attr"`
	Errors   int        `xml:"errors,attr"`
	TestCase []TestCase `xml:"testcase"`
}

UnitTestResults holds the unit test result created by JUnit.

type User

type User struct {
	// Encapsulates Name (combined first and last name,
	// however the user likes) and an e-mail address.
	//
	// Datastore will split this into two properties
	// called Name and Address, where Address must be
	// guaranteed to be unique.
	mail.Address `datastore:",index",json:",omitempty"`

	// Unique name for this user, like analogous to @flowlo
	// on GitHub/Twitter/...
	Nick string `datastore:",index",json:",omitempty"`

	// Points to the company a user works for, if any.
	Company *datastore.Key `datastore:",index",json:",omitempty"`

	// Hashed and salted password to be accessed by
	// corresponding helpers in util.
	// See https://godoc.org/golang.org/x/crypto/bcrypt
	HashedPassword []byte `datastore:",noindex" json:"-"`
}

User is anybody interacting with our systems. It will ultimately refer to who accessed Coduno (or on whose behalf).

func (*User) Key

func (ƨ *User) Key(key *datastore.Key) *KeyedUser

Key is a shorthand to fill a KeyedUser with an entity and it's key.

func (User) Put

func (ƨ User) Put(ctx context.Context, key *datastore.Key) (*datastore.Key, error)

Put will put this User into Datastore using the given key.

func (User) PutWithParent

func (ƨ User) PutWithParent(ctx context.Context, parent *datastore.Key) (*datastore.Key, error)

PutWithParent can be used to save this User as child of another entity. This will error if parent == nil.

type Users

type Users []User

Users is just a slice of User.

func (Users) Key

func (ƨ Users) Key(keys []*datastore.Key) (keyed []KeyedUser)

Key is a shorthand to fill a slice of KeyedUser with some entities alongside their keys.

Jump to

Keyboard shortcuts

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