verdict

package
v0.3.12 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: Apache-2.0 Imports: 9 Imported by: 3 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package verdict gives the verdict of an answer slot and of an item on the values read in them, by the check kinds of the module format and their normalization, with the reason of a value that cannot be read and the trap of a wrong one (format/README.md, section 15). api and tutor's eval runner call it through the package observation, which joins the observations of two readers and gives the verdict on the joined one (contracts/README.md, section 10; R29); the check of a module reads by it the rules of a task that the check of an answer slot sees itself.

OfItem and OfSlot give the verdict on values as they are written, Same compares two values as a check does, NormalForm gives a value as the kind normalizes it, ItemOf makes an item's verdict of its answer slots', and UnicodeVersion names the version of Unicode that the normalization follows (R27). A predicate runs in the sandbox of Starlark, and CheckPredicate holds the rule of its expression (R28). A rubric gives no verdict. The package imports no protobuf: the observation is the package observation's.

Index

Constants

View Source
const UnicodeVersion = normal.UnicodeVersion

UnicodeVersion is the version of Unicode that the normalization follows: that of the tables of NFKC the library is built with, which its tests hold equal to those of the standard library's package unicode. The format leaves the version to the reader's release, and this is where a release of module-kit names it (format/README.md, section 15; R27).

Variables

View Source
var ErrNoVerdict = errors.New("a rubric gives no verdict")

ErrNoVerdict is what the check of a rubric gives: a rubric gives feedback by its criteria, and the item it checks has no verdict.

View Source
var ErrPlaceholder = errors.New("the check holds the placeholder of a template, which an instance replaces with a number")

ErrPlaceholder is what the check of a number or a fraction gives when its key or a trap value holds the placeholder of a template: the check is a template's, and an instance of it replaces the placeholder with a number (format/README.md, section 23).

Functions

func CheckPredicate added in v0.1.15

func CheckPredicate(expression string) error

CheckPredicate says whether the expression of a predicate is one of the dialect of all the Starlark of the format, which names nothing but value, the names that it binds itself and the built-in names of the dialect: the rule task.predicate-expression (format/README.md, sections 15 and 24). The error says why not, at the line and the column where go.starlark.net finds it. A predicate that is not gives unchecked on every value in its notation.

func NormalForm added in v0.1.16

func NormalForm(slot AnswerSlot, value string) (form string, inNotation bool)

NormalForm gives a value as the check of an answer slot normalizes it, and whether it is in the kind's notation, with no Starlark (format/README.md, section 15): for a choice, its normal form by its notation, in the notation when it is the key's or an option's, or, with notation: word, one word of letters; for a number, a fraction and a predicate, steps 1 to 7, with a number's units dropped, in the notation when the kind takes what is left; for a time, steps 1 to 5 with the spaces at either end dropped, in the notation when it is a time read. An empty form is blank, and in no notation. A rubric normalizes nothing: the form is the value as it is, in no notation, and so is a value that is not UTF-8. The joining of two readings compares the values out of the notation by it (contracts/README.md, section 10).

func Same

func Same(slot AnswerSlot, a, b string) bool

Same says whether the check of an answer slot compares two values equal, as it compares a value with a trap value, after the same normalization (format/README.md, section 15): for a choice, the same normal form, an option or not, empty too; for a number and a fraction, two values in the kind's notation, of one value; for a predicate, the same integer. A rubric compares nothing, and a value that is not UTF-8 is equal to none.

A value out of a number's notation is equal to nothing here. The joining of two readings joins such values by their normal forms, NormalForm, and keeps apart a value out of the notation from one in it, which its normal form can spell, as 1/100000000000000 does (contracts/README.md, section 10).

Types

type AnswerSlot

type AnswerSlot struct {
	Binding string
	Check   formatv0.Check
	Options []formatv0.Text
}

AnswerSlot is an answer slot of an item as its check reads it: its binding as the format writes it — anywhere, sheet, zone, choice or box (format/README.md, section 14) — its check, and, when it is bound choice, its options, of which the learner taps one.

func AnswerSlots

func AnswerSlots(item formatv0.Item) []AnswerSlot

AnswerSlots gives the answer slots of an item, in their order: on a handwriting sheet its answer_slots, on a workbook the boxes of its line (format/README.md, section 14).

func (AnswerSlot) ChoiceOptions

func (s AnswerSlot) ChoiceOptions() []formatv0.Text

ChoiceOptions gives the options of a choice as written: the answer slot's when it is bound choice, and the check's own otherwise (format/README.md, section 15).

