Improve dynamic question learning loop
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
namespace QuestionsApi.Services;
|
||||
|
||||
public static class DynamicReviewPolicy
|
||||
{
|
||||
private static readonly int[] IntervalsDays = [1, 3, 7, 21, 45];
|
||||
|
||||
public static DateTime FirstDue(DateTime nowUtc) => nowUtc.AddDays(IntervalsDays[0]);
|
||||
|
||||
public static (int Stage, DateTime? DueUtc, bool Mastered) AfterReview(
|
||||
int currentStage,
|
||||
bool isCorrect,
|
||||
DateTime nowUtc)
|
||||
{
|
||||
if (!isCorrect)
|
||||
return (0, FirstDue(nowUtc), false);
|
||||
|
||||
var nextStage = Math.Clamp(currentStage + 1, 1, IntervalsDays.Length);
|
||||
if (nextStage >= IntervalsDays.Length)
|
||||
return (nextStage, null, true);
|
||||
return (nextStage, nowUtc.AddDays(IntervalsDays[nextStage]), false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user