Prefer high-performing distractors
This commit is contained in:
@@ -72,6 +72,7 @@ public class ExamSimulationStore
|
||||
var elos = await _ratings.GetQuestionElosAsync(bank.Select(question => question.ExternalId));
|
||||
var targets = BuildTargets();
|
||||
var selected = SelectForm(bank, seen, targets);
|
||||
var choicePercentages = await _statistics.GetPercentagesByQuestionAsync(selected.Select(question => question.ExternalId));
|
||||
var items = new List<ExamSimulationItem>();
|
||||
var position = 0;
|
||||
for (var block = 0; block < BlockSizes.Length; block++)
|
||||
@@ -84,7 +85,7 @@ public class ExamSimulationStore
|
||||
QuestionExternalId = question.ExternalId,
|
||||
BlockIndex = block,
|
||||
Position = offset,
|
||||
PresentedChoiceIds = SelectChoices(question),
|
||||
PresentedChoiceIds = SelectChoices(question, choicePercentages.GetValueOrDefault(question.ExternalId)),
|
||||
QuestionElo = elos.GetValueOrDefault(question.ExternalId, 1000),
|
||||
WasSeen = seen.Contains(question.ExternalId),
|
||||
BlueprintCategory = BlueprintCategory(question)
|
||||
@@ -115,12 +116,13 @@ public class ExamSimulationStore
|
||||
throw new InvalidOperationException($"At least {RequiredQuestions} published questions are required.");
|
||||
var targets = BuildTargets();
|
||||
var selected = SelectForm(bank, [], targets);
|
||||
var choicePercentages = await _statistics.GetPercentagesByQuestionAsync(selected.Select(question => question.ExternalId));
|
||||
var items = selected.Select((question, index) => new ExamSimulationItem
|
||||
{
|
||||
QuestionExternalId = question.ExternalId,
|
||||
BlockIndex = BlockIndexForPosition(index),
|
||||
Position = PositionWithinBlock(index),
|
||||
PresentedChoiceIds = SelectChoices(question),
|
||||
PresentedChoiceIds = SelectChoices(question, choicePercentages.GetValueOrDefault(question.ExternalId)),
|
||||
QuestionElo = 1000,
|
||||
WasSeen = false,
|
||||
BlueprintCategory = BlueprintCategory(question)
|
||||
@@ -501,12 +503,10 @@ public class ExamSimulationStore
|
||||
Media = question.Media
|
||||
};
|
||||
|
||||
private static List<string> SelectChoices(Question question)
|
||||
{
|
||||
var distractors = question.Choices.Where(choice => choice.Id != question.CorrectChoiceId).OrderBy(_ => Random.Shared.Next()).Take(4).Select(choice => choice.Id).ToList();
|
||||
distractors.Add(question.CorrectChoiceId);
|
||||
return distractors.OrderBy(_ => Random.Shared.Next()).ToList();
|
||||
}
|
||||
private static List<string> SelectChoices(
|
||||
Question question,
|
||||
IReadOnlyDictionary<string, int>? liveChoiceSelectionPercentages) =>
|
||||
ChoicePoolSelector.SelectChoiceIds(question, liveChoiceSelectionPercentages);
|
||||
|
||||
private static List<Question> SelectForm(List<Question> bank, HashSet<string> seen, Dictionary<string, int> targets)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user