Calculated fields

Re: exxample database showing use of Javascript to automagically calculate field contents

av Itamar Tzadok -
Antall svar: 5

The Dataform uses for formulas the same moodle lib that is used by the gradebook formulas and you can find a list of functions (in addition to the standard arithmetic operators) at http://docs.moodle.org/23/en/Grade_calculations.

At some point I will add logical operators.

A few tips for Dataform formulas:

- The F index of an aggregation should be lower than the F index of the aggregated (e.g. F1 can aggregate F3 but not vice versa).

- The aggregation works on subsequent formulas where ever they are and is neither limited to a particular column nor to a particular sub formula. So an aggregation such as %%F:=SUM(_F1_,AVERAGE(_F2_))%% should also work.

- The '!' prefix of the field name inside the formula disables editing mode for the field tag in the formula.

- You can aggregate in the table row level by using the entry id as the F index of the aggregated formulas (which will make the F indices unique per row). See illustration.

 

hth smiler

 

 

 

Gjennomsnittlig vurdering:Useful (1)
Som svar til Itamar Tzadok

Calculate age field from system date and birthday date fields

av David Le Blanc -

Does anyone know how to get the current month and day from moodle and use it to calculate/display the user's age? The user will have entered their birthday in a date field. 

For example:
Current system date = 2013/05/15 - User entered birthday =1995/04/10
= 2013 - 1995/05 - 4/15 - 10
= 0018/01/05

  Calculated Age = 18

I am unsure how to access the current year/month fields from both the system and from the manually entered birthday for the current user's record. blandet

Som svar til Itamar Tzadok

Re: exxample database showing use of Javascript to automagically calculate field contents

av Noah Freedman -

Itamar

Does the current version of Dataform (2012100500) support these formulae?  I have tried, but all I get in the browse view are the formulae themselves, not the calculated results.

Thanks

Vedlegg Screen Shot 2013-06-24 at 14.00.14.JPG
Som svar til Noah Freedman

Re: exxample database showing use of Javascript to automagically calculate field contents

av Stephanie Gerald -

Hello. Has anyone tried this recently on Moodle 2.8? I can't get this to work, like in Noah's previous post. 

Is there a trick to get this to work that we don't know about? I've used the same as Noah above and it only displays the formulae, not the calculated results.

Any help would be greatly appreciated.

Som svar til Stephanie Gerald

Re: exxample database showing use of Javascript to automagically calculate field contents

av William Lu -

The Standard Database module can do the calculation job with some JavaScript.

1,2

3,4

Please feel free to use the attached preset as your start point. Some lines are comment out. It was prepared for calculating more fields.

Hope this help and let me know if you need me to edit it for you. (btw: don't forget vote as useful smiler)


Gjennomsnittlig vurdering:Useful (2)
Som svar til Stephanie Gerald

Re: exxample database showing use of Javascript to automagically calculate field contents

av Itamar Tzadok -

It works on Moodle 2.8. Moreover you can simplify your view templates by entering the formulas in the template of a text field and then add to the view template the field template pattern. If you need further assistance with the Dataform, please post your question in the Dataform forum at https://moodle.org/mod/forum/view.php?id=8192. hth smiler