Moodle formulas units

Moodle formulas units

by Marko Nuskol -
Number of replies: 3

Hello.

I need help with entering a unit in Moodle formulas question.

 \[\text{S}\ \text{c}{{\text{m}}^{2}}\ \text{d}{{\text{m}}^{3/2}}\ \text{mo}{{\text{l}}^{-3/2}}\]

I can easily enter the full exponent (like \( mo{{l}^{3}} \) ) but I can't enter something like \[\text{mo}{{\text{l}}^{-3/2}}\]

I'm not talking about entering the unit inside the "Main question part" of a question but within the "Part 1 - Unit".

Here the SI unit will determine if the above entered unit is correct or not.

Thank you for any help (or ideas) you can provide.

Our Moodle version is 3.9

Average of ratings: -
In reply to Marko Nuskol

Re: Moodle formulas units

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers
Some say that units of measurement raised to a power which is a fraction have no physical meaning. The BIPM does not mention any in its SI-brochure. Others say that they are nevertheless used in practice and give several examples.

They can't be used directly with the Formulas question, but the following workaround should work.

  • Let the students enter the unit as follows: "mol^(-3/2)".
  • In the question settings, set the unit to "foo1".
  • In the question text, add a script that interprets "mol^(-3/2)" as "foo1".

The interpretation of units raised to a fractional power might one day be implemented in the Formulas question, but in the meantime you can use the workaround.

Average of ratings: Useful (1)
In reply to Dominique Bauer

Re: Moodle formulas units

by Marko Nuskol -
I'm amazed every day how we manage to get a workaround for just about everything smile

Since the script is not my forte could you maybe post it here so that I (and others) can use it. Or a link where I can see how it is done.

Thank you again for the prompt reply to my problem.
In reply to Marko Nuskol

Re: Moodle formulas units

by Marko Nuskol -

Our Moodle administrator (thx Zvonko) helped me with the jQuery code.

------------------------------

<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>

<script>

$("#responseform").submit(function(event) {

$('.formulaspart').eq(2).find('.formulas_unit').val($('.formulaspart').eq(2).find('.formulas_unit').val().replace("S cm^2 dm^(3/2) mol^(-3/2)", "foo"));

});

</script>

------------------------------

.eq(2) - this number starts from 0 (part 1), 1 (part 2), etc..depends on the location of the unit you want to change.

"foo" is what I have put inside the unit box (you can put whatever you want.

Hope this can help someone.

Average of ratings: Useful (1)