Reference · Framing, geometry and quiz tools
DistractorOptionstype
The wrong-answer count, optional seeded random source and candidate restriction.
Import it
import type { DistractorOptions } from "@johnmorrisdotca/chizu";
Definition
type DistractorOptions = {
count?: number;
pool?: number;
random?: Random;
among?: ReadonlyArray<string | number>;
};
Members
| Name | Type | Description |
|---|---|---|
count (optional) | number | undefined | How many wrong answers. Default 3. |
pool (optional) | number | undefined | How many of the most tempting places the wrong answers are drawn from. Default |
random (optional) | Random | undefined | The stream the draw is made from: the same seed offers the same choices. Default: the best |
among (optional) | readonly (string | number)[] | undefined | Codes that may be offered, if only some may be (the countries a school names). The target's own code is never offered. Default: every region. |
Examples
import WORLD from "@johnmorrisdotca/chizu/world";
import { pickDistractors, seededRandom, type DistractorOptions } from "@johnmorrisdotca/chizu";
const options: DistractorOptions = { count: 5, random: seededRandom(1) };
console.log(pickDistractors(WORLD, "BR", options).length);
// 55What it prints (run when this page was built)