Skip to content

Commit

Permalink
Not yet functional. Basic statistics on survey results
Browse files Browse the repository at this point in the history
git-svn-id: file:///Users/Shitiz/Downloads/lssvn/trunk/unstable@32 b72ed6b6-b9f8-46b5-92b4-906544132732
  • Loading branch information
jcleeland committed Mar 16, 2003
1 parent 971a35c commit 3f064c6
Showing 1 changed file with 190 additions and 0 deletions.
190 changes: 190 additions & 0 deletions admin/statistics.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,190 @@
<?php
/*
#############################################################
# >>> PHP Surveyor #
#############################################################
# > Author: Jason Cleeland #
# > E-mail: jason@cleeland.org #
# > Mail: Box 99, Trades Hall, 54 Victoria St, #
# > CARLTON SOUTH 3053, AUSTRALIA
# > Date: 20 February 2003 #
# #
# This set of scripts allows you to develop, publish and #
# perform data-entry on surveys. #
#############################################################
# #
# Copyright (C) 2003 Jason Cleeland #
# #
# 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 2 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. #
# #
# You should have received a copy of the GNU General #
# Public License along with this program; if not, write to #
# the Free Software Foundation, Inc., 59 Temple Place - #
# Suite 330, Boston, MA 02111-1307, USA. #
#############################################################
*/

include("config.php");

header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// always modified
header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
//Send ("Expires: " & Format$(Date - 30, "ddd, d mmm yyyy") & " " & Format$(Time, "hh:mm:ss") & " GMT ")

$slstyle2 = "style='background-color: #EEEFFF; font-family: verdana; font-size: 10; color: #000080; width: 150'";

echo $htmlheader;

if (!$sid)
{
//need to have a survey id
echo "<center>You have not selected a survey!</center>";
exit;
}

echo "<table width='100%' border='0' bgcolor='#555555'><tr><td align='center'><font color='white'><b>Quick Statistics</b></td></tr></table>\n";

