FormulasQuestion / moodle-qtype_formulas

Formulas question type for Moodle
17 stars 29 forks source link

Width of the answer boxes #126

Closed dbauer-ets closed 7 months ago

dbauer-ets commented 7 months ago

Hello Philipp,

Given that the 'Formulas' question is used in various contexts, the default width of input boxes is often not quite adequate. Moreover, within the same question, one might want to use different widths for input boxes. Therefore, it's not just a matter of being able to modify the default values for widths for different types of answers (number, numeric, numerical formula, algebraic formula), but rather allowing users to choose the width of each input box if the default value does not suit them.

Users can do this relatively easily with some CSS or the equivalent in JavaScript. However, for many users, this requires knowledge they may not possess. In any case, it would be convenient for all users to be able to define widths in the question settings.

Although the implementation may seem challenging, I believe it can be achieved without excessively burdening the settings page. Additionally, we could include font size, box height, vertical box position (all in px for simplicity), and text justification. These parameters are useful when the box is used to enter an exponent, which is quite common among users, and perhaps in other cases. Obviously, default values would be used by default, and the users wouldn't need to change anything if these values suit them.

I don't believe this would add to the complexity of the question. Indeed, it's just about simple formatting here. Moreover, the users don't need to do anything if the default values suit them. In fact, such a feature would add flexibility to the use of the 'Formulas' question, and I believe flexibility is a major asset.

The figure below illustrates how this could be done:

GitHub_20231122_1843

dbauer-ets commented 7 months ago

We could also include the auto-adjustment of the answer box width. This functionality has already been written in JavaScript specifically for the Formulas question. Here is a revised version of what it might look like:

GitHub_20231123_0117

Note that in certain situations, it is advisable to align the contents of the answer boxes to the right. For instance, numbers in the vertical columns of accounting statements, which have been done with the Formulas question, are typically aligned to the right for clarity and consistency.

PhilippImhof commented 7 months ago

Have you seen my last comment in #45 ?

PhilippImhof commented 7 months ago

I am closing this as a duplicate of #45, in order to have everything in one place.