Random variables in ASCIIIMaths

Random variables in ASCIIIMaths

by Rory Barrett -
Number of replies: 2

Hello Colleagues

I am very new to moodle but have quite a lot of experience in using java applets and latterly javascript.

Neither of these languages as far as I know readily allows the easy use of math symbols hence the need for mathml.

While the various tools available seem to produce satisfactory representation for something like one half or two to the power of three is it possible using ASCIIIMaths or indeed any maths tool to produce random fractions or pwers.

What I mean is that when Ben loads a page into his computer he sees 1/3 while Trudy would see 3/4 etc. The fractions written as fractions as we all know them ?

Rory Barrett

Average of ratings: -
In reply to Rory Barrett

Re: Random variables in ASCIIIMaths

by Davide Cervone -
While this could be done using MathML, that is not required. The jsMath filter would also work for this. You could install the jsMath filter in place of the tex filter, or even along side it, if you change the jsMath settings appropriately. Then you could do something like:
    <SCRIPT>
       var m = Math.floor(Math.random() * 5 + 2);
       var n = Math.floor(Math.random() * 4 + 2);
       document.write('$$\\left(\\frac{1}{'+m+'}\\right)^{'+n+'}$$');
    </SCRIPT>
to display the value (1/m)^n as a fraction to a power. Note that the TeX backslashes need to be doubled since they are in JavaScript strings (the double \\ becomes a single \ in the result).

I haven't actually tested the code, but it should get you started, at least.

Hope that helps.

Davide

In reply to Davide Cervone

Re: Random variables in ASCIIIMaths

by Paul Cacion -
Speaking of random quiz questions, how do you let Moodle know what the right answer is?

Also, is there a module that has random math questions created for quiz/exam?
What would be the closest module that creates math questions on the fly?

To clarify: I don't want to store any questions at all, but rather have code create them
dynamically, and score them once the quiz page is completed.

Im considering writing such a module and would like to know what module is a good place to start from.


Thanks,