feat: Don't forget about the adverbs
This commit is contained in:
@@ -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