Implement persistent review queue
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Bson.Serialization.Attributes;
|
||||
|
||||
namespace QuestionsApi.Models;
|
||||
|
||||
public static class ReviewQueueStates
|
||||
{
|
||||
public const string Pending = "pending";
|
||||
public const string Mastered = "mastered";
|
||||
public const string Unavailable = "unavailable";
|
||||
}
|
||||
|
||||
public sealed class ReviewQueueItem
|
||||
{
|
||||
[BsonId]
|
||||
[BsonRepresentation(BsonType.ObjectId)]
|
||||
public string? Id { get; set; }
|
||||
|
||||
public string UserId { get; set; } = "";
|
||||
public string QuestionExternalId { get; set; } = "";
|
||||
public string SourceAttemptId { get; set; } = "";
|
||||
public string State { get; set; } = ReviewQueueStates.Pending;
|
||||
public int Cycle { get; set; } = 1;
|
||||
public int ReviewCount { get; set; }
|
||||
public int IncorrectReviewCount { get; set; }
|
||||
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
||||
public DateTime UpdatedUtc { get; set; } = DateTime.UtcNow;
|
||||
public DateTime? LastReviewedUtc { get; set; }
|
||||
public DateTime? MasteredUtc { get; set; }
|
||||
}
|
||||
|
||||
public sealed class QuestionReviewAttempt
|
||||
{
|
||||
[BsonId]
|
||||
public string Id { get; set; } = "";
|
||||
|
||||
public string UserId { get; set; } = "";
|
||||
public string QuestionExternalId { get; set; } = "";
|
||||
public int Cycle { get; set; }
|
||||
public string ChoiceId { get; set; } = "";
|
||||
public List<string> PresentedChoiceIds { get; set; } = [];
|
||||
public bool IsCorrect { get; set; }
|
||||
public int DurationSeconds { get; set; }
|
||||
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public sealed class ReviewQueueBackfillState
|
||||
{
|
||||
[BsonId]
|
||||
public string UserId { get; set; } = "";
|
||||
public DateTime CompletedUtc { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
public sealed class ReviewQueueNextRequest
|
||||
{
|
||||
public List<string> ExcludeExternalIds { get; set; } = [];
|
||||
public bool SupportsChoicePools { get; set; } = true;
|
||||
}
|
||||
|
||||
public sealed class ReviewQueueNextResponse
|
||||
{
|
||||
public QuestionResponse? Question { get; set; }
|
||||
public int Cycle { get; set; }
|
||||
public int PendingCount { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ReviewQueueAttemptRequest
|
||||
{
|
||||
public string ClientAttemptId { get; set; } = "";
|
||||
public string QuestionExternalId { get; set; } = "";
|
||||
public int Cycle { get; set; }
|
||||
public string ChoiceId { get; set; } = "";
|
||||
public List<string> PresentedChoiceIds { get; set; } = [];
|
||||
public int DurationSeconds { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ReviewQueueAttemptResponse
|
||||
{
|
||||
public string QuestionExternalId { get; set; } = "";
|
||||
public bool IsCorrect { get; set; }
|
||||
public string QueueState { get; set; } = ReviewQueueStates.Pending;
|
||||
public int PendingCount { get; set; }
|
||||
}
|
||||
|
||||
public sealed class ReviewQueueRecordResult
|
||||
{
|
||||
public QuestionReviewAttempt Attempt { get; set; } = new();
|
||||
public ReviewQueueItem? Item { get; set; }
|
||||
}
|
||||
Reference in New Issue
Block a user