echo "<table width='100%'>\n";
echo "\t<form method='post'>\n";
// 1: Get list of questions with predefined answers from survey
$query = "SELECT qid, gid, type, title FROM questions WHERE sid='$sid' AND type IN ('5', 'G', 'L', 'O', 'M', 'P', 'Y', 'A', 'B', 'C')";
$result = mysql_query($query) or die("Couldn't do it!<br />$query<br />".mysql_error());
while ($row=mysql_fetch_row($result))
{
$filters[]=array("$row[0]", "$row[1]", "$row[2]", "$row[3]");
}
// 2: Get answers for each question
foreach ($filters as $flt)
{
if ($flt[1] != $currentgroup)
{
if ($currentgroup)
{
echo "\n\t\t\t\t</td></tr>\n\t\t\t</table>\n";
}
echo "\t\t<tr><td bgcolor='#CCCCCC' align='center'>\n";
echo "\t\t<b>Group $flt[1]</b></td></tr>\n\t\t<tr><td align='center'>\n";
echo "\t\t\t<table><tr>\n";
$counter=0;
}
//echo $flt[2]; //debugging line
if ($counter == 5) {echo "\t\t\t\t</tr>\n\t\t\t\t<tr>";}
if ($flt[2] != "A" && $flt[2] != "B" && $flt[2] != "C") //Have to make an exception for these types!
{
echo "\t\t\t\t<td align='center'>$setfont<B>$flt[3]<br />\n";
echo "\t\t\t\t<select name='QID$flt[0]GID$flt[1][]' multiple $slstyle2>\n";
}
switch ($flt[2])
{
case "5": // 5 point choice
for ($i=1; $i<=5; $i++)
{
echo "\t\t\t\t\t<option value='$i'>$i</option>\n";
}
break;
case "G": // Gender
echo "\t\t\t\t\t<option value='F'>Female</option>\n";
echo "\t\t\t\t\t<option value='M'>Male</option>\n";
break;
case "Y": // Yes\No
echo "\t\t\t\t\t<option value='Y'>Yes</option>\n";
echo "\t\t\t\t\t<option value='N'>No</option>\n";
break;
// ARRAYS
case "A": // ARRAY OF 5 POINT CHOICE QUESTIONS
echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
$query = "SELECT code, answer FROM answers WHERE qid='$flt[0]'";
$result = mysql_query($query) or die ("Couldn't get answers!<br />$query<br />".mysql_error());
while ($row=mysql_fetch_row($result))
{
echo "\t\t\t\t<td align='center'>$setfont<B>$flt[3] ($row[0])<br />\n";
echo "\t\t\t\t<select name='QID$flt[0]GID$flt[1]ANS$row[0]' multiple $slstyle2>\n";
for ($i=1; $i<=5; $i++)
{
echo "\t\t\t\t\t<option value='$i'>$i</option>\n";
}
echo "\t\t\t\t</select>\n";
}
$counter=0;
break;
case "B": // ARRAY OF 10 POINT CHOICE QUESTIONS
echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
$query = "SELECT code, answer FROM answers WHERE qid='$flt[0]'";
$result = mysql_query($query) or die ("Couldn't get answers!<br />$query<br />".mysql_error());
while ($row=mysql_fetch_row($result))
{
echo "\t\t\t\t<td align='center'>$setfont<B>$flt[3] ($row[0])<br />\n";
echo "\t\t\t\t<select name='QID$flt[0]GID$flt[1]ANS$row[0]' multiple $slstyle2>\n";
for ($i=1; $i<=10; $i++)
{
echo "\t\t\t\t\t<option value='$i'>$i</option>\n";
}
echo "\t\t\t\t</select>\n";
}
$counter=0;
break;
case "C": // ARRAY OF YES\No\Uncertain QUESTIONS
echo "\t\t\t\t</tr>\n\t\t\t\t<tr>\n";
$query = "SELECT code, answer FROM answers WHERE qid='$flt[0]'";
$result = mysql_query($query) or die ("Couldn't get answers!<br />$query<br />".mysql_error());
while ($row=mysql_fetch_row($result))
{
echo "\t\t\t\t<td align='center'>$setfont<B>$flt[3] ($row[0])<br />\n";
echo "\t\t\t\t<select name='QID$flt[0]GID$flt[1]ANS$row[0]' multiple $slstyle2>\n";
echo "\t\t\t\t\t<option value='Y'>Yes</option>\n";
echo "\t\t\t\t\t<option value='U'>Uncertain</option>\n";
echo "\t\t\t\t\t<option value='N'>No</option>\n";
echo "\t\t\t\t</select>\n";
}
$counter=0;
break;
default:
$query = "SELECT code, answer FROM answers WHERE qid='$flt[0]'";
$result = mysql_query($query) or die("Couldn't get answers!<br />$query<br />".mysql_error());

//$myfield = "QID$flt[0]GID$flt[1][]";

while ($row=mysql_fetch_row($result))
{
echo "\t\t\t\t\t\t<option value='$row[0]'";
//if (in_array($row[0], $$myfield)) {echo " selected";}
echo ">$row[1]</option>\n";
}
}
if ($flt[2] != "A" && $flt[2] != "B" && $flt[2] != "C") //Have to make an exception for these types!
{
echo "\t\t\t\t</select>\n\t\t\t\t</td>\n";
}
$currentgroup=$flt[1];
$counter++;
}
echo "\n\t\t\t\t</td></tr>\n\t\t\t</table>\n";
echo "\t\t</td></tr>\n";
echo "\t\t<tr><td align='center' bgcolor='#CCCCCC'>\n\t\t\t<input $btstyle type='submit'>\n\t\t</td></tr>\n";
echo "\t<input type='hidden' name='sid' value='$sid'>\n";
echo "\t<input type='hidden' name='display' value='stats'>\n";
echo "\t</form>\n</table>\n";


if ($display)
{
// 1: Get list of questions with answers chosen

// 2: Develop SQL query

// 3: Present results
}
?>

0 comments on commit 3f064c6

Please sign in to comment.