代写 Scheme html Java javascript statistic Skip navigation

Skip navigation
University of Liverpool –
Department of Computer Science

Computer Science

University home
 > Computer Science
 > People
 > Ullrich Hustadt
 > COMP284
 > Assignment 1 Re-sit
COMP284 Scripting Languages (2018-19) — Assignment 1 Re-sit: Perl and CGI
Your task for this practical assignment consists of two parts:
1. Develop a Perl script using CGI.pm for a web-based system that provides the functionality stated in the Requirements section below.
2. Make the system that you have created accessible and usable via the URL http://student.csc.liv.ac.uk/cgi-bin/cgiwrap//weather.pl 
taking care of the requirements set out in Submission and Setup section below.

Requirements
Your Perl script should perform a statistical analysis of weather data for a particular date.
1. The script should display a web page that contains a form with three text fields and a `Submit’ button. The three text fields should allow the user to enter the year, month, and day of the date he/she is interested in. There should be no restriction on what the user can enter into these text fields nor should any checks be performed using JavaScript.
2. If the user presses the `Submit’ button, then the script should first check that the input of the user constitutes a valid date. In doing so the script should take into account leap years. The script should also check that the year is between 2001 and 2015. If the input does not pass those checks, then the system should generate a HTML page containing appropriate error messages and prompt the user to start again.
3. If the user’s input passes the checks, then the script should try to retrieve weather data for that date. Before it can do that, it should convert the day and month of the date into the corresponding day within the year where days are numbered consecutively from 1 to 365, or 366 for leap years. For example, 1st March 2003 is the 60th day in 2003 (31 days of January + 28 days of February + 1 day of March) while 1st March 2004 is the 61st day in 2004 (31 days of January + 29 days of February + 1 day of March), since 2004 was a leap year. The weather data for the date can then be accessed via the URL 
http://cgi.csc.liv.ac.uk/cgi-bin/cgiwrap/ullrich/data.pl?year=YEAR&jday=JDAY 
where YEAR is the year entered by the user and JDAY is the day within the year that the script has just computed. 
So, for 1st March 2003 the script needs to retrieve the URL 
http://cgi.csc.liv.ac.uk/cgi-bin/cgiwrap/ullrich/data.pl?year=2003&jday=60 
while for 1st March 2004 the script needs to retrieve the URL http://cgi.csc.liv.ac.uk/cgi-bin/cgiwrap/ullrich/data.pl?year=2004&jday=61 

If for some reason the retrieval of data fails, the script should output an error message and ask the user to enter a new date.
4. The data retrieved will take the form of plain text consisting of a list of records, one record per line, with records divided into fields by commas. The first line / record always contains the names of the fields, while the remaining lines / records contain the actual weather data. The fields are
5. Field(s)
6. Description
7. id
8. a number uniquely identifying the record
9. date, year, jday
10. the date, year and day in year that the weather data is for
11. hour, min
12. weather data is recorded every five minutes from 00:00 to 24:00
13. precip
14. the precipitation measured in that five minute period
15. templo
16. the lowest temperature, in Fahrenheit, measured in that five minute period
17. temphi
18. the highest temperature, in Fahrenheit, measured in that five minute period
19. tempavg
20. the average temperature, in Fahrenheot, measured in that five minute period
21. wndmx
22. the highest wind speed, in miles per hour, measured in that five minute period
23. wndavg
24. the average wind speed, in miles per hour, measured in that five minute period
25. wnddir
26. the wind direction, as an angle between 0 and 360, measured in that five minute period
27. barlo
28. the lowest surface pressure, in hectoPascals, measured in that five minute period
29. barhi
30. the highest surface pressure, in hectoPascals, measured in that five minute period
31. For example, the first four records for 1st March 2003 look as follows:
32. id, date, year,jdate,hour,min,precip,templo,temphi,tempavg, wndmx, wndavg,wnddir,barlo,barhi
33. 44629,2003-03-01 00:05:00,2003, 60, 0, 5, 0, 13.14, 13.26, 0.00, 0.629, 0.629, 35.6, 1019, 1020
34. 44630,2003-03-01 00:10:00,2003, 60, 0, 10, 0, 13.08, 13.44, 0.00, 1.255, 0.844, 66.7, 1019, 1020
35. 44631,2003-03-01 00:15:00,2003, 60, 0, 15, 0, 13.32, 13.56, 0.00, 1.166, 0.784, 49.1, 1019, 1020
36. 

