[v3.0.0] - Migrated to Wanikani Open Framework and APIv2
There are some UI issues with dragging the settings box. If you drag it up quickly, you can actually make it go above the visible part of the browser window, making it so you canāt continue to move the dialog. Resizing the dialog fixes this issue.
Also, what does the āInclude this sourceā setting do? Is it just a namespacing type of thing?
Thatās entirely jquery UI, though I might be able to do a post-drag check and correction.
Iām not totally happy with some of jquery UIās behavior, but I also donāt want to write my own (ugh!).
Via the Open Framework, scripters can add external sources of data, like a Core10k deck, which will then have its own tab next to Wanikani in the Items section. If you want to create a preset that only quizzes you on Core10k vocab, you would uncheck the āInclude this sourceā on the Wanikani tab, and check it on the āCore10kā tab.
I see, so itās basically a way to add entirely different items to self quiz with your script.
Can you give an example for how Iād add a filter? I have a handful I want to add. Also, whatās your thought on best practice for bundling a bunch together versus including a separate script per additional filter?
wkof.ItemData.registry.sources.wk_items.filters.percent_filter = {
type: 'number',
label: 'Percent Correct',
filter_func: percent_filter_func,
set_options: function(options){options.review_statistics = true;},
hover_tip: 'Filter items by accuract (in percent)'
}
function percent_filter_func(filter_value, item) {
if (item.review_statistics === undefined) return false;
var percent = item.review_statistics.percentage_correct;
if (percent === null || percent === undefined) return false;
if (percent < filter_value)
return true;
else
return false;
}
Iāll probably create a āFilter Packā script, which will have its own [Menu -> Scripts: Settings -> Open Framework Filter Pack]
. That will open a separate Settings dialog where users can check which filters they want to register, so only desired ones will appear in the Self Study Quiz settings dialog (and any other script that uses the registry).
If you want to start by just bundling filters into a single script, or start your own filter pack like I described, that would be a good start.
[edit: by the way, I created a ābuttonā filter type in case you want to make a popup dialog for setting up a multi-criteria filter. Iām not ready to delve deeper to create a cascaded ācomplexā type yet.]
Would this just be to avoid cluttering the Self Study Quiz settings (and other script) UI? From what I could tell, each filter option is disabled by default, so including extra ones wouldnāt be harmful, just a potential eyesore. Is that right?
Sorry for all the questions, I just want to understand how it all works.
Essentially, yes. While testing, I had a handful of filters for testing specific item sets, and it was annoying having to wade through a large number of filters, even if most of them are disabled. I donāt like clutter, and I can envision there eventually being a large filter pack (especially when Core10k is implemented), so I wanted a way to hide ones Iām not using. I imagine there are other people who would want to do the same.
Looks like youāre not handling when a filter is deleted. Or rather, it looks like you are explicitly throwing an exception when that happens. I added the exact code you pasted above with the filter called percent_filter
and tested it, saving a value for it in the settings. Then I replaced it with a filter I actually wanted to add. Trying to test the new filter, I get the following error:
VM1467:138 Uncaught (in promise) Error: wkof.ItemData.get_item() - Invalid filter "percent_filter"
at apply_filters (<anonymous>:138:41)
at <anonymous>:60:13
Yeah, I noticed that just before quitting for dinner. The preset saved in your settings is calling for a filter to be used, yet that filter doesnāt exist. The framework is properly complaining that youāre asking it to use a filter that doesnāt exist.
It looks like I need to check in the Self-Study Quiz if a filter is missing, and just remove it from the preset.
Gotcha. This could definitely use some more documentation by the way. I was having trouble getting my filter to work on first page load, and I realized it was because I didnāt have set_options: function(options) { options.assignments = true; }
.
I just installed this and am using Chrome. No matter what options I choose, it takes a little while to load and then says, āNo questions found!ā Suggestions on what I should do or look at to resolve this?
Hehā¦ yeah, it was only a prototype until 3 hours ago
If you set the left drop-down the āAll Questionsā and the right one to āAll Wanikani Itemsā, you still get āNo questions found!ā ?
If so, check your Javascript console for errors. Press F12 and click on the āConsoleā tab, and post a snapshot of any errors.
Correct.
Based on those errors, it looks like the ItemData module isnāt loaded.
In the Javascript console, does it say āundefinedā when you type the following (and press enter)?
wkof.ItemData
If so, what happens when you type this?
wkof.include('ItemData')
If all else fails, you could try clearing the wkof cache:
wkof.file_cache.clear()
Then refresh the page.
Yes, undefined
If so, what happens when you type this?
wkof.include(āItemDataā)
If all else fails, you could try clearing the wkof cache:
wkof.file_cache.clear()
Then refresh the page.
No dice. I still get āno questionsā and this in the console:
@rfindley Yay for minor UI bugs! Open the settings and go to the Items tab. Change the name of a preset but donāt save. Close the settings dialog, and reopen it. The name of the preset in the Edit Preset Name input has gone back to the previous/saved value. But the Presets List shows the new/unsaved value.
I missed a step in what I intended to have you do.
After this:
wkof.include('ItemData')
Try this again:
wkof.ItemData
You shouldnāt get undefined
anymore. If you do, then the module is having trouble loading for some reason, in which case it would help to check the Network tab to scroll back and see if there are any files that didnāt load (highlighted in red).
Iāve got a fix for this. It was introduced during the big refactoring :-/
Iāll upload after fixing the other issue (missing filter).
Ok, so now I get this:
Nothing highlighted in red in the Network tab.