From 37dbea50b578a986bc15a21d8c1f33f591c51916 Mon Sep 17 00:00:00 2001 From: lingdocs <71590811+lingdocs@users.noreply.github.com> Date: Tue, 12 Apr 2022 16:16:11 +0500 Subject: [PATCH] bug fix --- package.json | 2 +- src/components/vp-explorer/VPExplorer.tsx | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 127ae3b..476747a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@lingdocs/pashto-inflector", - "version": "1.9.1", + "version": "1.9.2", "author": "lingdocs.com", "description": "A Pashto inflection and verb conjugation engine, inculding React components for displaying Pashto text, inflections, and conjugations", "homepage": "https://verbs.lingdocs.com", diff --git a/src/components/vp-explorer/VPExplorer.tsx b/src/components/vp-explorer/VPExplorer.tsx index 2b6233e..3b48b43 100644 --- a/src/components/vp-explorer/VPExplorer.tsx +++ b/src/components/vp-explorer/VPExplorer.tsx @@ -84,7 +84,8 @@ export function VPExplorer(props: { useEffect(() => { setVps(o => { if (mode === "quiz") { - const { VPS, qs } = makeQuizState(vps); + const newvps = makeVPSelectionState(props.verb, o); + const { VPS, qs } = makeQuizState(newvps); setQuizState(qs); return VPS; } @@ -331,11 +332,16 @@ function makeQuizState(oldVps: T.VPSelectionState): { VPS: T.VPSelectionState, q } const vps = getRandomVPSelection("both")(oldVps); const wrongStates: T.VPSelectionState[] = []; - [1, 2, 3, 4].forEach(() => { + // don't do the SO switches every time + const wholeTimeSOSwitch = randFromArray([true, false]); + [1, 2, 3].forEach(() => { // TODO: don't repeat tenses let v: T.VPSelectionState; do { - v = getRandomVPSelection("tenses")(vps); + const SOSwitch = wholeTimeSOSwitch && randFromArray([true, false]); + v = getRandomVPSelection("tenses")( + SOSwitch ? switchSubjObj(vps) : vps, + ); // eslint-disable-next-line } while (wrongStates.find(x => x.verb.tense === v.verb.tense)); wrongStates.push(v); @@ -370,9 +376,10 @@ function getOptionFromResult(r: { ps: T.SingleOrLengthOpts; e?: string[] | undefined; }): T.PsString { - // TODO: randomize length pick - const ps = "long" in r.ps ? r.ps.long : r.ps; - // TODO: randomize version pick + const ps = "long" in r.ps + ? r.ps[randFromArray(["short", "long"] as ("short" | "long")[])] + : r.ps; + // not randomizing version pick (for now) return ps[0]; }