moodle-qtype_formulas icon indicating copy to clipboard operation
moodle-qtype_formulas copied to clipboard

Séparateur décimal / Decimal separator

Open ebugnet opened this issue 5 years ago • 13 comments

Bonjour,

Je me permet le message en Français... Le séparateur décimal par défaut sur toutes les questions Moodle est soit le point soit la virgule et donc compatible en fonction des langues utilisateurs. Dans ce type de question, seul le point est autorisé sinon la réponse est considérée comme fausse. Il serait vraiment appréciable de permettre aussi la virgule, Français oblige, mais j'ignore la faisabilité ou la quantité de travail pour permettre cela. Merci !

Éric

========== Default decimal separator on all Moodle questions is dot or comma and is compatible depending on the user language. In this question type, only the dot is allowed, otherwise the answer is considered wrong. It would be really nice to allow the comma, but I don't know the feasibility or amount of work to allow this. Thank you!

ebugnet avatar Jun 13 '20 06:06 ebugnet

Éric,

Merci d'avoir ouvert cette question. Si je ne me trompe pas, Philipp, toi et moi avons le français comme langue maternelle. Nous vivons dans des régions où la majorité des gens parlent français. Par conséquent, nous pourrions travailler en français.

Cependant, il est indéniable que l'anglais est devenu la langue internationale. Afin d'atteindre le plus grand nombre de personnes à travers le monde, il serait préférable de parler ici en anglais.

dbauer-ets avatar Nov 24 '23 01:11 dbauer-ets

Philipp,

As Eric reminds us, most Moodle questions can use either the decimal point or the decimal comma.

It's surprising that the 'Formulas' question doesn't offer this option. It could be better, especially considering how long it has been requested.

It appears that more countries use the decimal comma, while more people use the decimal point. However, that should not be a reason for not having this option in the 'Formulas' question.

I wrote a small JavaScript snippet to make up for the absence of this option, that allows 'number' type answers to accept both the decimal point and the decimal comma. The snippet is used by different users, and reports indicate that it works very well. But a snippet for the Formulas question, it's embarrassing. :-)

There's no reason why we can't implement this option in the 'Formulas' question for all four types of responses (number, algebraic, numeric formula, algebraic formula).

We'll do it when you're ready. I'll be happy to chat with you about the best way to do it, if that helps. :-)

Thank you for your fantastic work.

Cheers!

dbauer-ets avatar Nov 24 '23 01:11 dbauer-ets

It appears that more countries use the decimal comma, while more people use the decimal point. However, that should not be a reason for not having this option in the 'Formulas' question.

The reason why this is not implemented yet is certainly not that I would consider it useless. I don't. And I do not take my own judgement as the sole measure for how a plugin that is used by many people all over the world should work.

There's no reason why we can't implement this option in the 'Formulas' question for all four types of responses (number, algebraic, numeric formula, algebraic formula).

I disagree very strongly. There are good reasons why this is not implemented yet. If it was as simple as you probably imagine, it would have been done long ago. Just to remind you that this issue is open for more than three years, long before I started my work. And there is even an issue in the Moodle tracker that was opened in 2016. You surely don't think that anyone would hold that back just for the sake of holding it back.

In the first version of your comment, you pointed out that "most questions" in Moodle allow entering localised numbers. That's true for questions that only accept numbers as their input. It is however not true for question types that are somewhat similar to this one. To the best of my knowledge, there is no question type where students can enter formulas or arithmetic expressions and use the comma as their decimal separator. So if even the guys who develop the STACK question type -- probably the most sophisticated and advanced question type that exists -- do not offer that option, one might take it as a very reliable hint that it's not that easy…

The main thing to bear in mind is that any solution must be made in a way that will work reliably for all users in all situations while maintaining full backwards compatibility. Also, adding this feature is a one way street; once it is there, there's no turning back. So it must be done in a way that will not limit or block further developments. There are already quite many restrictions because of some design choices that were made 15+ years ago.

While it is fairly easy to allow the decimal comma in the answer type number, this is absolutely not the case for numerical formulas, because we allow the student to use functions and they use comma as their separator of arguments. If the comma is used for numbers, one can either restrict the allowed functions to those with only one argument (thus not allowing ncr() although it absolutely makes sense to have that function) or the functions would have to be done differently and e.g. use the semicolon as a separator of arguments. But that could obviously only be changed on the student side, because teachers already use ncr() and other functions with the comma as a separator. That's not impossible, but it complicates stuff. (We already have that issue with the IMHO very bad idea that ^ means exponentiation for the student, but XOR for the teacher, unless they use it in an algebraic formula, where it will also mean exponentiation. That's a legacy we will carry forever and it goes back to a less than optimal implementation choice.) Also, in the future, we might allow the students to enter vectors or matrices. Or there might (Note to our users: this is not a promise!) be an answer type "set" and/or "list". Those would then need to use semicolons as well, even though all CAS packages use commas.

