#!/usr/bin/perl
require "blendcommon.cgi";


$surveydir = "/home/kirkjerk/SITES/MAIN/DATA/data-loveblender/survey";


print "Content-type: text/html\n\n" ;


print "<html><head><title>The Blender Survey</title></head><BODY  BGCOLOR=\"#FFFFFF\"  TEXT=\"#000000\"    LINK=\"#000088\" VLINK=\"#888888\" ALINK=\"#FF0000\" >\n";


print<<__EOQ__;

<H2>The Blender Survey Question</h2>

__EOQ__

&chugCGI(*input);

$num =  $input{"num"};

if($num eq ""){
    #show all question
print "<b>The Questions</b>:<br>\n";

    open(READ,"< $surveydir/quicklist")||print "Can't open $surveydir/quicklist";
    while(defined($line = <READ>)){
	chomp $line;
	($id,$ask) = split(/\t/,$line);
	print <<__EOQ__;
	<a href="surveyview.cgi?num=$id">$ask</a><br>

__EOQ__
    }

    close READ;






} else {
    #try to show responses for this question...

    if($num =~ /\D/){
	print "What num is $num ?";
	exit;
    }

    open(READ,"< /home/kirkjerk/SITES/MAIN/DATA/data-loveblender/survey/$num/ask") || print "Can't read question $!";
    $ask = <READ>;
    chomp $ask;
    close READ;
    print<<__EOQ__;
    <font size=+1>$ask</font>
__EOQ__
    print qq(<table>\n);
    open(READ,"< /home/kirkjerk/SITES/MAIN/DATA/data-loveblender/survey/$num/answer") || print "No one has responded to this one yet!";
    chomp $line;

    while(defined($line=<READ>)){
    ($userid,$username,$quote) = split(/\t/,$line);
	print<<__EOQ__;
	<tr><td valign="top" ><a href="av.cgi?id=$userid">$username</a></td>
	    <td bgcolor="#dddddd">$quote</td>
		</tr>
__EOQ__

    }

    close READ;


    print "</table>\n";

}


print <<__EOQ__;
<br><br>
<i><font size=+3>
<a href="surveyask.html">Answer the Latest Survey Question</a>
</font>
-- <a href="surveyview.cgi">View Past Survey Questions</a>
</i>
<br><br><br><br><br>
<nobr><a href="/"><img src="/blimage/b1.gif" border=0 alt="blender home"></a><a href="/blend/addwork.html"><img src="/blimage/b2.gif"border=0 alt="submit work"></a><a href="/blend/latest.cgi"><img src="/blimage/b3.gif" border=0 alt="read latest"></a><a href="/blend/feedback.html"><img src="/blimage/b4.gif" border=0 alt="add message"></a><a href="/comments.cgi"><img src="/blimage/b5.gif" border=0 alt="read board"></a></nobr>

__EOQ__