type ItemVerdict

type ItemVerdict struct {
	Verdict Verdict
	Slots   []SlotVerdict
}

ItemVerdict is the verdict of an item, made of the verdicts of its answer slots, which it holds in their order.

func OfItem

func OfItem(ctx context.Context, item formatv0.Item, values []*string) (ItemVerdict, error)

OfItem gives the verdict of an item on the values read in its answer slots, one for each, in the order of AnswerSlots: a value as it is written, or nil when nothing was read (format/README.md, section 15). An error gives no verdict: ctx is done, the item has no answer slots, the values are not one for each answer slot, or OfSlot gives one for an answer slot — ErrNoVerdict for an item that a rubric checks, and the error of ctx when it stops a predicate as it runs.

type Reason

type Reason string

Reason is why an answer slot is unreadable, as the format and the contracts write it: blank and notation, which a check kind gives itself (format/README.md, section 15), and the reasons that a reading gives before the value is judged, each named after a reason of the observation (contracts/README.md, section 10).

const (
	Blank    Reason = "blank"    // nothing was read, or nothing is left once the value is normalized
	Notation Reason = "notation" // the value is not in the kind's notation
)

The reasons that a check kind gives.

const (
	Illegible           Reason = "illegible"             // something is written, and it cannot be read
	Ambiguous           Reason = "ambiguous"             // it can be read more than one way, or two readers read it differently
	NoFinalAnswer       Reason = "no_final_answer"       // in a slot bound anywhere: the work holds no final answer
	SeveralFinalAnswers Reason = "several_final_answers" // in a slot bound anywhere: the work holds more than one
)

The reasons that a reading gives, by the table of contracts/README.md, section 10, which the package observation reads them by.

type SlotVerdict

type SlotVerdict struct {
	Verdict Verdict
	Reason  Reason
	Trap    *formatv0.TrapValue
}

SlotVerdict is the verdict of an answer slot: with its reason when it is Unreadable, and with the trap value that the value matches, a copy of it, when it is NotYet and matches one — the trap it shows, and the text that the learner reads after it, if the author wrote one (format/README.md, sections 15 and 19).

func OfSlot

func OfSlot(ctx context.Context, slot AnswerSlot, value *string) (SlotVerdict, error)

OfSlot gives the verdict of an answer slot on the value read in it: the value as it is written, or nil when nothing was read (format/README.md, section 15). The value and the trap values are normalized as the check kind normalizes them, and the key is read as it is written, in the kind's notation. A predicate on a value in its notation runs in the sandbox of Starlark, with the limits of a predicate and ctx (format/README.md, section 15; R11): True is correct and False not_yet, and an error, a result that is not a bool, the limit of steps, module-kit's clock and a panic of the interpreter are unchecked.

An error gives no verdict: ctx is done before the verdict, or stops a predicate as it runs — a predicate that its limit of steps, the clock or a panic stopped first, or that ended, gives its verdict; the value is not UTF-8; the check is one that the format does not take — its kind is none of the five, a number, a fraction or a choice has no key, the key of a number or a fraction is not in its notation, it or a trap value holds the placeholder of a template, ErrPlaceholder, a choice has no options, or a predicate no expression; or the check is a rubric, ErrNoVerdict. A check that breaks a rule of the format that the check sees itself — a key that is none of the options, two options alike, a key of a fraction in lowest terms that can be reduced, a trap value that is not wrong, a predicate that is no expression of the dialect — still gives its verdict, so that the check of a module reads those rules by it.

type Verdict

type Verdict string

Verdict is the verdict of an answer slot or of an item, as the format writes it (format/README.md, section 15).

const (
	Correct    Verdict = "correct"    // the value is right
	NotYet     Verdict = "not_yet"    // the value is in the kind's notation and is not right
	Unreadable Verdict = "unreadable" // the learner is asked to write the answer again, which is no wrong answer
	Unchecked  Verdict = "unchecked"  // the check could not run
)

The verdicts.

func ItemOf added in v0.1.16

func ItemOf(slots []SlotVerdict) Verdict

ItemOf gives the verdict of an item, made of its answer slots' verdicts: unchecked when there are none, since nothing was checked; correct when every one is; otherwise not_yet when one is, since a value read clearly and wrong is no doubt; otherwise unreadable when one is; otherwise unchecked (format/README.md, section 15). The verdict on an observation makes an item's of its answer slots' by it.

Jump to

Keyboard shortcuts

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