Repository navigation
Fix random problem selection by difficulty #256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,6 +79,8 @@ let durationCeiling = Infinity; | |
| let roll = Math.random(); | ||
| // Keep the exclusion with the roll so restoring the page repeats the same draw. | ||
| let avoidedProblem; | ||
| // Preserve the draw policy as well as its roll during history/page restores. | ||
| let pickerMode = "recommend"; | ||
|
|
||
| const nodes = { | ||
| accountStatus: document.querySelector("#account-status"), | ||
|
|
@@ -233,6 +235,7 @@ nodes.randomProblem.addEventListener("click", () => { | |
| keptDraw = null; | ||
| roll = Math.random(); | ||
| avoidedProblem = problem?.id; | ||
| pickerMode = "random"; | ||
| applyDifficulties(); | ||
| recommend(); | ||
| }); | ||
|
|
@@ -263,6 +266,7 @@ for (const input of levels) { | |
| keptDraw = null; | ||
| roll = Math.random(); | ||
| avoidedProblem = undefined; | ||
| pickerMode = "random"; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A level change is not an explicit random draw, but this switches it to uniform selection anyway. With a passed Hard problem and unseen Hard ones, checking Hard and unchecking the current level can now offer the passed problem first. That undoes "a problem already passed is not what gets recommended next", and the description does not mention it. If the goal is only to stop reviews crossing the selected levels, keep |
||
| // Not before the reports are in. Recommending from an empty history here | ||
| // would offer a problem the candidate has already passed and then swap it | ||
| // when the fetch lands. `settle` makes the pick for this level instead, and | ||
|
|
@@ -1021,6 +1025,7 @@ function recommend(note = "") { | |
| undefined, | ||
| avoidedProblem, | ||
| cards, | ||
| pickerMode, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Topic-filter redraws in random mode can select the current problem again because Prompt for AI agents
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| ); | ||
| // Nothing to offer is still an answer, and it has to go through `setProblem` | ||
| // like every other one. Returning here left whatever was picked for the | ||
|
|
@@ -1032,6 +1037,11 @@ function recommend(note = "") { | |
| return; | ||
| } | ||
| setProblem(choice.picked); | ||
| // Editing begins: When randomly selecting questions, display the difficulty level next to the question title. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Editing begins:" reads like an editor marker. A comment here should say why random mode skips the review sentence, e.g. that a random draw is never a review and the level is named because it may differ from the suggested one. |
||
| if (pickerMode === "random") { | ||
| nodes.recommendation.textContent = `${note}Selected problem: ${title(choice.picked)} (${choice.picked.difficulty}).`; | ||
| return; | ||
| } | ||
| if (choice.review) { | ||
| // A review can fall outside the levels now selected, so the card is | ||
| // unhidden and the level said out loud rather than silently ignored. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The difficulty half of this test only runs after the Random click has already set
pickerMode = "random", so deleting the assignment in the level handler still passes. It also checks only the level, not that the note lacksReview due. Exercise the level change from a fresh lobby with overdue reviews, as a separate test, and assert both.