Skip to content

Commit

Permalink
fix mastery script when the question queue is empty
Browse files Browse the repository at this point in the history
This can't happen in the standard script, but I wrote an extension that
ended up emptying the queue in the current topic, and I would have had
to rewrite the `after_answering` note. I think just adding some handling
for this edge case in the built-in script is the right thing to do.
  • Loading branch information
christianp committed Dec 4, 2024
1 parent 4bdd6ac commit 16c2061
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
10 changes: 7 additions & 3 deletions diagnostic_scripts/mastery.jme
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,21 @@ correct (Did the student get the current question right?):
after_answering (The state after the student answers a question):
let(
queue, state["question_queue"],
empty_queue, len(queue) = 0,

nquestion,
// Set the status of this question in the queue.
merge(
if(not empty_queue,
merge(
queue[0],
["status": if(correct,"passed","failed")]
),
),
nothing
),

nqueue,
// Change the queue: either remove the current question if correct, or add it to the end.
queue[1..len(queue)] + if(correct,[],[nquestion]),
queue[1..len(queue)] + if(correct or empty_queue, [], [nquestion]),

ntopics,
// Update the list of topics, setting the current topic to "passed" if the queue is now empty.
Expand Down
Loading

0 comments on commit 16c2061

Please sign in to comment.