Change how fractions are displayed in STACK

Change how fractions are displayed in STACK

by eduardo rivero -
Number of replies: 2

First of all, I would like to thank all your work in this resource. I am a secondary Maths teacher in Zaragoza (Spain) and I have never found anything such powerfull as STACK.

Actually, I have started working with STACK in order to use it as a basic tool in my courses. I have already prepared about 50 questions and learned while doing it. In this moment I am trying to write some kind of algorithm to generate random basic expressions, and I am stuck with this issue:

-If I have this expression in STACK:  a:15/3
                              

                     
-It is showed like this:  15
                                   --------
                                       3


   More or less in LaTeX: \frac{15}{3}

- I need it to be showed like this:  15 : 3
 
  Something like this in LaTeX: 15 \div 3

My students are so young that most of them ignore how to work properly with fractions, and this is why I need this.

As my intention is to create truly random questions, I dont want to divide the expression in two and put a ":" character between them.

I have tried to define a new operator with the infix order, but it is no allowed in stack....

Is there any solution to this?

Best Regards
Average of ratings: -
In reply to eduardo rivero

Re: Change how fractions are displayed in STACK

by Christopher Sangwin -
Picture of Particularly helpful Moodlers Picture of Plugin developers

Eduardo,

Thank you for your kind comments about STACK. I hope you and your students find this a useful tool as part of their teaching.

I agree that we should try to solve as many mathematical problems as possible at the CAS level.  While it would be easy to write \(@n@:@m@\) in the question, this isn't really very elegant.

For reasons I'm sure you appreciated, I have restricted the Maxima functions available to teachers, and drastically restricted those available to students.  I don't want teachers in general to be able to create new functions because this could be a security flaw, so "infix" is not allowed in 

privatestatic$teachernotallow

on line 104 of https://github.com/maths/moodle-qtype_stack/blob/master/stack/cas/casstring.class.php

I do want to support features where there is a good case though.

I suggest you get some code working in Maxima which you want, then we can talk about how to include it either locally in your version of STACK or in the core.

You could use the function "ratio" (which is not defined in STACK) to represent this.

For example, in a maxima application you could simply start by defining

texput(ratio,":",infix);

The function ratio has not been defined, so this is a function which does not evaluate, i.e. at this stage it is just a noun which represents something.

If you want to perform division in a later calculation then you can substitute the "ratio" function for division.  Try the following:

texput(ratio,":",infix);
p:ratio(n,m);
tex(p);
subst(ratio="/",p);

Of course, texput is also not permitted by teachers by default either!  If this is all you need, you could add it to stackmaxima.mac in your local version.

Does this make sense?

If you want to change all division operators to use :, simply use

texput("/",":",infix);

Please play around and come up with specific proposals.

Chris

In reply to Christopher Sangwin

Re: Change how fractions are displayed in STACK

by eduardo rivero -

Chris,

First of all, thank you for your response. I have been looking into the file you wrote about in your last message, and it seems that your suggestion is very useful and a good idea.

However, I am not allowed to access into the school server, and it seems pretty difficult to convince the responsible staff to do this, and the process will last months (I am still pressing for the installation of STACK since June, so I am working by now in a local server temporaly and preparing the exercises for this year).

I have come up with a not-so-good solution that I send you in case you want to see it. (I am sure it is not the best material).

I have duplicated all the variables, making a string version of all of them with the modifications I want to be shown. Also, I have used the function ascii to avoid the prohibition of using the character ":". I have substituted the dot character by "." as it seems than the ascii character is not recognized by the database and turns out an error message.

So, not a very clean solution, but it works...


Best regards and thank you again!!

Eduardo