Skip to content

Commit 2375b2c

Browse files
authored
clamp displayed skill in [0,1]... (#849)
2 parents 200692d + e8ef741 commit 2375b2c

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

packages/courseware/src/typing/questions/single-letter/index.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,9 @@ export class TypeLetterQuestion extends Question {
7171
if (t < 3000) {
7272
return 1.0;
7373
} else {
74-
// scale from 1 at 3s to 0.25 at 10s
75-
return 1 - ((t - 3000) / 7000) * 0.75;
74+
// scale from 1 at 3s to 0.25 at 10s, clamped to [0.25, 1]
75+
const skill = 1 - ((t - 3000) / 7000) * 0.75;
76+
return Math.max(0.25, skill);
7677
}
7778
}
7879
return 0;

packages/db/src/study/SpacedRepetition.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function newQuestionInterval(user: DocumentUpdater, cardHistory: CardHistory<Que
3939
}
4040

4141
if (currentAttempt.isCorrect) {
42-
const skill = currentAttempt.performance as number;
42+
const skill = Math.min(1.0, Math.max(0.0, currentAttempt.performance as number));
4343
logger.debug(`Demontrated skill: \t${skill}`);
4444
const interval: number = lastInterval * (0.75 + skill);
4545
cardHistory.lapses = getLapses(cardHistory.records);

0 commit comments

Comments
 (0)