How to delete all inserted spaces in a text string ?

Aritmometer shared this question 1 month ago
Answered

How to delete all inserted spaces in a text string ?

The text string is created when a student enter an expression in a input box.

I then want to get GeoGebra to check if the string matches another string.

In order to not have to take all space combinations between parts of the expression into account, I would rather just have all the space between signs, numbers and letters deleted.

How to do that in the easiest way ?

Best Answer
photo

parse structure: see attachment.

but sorry: for me the added value is not clear.

Comments (14)

photo
1

Maybe the best one is to use the TextToUnicode command, and parse their input as


TextToUnicode(InputBox+"")\{32}

32 is the Unicode value for blank space.

Please see https://wiki.geogebra.org/e...

Honestly text matching is rarely a good way to assess correctness of entries, because there are many different possibilities when entering a mathematical expression (fractions vs decimal values, just to say one).

photo
1

Thanks.

Text matching seams for me to be the only way to get GeoGebra to check if a student has inserted integers correctly in a formula and has not just written the correct result.

But yes, this way of evaluating an expression can only be used in certain situations.

In case you can think of another more appropriate way to evaluate if a student has inserted numbers correctly in a formula, I’ll be very happy to hear it.

photo
1

Maybe if you post an example file explaining what you want to check it's easier for us to give you better ideas :)

photo
1

Okay...

I have an input box which is related to a text variable.

From start the content of the text variable is “b^2 - 4 * a * c”.

The student substitute the letters with integers and press a check button.

I then want to use a script for this button that deletes all space between the parts of the expression, save the result in another text-variable and check if the content of this variable match the content of a third variable which holds the formula with correct placed integers.

My question is then: What shall the script be ?

photo
1

I should probably also mention that I want the content of the input box to be shown as Latex.

photo
1

Sorry, by “result” in my answer before, I meant the expression after the space between the parts of the expression have been deleted.

photo
photo
1

Wenn nicht die Struktur, sondern nur das Ergebnis von Interesse ist, verwenden Sie: ParseToNumber()

(alternative für Struktur folgt)

photo
1

parse structure: see attachment.

but sorry: for me the added value is not clear.

photo
1

That way seams rather easy. Thanks.

And I found out that it’s also possible to use dots instead of *.

I only miss the possibility to get the expression shown in LaTex in the input box so that ^ is missed out so its easier for the students to read the expression. But at this point that doesn’t seam to be possible. Or do you know a way to make this possible... ? For example to use a Java script in the update script of the input box.... If so please write a script I can use for that.

photo
1

use Text-Editor with latex=ON

optional if latex=ON: $.....$ inside is latex, outside is GGB-Text || without any $: all is latex

Note: to my knowledge latex does not work in the input box (also not with JS)

if it were possible, there would be a conflict between display and input

b4763d683a550525ab7b1c7a5648111e

photo
1

If LaTex doesn’t work in a input box, then how does it work when the input box is connected with a number (or function) variable... ? - here an expression with ^ is written nicely in the input box just like when using LaTex (at least when choosing the option Symbolic).

I mean, if LaTex isn’t being used to write the expression nicely in the input box, then what is being used instead of LaTex ?

And could I somehow use/do the same, and if so how ?

photo
photo
1

To rami: Thank you very much, I will look into your script and try to understand how it works.

photo
1

A completely different approach.

  • Display Latex
  • separate input for each parameter (numeric)
  • display and control the target values of the parameters
  • no automatic simplification


some hints

  • the biggest part is word processing.
  • there are 3 settings: the expression in GGB syntax, in latex syntax and the target values as a list. See also list examples. This is a DropDown list. Click the triangle show down for one of the samples.
  • all parameters have the prefix # and a letter (e.g. #a)
  • various scripts also with Execute (most important script in answerNum list).
  • there is also a custom tool (ReplaceText).
  • tested in GGB5 windows10 and GGB6 Classic Web Chrome (probably still contains bugs).

I am always open for your suggestions and questions.

photo
1

The way of choosing a letter and write the value of it is nice.

But in this way the students won’t insert integers in a formula themselves with all the difficulties that is related to that (as for example substituting the letters with the correct integers and remembering to add brackets when a negative integer is squared or when a integer is being multiplied with a negative integer).

So a important part of using a formula and evaluating the students abilities to correctly insert integers in a formula is left out.

Of cause as long as the students get the right result they have probably inserted the integers correctly - although they also could have made a wrong calculation that ended up with the right result. So to be certain an evaluation of how they inserted the integers in the formula is needed.

But more importantly: If the students get a wrong result and only check the calculation (which they often do), they won’t find out that the reason is wrongly inserted integers in the formula or missing brackets. And then they need to get help from a teacher.

If GeoGebra is able to check whether the students have inserted integers correctly in a formula (and after that the reduced expression and the result by using three separated input boxes), then it’s much easier for the students to find the root of an error themselves.

This makes it much faster for the students to learn to use the formula correctly and give the teacher more time in the classroom to help the students who really need the help of the teacher.

In your earlier app (parse1), you have shown a way to get GeoGebra to evaluate a formula where a student have substituted letters with integers.

The only thing I miss next is to get the expression written nicely in a input box when using ^ so that it’s easier for the students to read.

photo
© 2020 International GeoGebra Institute