1. Real grammar analyzer.
2. Checking accuracy of expression without reloading question's editing page.
3. Pluginable packages of functions (you can use any private functions).
4. Using arrays as parameters of functions.
Also included package of EGM Mathematical Finance class created by Enrique Garc�a M. (2003-2004) and distributed under GNU GPL.
Detailed information with screenshots and patches at MDL-7198.
Installation:
Replace old files in calculation folder by files in archive. Please don't test on production server and backup old files before.
I like very much what I have seen so I put it on a site with the almost last moodle 1.8 release and everybody interested can play with it.
The moodle site address is
http://132.208.141.198/moodle_head/
you log as a teacher
I have set a simple quiz with one question in category New grammar
name:moodle pw: moodle
I do think the Tim will appreciate when coming back from his holidays on canal boat http://moodle.org/mod/forum/discuss.php?d=56777&parent=258820
P.S. There a possible security issue so the added new functions should come from a Moodle release.
Here is an extract of the financial package from your zip if somebody want to try this new grammar
/**
* DDB
* Returns the depreciation of an asset for a specified period using
* the double-declining balance method or some other method you specify.
* @param float $cost is the initial cost of the asset.
* @param float $salvage is the value at the end of the depreciation (sometimes called the salvage value of the asset).
* @param integer $life is the number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).
* @param integer $period is the period for which you want to calculate the depreciation. Period must use the same units as life.
* @param float $factor is the rate at which the balance declines. If factor is omitted, it is assumed to be 2 (the double-declining balance method).
* @return float the depreciation of n periods.
*/
function financial_DDB($cost, $salvage, $life, $period, $factor = 2)
{ $finclass = new Financial();
return $finclass->DDB($cost, $salvage, $life, $period, $factor = 2);
}
/**
* SLN
* Returns the straight-line depreciation of an asset for one period.
* @param float $cost is the initial cost of the asset.
* @param float $salvage is the value at the end of the depreciation (sometimes called the salvage value of the asset).
* @param integer $life is the number of periods over which the asset is being depreciated (sometimes called the useful life of the asset).
* @return float the depreciation allowance for each period.
*/
function financial_SLN($cost, $salvage, $life)
{ $finclass = new Financial();
return $finclass->SLN($cost, $salvage, $life);
}
/**
* SYD
* Returns the sum-of-years' digits depreciation of an asset for
* a specified period.
*
* (cost - salvage) * (life - per + 1) * 2
* SYD = -----------------------------------------
* life * (1 + life)
*
* @param float $cost is the initial cost of the asset.
* @param float $salvage is the value at the end of the depreciation (sometimes called the salvage value of the asset).
* @param integer $life is the number of periods over which the asset is depreciated (sometimes called the useful life of the asset).
* @param integer $per is the period and must use the same units as life.
*/
function financial_SYD($cost, $salvage, $life, $per)
{ $finclass = new Financial();
return $finclass->SYD($cost, $salvage, $life, $per);
}
/**
* VDB
* Returns the depreciation of an asset for any period you specify,
* including partial periods, using the double-declining balance method
* or some other method you specify. VDB stands for variable declining balance.
*
* @param float $cost is the initial cost of the asset.
* @param float $salvage is the value at the end of the depreciation (sometimes called the salvage value of the asset).
* @param integer $life is the number of periods over which the asset is depreciated (sometimes called the useful life of the asset).
* @param integer $start_period is the starting period for which you want to calculate the depreciation. Start_period must use the same units as life.
* @param integer $end_period is the ending period for which you want to calculate the depreciation. End_period must use the same units as life.
* @param float $factor is the rate at which the balance declines. If factor is omitted, it is assumed to be 2 (the double-declining balance method). Change factor if you do not want to use the double-declining balance method.
* @param bool $no_switch is a logical value specifying whether to switch to straight-line depreciation when depreciation is greater than the declining balance calculation.
* @return float the depreciation of an asset.
*/
function financial_VDB($cost, $salvage, $life, $start_period, $end_period, $factor = 2.0, $no_switch = false)
{ $finclass = new Financial();
return $finclass->VDB($cost, $salvage, $life, $start_period, $end_period, $factor, $no_switch);
}
/**
* PV
* Returns the present value of an investment. The present value is
* the total amount that a series of future payments is worth now.
* For example, when you borrow money, the loan amount is the present
* value to the lender.
*
* If rate = 0:
* PV = -(FV + PMT * nper)
*
* Else
* / nper \
* | 1 - (1 + rate) |
* PMT * (1 + rate * type) * | ----------------- | - FV
* \ rate /
* PV = ------------------------------------------------------
* nper
* (1 + rate)
*
* @param float $rate is the interest rate per period.
* @param integer $nper is the total number of payment periods in an annuity.
* @param float $pmt is the payment made each period and cannot change over the life of the annuity.
* @param float $fv is the future value, or a cash balance you want to attain after the last payment is made.
* @param integer $type is the number 0 or 1 and indicates when payments are due.
* @return float the present value of an investment.
*/
function financial_PV($rate, $nper, $pmt, $fv = 0.0, $type = 0)
{ $finclass = new Financial();
return $finclass->PV($rate, $nper, $pmt, $fv, $type);
}
/**
Hi Dmitry,
I continue here our discussion on e-mail.
Hi Dmitry,
PP> I think that perhaps I could port your code to the calculated question
PP> but I will need your help about choosing what could be the more useful
PP> functions, testing them and getting good docs so they can really be used
PP> by teachers.
Hi Pierre,
Main idea of my changes is will let teachers create flexible questions which could solve ANY problem! So teacher can add his own package with wrappers for ANY STANDARD functions or for OWN functions for special problems.
In my course I need financial functions also included in MS Excel so I has found it (http://www.phpclasses.org/) and has created a
package...
Teachers could create and distribute their hardcoded functions in Moodle Community.
Dmitry.
Hi Dmitry,
Your idea to work through the Moodle Community is great, on the practical side I make the following suggestions.
Actually the package has to be put in the moodle code (in question/type/calculated/) and this is not allowed on a production installation at least at the teacher level.
Building an official Moodle set (limited...) of functions and putting the package in the Moodle official code appears the first step to use these packages.
A CVS contrib site could be set so that others could add more functions and it will be to each Moodle site administrator to choose what supplementary package they want.
Tim, your comments on this,
Pierre
1. makes the calculated question better for some teachers,
2. but can be ignored by teachers who do not need the extra flexibility.
Is definitly a good thing.
In terms of plugging in extra functionality, if PHP code is involved, then it needs to be a plugin which is installed by an admin and therefore live in contrib. But it is good to package it up as neatly as possible, so adding an extra library of functions is just a matter of downloading one extra PHP file, and copying it into a particular folder.
The initial package could contain ideally the math excel functions.
By the way, do you know how the excel library already on moodle could be used, this could be a better solution.
Pierre
Full back compatibility with standart Calculation type! Try it!
This is somewhere on my to-do list with the improvement of calculated question as a multiple answer type.
In the mean time, I have reworked the multianswer(cloze) interface and strengthened its code.
I have improved the calculated dataitems and tolerance validation and should be back soon to other calculated question improvements like your proposal...
Pierre
I have used the financial functions from EGM Mathematical Finance class created by Enrique García, to create calculated questions, but I can not edit them. Could you tell me what is the problem?