WDT: Tools Poll/Survey Script
uprm.edu | wdt | feedback | accesibility | code | web toolkit | DevNet
Poll Script
Description

Image of a webpage using the path crawlerThe POLL script allows users to easily create polls on their webpages. This tools allows uprm.edu users to add a poll without programming or CGI install.

Implementation

Anybody with an account in uprm.edu may use this tool. The POLL can only be used in webpages hosted by any server in the uprm.edu domain.

The poll works by adding a small JavaScript to your webpage. This JavaScript calls a tool hosted at our servers. This tools reads a text file that you will provide in your home page directory or in any server as long as it is readable by a browser. This text file is known as the configuration file. Here you will define your poll and the appearance of your poll. Ok lets see how we accomplish all of this...

Getting Ready:

To use this tool users must request a Poll ID by calling ext 3312 or by email at wmaster@uprm.edu. Send the Poll subject and your contact information along the email or when calling. Once you recieve this ID make sure you record this number in a safe place for future reference.

Assuming that you already have your poll topic and options we can start creating our configuration file. The configuration file is a text file that you can create in Notepad, TextEdit or any other text editor. The name of the file can be of any length but it must be a continous name. That is no spaces or other special characters. A good rule is to keep it short. The name doesn't have to be descriptive just enough for you to know what it is when you browse your files at your home page. The MAIN part of naming your file is that it must end with the extension ".txt". For example my configuration file can be named "mypoll.txt" or "classSICI3022p1.txt".

The format for the configuration file is very simple. You must have one field per line. A field has the following format field name=field value. Fields can appear in any order as long as you follow a few basic rules. The name of the field is CASE SENSITIVE and make sure you spell it correctly. The name is followed by an equal sign "=" and right after the value in a single line. Notice there are no spaces or tabs after the equal sign.

The following is an example of a configuration file:

ID=0001
Name=Jose Poll
Contact=dummy@domain.edu
URL=http://www.uprm.edu/app/testpoll.html
RowColor=#FFFFCC
TitleColor=#FFFF99
BorderColor=#FF9900
BarColor=#0000FF
Width=180
Question=Which compiler do you like the most?
Option=CodeWarrior
Option=REALBasic
Option=Visual Basic
Option=GCC/Apple Dev Tools
Option=Builder
Option=Delphi
Option=.Net Tools

Lets see each of the fileds in detail:

The first field is the "ID", this ID is the unique number assigned to your poll by the WDT.

The field "Name" is the name of your poll. This is a free string. Special punctuation characters must be encoded with their html equivalents.

The field "URL" is the full URL of the web page using this poll. When a vote is submited the tool will redirect users back to the web page with the poll. This URL must start with "http://".

The field "Contact" is the email of the person in charge of the poll. This must be a valid email address.

The field "Question" is the subject of your poll. This is a free string (one line). Special punctuation characters must be encoded with their html equivalents.

The field "Option" is a poll option. You can add as many options fields as need it. This is a free string (one line). Special punctuation characters must be encoded with their html equivalents.

*All of the above fields are requiered.

There are also a series of optional fields to control the appearance of your poll:

The field "Width" is the width of the poll table. This is numeric value. You may need to play with this value until you get a desirable size. The default size is 120.

The field "BorderColor" is the color of the borders in HTML. This value must have the "#" at the beginning.

The field "TitleColor" is the color of top row and bottom row. This value must have the "#" at the beginning.

The field "BarColor" is the color of graph bar. This value must have the "#" at the beginning.

The field "RowColor" is the color of the individual rows in HTML. This value must have the "#" at the beginning.

If your page uses CSS you can define a CSS class for the text in the header and inividual rows. This CSS is applied using a <span> tag. Remember to use a relative font size in your CSS to allow people to change the font size according to their needs.

The field "TitleCSSName" is the name of a CSS class defined in your page. This CSS class will be used for the title and footer in a <span> tag.

The field "RowCSSName" is the name of a CSS class defined in your page. This CSS class will be used for each row in a <span> tag.

Once you have created your configuration file upload this file to your web server like you would with any other web page. Before we continue you must know the URL where your configuration file is at. For example if I have an account in ACADEMIC.UPRM.EDU my webpage should be at "http://academic.uprm.edu/jose" where "jose" is my username. Assuming I uploaded my configuration file named "myconf.txt" there, the URL will be "http://academic.uprm.edu/jose/myconf.txt". We will need this information to add the poll to a webpage.

Using the poll in your pages:
There are a few things that you have to keep in mind while using the poll. First if you specify a "width" in your configuration file you must have atleast that much space available in your page or atleast 120 pixel for the default value. ingsThe crawler is placed in either the right or left side of your page right after the banner. To include a path crawler in a web page you must add one Javascript to your page.

This java script is the one that calls the poll tool and generates the your poll. The actual code for the javascript is not included instead you call an external script. When you call the external script you must provide some arguments to the poll tool so it can create your poll using your configuration file.

This is an example of the javascript need in your webpage.
<script type="text/javascript"
src="http://www.uprm.edu/app/ckpoll.php?n=jose/stdpoll&id=0001">
</
script>

The arguments to the poll tool are the ones after the ? question mark just like in any other cgi. Next we will discuss the diferent arguments and their uses.

The tool requires three arguments to be able to create the poll:

ckpoll.php?n=jose/stdpoll&id=0001&domain=academic.uprm.edu

id
Is a unique number assigned to your poll by the WDT.
n
The location (path) of the configuration file minus the ".txt" extension. The relative path from your domain to the document. This is the part after the domain in the url. For example if my url is "http://academic.uprm.edu/jose/myconf.txt" then the value of "n" will be "jose/myconf". Notice that we removed the leading backslash and the ".txt" extension from the name of the configuration file.
domain
The domain argument is very important if your page is served under a domain other than "www.uprm.edu" like "academic.uprm.edu" for example. The domain argument tells the tool that your configuration file is found in a different domain. The domain is nothing else than the actual domain name of your server. For example if I use this tool in the pages hosted in ADEM my domain will be "domain=enterprise.uprm.edu".

If the page using the poll is in "www.uprm.edu" then you may skip this argument.

NOTE The order in which the arguments appear is not relevant for the tool.

NF

Last Revision: Sep. 03, WDT, wmaster@uprm.edu