Lesson ordering changes on refresh

I have the default setting of Ascending level then subject selected for my lesson ordering. Every once in a while I’m in the middle of lessons and accidentally refresh the page. Multiple times (including just yesterday) when I continue my lessons I have different lessons. I’ve not completed any additional reviews, so it’s not like more new items would have unlocked. As far as I understand, the ordering should be completely fixed/deterministic.

With all that said, I do have a script enabled that influences lessons, but I’m pretty sure it wouldn’t cause this. I’ll still try refreshing a handful of times with the script off, but I’m not sure if that will reproduce the issue since it happens inconsistently anyway.

I have also experienced the offered lesson order changing upon refresh.

I’m currently on someone else’s computer. So no scripts, or even Tampermonkey on this one. I checked, and the lessons in my queue were completely the same between refreshes. I jumped onto my phone and started the lessons there - they were still in the exact same order as when I started lessons on this “clean” computer.

So you may be right that one or more scripts interfere with this.

Maybe that’s why I sometimes have a lesson where they refer to a word that they claim I learned during that level, but without me having actually learned that word yet. :thinking:

Do you normally use any scripts that change lesson order? If so, which ones?

On my normal machine I have Reorder Ultimate running. I can’t think of anything else that changes or lets me change the lesson order.

I don’t have access to my regular laptop right now, but when I get back onto it later, I will double-check to be sure I’m not forgetting any.

Do you use my Lesson Filter script? That’s the only one I have that does anything with lesson order.

You mean your Additional Filters scripts? You’re right, I also run that one.

Love that script by the way - how it facilitates leech learning with the Self-Study Quiz is amazing. :purple_heart:

Thanks for the praise. :blush: But not that one in this case. I’m talking about this one:

Ah, sorry for misunderstanding. ^^

No, I don’t run that particular one. If it helps any, I can post all the scripts I’m running (somewhere between seven and ten?) when I get back onto my regular machine.

That would be great, thanks!

1 Like

Everything I’m running right now. ^^

1 Like

@viet Any insight you can share on this?

The only script I have that interacts with lesson ordering is Lesson Filter and the only script that @Omun has that interacts with lesson ordering is Reorder Ultimate 2. So there’s no overlap between our scripts even though we’ve both seen this issue.

Additionally, can you share if all ordering is done on the server side or if any is done in JavaScript when the page loads? My Lesson Filter script works by filtering the content in l/activeQueue and l/lessonQueue and resetting them, but it does it specifically in sequential order so that the ordering set by the Ascending level then subject setting is maintained. If l/activeQueue and l/lessonQueue are set deterministically I can’t think of any way my script could filter them differently from one load to another.

And to add one more thing, I’ve never seen the items change just by refreshing the page or executing the filter behavior on my script. I always see this when I’ve completed at least one of my lesson batches (including the quiz portion) and the refresh occurs during the second or third batch. I tend to notice the items being different because I add notes during my kanji lessons and the kanji with notes is no longer in the remaining lessons batch(es) when I go to redo them after the accidental refresh, only to have the kanji with notes appear during the next day’s lessons.

It’s all done server side.

I’m thinking that it has to do with the lowest level sorting (or lack thereof) of items. So, we order them by level then by subject type (ahem). After that, the sorting gets a little fuzzy. All the radicals, for instance, are not sorted by anything more, so they’re served up in the order they’re read out of the database. My guess would be that ordering is pretty consistent, but doesn’t have guaranteed consistency.

I’ll make a task to make it guaranteed ordering. I’ll get that out next week.

When you say they don’t show up until the next day’s lessons, what do you mean? That those lessons drop out of your queue altogether (the counter would drop to zero) or that they get pushed further down your queue and you, by learning convention, don’t see them until later?

I ran through the JS that controls the ordering, and notes shouldn’t affect the ordering or make it drop out, but maybe I’m missing something. I’ll keep digging…


Sorry, I should have been clearer on that point. I do 12 lessons every day, consisting of 4 kanji and 8 vocab (if available). So they seem to get pushed further down my queue, resulting in me seeing them the following day.

I highly doubt the notes have anything to do with the ordering. I only brought that up because that’s how I know the lessons are getting pushed further down the queue and it’s not just me misremembering what I saw before the refresh.

As I said above, most days I’m doing lessons for kanji and vocab. So what is the tie break criteria for kanji and vocab after level and subject type? Since this seems to happen after I complete a lesson batch, is it possible that completing lessons for one batch of items can change the sort order for the remaining items? Anything to do with not having enough tie break criteria or using an unstable sorting algorithm could be related.

Something magical within PostgreSQL. :wink: Like I said, I’ll implement a guaranteed order next week that takes away the magic.

Let’s see if that change resolves your notes-triggered reordering. The notes and the subjects shouldn’t interact with each other in any way that should affect how they show up in lessons, but there could be a connection I’m not seeing quite yet.

1 Like

I can confirm.

I just reloaded the lessons page and got a different order with just vocab items. No userscripts running and no extensions installed.

As I said, I think it’s triggered by completing a lesson batch, not by notes (but if it is triggered by notes you got some funky queries :wink:). Either way, thanks for looking into it. Let me know when the fix is live and I’ll poke around a bit and see if I can still make it happen.

Alright, the change is live, so lessons should come from the server in the same order every time, guaranteed.

@seanblue: The front-end code that splices the lessons off the available queue does just that, so I don’t think vanilla WK should affect the ordering at all once it’s retrieved from the server.

@seanblue, @doncr, and @Omun, let me know if you’re still seeing the behavior without userscripts.


I checked it in a few ways, and without user scripts, the order is staying consistent across multiple devices. ^^

I did some checking by turning on user scripts one by one, and the culprit for me is the Ultimate Reorder script. Without it, the lessons are static. With it, they will switch on every refresh. Good to know.

I have a feeling you were seeing a different issue from me the whole time then. :sweat_smile:

Haha, whoops. :sweat_smile: