CSE 190 M, Spring 2007
Final Exam

Name: ___________________________________________
 
Student ID #: ___________________

Good luck!

ProblemDescription EarnedMax
1 HTML/CSS     20
2 Javascript/DOM     20
3 Ajax/XML     20
5 PHP     20
4 SQL     20
X Extra Credit     +1
TOTAL  100

1. HTML/CSS Interpreting (20 points)

Draw a picture of how the following HTML and CSS code will look when the browser renders it onscreen. Indicate a background coloring by shading lightly or by drawing repeated diagonal lines like this. Assume that stickman.png is a generic picture of a stick man.


HTML
CSS

2. Javascript/DOM (20 points)

Write the Javascript code to accompany the following HTML code, so that when the Delete button is clicked, any button whose text value is divisible by the number written in the text field is removed from the page. You may assume that a valid number has been typed in the text field. The HTML code is the following:



Divisible by:
Click a button:

For example, after typing the number 2 into the text field and pressing Delete, the following should be the page appearance:

Divisible by:
Click a button:

 

3. Ajax/XML (20 points)

Write the Ajax Javascript code to fetch and display XML data from the file named movie.xml (in the same directory as your code). This file contains lines spoken by a character in a movie. Your code should process the XML and display the character's lines, each in its own paragraph, in the format shown below. Assume that the code will execute on an HTML page containing a div with the CSS ID of q3html, and insert the paragraphs into this div.

The XML data will be in a format that matches the following abbreviated example:

<character name="Captain Jack Sparrow" actor="Johnny Depp" />
     <line time="02:55">Captain Jack Sparrow, if you please, sir.</line>
     <line time="3:21">I'm in the market as it were.</line>
     ...
     <line time="2:41:38">On deck, you scabrous dogs! Man the braces!
     Let down and haul to run free. Now... bring me that horizon.  And
     really bad eggs?  Drink up, me 'earties, yo ho.</line>
</character>

For the XML data above, your code would produce the following content on the HTML page:

You may assume that your page already contains the following code from lecture and the slides:

function ajaxHelper(url, fn)

4. PHP (20 points)

Write PHP code that processes the following form:

<form action="solution/q4.php" method="post">
  <fieldset>
  <input type="text" name="name" /> Name<br />
  <input type="text" name="pw" /> Password<br />
  <input type="text" name="cc" /> Credit Card Number<br />
  <input type="submit" />
  </fieldset>
</form>

(Onscreen, the form looks like this:)




Your code should examine the name, password, and credit card number submitted, and verify that they are valid. A valid name is any non-empty string. A valid password is any string that is at least 6 characters long. A valid credit card number contains exactly 16 digits. Optionally, the credit card number can contain dashes between some or all groups of four digits. No other characters may be part of a credit card number. For example, the following are some examples of valid and invalid credit card numbers:

ValidInvalid
1234567812345678
2457-1543-4367-4093
39485098-81902375
9834-34256678-9827
2457.1543.4367.4093
foo1234567812345678
12345678123456789
1234-5678-1234-5678-
12-34-56-78-12-34-56-78
Your PHP code's output should be a level 1 heading stating whether the data was valid or invalid, followed by a paragraph containing the data itself separated by commas. Replace the password by a string of * characters of equivalent length. Strip any dashes out of the credit card number while displaying it. For example, here are some outputs of your script for various form input:

Form InputOutput
Marty
booyah!
1234-5678-1234-5678

Successful.

Marty, *******, 1234567812345678

Kenneth
hulk
11112222-33334444

Denied! Invalid data.

Kenneth, ****, 1111222233334444

Jeff
quailman
4321-4321x-4321-43210

Denied! Invalid data.

Jeff, ********, 43214321x432143210

Use regular expressions for pattern matching and replacement. Assume that the page begins with some introductory HTML content stored in the file q4top.html and some ending content stored in the file q4bottom.html, both of which you must place into your page.

 

5. SQL (20 points)

Write an SQL query that will return the names of all characters that appeared in two or more of the Pirates of the Caribbean movies; that is, movies whose name contains the substring "Pirates of the Caribbean". Ensure that the results are returned in alphabetical order. If it helps you, you may assume that the character is played by the same actor in both movies. The following is a subset of the results returned:

+----------------------------+
| Anamaria                   | 
| Bad Pirate                 | 
| Barbossa                   | 
| Bo'sun                     | 
| Butler                     | 
| Captain Jack Sparrow       | 
...
| Young Elizabeth            | 
| Young Will                 | 
+----------------------------+
73 rows in set (53.41 sec)

Recall that the imdb database contains the following tables:

Actor
idfnamelnamegender
433259WilliamShatnerM
797926BritneySpearsF
831289JennyWeaverF
...
Movie
idnameyear
112290Fight Club1999
209658Pi2000
210511Memento2000
...
Cast
aidmidRole
433259313398James T. Kirk
433259407323T.J. Hooker
797926342189Herself
...

X. Extra Credit (+1 point)

Write a haiku related to CSE 190M. A haiku is a Japanese poem made of three lines with 5, 7, and 5 syllables respectively. For example, the following is a haiku about Java:

public class Marty
public static void Booyah
System out println

(Any reasonable attempt at a haiku will get the +1 point.)