feat: Don't forget about the adverbs
This commit is contained in:
@@ -29,6 +29,10 @@ export interface IAdjektivData {
|
||||
endung_n: string;
|
||||
};
|
||||
|
||||
export interface IAdverbData {
|
||||
grundform: string;
|
||||
};
|
||||
|
||||
export interface IVocab {
|
||||
// If a word has multiple meanings
|
||||
german: string[];
|
||||
@@ -36,7 +40,7 @@ export interface IVocab {
|
||||
mnemonic?: string;
|
||||
|
||||
type: VocabType;
|
||||
latin: INomenData | IVerbData | IAdjektivData;
|
||||
latin: INomenData | IVerbData | IAdjektivData | IAdverbData;
|
||||
|
||||
// This number is unique across all vocabulary items
|
||||
id: number;
|
||||
@@ -152,9 +156,14 @@ export function vocabToReviewCard(vocab: IVocab): IReviewCard[] {
|
||||
qtype: ReviewQType.ADJ_ENDUNG_N,
|
||||
id: vocab.id,
|
||||
}];
|
||||
default:
|
||||
// TODO: Remove after removing Adverbien
|
||||
return [];
|
||||
case VocabType.ADVERB:
|
||||
return [{
|
||||
// Latin -> German
|
||||
question: vocab.latin.grundform,
|
||||
answers: vocab.german,
|
||||
qtype: ReviewQType.GERMAN,
|
||||
id: vocab.id,
|
||||
}];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ const LevelPageWithRouter = withRouter(
|
||||
<b>Endung neutrum:</b> {aData.endung_n}
|
||||
</Typography>
|
||||
</div>;
|
||||
default:
|
||||
case VocabType.ADVERB:
|
||||
return <div />;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,9 @@ import CloseIcon from "@material-ui/icons/Close";
|
||||
|
||||
import { withRouter } from "react-router-dom";
|
||||
|
||||
import { IVocab, IReviewCard, vocabToReviewCard, reviewQTypeToStr } from "../models/vocab";
|
||||
import {
|
||||
IVocab, IReviewCard, vocabToReviewCard, reviewQTypeToStr, VocabType
|
||||
} from "../models/vocab";
|
||||
import { ReviewType, IReviewMetadata } from "../models/review";
|
||||
|
||||
import { levW } from "../algorithms/levenshtein";
|
||||
@@ -139,10 +141,6 @@ const ReviewPageWithRouter = withRouter(
|
||||
};
|
||||
}
|
||||
|
||||
vocabFromId = (id: number): IVocab | {} => {
|
||||
return this.vocab.find((el) => el.id === this.props.current.id);
|
||||
}
|
||||
|
||||
// When a vocabulary item has been answered, we need to update
|
||||
// the group's SuperMemo2-data.
|
||||
// We update based on the following State-Machine: (C = Correct; W = Wrong)
|
||||
@@ -275,12 +273,25 @@ const ReviewPageWithRouter = withRouter(
|
||||
|
||||
const { question, qtype } = this.props.current;
|
||||
const questionTitle = `${question} (${reviewQTypeToStr(qtype)})`;
|
||||
// TODO/NOTE: This assumes that each vocabulary item gets mapped to
|
||||
// exactly 3 review cards
|
||||
|
||||
// NOTE: This assumes that adverbs get mapped to only 1 card,
|
||||
// while every other type of vocabulary gets mapped to
|
||||
// exactly 3 cards each.
|
||||
// NOTE: The 'numCards === 0 ?' is neccessary as (for some reasdn) numCards
|
||||
// starts of by being 0, which results in progress === -Inifinity.
|
||||
// That looks weird as the user sees the progressbar jump.
|
||||
const numCards = this.vocab.length * 3;
|
||||
// NOTE: The arrow function needs the ': number' annotation as TS
|
||||
// will then deduce the type of acc and curr to be '1|3',
|
||||
// leads to compiler warnings, as a, b element {1, 3} is not
|
||||
// element {1, 3}.
|
||||
const numCards = this.vocab.map((vocab): number => {
|
||||
if (vocab.type === VocabType.ADVERB) {
|
||||
return 1;
|
||||
} else {
|
||||
return 3;
|
||||
}
|
||||
}).reduce((acc, curr) => acc + curr);
|
||||
|
||||
const progress = numCards === 0 ? (
|
||||
0
|
||||
) : (
|
||||
|
||||
Reference in New Issue
Block a user