UNPKG

@coorpacademy/progression-engine

Version:

41 lines (39 loc) 14.5 kB
// @flow import type {Instruction, ChapterRule} from "./rule-engine/types"; export type AcceptedAnswers = Array<Array<string>>; export type Action = {type: "init"} | {payload: {instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "move"} | {payload: {answer: Array<string>, content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, godMode: ?boolean, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, isCorrect: ?boolean, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "answer"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "clue"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "extraLifeAccepted"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "extraLifeRefused"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, resource: {ref: string, type: "video" | "pdf", version?: string}}, type: "resource"} | {payload: {instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "move"}; export type Answer = Array<string>; export type AnswerAction = {payload: {answer: Array<string>, content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, godMode: ?boolean, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, isCorrect: ?boolean, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "answer"}; export type AnswerCorrection = {corrections: Array<{answer: string | void, isCorrect: ?boolean}>, isCorrect: boolean}; export type AnswerRecord = {answer: Array<string>, isCorrect: ?boolean, slideRef: string}; export type AskClueAction = {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "clue"}; export type AvailableContent = Array<{ref: string, rules: Array<{conditions: Array<{operator: $Keys<{BETWEEN: <T>(expectedValues: Array<T>, value: T) => boolean, EQUALS: <T>(expectedValues: Array<T>, value: T) => boolean, GT: <T>(expectedValues: Array<T>, value: T) => boolean, GTE: <T>(expectedValues: Array<T>, value: T) => boolean, IN: <T>(expectedValues: Array<T>, value: T) => boolean, LT: <T>(expectedValues: Array<T>, value: T) => boolean, LTE: <T>(expectedValues: Array<T>, value: T) => boolean, NOT_BETWEEN: <T>(expectedValues: Array<T>, value: T) => boolean, NOT_EQUALS: <T>(expectedValues: Array<T>, value: T) => boolean, NOT_IN: <T>(expectedValues: Array<T>, value: T) => boolean}>, target: {field: "lives" | "stars" | string, scope: "variable"} | {field: "isCorrect" | "answer", ref: string, scope: "slide"}, values: Array<number | boolean | string | Array<string>>}>, destination: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}>, priority: number, ref?: string, source: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}> | null, slides: Array<{_id: string, chapter_id: string, position?: ?number, question: {content: {answers: Array<Array<string>>}, type: "qcm"} | {content: {answers: Array<Array<string>>}, type: "qcmGraphic"} | {content: {answers: Array<Array<string>>, matchOrder: boolean}, type: "qcmDrag"} | {content: {answers: Array<Array<string>>}, type: "slider"} | {content: {answers: Array<Array<string>>, maxTypos?: ?number}, type: "basic"} | {content: {answers: Array<Array<string>>, choices: Array<{type: "text" | "select"}>, matchOrder: boolean, maxTypos?: ?number}, type: "template"}}>}>; export type BasicQuestion = {content: {answers: Array<Array<string>>, maxTypos?: ?number}, type: "basic"}; export type ChapterContent = {ref: string, rules: Array<{conditions: Array<{operator: $Keys<{BETWEEN: <T>(expectedValues: Array<T>, value: T) => boolean, EQUALS: <T>(expectedValues: Array<T>, value: T) => boolean, GT: <T>(expectedValues: Array<T>, value: T) => boolean, GTE: <T>(expectedValues: Array<T>, value: T) => boolean, IN: <T>(expectedValues: Array<T>, value: T) => boolean, LT: <T>(expectedValues: Array<T>, value: T) => boolean, LTE: <T>(expectedValues: Array<T>, value: T) => boolean, NOT_BETWEEN: <T>(expectedValues: Array<T>, value: T) => boolean, NOT_EQUALS: <T>(expectedValues: Array<T>, value: T) => boolean, NOT_IN: <T>(expectedValues: Array<T>, value: T) => boolean}>, target: {field: "lives" | "stars" | string, scope: "variable"} | {field: "isCorrect" | "answer", ref: string, scope: "slide"}, values: Array<number | boolean | string | Array<string>>}>, destination: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}>, priority: number, ref?: string, source: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}> | null, slides: Array<{_id: string, chapter_id: string, position?: ?number, question: {content: {answers: Array<Array<string>>}, type: "qcm"} | {content: {answers: Array<Array<string>>}, type: "qcmGraphic"} | {content: {answers: Array<Array<string>>, matchOrder: boolean}, type: "qcmDrag"} | {content: {answers: Array<Array<string>>}, type: "slider"} | {content: {answers: Array<Array<string>>, maxTypos?: ?number}, type: "basic"} | {content: {answers: Array<Array<string>>, choices: Array<{type: "text" | "select"}>, matchOrder: boolean, maxTypos?: ?number}, type: "template"}}>}; export type Config = {answerBoundaryLimit: number, lives: number, livesDisabled: boolean, maxTypos: number, remainingLifeRequests: number, slidesToComplete: number, starsPerAskingClue: number, starsPerCorrectAnswer: number, starsPerResourceViewed: number, version: string}; export type Content = {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}; export type ContentResourceViewedAction = {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, resource: {ref: string, type: "video" | "pdf", version?: string}}, type: "resource"}; export type Engine = {ref: string, version: string}; export type EngineOptions = {lives?: number, livesDisabled?: boolean}; export type ExtraLifeAcceptedAction = {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "extraLifeAccepted"}; export type ExtraLifeRefusedAction = {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "extraLifeRefused"}; export type GenericContent = {ref: string, type: string, version?: string}; export type GenericState = {allAnswers: Array<{answer: Array<string>, isCorrect: ?boolean, slideRef: string}>, content?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, hasViewedAResourceAtThisStep: boolean, isCorrect: ?boolean, lives: number, livesDisabled?: boolean, nextContent?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, remainingLifeRequests: number, requestedClues: Array<string>, slides: Array<string>, stars: number, step: {current: number}, variables: {[_: string]: string | boolean | number}, viewedResources: Array<{ref: string, resources: Array<string>, type: mixed /* UNEXPECTED TYPE: EvalT */}>}; export type InitAction = {type: "init"}; export type MoveAction = {payload: {instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "move"}; export type PartialCorrection = {answer: string | void, isCorrect: ?boolean}; export type Progression = {actions: Array<{type: "init"} | {payload: {instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "move"} | {payload: {answer: Array<string>, content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, godMode: ?boolean, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, isCorrect: ?boolean, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "answer"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "clue"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "extraLifeAccepted"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "extraLifeRefused"} | {payload: {content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, resource: {ref: string, type: "video" | "pdf", version?: string}}, type: "resource"} | {payload: {instructions: Array<{field: string, type: "add" | "set", value: number | boolean | string}> | null, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}}, type: "move"}>, content: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, engine: {ref: string, version: string}, engineOptions: {lives?: number, livesDisabled?: boolean}}; export type QCMDragQuestion = {content: {answers: Array<Array<string>>, matchOrder: boolean}, type: "qcmDrag"}; export type QCMGraphicQuestion = {content: {answers: Array<Array<string>>}, type: "qcmGraphic"}; export type QCMQuestion = {content: {answers: Array<Array<string>>}, type: "qcm"}; export type Question = {content: {answers: Array<Array<string>>}, type: "qcm"} | {content: {answers: Array<Array<string>>}, type: "qcmGraphic"} | {content: {answers: Array<Array<string>>, matchOrder: boolean}, type: "qcmDrag"} | {content: {answers: Array<Array<string>>}, type: "slider"} | {content: {answers: Array<Array<string>>, maxTypos?: ?number}, type: "basic"} | {content: {answers: Array<Array<string>>, choices: Array<{type: "text" | "select"}>, matchOrder: boolean, maxTypos?: ?number}, type: "template"}; export type ResourceContent = {ref: string, type: "video" | "pdf", version?: string}; export type Slide = {_id: string, chapter_id: string, position?: ?number, question: {content: {answers: Array<Array<string>>}, type: "qcm"} | {content: {answers: Array<Array<string>>}, type: "qcmGraphic"} | {content: {answers: Array<Array<string>>, matchOrder: boolean}, type: "qcmDrag"} | {content: {answers: Array<Array<string>>}, type: "slider"} | {content: {answers: Array<Array<string>>, maxTypos?: ?number}, type: "basic"} | {content: {answers: Array<Array<string>>, choices: Array<{type: "text" | "select"}>, matchOrder: boolean, maxTypos?: ?number}, type: "template"}}; export type SliderQuestion = {content: {answers: Array<Array<string>>}, type: "slider"}; export type State = {content?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, nextContent: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}} & {allAnswers: Array<{answer: Array<string>, isCorrect: ?boolean, slideRef: string}>, content?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, hasViewedAResourceAtThisStep: boolean, isCorrect: ?boolean, lives: number, livesDisabled?: boolean, nextContent?: {ref: string, type: string, version?: string} | {ref: string, type: "video" | "pdf", version?: string}, remainingLifeRequests: number, requestedClues: Array<string>, slides: Array<string>, stars: number, step: {current: number}, variables: {[_: string]: string | boolean | number}, viewedResources: Array<{ref: string, resources: Array<string>, type: mixed /* UNEXPECTED TYPE: EvalT */}>}; export type Step = {current: number}; export type TemplateQuestion = {content: {answers: Array<Array<string>>, choices: Array<{type: "text" | "select"}>, matchOrder: boolean, maxTypos?: ?number}, type: "template"}; export type Variable = string | boolean | number; export type Variables = {[_: string]: string | boolean | number}; export type ViewedResource = {ref: string, resources: Array<string>, type: mixed /* UNEXPECTED TYPE: EvalT */}; declare module.exports: {};