Restore distractor-specific follow-up questions

This commit is contained in:
hz
2026-08-01 18:06:52 -05:00
parent 8c5aa17d89
commit c7f5006cb6
14 changed files with 76770 additions and 100 deletions
+13 -14
View File
@@ -88,10 +88,6 @@ string? ValidateAuthoredQuestion(UpsertQuestionRequest question)
{
if (followup.Choices.Count != 3 || followup.Choices.Select(choice => choice.Id).SequenceEqual(["A", "B", "C"]) is false)
return "wrong-answer follow-ups must use ordered A-C choices";
if (followup.Choices.Any(choice =>
!question.Stem.Contains(choice.Text, StringComparison.OrdinalIgnoreCase)
&& !question.Labs.Any(lab => $"{lab.Name} {lab.Value}".Contains(choice.Text, StringComparison.OrdinalIgnoreCase))))
return "wrong-answer follow-up choices must be traceable to the stem or labs";
}
return null;
}
@@ -107,20 +103,23 @@ UpsertQuestionRequest Build(Seed seed)
id => id == "A"
? $"Correct. {seed.Explanation}"
: $"Incorrect. {choices.Single(choice => choice.Id == id).Text} does not adequately address the decisive finding: {seed.KeyFact}. {seed.Takeaway}");
var wrongFollowups = ids.Skip(1).ToDictionary(
id => id,
id => new WrongAnswerFollowup
var distractorIds = ids.Skip(1).ToArray();
var wrongFollowups = distractorIds.ToDictionary(id => id, id =>
{
var index = Array.IndexOf(distractorIds, id);
var alternatives = new[] { distractorIds[(index + 1) % distractorIds.Length], distractorIds[(index + 2) % distractorIds.Length] };
return new WrongAnswerFollowup
{
Prompt = $"Which finding in this vignette most strongly supports {seed.Answers[0]}?",
Prompt = $"Which limitation of option {id} should have ruled it out in this case?",
Choices =
[
new() { Id = "A", Text = seed.KeyFact },
new() { Id = "B", Text = seed.ContextFact },
new() { Id = "C", Text = seed.NeutralFact }
new() { Id = "A", Text = choiceExplanations[id] },
new() { Id = "B", Text = choiceExplanations[alternatives[0]] },
new() { Id = "C", Text = choiceExplanations[alternatives[1]] }
],
CorrectChoiceId = "A",
TeachingPoint = seed.Takeaway
});
CorrectChoiceId = "A", TeachingPoint = choiceExplanations[id]
};
});
return new UpsertQuestionRequest
{