Computer Science | University of Kentucky College of ...
Program Components:JavaScript Query WebpagePHP Server ProgramRacetrack Data SpreadsheetProgram Interfaces:User submits a valid queryUser submits an invalid query, webpage throws an errorServer accesses data from spreadsheetServer provides requested data to userServer provides error report if requested data does not exist P3querypage.jsAuthor: Date: 10/14/2015Description: This program manages a webpage containing textboxes in which the user can enter tags for racetrack data they wish to inquire about. Three of the five textboxes take the date, month, and year in which a race may have taken place, one takes the abbreviated name of the racetrack in which the race was held, and one takes the race number. When the user presses SUBMIT, the program checks that the input is valid (for instance, month data should be numeric and range from 1-12) using validate(), returning an error alert if it is invalid and submitting the data to the server otherwise.Preconditions: For data to be submitted successfully, the corresponding server must be established. The user provides data to the web page in the form of textboxes. Each text box takes a piece of data about a race that may have taken place. These include the date, month, and year the race took place, the track where the race took place, and the race number.Postconditions: If the submitted data contains invalid values, an error alert box is displayed to the user reporting the first error caught. If the data is valid, then it is submitted to the server PHP program P3server.php. The server will then either return the results of the requested race or a report that the data could not be found.Funtion: validate()Preconditions: The function does not take parameters. The function reads the values in the webpage’s five text boxes for validation.Postconditions: If the data submitted in the text boxes is invalid, the function will report the error in an alert box. If all values are valid, then the information is sent to the server as a POST request.Description: The backbone of the program, validate() checks that the inputted data is valid (though not necessarily correct), returning an error alert if not. If all values are valid, the function submits the data to the query-handling server.Pseudocode:Assign text box value for day to variable dayIf day is not numericDisplay error “Day must be 1-31”ReturnConvert day to an integerIf day is less than 1 or greater than 31Display error “Day must be 1-31”ReturnAssign text box value for month to variable monthIf month is not numericDisplay error “Month must be 1-12”ReturnConvert month to an integerIf month is less than 1 or greater than 31Display error “Month must be 1-12”ReturnAssign text box value for year to variable yearIf year is not numericDisplay error “Year must be 2010-2015”ReturnConvert year to an integerIf year is less than 2010 or greater than 2015Display error “Year must be 2010-2015”ReturnAssign text box value for track to variable trackIf track has less than 2 characters or greater than 3 charactersDisplay error “Track must be 2 or 3 alphabetical characters”ReturnFor each character in trackIf the character’s ASCII value is not between 65 and 90 or 97 and 122Display error “Track must be 2 or 3 alphabetical characters”ReturnConvert track to all uppercase charactersAssign text box value for race number to variable raceNumIf raceNum is not numericDisplay error “Race number must be 1-15”ReturnConvert raceNum to an integerIf raceNum is less than 1 or greater than 15Display error “Race number must be 1-15”ReturnSubmit the webpage form to the server P3server.phpAuthor: Date: 10/14/2015Description: This program parses requests for race data, attempts to locate the requested race in cs316raceresults.csv, and returns results of that race to the requesting browser. If the requested race cannot be found, the program returns appropriate error messages to the browser.Preconditions: Request queries are received with five fields: day, month, year, track, and race number. These are assumed to be valid values, since the webpage should validate entries. Race results are contained in cs316raceresults.csv. Each entry in the results file should contain 10 fields: The date of the race, the abbreviated name of the racetrack, the race number, the name of a competing horse, its finishing placement in the race, the distance the horse won or lost by, its speed rating, its final odds, its morning odds, and its expected speed rating.Postconditions:If cs316raceresults.csv cannot be opened, the server returns “Error opening file cs316raceresults.csv” to the browser. Otherwise, the specified date, track, and race number are displayed on the browser. If there are entries in the results file that match the specified data, then each entry is displayed in a table, ordered by finishing placement according to the example at . If no entries can be found which contain the specified date, track, and race number, then the message “Requested race not found” is also returned to the browser. Additionally, if no entries exist for the specified date at all, the message “No races on this date” is also returned to the browser. Additionally, if no entries exist for the specified track at all, the message “No races on this track” is also returned to the browser. Additionally, if no entries exist for the specified race number at all, the message “No races for this race number” is also returned to the browser.Pseudocode:Attempt to open cs316raceresults.csv for readingIf opening failed:Return to browser “Error opening file cs316raceresults.csv”Else:For each entry in the readfile:For each field in the entry:Add the field data to a line arrayAdd the line array to a results array Access day, month, year, track, and race number data and store in appropriate variablesConcatenate day, month, and year into a single date string, in format month/day/yearInitialize Boolean variables dateFlag, trackFlag, and raceFlag to falseFor each entry element in results:If results[0] == date:dateFlag = trueIf results[1] == track:trackFlag = trueIf results[2] == raceNum:numberFlag = trueIf (results[0] == date & results[1] == track & results[2] == raceNum):Add the entry array to raceResults arrayCompose return message with date, track, and raceNumIf raceResults is empty:Add “Requested race not found” to return messageIf !dateFlag:Add “No races on this date” to return messageIf !trackFlag:Add “No races on this track” to return messageIf !numberFlag:Add “No races for this race number” to return messageElse:For each element in raceResults:Create a table entry with the element’s 5th, 4th, 6th, 7th, 8th, 9th, and 10th elementsAdd the table entry to a table in the return messageReturn to the browser the return message ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related searches
- university of minnesota college of education
- university of kentucky report card
- university of kentucky employee email
- university of kentucky football ranking
- university of kentucky softball schedule
- university of kentucky graduate school
- university of kentucky construction companies
- university of minnesota college of continuing education
- university of kentucky graduate apply
- university of kentucky core requirements
- university of kentucky master programs
- university of kentucky apply