Using exponent function in the calculated Questions

Using exponent function in the calculated Questions

by Ranjith Valliyedath -
Number of replies: 8

Hello All,

I have an answer formula "(((([y]/100)+1)**18-1)*[x] *1000)/([y]/100)" in a calculated question of WebCT CE6. I need to convert this question on the Moodle version. Please note that x and y are variables on this question.

Please help me.

Average of ratings: -
In reply to Ranjith Valliyedath

Re: Using exponent function in the calculated Questions

by Pierre Pichet -
Hi Ranjith,
First look at the help button on the upper part of the editing form of the calculated question.
There is also a reference to moodle docs at the editing form page.

So x and y will become {x} and {y} and you will be able to define there numerical values.
The other problem is that Moodle use mathematical php functions so that ** is converted to a power(...,...) function.
Being a teacher I let you find how to use the power function in your equationsmile as your homework.

Pierre

In reply to Pierre Pichet

Re: Using exponent function in the calculated Questions

by Ranjith Valliyedath -

Hi Pierre,

Many thanks for your reply. This will help. But i am still struggling to get the same answers which are appearing on the WebCT. Could you please provide me a answer formula for this one?

Regards,

Ranjith.

In reply to Ranjith Valliyedath

Re: Using exponent function in the calculated Questions

by Pierre Pichet -
On the docs that you can access from the bottom of the calculated question it is specified that pow (numberToRaise, NumberRaisedTo)
i.e pow(2,4) = 16 i.e 24

So (((([y]/100)+1)**18-1)*[x] *1000)/([y]/100)
becomes
(({y}/100)+1)**18
becomes
pow(
(({y}/100)+1) , 18 )
then
(
pow( (({y}/100)+1) , 18 )-1)*{x}*1000
then
(
( pow( (({y}/100)+1) , 18 )-1)*{x}*1000 ) / ({y}/100)
you remove the space and obtain a valid formula
((pow((({y}/100)+1),18)-1)*{x}*1000)/({y}/100)
that gives 64236.94 when {y} = 2 and {x} = 3

My conclusion is that analytical chemistry equations are easier...

Pierre



In reply to Pierre Pichet

Re: Using exponent function in the calculated Questions

by Tiffany Hoefer -
I am having a similar problem.  I tried to apply Pierre's example to my particular problem but I obviously still can't apply the logic.  Our instructor needs to measure exponents and decay and has the following question:


The Mendes family bought a new house {years} years ago for ${purchase},000. The house is now worth ${current},000. Assuming a steady rate of growth, what was the yearly rate of appreciation? Round your answer to the nearest tenth of a percent (1.2% etc)


They want the student to solve it by using the following formula:  1 minus {current} divided by {purchase} to the power of 1/{years}.


When I try to write the answer formula as:  1-{current}/{purchase}pow(1/{years}), I receive the error "the function 1pow is not supported".  I have tried many other incarnations but this was the most promising error message of all.  I usually receive a syntax error which leads me to believe that for those I just had it totally wrong.

Any ideas on how to render this formula?  Any kind words are appreciated.

In reply to Tiffany Hoefer

Re: Using exponent function in the calculated Questions

by Pierre Pichet -

The pow function is somehow tricky to use.

Calculated question docs :

pow (numberToRaise, NumberRaisedTo)

So your formula should be something as

1-pow({current}/{purchase},1/{years})

and for a house worthing $100,000 and purchased for $50,000 5 years ago this should give

1-pow(100000/50000,1/5) = -0.15

This is the same result as obtained in excel with =1-((100000/50000)^(1/5))

If I understand correctly your function...

Looking on other sites as

http://www.forsalebyowner.com/sell-my-house/deciding/how-to-calculate-average-rate-of-appreciation

your function could be (pow({current}/{purchase},1/{years})-1) * 100


In reply to Pierre Pichet

Re: Using exponent function in the calculated Questions

by Tiffany Hoefer -

Pierre,

Thank you so much for your help!  These are quite tricky, and I really appreciate you getting me past the dreaded error screen.

In reply to Ranjith Valliyedath

Re: Using exponent function in the calculated Questions

by Peter Halverson -

Just a comment...

You should take a look at the "Formulas Question Type" for Moodle. 

https://moodle.org/plugins/view/qtype_formulas

I like it better than the "Calculated Question Type."

It does require an administrator to install it and it does take some effort to learn how to use it, but I think its easier than Calculated.

---Peter H.

In reply to Peter Halverson

Re: Using exponent function in the calculated Questions

by Tiffany Hoefer -

Peter, 

Thank you for the suggestion.  I'll definitely give it a look and see if our administrator will buy in.  Thanks!!