Documentation
¶
Overview ¶
Package engine is NovaTrail's engine: it picks a learner's next lesson or task by a rule, and gives the choice a reason code, which the adult sees and the learner is not told.
It is a library with no input or output of its own. The api service — at stage 1, the learner simulator, sim — hands it the learner model's estimates, the skill graphs of the learner's modules, the lessons and the pool of tasks, the learner's lesson runs, and a summary of what has been handed out before, and passes the time in as a number; api keeps every choice the library makes. The library estimates no mastery — that is the learner model's — gives no verdict, calls no AI model, reads no module package or database, and keeps nothing between calls. The rule takes no randomness, so it takes no seed.
The same input gives the same choice and the same reason code, bit for bit, on any build by Go's gc compiler of one version of this module and of the learner model — on any architecture it knows, WebAssembly included, with any Go no older than go.mod names. The code imports nothing but Go's standard library and the learner model, and only the packages its rules allow.
Index ¶
- Variables
- func AreaLeft(in Input) (bool, error)
- type Candidate
- type Choice
- type ChoiceKind
- type Input
- type ItemTraps
- type Last
- type Lesson
- type Module
- type ModuleChoices
- type OrderedLesson
- type PreviewSkill
- type ReasonCode
- type RubricDone
- type Run
- type RunEnd
- type SkillArea
- type SkillIssue
- type SkillResult
- type Summary
- type TaskSolution
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("engine: invalid input")
ErrInvalid is an input that breaks a rule the engine relies on: a choice is never made of it. It comes as a value and never by panicking; errors.Is tells it apart, and the message says what and where. An error of learner-model the input brought, from Readout.Task, is wrapped, so that errors.Is finds learner-model's kind too.
Functions ¶
func AreaLeft ¶ added in v0.1.25
AreaLeft tells whether the area of the goal for the tutor, in.Goal, has a skill left, within reach now or once the learner grows: a skill of the area with a verdict, in a module of the engine, not mastered by the learner model, and primary in an item with a verdict of a task of its module's pool, which api gives by the age category whatever the route to AI. False is the engine's word that the area has nothing left — each of its skills mastered or with no task to practise it —, by which api ends the goal as reached; with no goal it is false too, and there is no goal to end.
A skill out of reach for now — below the corridor, behind prerequisites not met, or waiting for a lesson of the author's order — is left: it comes within reach as the learner grows, and until then the goal's level and its month are what end the goal. So the answer depends neither on the lesson runs, a pause after a lesson or a solution seen, nor on the choices before — the count of the choices across the modules, each module's own — and a module's placement. A skill its package has retired is in no graph of the current version, and so in no area. A skill of the preview is left, so with none left the preview is empty; an empty preview does not say that none is left.
It reads neither MapSkill nor Summary.AcrossChoices, but for the check of the count. It writes nothing, neither to its input nor anywhere else, and the same input gives the same answer, whatever the order of its lists. It refuses, with ErrInvalid, what PreviewGoal refuses.
Types ¶
type Candidate ¶
type Candidate struct {
Task learnermodel.Task
Traps []ItemTraps
}
Candidate is a task of the pool: its description, and the traps of its items.
type Choice ¶
type Choice struct {
Kind ChoiceKind
ID string
Reason ReasonCode
}
Choice is the engine's choice: a lesson or a task by its full ID — of a template, the template's — or nothing to give, with no ID; and the reason code of the branch that made it, ReasonUnspecified beside nothing to give. Beside ReasonToGoal, api gives the goal's area as the choice's goal_item, and keeps it with the choice.
func Choose ¶
Choose picks what the learner is given next, and the reason code of the choice. It refuses, with ErrInvalid, an input whose rules it relies on are broken: a module, a task of the pool or a lesson twice by ID; a skill of a graph, a task of the pool or a lesson that is not its module's by ID; a skill of a lesson that is not in the graph of its module; the traps of an item twice, or at a place where its task has no item; a run's end outside its list, an open run with a time of its end, and two open runs of one lesson; a skill, a module or a task twice in the summary, and a reason code of the summary outside its list; a skill twice in the results of the last attempt, and a result with first right verdicts fewer than none or more than its first verdicts; a module of the engine with no reading of the learner model, and an anchor skill a graph names with none or with a status off its list; a candidate task the reading refuses, or one with the P of an item outside [0, 1], NaN and the infinities included; and what the goal's checks refuse, as PreviewGoal says. The checks run in one order and each names the least ID that breaks it, so that the order of the input's lists does not change the error either.
Choose runs the rule: the lesson of an open run; then on the skill chosen on the map, or in "My subjects" — consolidation in the module of the last closed attempt, then, on a turn of the goal for the tutor, the first skill of its area, then the modules in turn, with the repetition, the lessons on the new and the author's order —; then a second pass with the tasks on pause, and gives a lesson or a task with the code of its branch, or nothing to give. Two choices across the modules of every three, by Summary.AcrossChoices, are the goal's turns, and the third is the modules' turn as with no goal.
type ChoiceKind ¶
type ChoiceKind int32
ChoiceKind is what a choice gives: ChoiceKind of cause.proto, names and numbers.
const ( ChoiceUnspecified ChoiceKind = 0 // never given ChoiceLesson ChoiceKind = 1 ChoiceTask ChoiceKind = 2 // a task outside a lesson ChoiceNothing ChoiceKind = 3 )
type Input ¶
type Input struct {
Time int64 // the time of the choice
// The learner model's reading at Time, by learnermodel.Read: the modules of the engine and
// the modules of the evidence log.
Readout learnermodel.Readout
Modules []Module // the modules of the engine: connected, and suited to the learner
// The full ID of the skill the learner chose on the skill map; empty in "My subjects".
MapSkill string
Runs []Run // the lesson runs of the profile in the modules of the engine
RubricDone []RubricDone // the attempts of tasks with a rubric closed by "Done"
Last Last // the last closed attempt of the profile, when HasLast
HasLast bool
Summary Summary // what was handed out before
// The goal for the tutor of the profile: one area, by its code in the closed list of the module
// format; empty — no goal. The rule of the goal reads it, with Module.Areas, in a choice across
// the modules — MapSkill empty —, in PreviewGoal and in AreaLeft. The engine does not know the
// list: an area no skill of its modules has leads nowhere. api gives no goal to a choice of a
// module's tasks, which is a choice inside one module.
Goal string
}
Input is all that one choice reads. The order of its lists does not change the choice: the rule orders by itself, by the order of the graph, of the lessons and of the IDs.
type ItemTraps ¶
ItemTraps is the traps of an item, by its place: the trap_values of its checks, by full ID.
type Last ¶
type Last struct {
Task string // the full ID of its task, whose beginning is its module
Left bool // whether it was closed as left: its outcome is "left"
Lesson string // the full ID of the lesson, when InLesson
InLesson bool // whether the attempt is a segment of a run of that lesson
Results []SkillResult // the result on each of its primary skills
}
Last is the last closed attempt of the profile.
type Lesson ¶
type Lesson struct {
ID string
Skills []string
Tasks []learnermodel.Task
}
Lesson is a lesson of a module: its full ID, its skills, and the descriptions of the tasks of its segments, in the order of the segments.
type Module ¶
type Module struct {
Graph learnermodel.Graph
Pool []Candidate
Lessons []Lesson // the lessons that suit the learner whole
// The area of each skill of the graph, from skill_areas of the package: the rule of the goal
// reads it. A skill with none is in no area.
Areas []SkillArea
}
Module is a module of the engine: the graph of its current version, and the pool and the lessons api gives the learner of it.
type ModuleChoices ¶
ModuleChoices is the number of choices of a module, a lesson counted once.
type OrderedLesson ¶ added in v0.1.22
OrderedLesson is a lesson of a module in the author's order: its full ID, and the place of its group from 0. The lessons of one group have no order between them by the skill graph, so a page may show them in any order; the order of the list is still the one the rule takes them in.
func LessonOrder ¶ added in v0.1.22
func LessonOrder(g learnermodel.Graph, lessons []Lesson) ([]OrderedLesson, error)
LessonOrder gives the lessons of one module in the author's order, by the same rule a choice takes them by: first a lesson that comes after none of the others by the prerequisites of the graph, of the least tier, then by ID byte by byte; then the first of the rest, and so on. A lesson starts a new group when it and a lesson of the group before it come one after the other by the graph; otherwise it joins that group. Only the lessons' IDs and skills are read, and the lessons need not suit the learner: the caller gives those it lists. A lesson twice by its ID is ErrInvalid.
type PreviewSkill ¶ added in v0.1.24
PreviewSkill is a skill of the preview of the goal for the tutor: its full ID, and its module's full ID.
func PreviewGoal ¶ added in v0.1.24
func PreviewGoal(in Input) ([]PreviewSkill, error)
PreviewGoal gives the first skills toward the goal for the tutor, the area in.Goal: five at most, each once, with its module, in the order of the area's list; fewer when the list holds fewer, and none with no goal. With a goal, none says only that the goal has nothing to give now — each skill of the area with a verdict is mastered, out of reach for now, or waits for a lesson of the author's order — and ends no goal: AreaLeft says whether the area has a skill left.
It reads the input as Choose does, over every module of the engine, with the second pass's candidates — the tasks on pause too —, so that a pause after a lesson does not hide a skill; it does not read MapSkill, nor Summary.AcrossChoices. The list holds a skill only within reach, so a skill with no task in the pool api gives is in none: the pool sets which skills the preview leaves out, and api gives it the pool by the age category, whatever the route to AI. Consolidation, the probe, repetition and a module's placement are no part of it. It writes nothing, neither to its input nor anywhere else, and the same input gives the same preview, whatever the order of its lists.
It refuses, with ErrInvalid, what Choose refuses, the goal's checks last: a skill twice in a module's areas or one its module's graph does not have, and a count of the choices across the modules below zero.
type ReasonCode ¶
type ReasonCode int32
ReasonCode is why the engine gave what it chose: one value of the closed list ReasonCode of cause.proto in spec's contracts, with its number, which api translates the code by. The adult sees it; the learner is not told it, but for ReasonToGoal. A test holds the names and numbers to the file.
const ( ReasonUnspecified ReasonCode = 0 // a choice of nothing ReasonConsolidation ReasonCode = 1 // after a wrong answer, another task on the skill ReasonNewSkill ReasonCode = 2 // a skill not given before, whose prerequisites are met ReasonQueue ReasonCode = 3 // the skill within reach not given for longest in its module ReasonRepetition ReasonCode = 4 // the review date of a mastered skill has come ReasonProbe ReasonCode = 5 // a skill put aside comes back as a check ReasonSkillChosen ReasonCode = 6 // the skill the learner chose, on the map or for a module ReasonAuthorOrder ReasonCode = 7 // a skill with a rubric or without assessment, by the graph ReasonOpenRun ReasonCode = 8 // the lesson of a run that is open ReasonRotation ReasonCode = 9 // a skill given before comes round again, outside the queue // A lesson the learner chose from its module's lessons: Choose never gives it, api records it for // the run it opens, and the summary may name it as the code of a skill's last attempt. ReasonLessonChosen ReasonCode = 10 // A skill of the area of the goal for the tutor, on a turn of the goal in a choice across the // modules. The learner sees it too, a child as well, with the goal's area. ReasonToGoal ReasonCode = 11 )
type RubricDone ¶
RubricDone is an attempt of a task with a rubric that "Done" closed, and when. The attempts of one task repeat by right: a task with a rubric is given again by a new attempt.
type Run ¶
type Run struct {
Lesson string
Skills []string
End RunEnd // RunOpen while it is open
EndedAt int64 // zero while it is open
}
Run is a lesson run of the profile: its lesson and the lesson's skills — translated, on a package before — how it ended, and when. The runs of one lesson repeat by right: a lesson is given again by a new run.
type RunEnd ¶
type RunEnd int32
RunEnd is how a lesson run ended: RunEndReason of cause.proto, names and numbers. Its zero is a run that is open.
type SkillArea ¶ added in v0.1.24
SkillArea is the area of a skill of a module: its full ID, and the code of its area as the package gives it, the fallback area of the module's subject filled in.
type SkillIssue ¶
type SkillIssue struct {
Skill string
LastIssued int64
Issued bool
LastCode ReasonCode
LastResult SkillResult
HasLast bool
TasksPassed bool
}
SkillIssue is when a skill was last handed out, by a task on it or by a lesson that teaches it, when Issued; and, when HasLast, the reason code of the choice of its last closed attempt and the attempt's result on it. TasksPassed is whether the skill's tasks are passed: each task of the module's current version where the skill is primary, of those that suit the learner's age category, has had an attempt — a template is one task, and an attempt left without a verdict is not right — and at more than half of them the first attempt gave each item where the skill is primary the first verdict "correct". api counts it; the engine counts such a skill, when it has a verdict, as a prerequisite of its module as it counts a mastered one, and gives it on as any skill not mastered. It counts nothing for a skill with a rubric or none, nor for an anchor skill.
type SkillResult ¶
SkillResult is the result of an attempt on a skill, in facts: of the items of the attempt the skill is primary in, how many got a first verdict, how many of those are right, and whether the solution was shown. The engine tells a failure from them, by the same rule as the learner model.
type Summary ¶
type Summary struct {
Skills []SkillIssue
Modules []ModuleChoices
Tasks []TaskSolution
// The choices across the modules before this one that gave a lesson or a task, a lesson counted
// once: the records of choices that name neither a module nor a skill. Choose reads it only with
// a goal: which choices are the goal's turns.
AcrossChoices int64
}
Summary is what api gives of what was handed out before, from the records of choices and attempts it keeps.
type TaskSolution ¶
TaskSolution is when the solution of a task with a key last went to the learner's device. A task with a rubric is not here: its solution, open after "Done", does not count, and the engine reads such a task by RubricDone.