Track real first attempt question stats

This commit is contained in:
hz
2026-07-11 01:42:18 -05:00
parent e991dccbb2
commit 8a86734a0b
13 changed files with 297 additions and 6 deletions
@@ -0,0 +1,17 @@
using MongoDB.Bson;
using MongoDB.Bson.Serialization.Attributes;
namespace QuestionsApi.Models;
public class QuestionAttempt
{
[BsonId]
[BsonRepresentation(BsonType.ObjectId)]
public string? Id { get; set; }
public string QuestionExternalId { get; set; } = "";
public string UserId { get; set; } = "";
public string ChoiceId { get; set; } = "";
public bool IsCorrect { get; set; }
public DateTime CreatedUtc { get; set; } = DateTime.UtcNow;
}
@@ -28,3 +28,9 @@ public class UpsertQuestionRequest
public List<string> Tags { get; set; } = [];
public bool IsPublished { get; set; } = true;
}
public class FirstQuestionAttemptRequest
{
public string QuestionExternalId { get; set; } = "";
public string ChoiceId { get; set; } = "";
}
+10 -2
View File
@@ -18,7 +18,7 @@ public class QuestionResponse
public List<string> Media { get; set; } = [];
public List<string> Tags { get; set; } = [];
public static QuestionResponse FromModel(Question question) => new()
public static QuestionResponse FromModel(Question question, Dictionary<string, int>? liveChoiceSelectionPercentages = null) => new()
{
Id = question.Id ?? "",
ExternalId = question.ExternalId,
@@ -28,7 +28,9 @@ public class QuestionResponse
CorrectChoiceId = question.CorrectChoiceId,
Explanation = question.Explanation,
ChoiceExplanations = question.ChoiceExplanations,
ChoiceSelectionPercentages = question.ChoiceSelectionPercentages,
ChoiceSelectionPercentages = liveChoiceSelectionPercentages is { Count: > 0 }
? liveChoiceSelectionPercentages
: question.ChoiceSelectionPercentages,
Discipline = question.Discipline,
System = question.System,
Difficulty = question.Difficulty,
@@ -37,3 +39,9 @@ public class QuestionResponse
Tags = question.Tags
};
}
public class FirstQuestionAttemptResponse
{
public string QuestionExternalId { get; set; } = "";
public Dictionary<string, int> ChoiceSelectionPercentages { get; set; } = [];
}