Calculate multichoice answer including text with exponent

Calculate multichoice answer including text with exponent

by Petrie Van Wyk -
Number of replies: 10

Any help on adding an exponent in the text as part of the answer for a calculated multichoice quiz question. 

For example: What is the area of a square with sides of 3.0 m and 4.0 m?

The answer should read 12 m2.

How do I formulate the answer in the answer block to produce the exponent (I use wildcards for the size variables)?

Average of ratings: -
In reply to Petrie Van Wyk

Re: Calculate multichoice answer including text with exponent

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

You could use the ² character (copy and paste it from http://www.amp-what.com/unicode/search/superscript%20two).

In reply to Dominique Bauer

Re: Calculate multichoice answer including text with exponent

by Petrie Van Wyk -

Thank you it works, but it is rather limiting. I have tried to use html tags (<sup>2</sup>) but this does not seem to be recognized in the answer field?

In reply to Petrie Van Wyk

Re: Calculate multichoice answer including text with exponent

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

The HTML tags in the Answers/Choice fields are actually recognized by Moodle as we can see on the Edit the wildcards datasets page. Unfortunately, tags are not recognized in the final display of the question.


In reply to Petrie Van Wyk

Re: Calculate multichoice answer including text with exponent

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

If you are using a Windows computer to create your questions, place your cursor where you want m² to appear, type the m, then hold down the Alt key and type 0178 on your number keypad. Then let go of the Alt key after which you should get a superscript ².

I don't have a Linux computer handy at the moment, to check if they work the same, but basically, you are just typing another letter in the character set, that just doesn't have a dedicated key.

Also, if on windows, go to Start > Windows accessories > Character map. You can use it to find many other letters, even many foreign ones.


Average of ratings: Useful (1)
In reply to AL Rachels

Re: Calculate multichoice answer including text with exponent

by Petrie Van Wyk -

Thank you for the tip, I do use a windows machine. I guess there is no method then to do any custom sub/superscripts and only these workarounds for commonly used characters.

In reply to Petrie Van Wyk

Re: Calculate multichoice answer including text with exponent

by AL Rachels -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers

I think you might be able to do what you want with the Formula type question because with it you 'build' your question and answer display in a text widow that has an editor. Then it is just a matter of using the subscript and superscript tool buttons, or the Alt+number method. I don't have time to test it today as I was shutting down when I saw you reply. Will try tomorrow.

In reply to AL Rachels

Re: Calculate multichoice answer including text with exponent

by Jean-Michel Védrine -

Yes this is possible with the Formulas question type:

square area question

I used the join function to write the answers like c=join(" ",a*b,"m<sup>2</sup>");

This also makes me realize that multichoice with radio buttons answers could use some dedicated styles to improve the display !!

In reply to Jean-Michel Védrine

Re: Calculate multichoice answer including text with exponent

by Jean-Michel Védrine -

As I said in the previous message now that multichoice answers are used a lot in Formulas questions (just for history this feature was undocumented in Hon Wai Lau documentation, I discovered it when I studied the code wink ) I think they need a little more love to improve the display

I added some styling because the labels were too close from the radio buttons and i managed to have something similar both in Boost and More or Clean theme (this was NOT the easy part !)

mc answer in Boost themeBoost theme

mc answer More themeMore theme

But maybe you have already spotted some other change in the above screenshots? I added a numbering feature to the choices. I simply borrowed the one from the multichoice qtype (similar to what is doing calculated multichoice question type) to avoid the need to duplicate code.

edit Formulas question

So that means that the formulas qtype is now dependent of the multichoice qtype but as I think qtype_multichoice is installed on all Moodle websites this shouldn't be a problem for anyone.

I didn't bother to introduce a setting for the default value, the Formulas qtype simply use the one defined for the multichoice qtype.

I also introduced a new sigfig function (sigfig for significant figures) with two numerical arguments the first one is the float to be displayed and the second one is an integer : the desired number of significant figures. The function return a string ready to be displayed (it can't be a number as we need trailing zeros in some cases !)

I will post here when this version will be available in the Moodle plugin database


In reply to Jean-Michel Védrine

Re: Calculate multichoice answer including text with exponent

by Dominique Bauer -
Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Plugin developers

Jean-Michel,

The numbering of multiple choices and the display of significant figures will bring interesting improvements to the Formulas question. Good work!

In reply to AL Rachels

Re: Calculate multichoice answer including text with exponent

by Giovanni Bratti -
Hi,

I am trying to use the Tex notation, like:



on "Calculated Multichoice questions", but the Tex scripts isn't compiled in the answers fields.



The administrator set the configs described in https://moodle.org/mod/forum/discuss.php?d=193975#p1260466, but also it doesn't compile the Tex scripts.

Someone knows how can I use latex notation in answers of this type of question?
I am using moodle 3.4.

Bratti