Add user progress dashboard

This commit is contained in:
hz
2026-07-18 23:45:38 -05:00
parent 2e52a7ea0a
commit 2dcac51452
26 changed files with 983 additions and 17 deletions
@@ -27,6 +27,8 @@ public class QuestionAttemptStore
var createdIndex = Builders<QuestionAttempt>.IndexKeys.Ascending(a => a.CreatedUtc);
_col.Indexes.CreateOne(new CreateIndexModel<QuestionAttempt>(createdIndex));
_col.Indexes.CreateOne(new CreateIndexModel<QuestionAttempt>(
Builders<QuestionAttempt>.IndexKeys.Ascending(a => a.UserId).Descending(a => a.CreatedUtc)));
}
public async Task<QuestionAttemptRecordResult> RecordFirstAttemptAsync(
@@ -35,7 +37,8 @@ public class QuestionAttemptStore
string choiceId,
bool isCorrect,
bool isSkip = false,
IReadOnlyCollection<string>? presentedChoiceIds = null)
IReadOnlyCollection<string>? presentedChoiceIds = null,
int durationSeconds = 0)
{
var attempt = new QuestionAttempt
{
@@ -46,6 +49,7 @@ public class QuestionAttemptStore
TracksPresentation = presentedChoiceIds is { Count: > 0 },
IsCorrect = isCorrect,
IsSkip = isSkip,
DurationSeconds = Math.Clamp(durationSeconds, 0, 86_400),
CounterBucket = GetCounterBucket(userId),
RatingApplied = false,
CreatedUtc = DateTime.UtcNow