Now, one could argue that we might at least do it for the number type or even for numeric answers where no functions are allowed. That's true and it would not be extremely difficult. But it would mean that if you have a numeric answer in part 1 and a numerical formula in part 2, the user will have to use a different format for numbers within the same question. IMHO that would be a total usability nightmare.

So while I agree that the current state is not perfect, I simply do not see any better alternative. (I think your script is a nice workaround that people can use in certain situations. But it's not a complete solution that addresses all points mentioned above.) Most students know that they have to use the point in many situations, e.g. when using Wolfram Alpha or CAS packages, in programming languages or when working with their calculator. So they can somehow accept that weakness as a "known problem with those strange computers", even if they don't like it. And, most important, if they enter a comma instead of a point by mistake, the warning triangle gently reminds them of the format to use.

PhilippImhof avatar Nov 24 '23 08:11 PhilippImhof

While preparing test cases for the next major version (which will still take some time…), I had an idea for a viable solution:

Whenever the student (and the student only) enters an answer that does not pass validation, we substitute every occurrence of , by . and send it to validation again. If it passes, we put this as their new answer and show some notice, e.g. "Your input has been changed. Please check your answer. Note that you should use a decimal point rather than a comma."

I think it is legitimate to alter the student's answer in such a case, because (a) if their answer does not pass validation, it would be graded wrong anyway and (b) they can change it back easily. There might even be an "undo" button in the notice.

I have yet to think about possible risks of this, but it might work. Depending on the implementation, it would even be possible to substitute only some of the commas in case the first attempt was not successful. If there are not more than 5, that would be just 32 cycles, so thats probably just a few milliseconds. (I can probably come up with some good heuristics as to what commas are more likely, e.g. commas followed by a space are likely to be separators and commas between numbers are probably decimal points. Also, we already know that a "real" comma can only occur inside a list or inside a function that accepts more than one parameter. Any comma occurring in a string can be skipped as well.)

This method could, in a later step, even be extended e.g. to unmatched parentheses, similar to what Wolfram Alpha does: if the student enters 5*sqrt(3, it might suggest 5*sqrt(3) or if they enter 5*sqrt(3+5 the suggestion would be 5*sqrt(3+5) even though that is probably not what they intended, so the notice should now say something like: "An attempt was made to fix mismatched parentheses. Please check if the expression matches your intention."

PhilippImhof avatar Nov 26 '23 17:11 PhilippImhof

Forgot to mention: With the new parser, we have a good idea as to why the validation failed. With some errors, it is clear that we do not have to try this at all, e.g. if the error concerns mismatched parens, unknown variables or unknown functions.

PhilippImhof avatar Nov 26 '23 17:11 PhilippImhof

Hi Dominique (and Philipp),

First of all – thank you so much for your great snippet! I’ve been using it for some years now, and I’m one of the very happy users you mentioned 😊 I run a platform in Austria with thousands of Formulas questions, and your code made it possible for my students to finally use commas as decimal separators in their input – exactly what they are used to.

Before using your snippet, I had added a note to every single question: "Please use a comma instead of the decimal point." I was able to delete all those instructions thanks to your solution – that felt amazing!

That said, there is still one issue that’s quite hard for my students: They see numbers like 3.5 in the question text, even though they are taught (and now allowed!) to write 3,5. This inconsistency between display and input causes confusion – especially because my learners are 10–14 years old and don’t use tools like Wolfram Alpha or programming languages where the dot is common.

So my wish would be: a way to format numbers in {=...} expressions maybe based on the language pack (e.g. de, de_du

Image

) – or via a workaround or another java code, ...

I know this is not trivial (Philipp explained that very clearly), but maybe the two approaches could complement each other:

Philipp’s validation logic for smarter error handling in student input

and localized formatting for displayed values in the question text

I’d be more than happy to sponsor the development of such a feature – it would be a huge benefit for many students in comma-based countries.

Thanks again for your great contribution – and thank you Philipp, too, for the continued work on this fantastic plugin!

Feel free to contact me under [email protected]

marlisschedler avatar Apr 14 '25 17:04 marlisschedler

Thank you @marlisschedler for your kind feedback. I have opened a new issue for the feature you are requesting. I think it is definitely a nice thing to have.

Please note, however, that it may take some time to do it. (That's mainly because I only to this in my free time, so quite often things take longer than what I initially hoped.) For the moment, there are a few things to be done before I can get to this one. I hope you are able to wait a bit.

PhilippImhof avatar Apr 15 '25 07:04 PhilippImhof

Dear Philipp,

Thank you very much for your kind reply on GitHub and for creating a dedicated issue for the new feature regarding comma output. I really appreciate your openness and engagement.

Of course, I fully understand that implementation may take time – especially when done in your free time.

To support the development, I’d be happy to sponsor the feature with €300, as it would make a real difference for my work and – most importantly – for my students.

If it’s somehow possible to implement it by early September, that would be ideal, as the new school year starts then here in Austria. I’m also planning to update my platform to Moodle 5.0 over the summer and hope that the Formulas plugin will continue to work smoothly with that version.

That said, please don’t feel pressured – I’m grateful that you’re continuing the development of this great plugin, and I’m happy to wait if it takes longer.

Thanks again for your fantastic work!

Best regards from Austria, Marlis Schedler

Von: Philipp Imhof @.> Gesendet: Dienstag, 15. April 2025 09:04 An: FormulasQuestion/moodle-qtype_formulas @.> Cc: marlisschedler @.>; Mention @.> Betreff: Re: [FormulasQuestion/moodle-qtype_formulas] Séparateur décimal / Decimal separator (#11)

Thank you https://github.com/marlisschedler @marlisschedler for your kind feedback. I have opened a new issue for the feature you are requesting. I think it is definitely a nice thing to have.

Please note, however, that it may take some time to do it. (That's mainly because I only to this in my free time, so quite often things take longer than what I initially hoped.) For the moment, there are a few things to be done before I can get to this one. I hope you are able to wait a bit.

— Reply to this email directly, <https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issueco mment-2804034293> view it on GitHub, or <https://github.com/notifications/unsubscribe-auth/BQOFH5NKXQHVU26NMNFNXTD2Z SVOPAVCNFSM6AAAAAB3DS4X5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBUGAZTI MRZGM> unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

PhilippImhof left a comment <https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issueco mment-2804034293> (FormulasQuestion/moodle-qtype_formulas#11)

Thank you https://github.com/marlisschedler @marlisschedler for your kind feedback. I have opened a new issue for the feature you are requesting. I think it is definitely a nice thing to have.

Please note, however, that it may take some time to do it. (That's mainly because I only to this in my free time, so quite often things take longer than what I initially hoped.) For the moment, there are a few things to be done before I can get to this one. I hope you are able to wait a bit.

— Reply to this email directly, <https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issueco mment-2804034293> view it on GitHub, or <https://github.com/notifications/unsubscribe-auth/BQOFH5NKXQHVU26NMNFNXTD2Z SVOPAVCNFSM6AAAAAB3DS4X5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBUGAZTI MRZGM> unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

marlisschedler avatar Apr 15 '25 10:04 marlisschedler

Thank you @marlisschedler.

I think that implementing number formatting in output (e.g. feedback, correct answer, question text substitutions) might actually be easier than in the input.

Also, I can confirm that the Formulas question plugin will work with Moodle 5.0, when updating to the newest version. I am currently doing final tests and preparing the release of version 6.0.0. I hope finishing that work by the end of the week.

PhilippImhof avatar Apr 15 '25 11:04 PhilippImhof

That’s fantastic news – thank you so much, Philipp! I’m very happy to hear that the formatting in the output might be easier to implement, and especially that the plugin will be compatible with Moodle 5.0. Looking forward to version 6.0.0 – and thanks again for your continued work and responsiveness. It really means a lot!

Marlis

Von: Philipp Imhof @.> Gesendet: Dienstag, 15. April 2025 13:04 An: FormulasQuestion/moodle-qtype_formulas @.> Cc: marlisschedler @.>; Mention @.> Betreff: Re: [FormulasQuestion/moodle-qtype_formulas] Séparateur décimal / Decimal separator (#11)

Thank you @marlisschedler https://github.com/marlisschedler .

I think that implementing number formatting in output (e.g. feedback, correct answer, question text substitutions) might actually be easier than in the input.

Also, I can confirm that the Formulas question plugin will work with Moodle 5.0, when updating to the newest version. I am currently doing final tests and preparing the release of version 6.0.0. I hope finishing that work by the end of the week.

— Reply to this email directly, view it on GitHub https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issuecomment-2804673116 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BQOFH5IANDLTWGLYZJZZI7D2ZTRSHAVCNFSM6AAAAAB3DS4X5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBUGY3TGMJRGY . You are receiving this because you were mentioned.Message ID: @.***>

PhilippImhof left a comment (FormulasQuestion/moodle-qtype_formulas#11) https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issuecomment-2804673116

Thank you @marlisschedler https://github.com/marlisschedler .

I think that implementing number formatting in output (e.g. feedback, correct answer, question text substitutions) might actually be easier than in the input.

Also, I can confirm that the Formulas question plugin will work with Moodle 5.0, when updating to the newest version. I am currently doing final tests and preparing the release of version 6.0.0. I hope finishing that work by the end of the week.

— Reply to this email directly, view it on GitHub https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issuecomment-2804673116 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BQOFH5IANDLTWGLYZJZZI7D2ZTRSHAVCNFSM6AAAAAB3DS4X5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMBUGY3TGMJRGY . You are receiving this because you were mentioned.Message ID: @.***>

marlisschedler avatar Apr 15 '25 11:04 marlisschedler

Hello Marlis,

Following your concern regarding the decimal comma in question texts, please note that I proposed a solution four years ago, which simply involves wrapping the values with a tag. For example, if the variable "a" is equal to 17.3, it will be displayed as "17,3" when wrapped like this: {a}. This is part of the script available at https://dynamiccourseware.org/course/view.php?id=22#sectionid-1579-title

Please note that even if the decimal comma is eventually handled directly within the Formulas question and my JavaScript snippet becomes unnecessary, you won’t need to change the text of your questions. The will then simply have no effect and remain completely invisible.

dbauer-ets avatar Apr 17 '25 18:04 dbauer-ets

Dear Dominique,

Thank you so much for your thoughtful reply and for offering to expand your JavaScript snippet to support all four answer types – that would be incredibly helpful for many users, including myself. I'm genuinely looking forward to seeing how it evolves.

I really appreciate the practical and user-focused approach you're taking. In my classroom context (with students aged 10–14), your snippet has already made a big difference in how they interact with the Formulas question. Making things more intuitive for them is my top priority.

I also value the ongoing work Philipp is doing on the plugin itself – especially his focus on long-term maintainability and compatibility. From my perspective as a teacher, it's encouraging to see both directions being explored:

  • A flexible, client-side solution that solves problems quickly
  • And a solid core solution that may take longer but ensures consistency

I hope both of your approaches can eventually complement each other. And I'd be very happy to stay involved in testing or feedback from the user side – especially from the classroom perspective.

Thank you again for your initiative and your continued efforts!

Von: Dominique Bauer @.> Gesendet: Donnerstag, 17. April 2025 20:28 An: FormulasQuestion/moodle-qtype_formulas @.> Cc: marlisschedler @.>; Mention @.> Betreff: Re: [FormulasQuestion/moodle-qtype_formulas] Séparateur décimal / Decimal separator (#11)

We probably shouldn’t attempt to integrate the decimal comma directly into the core calculations of the Formulas question. As you rightly pointed out, this approach would be both complex and potentially unsuitable. A better solution—similar to the one I implemented with my client-side JavaScript snippet—might be to handle it at the level of user input and output. For instance, if a user enters “3,2”, it could be immediately converted to “3.2” before any further processing takes place.

One advantage of using a client-side snippet is that it’s quick to develop and deploy. Later on, it could be used for integrating this feature more deeply into the Formulas code. I’ll try to find time to expand the JavaScript snippet so that it works with all four answer types in Formulas, and I’ll keep you updated on my progress.

— Reply to this email directly, view it on GitHub https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issuecomment-2813731420 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BQOFH5PG6D3LX3P5K5GQIWL2Z7XELAVCNFSM6AAAAAB3DS4X5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJTG4ZTCNBSGA . You are receiving this because you were mentioned.Message ID: @.***>

dbauer-ets left a comment (FormulasQuestion/moodle-qtype_formulas#11) https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issuecomment-2813731420

We probably shouldn’t attempt to integrate the decimal comma directly into the core calculations of the Formulas question. As you rightly pointed out, this approach would be both complex and potentially unsuitable. A better solution—similar to the one I implemented with my client-side JavaScript snippet—might be to handle it at the level of user input and output. For instance, if a user enters “3,2”, it could be immediately converted to “3.2” before any further processing takes place.

One advantage of using a client-side snippet is that it’s quick to develop and deploy. Later on, it could be used for integrating this feature more deeply into the Formulas code. I’ll try to find time to expand the JavaScript snippet so that it works with all four answer types in Formulas, and I’ll keep you updated on my progress.

— Reply to this email directly, view it on GitHub https://github.com/FormulasQuestion/moodle-qtype_formulas/issues/11#issuecomment-2813731420 , or unsubscribe https://github.com/notifications/unsubscribe-auth/BQOFH5PG6D3LX3P5K5GQIWL2Z7XELAVCNFSM6AAAAAB3DS4X5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDQMJTG4ZTCNBSGA . You are receiving this because you were mentioned.Message ID: @.***>

marlisschedler avatar Apr 18 '25 10:04 marlisschedler

Thank you, @marlisschedler for your kind words.

And I'd be very happy to stay involved in testing or feedback from the user side – especially from the classroom perspective.

That is always a very, very good thing to read…

If you have a testing installation (i. e. one that you do not use in class), you might want to try out the future version which is available from this GitHub repository. It will be released very soon, and works fine for me, but having some more people testing it is always welcome.

PhilippImhof avatar Apr 18 '25 10:04 PhilippImhof