pack

package
v0.1.44 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2026 License: Apache-2.0 Imports: 20 Imported by: 0 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 pack reads published packages of modules as the bench needs them: the server part, server.json, by the types of spec's canonical view and without module-kit, checked through the chain of digests from a pinned module index. It translates the canonical view into what learner-model and engine take, as api would.

Index

Constants

Format is the version of the module format the bench reads in a package a build wrote, the version of the format text it is built on: while the format is v0, the platform reads only the current version, the one module-kit builds.

Variables

View Source
var ErrDigest = errors.New("pack: a digest does not match")

ErrDigest is a file whose SHA-256 is not the one the chain of digests names.

View Source
var ErrFormat = errors.New("pack: a version of the module format outside the window")

ErrFormat is a package of a version of the format the bench does not read: a package a build wrote of another version than Format, or a published one of none of the releases' versions.

View Source
var ErrIdentity = errors.New("pack: the package is not the version its entry names")

ErrIdentity is a package that is not the module and version its entry names.

View Source
var ErrNoTask = errors.New("pack: no such task in the module")

ErrNoTask is a task the module has not.

View Source
var ErrTranslate = errors.New("pack: the canonical view cannot be translated")

ErrTranslate is a canonical view the bench cannot translate.

View Source
var ErrWithdrawn = errors.New("pack: the version is withdrawn from publication")

ErrWithdrawn is a version the index marks withdrawn from publication: api begins no attempt on it, and the bench reads none.

Functions

func Digest

func Digest(data []byte) formatv0.Digest

Digest gives the SHA-256 of a file as the format writes a digest: the package digest, when the file is a package's inventory.json.

func Entry

Entry gives the entry of a version of a module in an index, if the bench may read it: one the index names, of a version of the format the bench reads in a release, and not withdrawn.

func Needs added in v0.1.44

func Needs(g learnermodel.Graph, id string) []string

Needs gives the skills of a graph a skill needs: its prerequisites among them, and theirs, each once. An anchor skill is no skill of the graph, and it is none of them.

func ReadFiles

func ReadFiles(inventory, server []byte, e *formatv0.Entry) (*formatv0.CanonicalView, *formatv0.Inventory, error)

ReadFiles reads a package from its inventory.json and server.json, as a folder holds them: the digest and size of server.json must be the inventory's, whatever the version of the format, since the inventory keeps server_part in every version; that version must be one the bench reads, and the manifest must name the module, the version and the version of the format the inventory names; server.json is read by the types of the canonical view, and what of it the bench does not read — the areas of the skills, the reading list — is passed over, never refused. With an entry of an index, the SHA-256 of inventory.json must be the entry's package digest and its version of the format the entry's: the chain of digests from the index. With none, the package is one a build wrote, which no index names yet, and only of Format. The inventory comes back whenever it could be read, so that a caller can tell a package of a version of the format the bench does not read.

func ReadIndex

func ReadIndex(data []byte, digest string) (*formatv0.ModuleIndex, error)

ReadIndex reads a module index whose SHA-256, in hex, must be digest: the digest the gate file pins, as the configuration of api pins it. It reads the index's members by their places alone, whatever version of the format the index is of: a reader skips an entry whose format version it does not read, rather than refuse the index, and Entry does that.

func ReadPackage

func ReadPackage(archive []byte, id formatv0.ModuleID, version formatv0.ModuleVersion, e formatv0.Entry) (*formatv0.CanonicalView, error)

ReadPackage reads the server part of the archive of a version of a module whose entry in the index is e: the SHA-256 of its inventory.json must be the entry's package digest, and the digest and size of server.json the inventory's; the inventory and the manifest must name the module, the version and the version of the format the entry names; server.json is read by the types of the canonical view.

func Untar

func Untar(archive []byte) (map[string][]byte, error)

Untar gives the regular files of a package's archive, by name. The archive is a gzip of a tar of 512-byte blocks: a header — the name in its first 100 bytes, the size in octal at 124, the type at 156 — then the file's blocks; the packages name their files short, with no ustar prefix. It is read here, as engine's test reads it, since archive/tar would pull os/user, whose cgo the rules of code cannot type-check for every target.

