Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrScoreNotFound = errors.New("score not found in string")
ErrScoreNotFound is returned if the parse string did not contain a JSON score string.
var GlobalSecret = "NOT SET"
GlobalSecret represents the unique course identifier that will be used in the Score constructors. Users of this package must set this variable appropriately (for example in func init) before using any exported function in this package. The value of the global secret is available from the teachers panel after a course has been created.
Functions ¶
Types ¶
type GradingScheme ¶
type GradingScheme struct { ID uint64 `json:"id"` Name string GradePoints []uint8 GradeNames []string }
GradingScheme for an assignment
func (*GradingScheme) Grade ¶
func (g *GradingScheme) Grade(points uint8) string
Grade computes the grade for the given points. The points must be in the range [0,100].
type Score ¶
type Score struct { Secret string // the unique identifier for the course TestName string // name of the test Score int // the score obtained MaxScore int // max score possible to get on this specific test Weight int // the weight of this test; used to compute final grade }
Score encodes the score of a test or a group of tests. When a test passes in Autograder, a JSON object representing this struct is emitted to the output stream.
The JSON object emitted on the output stream contains a Secret hash value which is a unique course identifier that can be obtained from the teachers panel in Autograder. This Secret is used by Autograder to extract Score objects from the output stream. All other output is ignored when computing the score.
The Autograder computes the score accoring to the formula below, providing a percentage score for a test or a group of tests. The Weight parameter can be used to give more/less value to some Score objects (representing different test sets). For example, a Weight of 2 on test A and a Weight of 1 on all other tests will give twice the score for test A compare to the other tests.
If you want to only give a score for completing a test, then you can simply use NewScoreMax(1, 1), without using any API methods to decrement the score, giving a result of Score = MaxScore = 1 (and Weight = 1).
The Autograder computes the final score as follows: TotalWeight = sum(Weight) TaskScore[i] = Score[i] / MaxScore[i], gives {0 < TaskScore < 1} TaskWeight[i] = Weight[i] / TotalWeight Score = sum(TaskScore[i]*TaskWeight[i]), gives {0 < Score < 1}
func NewScore ¶
NewScore returns a new Score object with the given max and weight. The Score.Score field is 0 initially, and so Score.Inc() and IncBy() can be called on the returned Score object. Note that the TestName is initialized to the name of the calling method.
func NewScoreMax ¶
NewScoreMax returns a new Score object with the given max and weight. The Score.Score field is max initially, and so Score.Dec() and DecBy() can be called on the returned Score object. Note that the TestName is initialized to the name of the calling method.
func (*Score) String ¶
String returns a string representation of score s. Format: "TestName: 2/10 cases passed".
func (*Score) WriteString ¶
WriteString writes the string representation of s to w.