Formulas question type - can the 'number and unit' be made to disappear

Formulas question type - can the 'number and unit' be made to disappear

by John Hicks -
Number of replies: 1

Hi there,

Does anyone know of any script to make, for example, the 'Number and unit' disappear when typing in an answer.  The rationale for this is algebraic answers can then be used for 'strings', and questions using a formula for a calculation can be included on the same question in a different part.


Kind Regards,

John

Average of ratings: -
In reply to John Hicks

Re: Formulas question type - can the 'number and unit' be made to disappear

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

John,

This tooltip is actually the 'title' attribute of the input box.

One way to locate the input boxes is to select them directly using for example their class, such as $(".formulas_number_unit"), and if required their position in the series of occurrences, such as $(".formulas_number_unit:eq(2)").

Another way, which might be simpler to do, is to enclose the input boxes, i.e. {_0}, {_1}, {_u}, etc., in a span, p or div element with a class that removes the 'title' attribute. It is very simple. In the script, add the following line:

   $(".mf_nolabel input").removeAttr("title");

where mf_nolabel is any name.

For example, if you don't want any title, write in the question text:

   <div class="mf_nolabel">
       Force is {FA} kN + {FB} kN:
       {#1}
       Pressure is Force divided by Area where Area is {A} m2:
       {#2}
   </div>

If you don't want a title for a specific answer box, for example {_1}, write in the part's text:

  {_0} <span class="mf_nolabel">{_1}</span> {_2}