Documentation ¶
Index ¶
- func Markdown(input io.Reader, output io.Writer) error
- func Mothball(c Category, w io.Writer) error
- type AnswerResponse
- type Category
- type FsCategory
- type FsCommandCategory
- type FsCommandPuzzle
- type FsPuzzle
- type Inventory
- type InventoryResponse
- type NopReadCloser
- type Puzzle
- type PuzzleDebug
- type PuzzleProvider
- type ReadSeekCloser
- type RecursiveBasePathFs
- type StaticAttachment
- type StaticPuzzle
- Bugs
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnswerResponse ¶
type AnswerResponse struct {
Correct bool
}
AnswerResponse is handed back when we ask for an answer to be checked.
type Category ¶
type Category interface { // Inventory lists every puzzle in the category. Inventory() ([]int, error) // Puzzle provides a Puzzle structure for the given point value. Puzzle(points int) (Puzzle, error) // Open returns an io.ReadCloser for the given filename. Open(points int, filename string) (ReadSeekCloser, error) // Answer returns whether the given answer is correct. Answer(points int, answer string) bool }
Category defines the functionality required to be a puzzle category.
type FsCategory ¶
type FsCategory struct {
// contains filtered or unexported fields
}
FsCategory provides a category backed by a .md file.
func (FsCategory) Answer ¶
func (c FsCategory) Answer(points int, answer string) bool
Answer checks whether an answer is correct.
func (FsCategory) Inventory ¶
func (c FsCategory) Inventory() ([]int, error)
Inventory returns a list of point values for this category.
func (FsCategory) Open ¶
func (c FsCategory) Open(points int, filename string) (ReadSeekCloser, error)
Open returns an io.ReadCloser for the given filename.
type FsCommandCategory ¶
type FsCommandCategory struct {
// contains filtered or unexported fields
}
FsCommandCategory provides a category backed by running an external command.
func (FsCommandCategory) Answer ¶
func (c FsCommandCategory) Answer(points int, answer string) bool
Answer checks whether an answer is correct.
func (FsCommandCategory) Inventory ¶
func (c FsCommandCategory) Inventory() ([]int, error)
Inventory returns a list of point values for this category.
func (FsCommandCategory) Open ¶
func (c FsCommandCategory) Open(points int, filename string) (ReadSeekCloser, error)
Open returns an io.ReadCloser for the given filename.
type FsCommandPuzzle ¶
type FsCommandPuzzle struct {
// contains filtered or unexported fields
}
FsCommandPuzzle provides an FsPuzzle backed by running a command.
func (FsCommandPuzzle) Answer ¶
func (fp FsCommandPuzzle) Answer(answer string) bool
Answer checks whether the given answer is correct.
func (FsCommandPuzzle) Open ¶
func (fp FsCommandPuzzle) Open(filename string) (ReadSeekCloser, error)
Open returns a newly-opened file. BUG(neale): FsCommandPuzzle.Open() reads everything into memory, and will suck for large files.
func (FsCommandPuzzle) Puzzle ¶
func (fp FsCommandPuzzle) Puzzle() (Puzzle, error)
Puzzle returns a Puzzle struct for the current puzzle.
type FsPuzzle ¶
type FsPuzzle struct {
// contains filtered or unexported fields
}
FsPuzzle is a single puzzle's directory.
type InventoryResponse ¶
type InventoryResponse struct {
Puzzles []int
}
InventoryResponse is what's handed back when we ask for an inventory.
type NopReadCloser ¶
type NopReadCloser struct { }
NopReadCloser provides an io.ReadCloser which does nothing.
type Puzzle ¶
type Puzzle struct { // Debug contains debugging information, omitted in mothballs Debug PuzzleDebug // Authors names all authors of this puzzle Authors []string // Attachments is a list of filenames used by this puzzle Attachments []string // Scripts is a list of EMCAScript files needed by the client for this puzzle Scripts []string // Body is the HTML rendering of this puzzle Body string // AnswerPattern contains the pattern (regular expression?) used to match valid answers AnswerPattern string // AnswerHashes contains hashes of all answers for this puzzle AnswerHashes []string // Answers lists all acceptable answers, omitted in mothballs Answers []string // Extra is send unchanged to the client. // Eventually, Objective, KSAs, and Success will move into Extra. Extra map[string]any // Objective is the learning objective for this puzzle Objective string // KSAs lists all KSAs achieved upon successfull completion of this puzzle KSAs []string // Success lists the criteria for successfully understanding this puzzle Success struct { // Acceptable describes the minimum work required to be considered successfully understanding this puzzle's concepts Acceptable string // Mastery describes the work required to be considered mastering this puzzle's conceptss Mastery string } }
Puzzle contains everything about a puzzle that a client will see.
type PuzzleDebug ¶
type PuzzleProvider ¶
type PuzzleProvider interface { // Puzzle returns a Puzzle struct for the current puzzle. Puzzle() (Puzzle, error) // Open returns a newly-opened file. Open(filename string) (ReadSeekCloser, error) // Answer returns whether the provided answer is correct. Answer(answer string) bool }
PuzzleProvider establishes the functionality required to provide one puzzle.
func NewFsPuzzlePoints ¶
func NewFsPuzzlePoints(fs afero.Fs, points int) PuzzleProvider
NewFsPuzzlePoints returns a new FsPuzzle for points.
type ReadSeekCloser ¶
ReadSeekCloser provides io.Reader, io.Seeker, and io.Closer.
type RecursiveBasePathFs ¶
RecursiveBasePathFs is an overloaded afero.BasePathFs that has a recursive RealPath().
func NewRecursiveBasePathFs ¶
func NewRecursiveBasePathFs(source afero.Fs, path string) *RecursiveBasePathFs
NewRecursiveBasePathFs returns a new RecursiveBasePathFs.
type StaticAttachment ¶
type StaticAttachment struct { Filename string // Filename presented as part of puzzle FilesystemPath string // Filename in backing FS (URL, mothball, or local FS) }
StaticAttachment carries information about an attached file.
func (*StaticAttachment) UnmarshalYAML ¶
func (sa *StaticAttachment) UnmarshalYAML(unmarshal func(interface{}) error) error
UnmarshalYAML allows a StaticAttachment to be specified as a single string. The way the yaml library works is weird.
type StaticPuzzle ¶
type StaticPuzzle struct { Authors []string Attachments []StaticAttachment Scripts []StaticAttachment AnswerPattern string Answers []string Debug PuzzleDebug Extra map[string]any Objective string Success struct { Acceptable string Mastery string } KSAs []string }
StaticPuzzle contains everything a static puzzle might tell us.
Notes ¶
Bugs ¶
FsCategory.Answer should probably always return false, to prevent you from running uncompiled puzzles with participants.
FsCommandPuzzle.Open() reads everything into memory, and will suck for large files.