Forms-ManyDataPages

Technically this doesn't have anything to do with forms, per se, but if you save data on many pages then you've got to have some way of processing that data afterwards if you don't want to create a "write-only" data collection system. WikiSh shines in this arena.

It's all fine and dandy to save data on many different pages, but at some point you've got to have some way of aggregating or reporting on that data or else it's useless. In some cases a pagelist will do the trick, but if you are doing sums, counts, averages or etc then you will need something better than that.

Let's say that we have a bunch of pages named Data-01, Data-02, ..., Data-59. Each of them contains 3 PTVs named , , and representing the number of hours that employees worked each day. You would like to see the total number of hours each person worked and the average number of hours per day each person worked.

(:linebreaks:)
{(wikish source {$FullName}#calc)}

(:if false:)
[[#calc]]
echo "" >Tmp.Names
for pn in Data-*
do
   set tot{${pn}$:name} += {${pn}$:hours}
   set cnt{${pn}$:name} ++
   echo {${pn}$:name} >>Tmp.Names
done

echo "||border=1 width=700px"
echo "||! Name ||! Total Hours ||! Days Worked ||! Avg per Day ||"
sort -u Tmp.Names | while read name
do
   set avg = ${tot${name}} / ${cnt${name}}
   echo "||${name} || ${tot${name}}|| ${cnt${name}}|| ${avg}||"
done
[[#calcEnd]]
(:ifend:)

You can see this page on a working system at http://pmwiki.qdk.org/pmwiki.php/Forms/Calc.

Note that we haven't put in any code to deal with the special case of no Data-* pages existing...

That shows just one example of the capabilities of reporting on data held in PTVs in pages. Obviously you can combine these and other capabilities with a lot of flexibility...