fix: All vocab items now get turned into review cards
This commit is contained in:
parent
2b0d472754
commit
cb452a3c54
@ -50,8 +50,8 @@ export enum ReviewQType {
|
||||
NOMEN_GENITIV,
|
||||
NOMEN_GENUS,
|
||||
|
||||
ADJ_NOM_A,
|
||||
ADJ_NOM_B,
|
||||
ADJ_ENDUNG_F,
|
||||
ADJ_ENDUNG_N,
|
||||
|
||||
VERB_PRAESENS,
|
||||
VERB_PERFEKT,
|
||||
@ -77,12 +77,10 @@ export function reviewQTypeToStr(type: ReviewQType): string {
|
||||
return "Genitiv";
|
||||
case ReviewQType.NOMEN_GENUS:
|
||||
return "Genus";
|
||||
case ReviewQType.ADJ_NOM_A:
|
||||
// TODO
|
||||
return "Nominativ A";
|
||||
case ReviewQType.ADJ_NOM_B:
|
||||
// TODO
|
||||
return "Nominativ B";
|
||||
case ReviewQType.ADJ_ENDUNG_F:
|
||||
return "Endung feminin";
|
||||
case ReviewQType.ADJ_ENDUNG_N:
|
||||
return "Endung neutrum";
|
||||
case ReviewQType.VERB_PRAESENS:
|
||||
return "1. Person Präsens";
|
||||
case ReviewQType.VERB_PERFEKT:
|
||||
@ -97,27 +95,70 @@ export function reviewQTypeToStr(type: ReviewQType): string {
|
||||
export function vocabToReviewCard(vocab: IVocab): IReviewCard[] {
|
||||
switch (vocab.type) {
|
||||
case VocabType.NOMEN:
|
||||
const latin = vocab.latin as INomenData;
|
||||
const nData = vocab.latin as INomenData;
|
||||
return [{
|
||||
// Latin -> German
|
||||
question: latin.grundform,
|
||||
question: nData.grundform,
|
||||
answers: vocab.german,
|
||||
qtype: ReviewQType.GERMAN,
|
||||
id: vocab.id,
|
||||
}, {
|
||||
// Latin -> Genitiv
|
||||
question: latin.grundform,
|
||||
answers: [latin.genitiv],
|
||||
question: nData.grundform,
|
||||
answers: [nData.genitiv],
|
||||
qtype: ReviewQType.NOMEN_GENITIV,
|
||||
id: vocab.id,
|
||||
}, {
|
||||
// Latin -> Genus
|
||||
question: latin.grundform,
|
||||
answers: [latin.genus],
|
||||
question: nData.grundform,
|
||||
answers: [nData.genus],
|
||||
qtype: ReviewQType.NOMEN_GENUS,
|
||||
id: vocab.id,
|
||||
}];
|
||||
case VocabType.VERB:
|
||||
const vData = vocab.latin as IVerbData;
|
||||
return [{
|
||||
// Latin -> German
|
||||
question: vData.grundform,
|
||||
answers: vocab.german,
|
||||
qtype: ReviewQType.GERMAN,
|
||||
id: vocab.id,
|
||||
}, {
|
||||
// Latin -> Präsens
|
||||
question: vData.grundform,
|
||||
answers: [vData.praesens],
|
||||
qtype: ReviewQType.VERB_PRAESENS,
|
||||
id: vocab.id,
|
||||
}, {
|
||||
// Latin -> Perfekt
|
||||
question: vData.grundform,
|
||||
answers: [vData.perfekt],
|
||||
qtype: ReviewQType.VERB_PERFEKT,
|
||||
id: vocab.id,
|
||||
}];
|
||||
case VocabType.ADJEKTIV:
|
||||
const aData = vocab.latin as IAdjektivData;
|
||||
return [{
|
||||
// Latin -> German
|
||||
question: aData.grundform,
|
||||
answers: vocab.german,
|
||||
qtype: ReviewQType.GERMAN,
|
||||
id: vocab.id,
|
||||
}, {
|
||||
// Latin -> Endung f
|
||||
question: aData.grundform,
|
||||
answers: [aData.endung_f],
|
||||
qtype: ReviewQType.ADJ_ENDUNG_F,
|
||||
id: vocab.id,
|
||||
}, {
|
||||
// Latin -> Perfekt
|
||||
question: aData.grundform,
|
||||
answers: [aData.endung_n],
|
||||
qtype: ReviewQType.ADJ_ENDUNG_N,
|
||||
id: vocab.id,
|
||||
}];
|
||||
default:
|
||||
// TODO: Remove after removing Adverbien
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
@ -67,22 +67,12 @@ const ReviewPageWithRouter = withRouter(
|
||||
private sm2_metadata: any = {};
|
||||
private score_delta = 0;
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
|
||||
componentDidMount() {
|
||||
// Hide the drawer button
|
||||
this.props.drawerButtonState(false);
|
||||
|
||||
const vocToQueue = () => {
|
||||
this.vocab.forEach((vocab) => {
|
||||
vocabToReviewCard(vocab).forEach(this.reviewQueue.enqueue);
|
||||
});
|
||||
this.props.setReview(this.reviewQueue.dequeue(), {
|
||||
correct: 0,
|
||||
wrong: 0,
|
||||
});
|
||||
this.props.setLoading(false);
|
||||
};
|
||||
// Show a loading spinner
|
||||
this.props.setLoading(true);
|
||||
|
||||
// Get the correct vocabulary
|
||||
const { reviewType, vocabByLevel, levelId, vocabByQueue } = this.props;
|
||||
@ -101,8 +91,20 @@ const ReviewPageWithRouter = withRouter(
|
||||
}[reviewType];
|
||||
|
||||
getVocab().then((res: IVocab[]) => {
|
||||
// Stop the loading
|
||||
this.props.setLoading(false);
|
||||
this.vocab = res;
|
||||
vocToQueue();
|
||||
|
||||
// Convert the vocab items into review queue cards
|
||||
res.forEach(vocab => {
|
||||
vocabToReviewCard(vocab).forEach(this.reviewQueue.enqueue);
|
||||
});
|
||||
|
||||
// Set the initial vocabulary card
|
||||
this.props.setReview(this.reviewQueue.dequeue(), {
|
||||
correct: 0,
|
||||
wrong: 0,
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user