#!/usr/bin/perl
# WikiWork statistics calculator
# Copyright (C) 2007-2008 Scott V. Nazelrod
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# See for a copy of the GPL.
$version = "0.2.0";
require "formparser.lib";
&parseform;
$fa = $formdata{'fa'};
$a = $formdata{'a'};
$ga = $formdata{'ga'};
$b = $formdata{'b'};
$start = $formdata{'start'};
$stub = $formdata{'stub'};
$eds = $formdata{'eds'};
$subs = $formdata{'subs'};
$total = $fa + $a + $ga + $b + $start + $stub;
#percentages
$fa_pct = $fa/$total * 100;
$a_pct = $a/$total * 100;
$ga_pct = $ga/$total * 100;
$b_pct = $b/$total * 100;
$start_pct = $start/$total * 100;
$stub_pct = $stub/$total * 100;
#rounded %s
$fa_pctrd= sprintf("%.2f", $fa_pct);
$a_pctrd= sprintf("%.2f", $a_pct);
$ga_pctrd= sprintf("%.2f", $ga_pct);
$b_pctrd= sprintf("%.2f", $b_pct);
$start_pctrd= sprintf("%.2f", $start_pct);
$stub_pctrd= sprintf("%.2f", $stub_pct);
#wikiwork stats
$wikiwork = $a + 2*$ga + 3*$b + 4*$start + 5*$stub;
$rel = $wikiwork/$total;
$rel_rounded = sprintf("%.3f", $rel); #rounded to 3 dec places
#rel bar positioning
$rel40 = $rel*40;
$rel40_round = sprintf("%.0f", $rel40);
$rel_pos = $rel40_round."px";
#extra stats
if( $eds != 0 )
{
$ww_percapita = $wikiwork / $eds;
$capitastring = "