It could happen that the data retrieved only consists of the first record and contains no weather data. Then the script should output an error message and ask the user to enter a new date.
37. The script should analyse the data and compute the following values:
◦ the total precipitation, computed as the sum of the precipitations measured that day,
◦ the highest temperature, computed as the maximum of the highest temperatures measured,
◦ the lowest temperature, computed as the minimum of the lowest temperatures measured,
◦ the average temperature, computed as the average of the average temperatures measured, and
◦ the highest wind speed, computed as the maximum of the maximum wind speeds measured.
38. Once the script has completed the analysis, it should produce a HTML page that includes
◦ the date entered by the user,
◦ the data that was retrieved, in a form that preserves the layout of the data,
◦ a table with two columns and five rows, the second column contains the five values computed in the previous step and the first column contains a short description of each. Highest temperature, lowest temperature, average temperature and highest wind speed should be shown as decimal numbers with two decimal places while total precipitation should be shown as natural number.
Additional requirements and comments:
• As this is an assignment on Perl, no other scripting languages should be used. In particular, JavaScript should not be used for input validation.
• All HTML markup that the script produces should be produced using CGI.pm HTML shortcuts.
• You are allowed to use other Perl modules besides CGI.pm provided that those modules are available on our web server. For example, the module LWP::Simple that you have already seen in the COMP284 practicals as well as the module List::Util provide functions that can be useful for this assignment.
• Your code should be properly commented. This includes pointing out which parts of your code have been developed with the help of on-line sources or textbooks by including references for these sources at the appropriate points.
Each of these requirements is linked to one of more of the assessment criteria for this assignment. Therefore, the more requirements a system satisfies, the higher the mark.
Test data
Two test cases with the expected results can be found at http://cgi.csc.liv.ac.uk/~ullrich/COMP284/tests1R-2018-19/.
Submission and Setup
Submit your Perl script via the departmental submission system at https://sam.csc.liv.ac.uk/COMP/Submissions.pl (COMP284-11: Perl and CGI). You also need to make weather.pl and any auxiliary files usable via the departmental web server.
The files submitted must be identical to those set up on the departmental web server. Furthermore, no alterations are allowed to the latter after files have been submitted. If a submitted file and the corresponding file on the departmental web server have different timestamps, then the later timestamp will be used to determine lateness. This applies even if the earlier file is used for marking.
Permissions of the files in your filestore must be such that no other user can view their contents in the filestore.
Deadline
The deadline for this assignment is
Friday, 9 August 2019, 17:00
Earlier submission is possible, but any submission after the deadline attracts the standard lateness penalties. Please remember that a strict interpretation of `lateness’ is applied by the Department, that is, a submission on Friday, 9 August 2019, 17:01 is considered to be a day late (analogously for submissions that are delayed further).
Assessment
This assignment addresses the following learning outcomes of the module:
• rapidly develop simple applications, both computer and web-based, using an appropriate scripting language.
• document and comment applications written using a scripting language.
This assignment contributes 30% to the overall mark of COMP284. Failure on this assignment may be compensated by higher marks on other assignments for this module.
Marks will be awarded according to the following scheme:
• Submission, setup, and error-freeness: 10
• Creating web interface, accessing user input, and error handling for those inputs: 23
• Retrieving the weather data, performing its analysis, and handling associated errors: 36
• Creating HTML page with result: 19
• Formatting, commenting, and quality of code: 12
In more detail, the requirements above translate into about 25 criteria that your system and its underlying code must satisfy. Marks are given according to the extent to which the system is observed to satisfy these criteria. Code that has no observable effect will typically receive no marks.
As stated above, the University policy on late submissions applies to this assignment, as do the University policy on coursework submission (available at https://www.liverpool.ac.uk/media/livacuk/tqsd/code-of-practice-on-assessment/appendix_Q_cop_assess.pdf) and the University policy on academic integrity (available at http://www.liv.ac.uk/student-administration/student-administration-centre/policies-procedures/academic-integrity/). You should follow the COMP284 Lab Rules to ensure that you do not breach the latter policy.

Department of Computer Science, University of Liverpool
Ashton Building, Ashton Street, Liverpool L69 3BX, United Kingdom
+44 (0)151 795 4275
Maintained by Ullrich Hustadt, u.hustadt@liverpool.ac.uk
© University of Liverpool – a member of The Russell Group
Departmental Contacts | University Contacts | Map | Legal | Accessibility