this should roundabout work:
Code (untested)
wkof.include('ItemData');
wkof.ready('ItemData').then(getItems).then(mapItemsToSrs).then(showRandomBurned);
function getItems() {
return wkof.ItemData.get_items(config);
//return wkof.ItemData.get_items(config).then(filterToActiveAssignments);
}
function getSrsStage(assignments) {
if (!assignments) {
return 0; // not yet learned
}
return assignments.srs_stage;
}
function mapItemsToSrs(items) {
let itemsBySrs = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].reduce((result, srs) => { // stage 0 = not yet learned
result[srs] = [];
return result;
}, {});
// separation by srs stage may be necessary in future if we want to show kanji learned per SRS stage etc.
items.forEach(function(item) {
let srsStage = getSrsStage(item.assignments);
if (srsStage == 9 && item.object == 'vocabulary') { // 9 = burned
itemsBySrs[srsStage].push(item);
itemsBySrs.totalVocab++;
}
});
return itemsBySrs;
}
function showRandomBurned(items) {
let totalBurnedVocab = itemsBySrs[9].length;
let randomItem = itemsBySrs[9][4]; // 9 = burned. 4 was determined to be random by dice roll
// do stuff with it
}
obviously you use a smarter random function, that checks the length/number of burned items.
It’s adapted and simplified from my Show Number of Learned Kanji, Vocabulary script,
which adapts and simplifies the code from the SRS and Leech breakdown script mentioned.
It could be further simplified, but i don’t know what data you may need.
Kumirei’s code is better though, much simpler: