* If you are interested in building a website that uses a database, and want to learn some MySQL, contact me and I'll give you some guidance on how you can use your userid.cisc103.pconrad.info
account to learn some basic MySQL.
However, learning MySQL is not a part of this lab and is not a required part of the course. This lab is the last thing you are required to do this semester other than attend class, take quizzes, and take the final exam.
This lab has three goals
In this lab, you'll first choose one of three problems to work on. The problems come from three different areas:
Each of the problems has one input, and one output.
For the problem you choose, you'll first follow each of the following steps to produce a JavaScript solution:
You'll then follow all of these steps to produce a PHP solution:
userid.cisc103.pconrad.info
called lab11 to store your filesradius
, area
, diameter
, ticketPrice
, and cost
, you'd have names like these: $radius
, $area
, $diameter
, $ticketPrice
, and $cost
). Math.PI
but in PHP, we just write M_PI
Math.pow(x,y)
but in PHP, we just write pow(x,y)
When finished with both parts:
copland.udel.edu
, and then again on userid.cisc103.pconrad.info
), you'll create a script showing that your function definition works and passes the tests. these two files on WebCT.At that point, except for...
... you'll be finished with the course!
Here are three problems you may choose from. Choose only ONE problem. Use the same problem for both Part 1 and Part 2 of the lab.
problem title |
problem description |
formula (in math notation) |
||
---|---|---|---|---|
(A) | Music | Frequencies in a well-tempered scale | Find the frequency a musical note that is a given number of half-steps up or down from the starting pitch A440, using a well-tempered scale.
For more information, see: http://members.cox.net/mathmistakes/music.htm |
f=p(sh) |
(B) | Sports | Pace | An athlete is running a timed course of a 500 meters (as in track, luge, cycling, swimming, etc.) A split time is taken at 250 meters. Given a split time in seconds, calculate the total time required to complete the course, assuming the athlete stays at the same pace.
For some example results, see http://www.udel.edu/sportsinfo/womens_swimming/stats07.pdf
|
t = ls/d |
(C) | Carnival Rides (Also, Math & Physics) |
Ride Speed |
On some carnival rides, riders travel in a circle facing forward. These rides are often variations on the theme of a carousel, but might go considerably faster and involve seats that swing out on ropes or arms. A question arises—at what speed are you traveling around the circle? Assume that the radius of the circle is 20 feet. Given the period (how long it takes to make one rotation, in seconds), calculate the speed around the circle in miles per hour.
| s = (2πr/p)(3600/5280) |
Once you know which problem you are going to do, you can proceed with the remaining steps in the lab.
Create a directory ~/public_html/cisc106/lab11 in which to store your files, and make the directory readable on the web.
This step is straightforward, and detailed instructions appear in previous labs.
This step is also straightforward. You can write your function directly in the directory ~/public_html/cisc106/lab11
When choosing the name of your file, make the name match the name of your function, e.g. wtf.js
, split2finish.js
, or rideSpeed.js
Your JavaScript function definition should include comments with information about what the function consumes and produces, and examples, just like the examples given in lab08 and lab09.
Do not give up until you have tried all of the above items.
To write a test script, consult the test scripts that you used in lab08 and lab09. Your test script should operate in a similar fashion.
Your test script should be called with a name that is the same as the your function, but with the word test in front of it—for example: testWtf.js
, testSplit2finish.js
, or testRideSpeed.js
When your function passes all the tests, proceed to the next step.
This HTML page allows the user to enter the input value in an input box, click a button, and see the output value.
This page will be structured in a way that is similar to the pages you write in lab08 and lab09.
You'll need to pull in the definition of your function with a <script src="filename.js" type="text/javascript"><script> element, as well as include another <script type="text/javascript></script> element containing a function definition that will serve as an event handler for when your button is clicked.
You'll need to put id attributes on your input boxes so that you can use getElementById() in your event handler function. Remember that the choice of id attributes is up to you, but the id attributes must match the ones that you pass into getElementById.
This is an opportunity to practice again the skills that may have eluded you in lab08 and lab09, so that you can be sure to be prepared to answer any questions about these topics that may be on the final exam. So be sure you understand how all the parts work. This is your last opportunity to work with these ideas, so take full advantage of it!
When you are done, and your page works properly, move on to step 2, where you'll follow do a similar process, but in PHP—just like in lab10, but this time you are doing the thinking to come up with the code.
userid.cisc103.pconrad.info
server You do this by logging into the server called userid.cisc103.pconrad.info
just like you did in lab10. Remember:
userid.cisc103.pconrad.info
this stands in place of copland.udel.edu
in the usual process you use for logging in. Remember that the actual hostname is jsmith.cisc103.pconrad.info
, or bfd.cisc103.pconrad.info
, or whatever your userid happens to be. initWikiPw
field. Once you have logged in, the process works just like it does on copland.udel.edu—emacs is even working now too (which wasn't true when we did lab10.)
However, instead of creating a directory ~/public_html/cisc103/lab11
, we'll just create ~/public_html/lab11
since the cisc103 part is included in the server name already.
Your URL to access these files will be http://userid.cisc103.pconrad.info/lab11
Now, cd into your ~/public_html/lab11 directory on your userid.cisc103.pconrad.info server, and use emacs to create a file with a .php extension with one of the following names, depending on whether you are doing problem A, B, or C: wtf.php
, split2finish.php
, or rideSpeed.php
.
In this file, put a PHP function definition.
As an example, see the function definition from step 3 of lab10
The function will be similar to the one you write in JavaScript, with some small changes:
<?php
on a line by itself, and end it with ?>
on a line by itself radius
, area
, diameter
, ticketPrice
, and cost
, you'd have names like these: $radius
, $area
, $diameter
, $ticketPrice
, and $cost
).1.0/12.0
not 1/12
3600.0/5280.0
not 3600/5280
1/12
and 3600/5280
end up being counted as 0
in PHP, but 1.0/12.0
would be counted as 0.0833333333
and 3600/5280
is counted as 0.681818182
Here are some specific things that may have to change depending on which problem you are working on:
Math.pow(x,y)
but in PHP, we just write pow(x,y)
Math.PI
but in PHP, we just write M_PI
For PHP, I've provided three test scripts you can use, plus instructions on how to run them. The test scripts are located at these web pages:
testWtf.php
: http://www.udel.edu/CIS/103/pconrad/07F/labs/lab11/testWtf.phptestSplit2finish.php
: http://www.udel.edu/CIS/103/pconrad/07F/labs/lab11/testSplit2Finish.phptestRideSpeed.php
. http://www.udel.edu/CIS/103/pconrad/07F/labs/lab11/testRideSpeed.phpTo copy the test script into your account:
wget
on the command line, and then after the command wget, paste in the URL that you want to retrieve.
testWtf.php
, use the command wget http://www.udel.edu/CIS/103/pconrad/07F/labs/lab11/testWtf.php
In general, the wget
command, when it is available, is a very useful Unix command for quickly obtaining a file over the web. Many web hosting companies that offer shell access (i..e the ability to get a Unix prompt) offer this command.
To run the test script, you will need to type the Unix command php followed by the name of the test script, e.g.
[userid@linux3 lab11]$ php testWtf.php
You should see that the test passes, for example:
[pconrad@linux3 lab11]$ php testWtf.php test 1 passed test 2 passed [pconrad@linux3 lab11]$
If it does not, look at your function defintion and try to determine what is wrong.
If you need help, ask your TA or instructor for assistance.
A reminder: when asking for assistance by email, cc both your instructor and your TA, and copy and paste the command you are typing, and the message you are getting.
Write a pair of web pages that allow users to calculate solutions to your problem similar to the ones from lab10:
The result page should have link back to the HTML page that asks for the input, just as in lab10. Also, both pages should have links that allow the pages to be validated at validator.w3.org, and should validate as strict XHTML1.0.
When your pages work properly, you are ready to finish and submit.
Now, create two scripts documenting your work on this lab.
Login to copland.udel.edu
one last time, and cd into your ~/public_html/cisc103/lab11
directory.
Create a script file called lab11a.txt showing that your JavaScript function works, and passes its tests. You will do this by using the Unix comand script lab11a.txt
and then going into the JavaScript command line interpreter (the js> prompt), loading the function definition and the definition of the test function, and then executing it.
Detailed instructions on how to make a script file (with the Unix script command) appeared in the folowing places, so if you need more detail than what is provided above, consult these previous labs.
Login to userid
.cisc103.pconrad.info
one last time, and cd into your ~/public_html/lab11
directory.
Create a script file called lab11a.txt showing that your PHP function passes its tests.
To do this:
script lab11b.txt
at the Unix prompt pwd
command to show your curent directory exit
to end the script The two files are:
lab11a.txt
lab11b.txt
We'll look at the other files (including the PHP files) by accessing them directly on the server. (The TA and instructor have access to see server side files under your accounts on the userid.cisc103.pconrad.info
server).
Except for quizzes and the final exam, you are finished with CISC103!
Please see the wiki page for lab11 for the detailed grading rubric.
Submitted by | Penalty |
---|---|
Thu 11/29/2007, 11:55pm | None |
Fri 11/30/2007, 11:55pm | none (amnesty) |
Sat 12/01/2007, 11:55pm | 2% |
Sun 12/02/2007, 11:55pm | 4% |
Mon 12/03/2007, 11:55pm | 8% |
Tue 12/03/2007, 11:55pm | 8% |
Wed 12/03/2007, 11:55pm | 16% |
After Wed 12/03/2007, 11:55pm | NO CREDIT NO EXCEPTIONS |
Copyright 2007, Phillip T. Conrad, CIS Dept., University of Delaware. Permission to copy for non-commercial, non-profit, educational purposes granted, provided appropriate credit is given; all other rights reserved