Types

type Lesson

type Lesson struct {
	Lesson engine.Lesson
	Links  int // its segments: explanations, worked examples and tasks, in the author's order
	// Order gives each link in the author's order: the index of its task in Lesson.Tasks, or -1 for
	// an explanation or a worked example.
	Order []int
	Ages  []string // its own age categories; none, the module's
}

Lesson is a lesson of the module: what engine takes of it, and its links beside.

type Module

type Module struct {
	ID    string
	Graph learnermodel.Graph // by learnermodel.NewGraph, for both libraries
	Ages  []string           // the module's age categories, its audience
	Tasks []Task             // ordered by full ID
	// Lessons are the module's lessons, ordered by full ID.
	Lessons []Lesson
	// Areas give the area of each skill of the graph, ordered by full ID, as engine takes them for
	// the goal for the tutor: skill_areas of the package, or, where the package has no area of a
	// skill — a version of the format before 0.6 has none —, the fallback area of its subject.
	Areas []engine.SkillArea
}

Module is a module as the bench reads it: the graph and the inputs of engine, translated once from the canonical view, and what the virtual learners need beside them.

func Translate

func Translate(cv *formatv0.CanonicalView) (*Module, error)

Translate reads a canonical view into the bench's module: full IDs — the module, the kind and the local ID joined by / —, anchor skills as they are; bands by place from the manifest; tiers from skill_tiers; a slot's kind of check and a choice's number of options, whether they stand beside the check or in it; a check by a rubric gives no slot with a verdict; of a leading question, only that the task has one. The graph is learner-model's own NewGraph, so that sim and api build one graph of one module alike.

func (*Module) ForAge

func (m *Module) ForAge(age string) ([]engine.Candidate, []engine.Lesson)

ForAge gives the pool and the lessons as api gives them to a learner of an age category: the tasks that suit them, and the lessons that suit them whose every task does too. The age category is api's filter, not an input of engine.

func (*Module) Instance

func (m *Module) Instance(id string, attemptSeed uint64) (int, formatv0.Numbers, error)

Instance gives the instance of a template an attempt with seed attemptSeed takes: its number, chosen as the platform chooses it — the place names the task's ID in the module, as the format's task has it —, and its numbers, read from the canonical view, whose instances are in that order. A task that is no template has no instance.

func (*Module) Task

func (m *Module) Task(id string) (*Task, error)

Task gives a task of the module by its full ID.

func (*Module) Text

func (m *Module) Text() ([]byte, error)

Text gives the canonical text of what the bench reads of the module for the populations of the gate: the module translated — its graph with the bands and the tiers, its audience, its tasks with their items, slots, traps, canvases and ages, whether each has a leading question and the numbers of each template's instances, its lessons, and the area of each skill, which the populations of the goal for the tutor read —, as JSON, whose fields keep their order and whose maps are written by their keys. What Translate does not read — the texts for the learner, the leading question's own words among them, the version — is not in it: two packages give the same text when the gate's populations read the same of them.

type Task

type Task struct {
	Candidate engine.Candidate // the task as engine takes it, with the traps of its items
	Local     string           // its ID in the module
	Canvas    formatv0.CanvasKind
	Rubric    bool     // a task with a rubric: no verdict and no evidence
	Ages      []string // its own age categories; none, the module's
	Instances int      // the number of instances of a template; 0 for a task
	// Leading tells that the task has a leading question, which a hint asked for gives before the
	// first wrong answer. The bench reads that it has one, not its text.
	Leading bool
	// contains filtered or unexported fields
}

Task is a task of the module: what engine takes of it, and what the bench reads beside.

func (*Task) ItemPrimary

func (t *Task) ItemPrimary(i int) []string

ItemPrimary gives the primary skills of the item at index i of the task: the item's own, when it has skills of its own, and the task's otherwise. The truth, the engine's results and the measures read an item's skills by this one rule.

Jump to

Keyboard shortcuts

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