Random number generator (and mathetical expression evaluation)

Context: I’d like to have cards display one of multiple possibilities. For instance, blanking out two of the four kanji in a 四字熟語. It would not make sense to make cards for all 6 possibilities.

Request: In the previous example, it would be possible on my side to have each kanji in a separate field. I however need a way to do a rand() and use that result with some if logic.

Additional: The rand could either take an argument and return an int between 0 and that number, or the card creator could deal with that by using a modulo (which requires some arithmetic evaluation). In that later case, it could be nice to have full fledged arithmetic evaluations to allow for biased sampling, or simply making math problem cards.

1 Like

Sorry for derailing, but I read the title and I just knew that the one posting had to be you :green_heart:

You may proceed with the topic

3 Likes

Sorry for further derailing, but I don’t recognize you with your new avatar.


On topic, it’s an interesting idea. But I wonder on the feasibility of giving you full fledged arithmetic evaluations without allowing any JavaScript (which we all know is bad) or writing something unnecessarily more complicated. What if you could just supply the percentages in some way to allow biasing?

(Well, I just did the same thing I did on WK: I took the default image and made it green)

Yes, I agree that it could take a bit of work to get the calculator working in Kitsun. That’s why I mentioned it as additional. It would be great to have it, but not necessary.

Even with a uniform distribution rand(), it’s possible to bias the outcome by simply having multiple copies of some field. It’s less elegant and less flexible, but I can deal with that.

For that reason, the random generator is the main request.

Giving percentages could be a nice second step though.

Grr I was afraid my message wasn’t going to be clear. I was talking about @jprspereira’s avatar and simultaneously poking fun at him for derailing the thread. I guess it didn’t work haha.

2 Likes

I was thinking of a question type like “Shikoku consists of Ehime, Kagawa, Kochi and ______.” with a text input for the last item.

My idea was to introduce some kind of “runtime fields” that you can use, like

{{Region}} consists of {{Prefectures@Pickone:Tail}} and _____.
{{type:Prefectures@Pickone:Head}}

where Prefectures is a comma-separated list, and the @ part accesses some runtime modifications of the field (randomizing, splitting, …). I think actually putting some code-like thing with rand() into the layout will make it fragile.

(The syntax is debatable, of course :slight_smile:)

2 Likes

I have no background in front-end programming, so I may not use the appropriate syntax. But the @ modifier seems to be what I was aiming for. That being said, I’d love to be able to use Pick(n) rather than Pickone

Also, it might be difficult to split into three or more groups (I don’t have an example of use for that, it’s just something that came to mind)

But anyway, if it’s easy to implement runtime modifications that way, I’m all for it.

I don’t really know either, I just have the feeling that it should fit into the {{。}} somehow :slight_smile:

But you could have an arbitrary number of runtime fields prepared for you (with one that does exactly what you want :slight_smile:), but for the template user it looks like accessing some strings.

So, Basically you’d like one (or more) parts of a value to be hidden at random?

What would you like to have as the splitting character? Comma? I guess that this would give some display errors when using it with your example (四字熟語)? Say we literally take 四字熟語, this would then be entered like 四,字,熟,語 and it would display like 四,熟,語?

Having it hide a few comma separated values by number (e.g. pick(n) ) wouldn’t be too hard to implement. However, combining it with an input field is going to be horror for me to build I think :stuck_out_tongue:

Btw, isn’t this similar to having cloze fields in anki?

1 Like

I was thinking of having it display 四じ熟語 and then you have to draw on a piece of paper the missing kanji, then reveal 四字熟語 and tick if yes or no you got it right. (This application brought to you by me starting to prepare for the 漢字検定4級)
This application is indeed a case of cloze deletion, but as far as I know, those are fixed (like, it’s always the same part that is hidden).

Your example somehow also made me think of one exercise from the JLPT, where they give you sentence parts in a random order, and you have to put them back into a correct sentence. That could be used for grammar, I guess (but it’s beyond the scope of this proposal, I think).

Hm, I suspected so. Still in the case of 四字熟語 (or cloze deletion in general), it could be fine to have the user just write the full text (not just the deleted part). Then there’s no need to connect the input to the deleted parts. However, that invalidates @acm2010’s example (or forces them to always use the same order)

1 Like

Yeah I’m kinda thinking this will turn into two separate feature requests, as there’s the display formatting issue and the input issue. Your usecase is quite a bit different from @acm2010’s

1 Like

Please feel free to move it around, it seems it is less similar than I was thinking :slight_smile:

2 Likes

Well, it feels similar in the sense that if it’s possible to do your thing, then it’s also possible to do mine :thinking:

Edit: hm, as long as I can still control the order, though… So maybe still two different features.

Sounds like a chance to use :nth-child() with a display style to alleviate the work you’d have to do with template parsing.