added verb situations and also stopped using fragments in the Situations bc it breaks the comparison used in the pool function

This commit is contained in:
lingdocs 2022-09-09 19:01:02 +04:00
parent 6344b59034
commit cbe51eed48
4 changed files with 217 additions and 32 deletions

View File

@ -3,6 +3,7 @@ import VerbGame from "./sub-cores/VerbGame";
import GenderGame from "./sub-cores/GenderGame";
import UnisexNounGame from "./sub-cores/UnisexNounGame";
import EquativeSituations from "./sub-cores/EquativeSituations";
import VerbSituations from "./sub-cores/VerbSituations";
import EquativeIdentify from "./sub-cores/EquativeIdentify";
// NOUNS
@ -235,19 +236,40 @@ export const habitualPastVerbGame2 = makeGameRecord({
SubCore: VerbGame,
});
export const allPastVerbGame1 = makeGameRecord({
title: "Write the past verb (one)",
title: "Write the past verb - all past tenses (one)",
id: "all-past-verbs-write-1",
link: "/verbs/past-verbs/",
level: { level: 1, type : "allPast" },
SubCore: VerbGame,
});
export const allPastVerbGame2 = makeGameRecord({
title: "Write past verb (mix)",
title: "Write past verb - all past tenses (mix)",
id: "all-past-verbs-write-2",
link: "/verbs/past-verbs/",
level: { level: 2, type: "allPast" },
SubCore: VerbGame,
});
export const allVerbGame1 = makeGameRecord({
title: "Write verb - all tenses (one)",
id: "all-verbs-write-1",
link: "/verbs/master-chart/",
level: { level: 1, type : "allPast" },
SubCore: VerbGame,
});
export const allVerbGame2 = makeGameRecord({
title: "Write verb - all tenses (mix)",
id: "all-verbs-write-2",
link: "/verbs/master-chart/",
level: { level: 2, type: "allPast" },
SubCore: VerbGame,
});
export const verbSituationsGame = makeGameRecord({
title: "Choose the right verb tense for the situation",
id: "verb-tense-situations",
link: "/verbs/verbs-intro/",
level: "situations",
SubCore: VerbSituations,
});
const games: { chapter: string, items: GameRecord[] }[] = [
{
@ -297,6 +319,9 @@ const games: { chapter: string, items: GameRecord[] }[] = [
habitualPastVerbGame2,
allPastVerbGame1,
allPastVerbGame2,
allVerbGame1,
allVerbGame2,
verbSituationsGame,
],
},
];
@ -305,6 +330,8 @@ const games: { chapter: string, items: GameRecord[] }[] = [
games.forEach(({ items }) => {
const allAreUnique = (arr: unknown[]) => arr.length === new Set(arr).size;
const ids = items.map(x => x.id);
const title = items.map(x => x.title);
if (!allAreUnique(title)) throw new Error("duplicate game title");
if (!allAreUnique(ids)) throw new Error("duplicate game key");
})

View File

@ -1,5 +1,6 @@
import GameCore from "../GameCore";
import {
humanReadableEquativeTense,
Types as T,
} from "@lingdocs/pashto-inflector";
import { makePool } from "../../lib/pool";
@ -18,43 +19,43 @@ const timeLimit = 100;
const situations: Situation[] = [
{
description: <>A is B, for sure, right now</>,
description: "A is B, for sure, right now",
tense: ["present"],
},
{
description: <>A is <em>probably</em> B, right now</>,
description: "A is probably B, right now",
tense: ["future"],
},
{
description: <>A will be B in the future</>,
description: "A will be B in the future",
tense: ["future"],
},
{
description: <>We can assume that A is most likely B</>,
description: "We can assume that A is most likely B",
tense: ["future"],
},
{
description: <>You <em>know</em> A is B, currently</>,
description: "You know A is B, currently",
tense: ["present"],
},
{
description: <>A tends to be B</>,
description: "A tends to be B",
tense: ["habitual"],
},
{
description: <>A is usually B</>,
description: "A is usually B",
tense: ["habitual"],
},
{
description: <>A is generally B</>,
description: "A is generally B",
tense: ["habitual"],
},
{
description: <>A is B, right now</>,
description: "A is B, right now",
tense: ["present"],
},
{
description: <>A is always B, as a matter of habit</>,
description: "A is always B, as a matter of habit",
tense: ["present"],
},
{
@ -151,7 +152,7 @@ export default function EquativeSituations({ inChapter, id, link, level }: { inC
className="btn btn-outline-secondary mb-3"
onClick={() => handleTenseClick(t)}
>
{humanReadableTense(t)}
{humanReadableEquativeTense(t)}
</button>
</div>)}
</div>
@ -182,18 +183,7 @@ function DisplayCorrectAnswer({ question }: { question: Question }): JSX.Element
// {possibleCorrect.map(humanReadableTense).join(" or ")}
// </div>)
return <div>
{question.tense.map(humanReadableTense).join(" or ")}
{question.tense.map(humanReadableEquativeTense).join(" or ")}
</div>;
}
function humanReadableTense(tense: T.EquativeTense | "allProduce"): string {
return tense === "allProduce"
? ""
: tense === "pastSubjunctive"
? "past subjunctive"
: tense === "wouldBe"
? `"would be"`
: tense === "wouldHaveBeen"
? `"would have been"`
: tense;
}

View File

@ -93,9 +93,9 @@ type VerbGameLevel = {
type: "presentVerb" | "subjunctiveVerb"
| "futureVerb" | "imperative" | "intransitivePerfectivePast"
| "intransitiveImperfectivePast" | "transitivePerfectivePast" | "transitiveImperfectivePast"
| "allPast" | "habitualPast";
| "allPast" | "habitualPast" | "allTenses";
}
type VerbPoolName = "basic" | "transitivePast" | "intransitivePast" | "mixedPast";
type VerbPoolName = "basic" | "transitivePast" | "intransitivePast" | "mixedPast" | "mixedAll";
function selectVerbPool({ type }: VerbGameLevel): VerbPoolName {
return type === "presentVerb"
@ -114,8 +114,9 @@ function selectVerbPool({ type }: VerbGameLevel): VerbPoolName {
? "transitivePast"
: type === "transitivePerfectivePast"
? "transitivePast"
// : type === "habitualPast" || type === "allPast"
: "mixedPast";
: type === "habitualPast" || type === "allPast"
? "mixedPast"
: "mixedAll";
}
// TODO: Level where you create the formulas (seperate file)
@ -136,6 +137,7 @@ const VerbGame: GameSubCore<VerbGameLevel> = ({ id, link, level, inChapter }: {
transitivePast: makePool(transitivePastVerbs, 15),
intransitivePast: makePool(intransitivePastVerbs, 15),
mixedPast: makePool([...transitivePastVerbs, ...intransitivePastVerbs], 15),
mixedAll: makePool([...verbs, ...transitivePastVerbs, ...intransitivePastVerbs], 15),
};
const oneVerb: T.VerbEntry = verbPools[selectVerbPool(level)]();
const getVerb = level.level === 1
@ -274,8 +276,12 @@ const VerbGame: GameSubCore<VerbGameLevel> = ({ id, link, level, inChapter }: {
}
function Instructions() {
const desc = levelToDescription(level);
return <div>
<p className="lead">Write the {levelToDescription(level)} verb to complete the phrase</p>
<p className="lead">
Write the {desc} verb to complete the phrase
{desc ? "" : " (all tenses)"}
</p>
</div>
}
@ -397,8 +403,10 @@ function levelToDescription({ type }: VerbGameLevel): string {
? "imperfective imperative or perfective imperative"
: type === "allPast"
? "past tense"
// : type === "habitualPast"
: "habitual past";
: type === "habitualPast"
? "habitual past"
// : type === "allTenses"
: "";
}
function levelToTense({ type }: VerbGameLevel): T.VerbTense | T.ImperativeTense {

View File

@ -0,0 +1,160 @@
import GameCore from "../GameCore";
import {
humanReadableVerbForm,
Types as T,
} from "@lingdocs/pashto-inflector";
import { makePool } from "../../lib/pool";
const tenses: T.VerbTense[] = [
"presentVerb",
"subjunctiveVerb",
"imperfectiveFuture",
"perfectiveFuture",
"imperfectivePast",
"perfectivePast",
"habitualImperfectivePast",
"habitualPerfectivePast",
];
type Situation = {
description: string | JSX.Element,
tense: T.VerbTense[],
};
const amount = 12;
const timeLimit = 100;
const situations: Situation[] = [
{
description: "Something happens generally",
tense: ["presentVerb"],
},
{
description: "Something is happening right now",
tense: ["presentVerb"],
},
{
description: "Something is definately about to happen soon",
tense: ["presentVerb", "imperfectiveFuture", "perfectiveFuture"],
},
{
description: "...so that something happens",
tense: ["subjunctiveVerb"],
},
{
description: "something should happen (judgement/necessity)",
tense: ["subjunctiveVerb"],
},
{
description: "you hope that something happens",
tense: ["subjunctiveVerb"],
},
{
description: "something will happen",
tense: ["imperfectiveFuture", "perfectiveFuture"],
},
{
description: "an action will happen, and be ongoing",
tense: ["imperfectiveFuture"],
},
{
description: "an action will happen, and it will just be a one-time, complete action",
tense: ["perfectiveFuture"],
},
{
description: "something happened",
tense: ["perfectivePast"],
},
{
description: "something was happening",
tense: ["imperfectivePast"],
},
{
description: "something was going to happen (but it didn't)",
tense: ["imperfectivePast"],
},
{
description: "something would have happened",
tense: ["imperfectivePast", "habitualImperfectivePast"],
},
{
description: "something would happen, again and again in the past",
tense: ["imperfectivePast", "habitualImperfectivePast", "habitualPerfectivePast"],
},
{
description: "an event was completed, one-time, in the past",
tense: ["perfectivePast"],
},
{
description: "something would happen habitually in the past - and each time it was a whole/complete event",
tense: ["habitualPerfectivePast"],
},
{
description: "something would happen habitually in the past - and each time it was ongoing/like an action in process",
tense: ["habitualImperfectivePast"],
},
];
type Question = Situation;
export default function VerbSituations({ inChapter, id, link, level }: { inChapter: boolean, id: string, link: string, level: "situations" }) {
const situationsPool = makePool(situations);
function getQuestion(): Question {
return situationsPool();
};
function Display({ question, callback }: QuestionDisplayProps<Question>) {
function handleTenseClick(t: T.VerbTense) {
callback(question.tense.includes(t));
}
return <div>
<div className="my-4" style={{ maxWidth: "300px", margin: "0 auto" }}>
<p className="lead">
{question.description}
</p>
</div>
<div className="text-center">
<div className="row">
{tenses.map(t => <div className="col" key={Math.random()}>
<button
style={{ width: "8rem" }}
className="btn btn-outline-secondary mb-3"
onClick={() => handleTenseClick(t)}
>
{humanReadableVerbForm(t)}
</button>
</div>)}
</div>
</div>
</div>
}
function Instructions() {
return <p className="lead">Choose a verb tense that works for each given situation</p>;
}
return <GameCore
inChapter={inChapter}
studyLink={link}
getQuestion={getQuestion}
id={id}
Display={Display}
DisplayCorrectAnswer={DisplayCorrectAnswer}
timeLimit={timeLimit}
amount={amount}
Instructions={Instructions}
/>
};
function DisplayCorrectAnswer({ question }: { question: Question }): JSX.Element {
// callback(<div className="lead">
// {possibleCorrect.map(humanReadableTense).join(" or ")}
// </div>)
return <div>
{question.tense.map(humanReadableVerbForm).join(" or ")}
</div>;
}