design

package
v0.0.0-...-98441cc Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2019 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AbstractEntry = Type("AbstractEntry", func() {
	Description("Abstracts the common attributes from EntryPayload and EntryFormPayload")
	Attribute("contestSlug", String, "Contest unique and human readable string identifier", func() {
		Pattern("[_a-zA-Z0-9\\-]+")
		Example("con_test")
		Default("")
	})
	Attribute("taskSlug", String, "Task unique and human readable string identifier", func() {
		Pattern("[_a-zA-Z0-9\\-]+")
		Example("simpleBatch-95")
		Default("")
	})
	Attribute("language", String,
		`Identifies the programming language used in the entry's content. The special keyword "none" should be used 
		instead when submitting plain text, which are used for user test inputs and  diff based grading`, func() {
			Default("")
			Example("Python 3")
		})
	Attribute("token", Boolean,
		`Identifies when an Entry has been processed using a CMS Entry Token. The default value is true, in other words 
		any submitted Entry will use a CMS Token`, func() {
			Default(true)
		})
})
View Source
var AbstractEntrySubmitTrx = Type("AbstractEntrySubmitTrx", func() {
	Description("Abstracts the common attributes from SubmitEntry and SubmitDraft transactional resources")
	Attribute("createdAt", DateTime, "Transaction creation timestamp")
	Attribute("updatedAt", DateTime, "Transaction last update timestamp")
	Attribute("status", String, "", func() {
		Enum(cmsAsyncUnprocessed, cmsAsyncSubmitted, cmsAsyncFailed, cmsAsyncEvaluated)
		Default(cmsAsyncUnprocessed)
	})
})
View Source
var CompilationResult = Type("CompilationResult", func() {
	Description(`Embedded representation of an entry compilation result. It can be unprocessed when compilation 
is pending, otherwise it should be either ok or fail.`)
	Attribute("status", String, "Execution result status", func() {

		Enum(cmsAsyncOK, cmsAsyncFail, cmsAsyncUnprocessed)
		Default(cmsAsyncUnprocessed)
	})
	Attribute("tries", Integer, "Compilation retries", func() {
		Default(0)
	})
	Attribute("stdout", String, "Compilation process' standard output", func() {
		Example(`Done`)
		Default("")
	})
	Attribute("stderr", String, "Compilation process' standard error", func() {
		Example(`batch.cpp: In function ‘int main()’:
batch.cpp:7:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &a, &b);
                           ^`)
		Default("")
	})
	Attribute("time", Number, "The spent execution CPU time", func() {
		Example(0.035)
		Default(0)
	})
	Attribute("wallClockTime", Number, "The spent execution human perceived time", func() {
		Example(0.568)
		Default(0)
	})
	Attribute("memory", Integer, "Memory consumed", func() {
		Example(64)
		Default(0)
	})
})
View Source
var DraftMedia = MediaType("application/vnd.com.jossemargt.sao.draft+json", func() {
	Description("Any source code or input to be compiled and executed against the user test case")
	Reference(AbstractEntry)

	Attributes(func() {
		Attribute("id", Integer, "Unique entry ID", func() {
			Example(1236)
		})
		Attribute("href", String, "API href for making requests on the entry", func() {
			Example("/drafts/1236")
		})
		Attribute("contestSlug")
		Attribute("contestID", Integer, "Contest ID where this Entry has been submitted", func() {
			Default(0)
		})
		Attribute("taskSlug")
		Attribute("taskID", Integer, "Task ID where this Entry has been submitted", func() {
			Default(0)
		})
		Attribute("userID", Integer, "User ID of the Entry's owner", func() {
			Default(0)
		})
		Attribute("language")
		Attribute("result", DraftResultMedia, "The entry processing result")

		Required("id", "href")
	})

	Links(func() {
		Link("result", "link")
	})

	View("link", func() {
		Attribute("id")
		Attribute("href")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("contestSlug")
		Attribute("taskSlug")
	})

	View("full", func() {
		Attribute("id")
		Attribute("href")
		Attribute("contestID")
		Attribute("contestSlug")
		Attribute("taskID")
		Attribute("taskSlug")
		Attribute("userID")
		Attribute("language")
		Attribute("links")
	})
})
View Source
var DraftResultMedia = MediaType("application/vnd.com.jossemargt.sao.draft-result+json", func() {
	Description("The representation of the result of an entry draft compile, execution and evaluation process")
	Attributes(func() {
		Attribute("id", String, "Compound Result ID", func() {
			Example("1236-5689")
		})
		Attribute("href", String, "API href for making requests on the result", func() {
			Example("/draft-results/1236-5689")
		})
		Attribute("compilation", CompilationResult, "Entry compilation result")
		Attribute("execution", ExecutionResult, "Entry execution result")
		Attribute("evaluation", EvaluationResult, "Entry evaluation result")

		Required("id", "href", "execution")
	})

	View("link", func() {
		Attribute("id")
		Attribute("href")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("execution")
	})

	View("full", func() {
		Attribute("id")
		Attribute("href")
		Attribute("compilation")
		Attribute("execution")
		Attribute("evaluation")
	})
})
View Source
var DraftSubmitTrx = MediaType("application/vnd.com.jossemargt.sao.draft-submit-transaction+json", func() {
	Description("Represents the process of queueing, compilation and execution of an Entry Draft")
	Reference(AbstractEntrySubmitTrx)

	Attributes(func() {
		Attribute("id", String, "Unique SubmitDraftTransaction ID", func() {
			Example("5cf4a17916fdac79059141a0")
		})
		Attribute("href", String, "API href for making requests on the entry", func() {
			Example("/draft-submit-transaction/1236")
		})
		Attribute("createdAt")
		Attribute("updatedAt")
		Attribute("status")

		Attribute("draft", DraftMedia, "The entry draft being processed on this transaction")

		Required("id", "href", "status")
	})

	Links(func() {
		Link("draft", "link")
	})

	View("link", func() {
		Attribute("id")
		Attribute("href")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("status")
	})

	View("full", func() {
		Attribute("id")
		Attribute("href")
		Attribute("status")
		Attribute("createdAt")
		Attribute("updatedAt")
		Attribute("links")
	})
})
View Source
var EntryMedia = MediaType("application/vnd.com.jossemargt.sao.entry+json", func() {
	Description("Any source code or input to be compiled, executed and evaluated")
	Reference(AbstractEntry)

	Attributes(func() {
		Attribute("id", Integer, "Unique entry ID", func() {
			Example(1236)
		})
		Attribute("href", String, "API href for making requests on the entry", func() {
			Example("/entries/1236")
		})
		Attribute("contestSlug")
		Attribute("contestID", Integer, "Contest ID where this Entry has been submitted", func() {
			Default(0)
		})
		Attribute("taskSlug")
		Attribute("taskID", Integer, "Task ID where this Entry has been submitted", func() {
			Default(0)
		})
		Attribute("userID", Integer, "User ID of the Entry's owner", func() {
			Default(0)
		})
		Attribute("token")
		Attribute("language")
		Attribute("result", ResultMedia, "The entry processing result")

		Required("id", "href")
	})

	Links(func() {
		Link("result", "link")
	})

	View("link", func() {
		Attribute("id")
		Attribute("href")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("contestSlug")
		Attribute("taskSlug")
		Attribute("token")
	})

	View("full", func() {
		Attribute("id")
		Attribute("href")
		Attribute("contestID")
		Attribute("contestSlug")
		Attribute("taskID")
		Attribute("taskSlug")
		Attribute("userID")
		Attribute("token")
		Attribute("language")
		Attribute("links")
	})
})
View Source
var EntryPayload = Type("EntryPayload", func() {
	Description("Any source code or input that should be compiled, executed or evaluated")
	Reference(AbstractEntry)
	Attribute("contestSlug")
	Attribute("taskSlug")
	Attribute("token")

	Attribute("sources", ArrayOf(SourceType), func() {
		Description("Source files representation. Within this list the source code files and input files can be sent alike.")
		MinLength(1)
	})

	Required("contestSlug", "taskSlug", "token", "sources")
})
View Source
var EntrySubmitTrx = MediaType("application/vnd.com.jossemargt.sao.entry-submit-transaction+json", func() {
	Description("Represents the process of queueing, compilation, evaluation and grading of an Entry")
	Reference(AbstractEntrySubmitTrx)

	Attributes(func() {
		Attribute("id", String, "Unique SubmitEntryTransaction ID", func() {
			Example("5cf4a17916fdac79059141a0")
		})
		Attribute("href", String, "API href for making requests on the entry", func() {
			Example("/entry-submit-transaction/1236")
		})
		Attribute("createdAt")
		Attribute("updatedAt")
		Attribute("status")

		Attribute("entry", EntryMedia, "The entry being processed on this transaction")

		Required("id", "href", "status")
	})

	Links(func() {
		Link("entry", "link")
	})

	View("link", func() {
		Attribute("id")
		Attribute("href")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("status")
	})

	View("full", func() {
		Attribute("id")
		Attribute("href")
		Attribute("status")
		Attribute("createdAt")
		Attribute("updatedAt")
		Attribute("links")
	})
})
View Source
var EvaluationResult = Type("EvaluationResult", func() {
	Description("Embedded representation of an entry evaluation result")
	Attribute("status", String, "Execution result status. It only indicates if the result has been evaluated or not", func() {

		Enum(cmsAsyncOK, cmsAsyncUnprocessed)
		Default(cmsAsyncUnprocessed)
	})
	Attribute("tries", Integer, "Evaluation retries", func() {
		Minimum(0)
		Default(0)
	})

})
View Source
var ExecutionResult = Type("ExecutionResult", func() {
	Description("Embedded representation of an entry execution result")
	Attribute("time", Number, "The spent execution CPU time", func() {
		Example(0.035)
		Default(0)
	})
	Attribute("wallClockTime", Number, "The spent execution human perceived time", func() {
		Example(0.568)
		Default(0)
	})
	Attribute("memory", Integer, "Memory consumed", func() {
		Example(64)
		Default(0)
	})
	Attribute("output", String, "Execution output", func() {
		Default("")
	})
})
View Source
var ResultMedia = MediaType("application/vnd.com.jossemargt.sao.result+json", func() {
	Description("The representation of the result of an entry compile, evaluation and grading process")
	Attributes(func() {
		Attribute("id", String, "Compound Result ID", func() {
			Example("1236-5689")
		})
		Attribute("href", String, "API href for making requests on the result", func() {
			Example("/results/1236-5689")
		})
		Attribute("compilation", CompilationResult, "Entry compilation result")
		Attribute("evaluation", EvaluationResult, "Entry evaluation result")
		Attribute("score", ScoreResult, "Entry graded score")

		Required("id", "href", "evaluation")
	})

	View("link", func() {
		Attribute("id")
		Attribute("href")
	})

	View("default", func() {
		Attribute("id")
		Attribute("href")
		Attribute("evaluation")
		Attribute("score")
	})

	View("full", func() {
		Attribute("id")
		Attribute("href")
		Attribute("compilation")
		Attribute("evaluation")
		Attribute("score")
	})
})
View Source
var ScoreResult = Type("ScoreResult", func() {
	Description("Embedded representation of the entry's scoring after being evaluated")
	Attribute("taskValue", Number, "The graded value relative to the Task score (percent of successful runs against task's  dataset)", func() {
		Example(80.00)
		Default(0)
	})
	Attribute("contestValue", Number, "The graded value relative to the Contest score", func() {
		Example(10.50)
		Default(0)
	})
})
View Source
var ScoreSumMedia = MediaType("application/vnd.com.jossemargt.sao.score-sum+json", func() {
	Description("The representation of a summarized entry's score")
	Attributes(func() {
		Attribute("contestID", Integer, "Contest Identifier associated with this score", func() {
			Example(1)
			Minimum(1)
		})
		Attribute("userID", Integer, "Contest Identifier associated with this score", func() {
			Example(1)
			Minimum(1)
		})
		Attribute("username", String, "Contest Identifier associated with this score", func() {
			Example("foobar")
		})
		Attribute("taskID", Integer, "Contest Identifier associated with this score", func() {
			Example(1)
			Minimum(1)
		})
		Attribute("taskValue", Number, "The graded value relative to the Task total score", func() {
			Example(100.00)
		})
		Attribute("contestValue", Number, "The graded value relative to the contest", func() {
			Example(25.00)
		})

		Required("contestValue", "taskValue")
	})

	View("default", func() {
		Attribute("contestID")
		Attribute("userID")
		Attribute("taskID")
		Attribute("taskValue")
		Attribute("contestValue")
	})
})
View Source
var SourceType = Type("EntrySource", func() {
	Description("Entry's embed type which represents a source file")
	Attribute("filename", String,
		`Source file name including its extension. This field's value should comply with the name format (fileid) 
		constraint declared by the Task resource. Taking the "batch.%l" format as example, the valid source code file 
		names could be "batch.py", "batch.cpp" or "batch.js"`, func() {
			Example("my_solution.py")
			Default("")
		})
	Attribute("fileid", String,
		`Also known as filepattern, and is expected to be sent along with the filename. This field is defined by the 
		Task resource`, func() {
			Example("my_solution.%l")
			Example("batch.cpp")
			Default("")
		})
	Attribute("content", String, "Source content", func() {
		Default("")
		Example(`#include <stdio.h>
int main() {
    int a, b;
    scanf("%d %d", &a, &b);
    printf("%d\\n", a+b);
    return 0;
}`)
		Example("1 2")
	})
	Attribute("language", String,
		`Identifies the programming language used in the entry's content. This attribute can be omitted for "plain text" files`,
		func() {
			Example("C++11 / g++")
			Example("Python 3")
			Default("")
		})
})

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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