#!/usr/local/bin/perl ############################################################## # This was written by Kevin Epperson for credit in # INFS-5510 at the Univesity of Colorado at Boulder. I can # be reached for any question you might have via e-mail at # epperson@colorado.edu or epperson@us1.ibm.com ############################################################## # Get initial information from user print "This program will assist in setting a survey for you.\n"; print "Please enter the title of your survey:\n"; $title = ; chop($title); print "Please enter the filename of the survey to be created without exstensions:\n"; $name = ; chop($name); print "Please enter the number of questions in your survey:\n"; $numquest = ; chop($numquest); ############################################################## # Create directory and set permissions if necessary. mkdir data, 0777; chmod 0777, "data"; ############################################################## # Open file and write partial header open(NEWSURVEY,"+>./data/$name.srv") || die "Sorry, I could not create $name.srv This file may already exist.\n"; print NEWSURVEY "

$title


\n"; print NEWSURVEY "Please read the following questions and answer them to the best of your abilities. If there is a question you have no opinion on please choose N/A. When you have finished the survey click on the \"Submit Survey\" button to submit \n"; print NEWSURVEY "your answers. If you would like to clear your answers at any time click the \"Clear Survey\" button.

\n"; print NEWSURVEY "\n\n"; ############################################################## # Gets question type and question text for 1 to numquest # Write questions to file for ($x = 1; $x <= $numquest; $x++) { print "Would you like question $x to be a (Y)es/No question or\n"; print "a (S)caler question? Please enter (Y) or (S).\n"; $q_type = ; chop ($q_type); print "Please enter the text description for question $x\n"; $q_text = ; chop ($q_text); if ($q_type eq "S" or $q_type eq "s") { print NEWSURVEY "\n"; print NEWSURVEY "


Question $x

$q_text

\n"; print NEWSURVEY "Please rate on a scale of 1 to 10. With 1 being least important and 10 being most important.\n"; print NEWSURVEY "If you have no opinion on the question please choose N/A.\n"; print NEWSURVEY "

\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "
Least
Important
Moderately
Important
Most
Important
12345678910N/A

\n"; print NEWSURVEY "\n\n"; } elsif ($q_type eq "Y" or $q_type eq "y") { print NEWSURVEY "\n"; print NEWSURVEY "

Question $x

\n"; print NEWSURVEY "$q_text

\n"; print NEWSURVEY "Please answer the question either Yes or No. If you have no opinion on the question please choose N/A\n"; print NEWSURVEY "

\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "
YesNoN/A

\n"; print NEWSURVEY "\n\n"; } else { print "This is not a valid option. Please try again.\n"; $x--; } } #for loop end bracket ############################################################## # Writes footer, hidden fields, and closes survey file print NEWSURVEY "

\n"; print NEWSURVEY "Please use this space for any comments you would like to submit:\n"; print NEWSURVEY "

\n"; print NEWSURVEY "

\n"; print NEWSURVEY "\n"; print NEWSURVEY "\n"; print NEWSURVEY "
\n"; print NEWSURVEY "\n"; close(NEWSURVEY); ############################################################## # Creates data files # Future improvement would be getting the perl chmod command to work # so that permissions are set automatically open(DATAFILE,"+>./data/$name.dat") || die "Sorry, I could not create $name.dat This file may already exist.\n"; print DATAFILE "password|user's name|user's remote host|"; for ($y = 1; $y <= $numquest; $y++) { print DATAFILE "q$y|"; } print DATAFILE "comments|\n"; close(DATAFILE); chmod 0644, "./data/$name.srv"; chmod 0666, "./data/$name.dat"; ############################################################## # Tells user status print "\n\n\n\n\n\n"; print "This survey has been sucessfully created.\n"; print "This process created two files:\n"; print " ./data/$name.srv |The survey file in html format\n"; print " ./data/$name.dat |The data file where results will be stored\n\n\n";