Very nice, thanks for sharing!
Peter
On Thursday, 5 January 2023 at 20:42:24 UTC+1 MTSowbug wrote:
> Sorry for replying to a years-old thread, but I have a solution to this
> problem. The OP had a math card that generated a math problem with
> JavaScript, and he wanted the randomly generated question to match the
> randomly generated solution. Although Mnemosyne doesn't let the front and
> back sides of a card pass data to each other, we can bypass the issue if
> the front and back use identically seeded pseudo-RNGs, e.g. by using
> today's date as the seed. In this manner, the front and back will always
> produce matching randomly generated equations.
>
> Here is an example for a "front-to-back only" card. First, the front:
>
>
> Add these numbers:
> <script language="JavaScript">
> //FRONT OF CARD
> function Random() { seed = seed * 48271 % 2147483647 <(214)%20748-3647>;
> return seed; } //Lehmer MINSTD
> const d = new Date();
> _cardsalt = 879; //arbitrary card-specific number to stop other cards in
> the deck from sharing RNG
> seed = d.getDate()+d.getMonth()+_cardsalt; //hash today's date
> Random(); Random(); //burn the first couple random numbers
>
> aVal=Random()%900000+100000;
> bVal=Random()%900000+100000;
> cVal = aVal+bVal;
>
> document.write(aVal + " + " + bVal + " = ???<br>"); //This is the only
> line that differs front vs back
> </script>
>
>
> Then, the back:
>
>
> Add these numbers:
> <script language="JavaScript">
> //BACK OF CARD
> function Random() { seed = seed * 48271 % 2147483647 <(214)%20748-3647>;
> return seed; } //Lehmer MINSTD
> const d = new Date();
> _cardsalt = 879; //arbitrary card-specific number to stop other cards in
> the deck from sharing RNG
> seed = d.getDate()+d.getMonth()+_cardsalt; //hash today's date
> Random(); Random(); //burn the first couple random numbers
>
> aVal=Random()%900000+100000;
> bVal=Random()%900000+100000;
> cVal = aVal+bVal;
>
> document.write(aVal + " + " + bVal + " = " + cVal + "<br>"); //This is the
> only line that differs front vs back
> </script>
>
>
> I believe this method generalizes to any randomized math-based flashcards.
> On Saturday, March 2, 2019 at 5:25:16 AM UTC-6 [email protected] wrote:
>
>> Hello,
>>
>> I was lazy and figured out that I can add the answer in the Front, if I
>> simply make it invisible by using "color:white". When I need to check my
>> answer, I can select the white text and see if I'm correct or not.
>>
>> The Back then is left either empty, or contains some general explanation
>> related to the question.
>>
>> Best wishes,
>> Ilmars
>>
>>
>> On Friday, March 1, 2019 at 10:26:02 AM UTC+2, Peter Bienstman wrote:
>>
>>> Hi,
>>>
>>>
>>>
>>> I’m not sure if this will work out of the box, I suggest you try it.
>>>
>>>
>>>
>>> In any case, it’ll certainly be possible to achieve this by writing a
>>> plugin for a custom Renderer and/or CardType.
>>>
>>>
>>>
>>> To see how Mnemosyne assembles html, see here:
>>>
>>>
>>> https://github.com/mnemosyne-proj/mnemosyne/blob/master/mnemosyne/libmnemosyne/renderers/html_css.py
>>>
>>>
>>>
>>> Cheers,
>>>
>>>
>>>
>>> Peter
>>>
>>> *From:* [email protected] <[email protected]> *On
>>> Behalf Of *Ilmars Cirulis
>>> *Sent:* 28 February 2019 22:39
>>> *To:* mnemosyne-proj-users <[email protected]>
>>> *Subject:* [mnemosyne-proj-users] How to change card's Back from Front
>>> using JavaScript?
>>>
>>>
>>>
>>> Hello!
>>>
>>>
>>> If I want to add some element to Back, using JavaScript in Front, is it
>>> possible?
>>> I added an ilustration in the attachment.
>>>
>>>
>>>
>>> Best wishes,
>>> Ilmars
>>>
>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "mnemosyne-proj-users" group.
>>>
>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to [email protected].
>>> To post to this group, send email to [email protected].
>>>
>>
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/mnemosyne-proj-users/9bd1ad05-d174-4773-854a-da9b6a94cd4b%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/mnemosyne-proj-users/9bd1ad05-d174-4773-854a-da9b6a94cd4b%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
--
You received this message because you are subscribed to the Google Groups
"mnemosyne-proj-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/mnemosyne-proj-users/25e674b5-06ea-4dfb-bffe-9db79b97afa8n%40googlegroups.com.