Part A Short Answer (50 marks) NOTE: Answers for Part A should be no more than 3-4 sentences long. 1. (5 marks) What is the purpose of HTML? What is the purpose of a DTD? How do HTML and DTDs relate to each other? 2. (3 marks) What is the main purpose of using <div> and <span> HTML tags? What is the difference between <div> and <span>? 3. (2 marks) Give two main advantages of using CSS. 4. (6 marks) What are the three ways to include CSS in web pages? Explain what each one actually means by giving an example of how to access the CSS from the web page. 5. (3 marks) Regarding CSS and XHTML, what is a validator used for? Explain how the W3C Validators are used. Why is it a good idea to make sure web pages are valid? 6. (4 marks) In relation to JavaScript, describe what the DOM is. Give a JavaScript instruction which would change the source file of an image on a form to beach.jpg. 7. (4 marks) Explain what is meant by client-server architecture for the web. In particular, identify which processes occur on the server side and which on the client side. Also state which side is more secure and why? 8. (6 marks) What is meant by "form validation"? What function can be used to match a regular expression in PHP? What function do we use to match a regular expression in JavaScript? Why is it important to validate on both the server and the client side? 9. (3 marks) Explain what is meant by the term HCI what do the letters stand for and broadly what considerations should be taken into account? For instance in what circumstances could website background colour be an issue? Apart from accessibility issues, what other features of HCI should be considered when designing a website? COSC2413/2426 Web Programming, Semester 1, 2010 Page 1 of 8
10. (3 marks) List the 3 different modes to open a file with using PHP (using fopen). Briefly explain each mode. 11. (3 marks) Identify three things which a PHP session can enable to happen on a website. 12. (4 marks) List two popular types of layouts used for web pages. List two things you can do to make your website navigation more usable and user friendly. 13. (4 marks) What is XML? Explain two differences between an.xml file and a.txt file. COSC2413/2426 Web Programming, Semester 1, 2010 Page 2 of 8
Part B Understanding and Writing Code (50 marks) 1. (6 Marks) Look at the following HTML. There are some problems with the code which prevent it from validating as strict XHTML. Find all the problems and rewrite the correct code below: HTML Code: <html> <head> <title>find the errors!</head> </title> <body> <p> <h1>the Heading! <a HREF=http://google.com>Link 1</a> <br> <STRONG>The Body</STRONG> </body> </html> Rewrite the code here (some code given already): <?xml version= 1.0?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> COSC2413/2426 Web Programming, Semester 1, 2010 Page 3 of 8
2. (6 marks) First look at the following XHTML code which is designed to make a table and then draw what the table will look like in the box below: Table Code: <table width="80%" height="80% border= 1px > <tr> <td>a</td> <td colspan= 2 style= text-align: center >B</td> </tr> <tr> <td rowspan= 2 >C</td> <td style= text-align: right >D</td> <td>e</td> </tr> <tr> <td>f</td> <td>g</td> </tr> </table> Draw what the table will look like here: COSC2413/2426 Web Programming, Semester 1, 2010 Page 4 of 8
3. (14 marks) Using XHTML and JavaScript, please code a registration form like the following: Registration * means required field Full Name * Username * Password * Melbourne Location Canberra Other Age 14-18 Type here Profile Register! Note: The age field should have options 0-13, 14-18, 19-30, and 30+. If the form is submitted and a required field is missing o Pop up a window saying Please fill in all required fields (the error message doesn t have to be specific). o Do not submit the page (i.e. stay on the same page) If the form is filled in correctly, submit to process_form.php Write your code here (some code given already): <?xml version= 1.0?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> COSC2413/2426 Web Programming, Semester 1, 2010 Page 5 of 8
(Problem 3 Continued) COSC2413/2426 Web Programming, Semester 1, 2010 Page 6 of 8
4. (8 marks) Write regular expressions to match each of the following inputs. (a) A full name consisting of two words (Example: Kevin Chang) (b) A username that has at least 6 characters, which can contain alphanumeric characters, underscores(_), and periods (.) (c) A valid RMIT student ID (example: s1234567) (d) A valid email ending in either.com,.net, or.edu (example: ben@gmail.com) 5. (8 marks) Look at the following code and write what the output to the browser will look like. Then rewrite the code to use a while or for loop instead of using foreach. PHP Code: <?php $my_array = array(); $my_array[] = "apples" $my_array[] = "oranges" $my_array[] = "grapes"?> foreach($my_array as $fruit) { if ($fruit == "orange") { echo "I like to eat ". $fruit. "<br />"; } else { echo "I don't like to eat ". $fruit. "<br />"; } } Write Output Here: COSC2413/2426 Web Programming, Semester 1, 2010 Page 7 of 8
Rewrite Code Here: <?php $my_array = array(); $my_array[] = "apple" $my_array[] = "orange" $my_array[] = "grape" // Write your code here to use a while or for loop instead?> 6. (8 Marks) Using PHP sessions, write a page that will count how many times a user has visited the page, then output it to the screen. Your PHP Code: <?php?> COSC2413/2426 Web Programming, Semester 1, 2010 Page 8 of 8