代写接单- FIT2104 Web-interfaced database

     Berwick Caulfield Parkville Clayton Malaysia Off Campus Learning Gippsland Peninsula Enhancement Studies Sth Africa Other (specify) Sample Examination Period Faculty of Information Technology EXAM CODES: TITLE OF PAPER: EXAM DURATION: READING TIME: THIS PAPER IS FOR STUDENTS STUDYING AT:( tick where applicable) FIT2104 Web-interfaced database - PAPER 1 3 hours writing time 10 minutes During an exam, you must not have in your possession, a book, notes, paper, electronic device/s, calculator, pencil case, mobile phone, smart watch/device or other material/item which has not been authorised for the exam or specifically permitted as noted below. Any material or item on your desk, chair or person will be deemed to be in your possession. You are reminded that possession of unauthorised materials, or attempting to cheat or cheating in an exam is a discipline offence under Part 7 of the Monash University (Council) Regulations. No exam paper or other exam materials are to be removed from the room. AUTHORISED MATERIALS OPEN BOOK CALCULATORS SPECIFICALLY PERMITTED ITEMS if yes, items permitted are: YES YES YES NO NO NO Office Use Only Open Learning Candidates must complete this section if required to write answers within this paper STUDENTID: ________________ DESKNUMBER: __________ FIT2104 Sample Final Examination PART A Multiple Choice Questions NOTE: There is only ONE correct answer for each question 1. Given the following PHP code section $intNumA = $_POST["numA"]; $intNumB = 3; $intTotal = $intNumA + $intNumB; echo $intTotal; If the user enters a value of 12 in the form, which ONE of the following will be displayed to the user? a. "123" b. 123 c. 15 d. "15" 2. Which ONE of the following is the first function loaded from a Controller in CakePHP? a. The function which is written first. b. The index function. c. The function the user calls via the browser. d. None of the above 3. How many times will the following PHP for loop execute? for ($i=6; $i<10; $i++) { $i=$i +1; } a. b. c. d. one two three four 4. When processing a HTML form, which ONE of the following describes the difference between a hidden form element and a visible form element? a. There is no difference. b. The hidden element does not have a value. c. The hidden element's value cannot be retrieved d. The hidden element is excluded from the HTTP request data Page 2of19 FIT2104 Sample Final Examination 5. Which ONE of following variable assignments is 'by value' assignment in PHP ? a. $value1= &$value b. $value1= $value c. $value1= $value d. None of the stated 6. Which ONE of the following CANNOT be used to decrement the value of $var by 1 in PHP? a. $var--; b. --$var; c. $var=-1; d. $var-=1; 7. Which ONE of the following is an invalid operator in PHP? a. === b. += c. == d. +== 8. Which ONE of the following best describes "responsive design", with regard to a web application? a. A design which responds to a user's environment based on screen size and orientation b. A design which responds quickly to user inputs c. A design which responds to alternative inputs such as voice or motion d. A design which responds to server-side requests rather than client-side requests 9. Which ONE of the following best describes CakePHP's preferred naming conventions? a. Model names plural, Database table names plural, Controller names plural. b. Controller names plural, Database table names singular, Model names singular. c. Controller names plural, Model names plural, Database table names singular. d. Database table names plural, Model names singular, Controller names plural. 10. If you set a cookie in PHP, using setcookie(), you can immediately check to see if the client accepted it. a. True, you can check the $_COOKIE superglobal array to see if it contains the value you set. b. True, but only if register_globals is enabled. c. False, you can only use setcookie() if you need to test for acceptance. Using header() does not work. d. False, you must wait until you receive another HTTP request to determine whether it includes the Cookie collection Page 3of19 FIT2104 Sample Final Examination PART B The Tables and PHP pages used in the following questions are described in Appendices A, B, C & D. Question 1. [6 marks] Briefly explain the differences between the Waterfall and Agile methodologies with regard to System development. Need to include things such as: 1. Rather than developing the whole system as in the Waterfall method, Agile breaks the system down into builds or iterations, which contain specific and complete functions. These iterations are then fully developed and delivered to the client. 2. When using Agile, developers don't have to include as much prediction in their development 3. Agile allows for easier changes as the project progresses 4. Agile allows the client to get an idea of the system functionality and look and feel much quicker 5. Agile is much more likely to deliver a product which meets the client requirements as they have been involved through each of the builds Page 4of19 FIT2104 Sample Final Examination Question 2. [6 marks] Identify and briefly describe the 3 different types of prototypes a developer may use as part of their design approach. Low fidelity Usually rough and paper based Allows rapid feedback on concepts and colours Medium fidelity Usually produced using a computer based tool Usually able to demonstrate behavior such as interaction and navigation High fidelity Usually a high-tech representation of the application Can provide partial to complete functionality Usually provides almost complete UI Page 5of19 FIT2104 Sample Final Examination Question 3. [6 marks] Write the PHP code to complete the following function which displays the source code of a PHP file, including line numbers and then counts the lines in the file and outputs the number of lines to a web page. The filename is passed to this function as a parameter called fname. See Appendix A for example output. <html> <head> </head> <body> <?php <title> function displayFile($fname) </title> $trans = get_html_translation_table(HTML_ENTITIES); PHP Read File { echo "<b>Displaying output for " . $fname. "</b><br />"; $fp = fopen($fname, "r"); $lineCount = 0; while (!feof($fp)) { $lineCount++; //get one line from file $fp $line = fgets($fp); //performs translation based on translation table $line = strtr($line, $trans); //replace tab character with 4 spaces to maintain some formatting $line = str_replace("\t", "    ", $line); //print line to screen, followed by break echo $lineCount . " : " . $line . "<br />"; } fclose($fp); $lineCount = $lineCount; echo "<br />Line Count is " . $lineCount; Page 6of19 } displayFile("DisplayPost.php"); </body> </html> FIT2104 Sample Final Examination ?> Page 7of19 FIT2104 Sample Final Examination Question 4. [10 marks] Below is the partially completed code for ActorListBox.php. The code must be completed to display a drop down list box, as pictured below, which retrieves the actorID, firstname and surname attributes from the Actor table as described in Appendix B. The list must store the actorID attribute when a value is selected, but will display ONLY the firstname and surname attributes as pictured. Assume that a valid statement has already been executed against the database, using the mysql.PDO database connection $conn and the result is contained in the variable $result. Write the code for the List Box ONLY Use ONLY PHP mysqli or PHP PDO mysql functions IT IS NOT NECESSARY TO GUARD AGAINST SQL INJECTION ActorListBox.php <? ?> <html> <head> <title>Exam Actor List Box</title> </head> <body> <form method="post" action="DisplayActor.php"> <center> <font face="Arial" size="3"> Select an Actor:</font><br /> code would appear here to handle connection to database and data retrieval DO NOT WRITE THE CODE TO DO THIS Page 8of19 FIT2104 Sample Final Examination Question 4 cont ..... Write the code for the list box here select name="ActorList" size="1"> 1 <?php mysql while($row=$result->fetch_array()) OR while ($row = $result->fetch_array()) 2 PDO while($row = $result->fetch()) 2 { echo "<option value=".$row[0].">".$row[1]. 3 " ".$row[2]."</option>"; } OR { echo "<option value=".$row["actorID"].">".$row["firstname"]. 3 " ".$row["surname"]."</option>"; } ?> </select> </form> </center> </body> </html> mysql <?php mysqli_free_result($result); mysqli_close($conn OR $result->free(); $conn->close(); ?> PDO <?php $result->closeCursor(); ?> 1 1 1 1 1 2 Page 9of19 Question 5. [20 marks] FIT2104 Sample Final Examination Below is the partially completed code for ActorMultiDelete.php. The code must be completed to allow execution of the appropriate SQL statement against the database, which will enable the display of the page as seen in Appendix B, Image 1. deletion of any selected Actors and the display of the deleted actors ActorID, as seen in Appendix B, Image 2. Use ONLY PHP mysqli or PHP PDO mysql functions It is not necessary to display any confirmation message regarding the Delete DO NOT USE ANY HIDDEN HTML FIELDS DO NOT USE ANY COOKIES DO NOT USE ANY JAVASCRIPT <html> <head> <title>Exam Actor Multi Delete</title> </head> <body> <?php code would appear here to handle connection to database and query execution DO NOT WRITE THE CODE TO DO THIS Use the Connection Identifier $conn and $stmt identifier $stmt if(empty($_POST["actorID"])) { ?> <form method="post" action="ActorMultiDelete.php"> <table border="0"> <tr> <th></th> <th>id</th> <th>firstname</th> <th>surname</th> </tr> <?php ?> while($Actor = $stmt->fetchObject()) Page 10 of 19 FIT2104 Sample Final Examination <tr> <td> <input type="checkbox" name="actorID[]" value=" "> </td> <td> </td> <td> </td> </tr> </table> <table border="0" width="90%"> <tr> <td> <input type="submit" name="action" value="Delete">   </td> </tr> </table> </form> } else { foreach($_POST["actorID"] as $index => $id { $query = "DELETE FROM Actor WHERE actorID = ".$id; $stmt = $dbh->prepare($query); $stmt->execute(); echo "Actor: ".$id." Deleted >br />"; <?php echo $Actor->actorID; ?> <?php echo $Actor->actorID; ?> <?php echo $Actor->firstname; ?> <?php echo $Actor->surname; ?> } } </body> </html> Page 11 of 19 FIT2104 Sample Final Examination Question 6. [6 marks] Give the output from the following PHP script as it would appear in a web browser. <html> <head> <title>PHP Array Test</title> </head> <body> <?php function showit($a) { if (is_array($a)) { foreach ($a as $key=>$value) { echo "$key:$value "; } } else { echo "$a:", gettype($a); } echo "<br />"; } $a1 = array(2=>20, 1=>30, 0=>40, 3=>10); $a2 = "bogus"; showit($a1); showit($a2); sort($a1); showit($a1); unset($a1[2]); showit($a1); ?> </body> </html> OUTPUT 2:20 1:30 0:40 3:10 bogus:string 0:10 1:20 2:30 3:40 0:10 1:20 3:40 Page 12 of 19 FIT2104 Sample Final Examination Question 7. [9 marks] Below is the code for a PHP animal class. Using this class as a basis, create a cat class which inherits from the animal class. The cat class should have a protected member called $_species and a set_name method which converts the $_name member to uppercase. The set_name method should be called from the constructor which takes a name variable as an input parameter. <?php class animal { protected $_name; function __construct($animal_name) { $this->_name = $animal_name; } public function set_name($new_name) { $this->_name = $new_name; } public function get_name() { return $this->_name; } } ?> class cat extends animal { function __construct($animal_name) { $this->set_name($animal_name); } public function set_name($new_name) { $this->_name = strtoupper($new_name); } } Page 13 of 19 <?php FIT2104 Sample Final Examination Question 8. [11 marks] Below is the code for a partially complete PHP Data Access object (DirectorDAO.php) which will use the director table described in Appendix A. Complete this object so that 1. It contains a constructor which will take a connection identifier 2. It contains appropriate members 3. The find_by_id method will execute an appropriate SQL query and if a director record is found, display the details of that director. If a record is not found, there should be some way of informing the calling page. { { } public function find_by_id($directorID ) { class Director_DAO } } private $directorID; public $firstname; public $surname; private $_conn; function __construct($conn) $this->_conn = $conn; $sql = 'SELECT FROM director WHERE directorID ='.$directorID; $stmt = $this->_conn->prepare($sql); $stmt->execute(); $result = $stmt->fetchObject(); if($result) { $this->directorID = $result->directorID; $this->firstname = $result->firstname; } $this->surname = $result->surname; else { return false; } Page 14 of 19 FIT2104 Sample Final Examination Question 9. [9 marks] Explain the role of Models, Views and Controllers in an MVC Application. You may use diagram(s) to aid your explanation. Models Represents a particular database table. Contains code that defines its relationship with other models and defines the data validation rules to be used when adding or updating data. Can be thought of as the data layer. Views The UI output or other responses that are sent back once a request is processed. Consists HTML or XML or PDF or whatever. Can be thought of as the presentation layer and should be as dumb as possible. Page 15 of 19 FIT2104 Sample Final Examination Question 9 cont.... Controllers The brains of the operation. Each web request is directed to a controller which then decides what response should be generated. Often contains calls to models to access data and then passes the response to the view. Also contains code for other functionality like access control, uploading files, sending emails etc. Page 16 of 19 Appendix A: Sample Output for Question 3 FIT2104 Sample Final Examination Page 17 of 19 Appendix B: Table definitions for PHP Questions DIRECTOR with attributes of: directorID firstname surname MOVIE with attributes of: movieID movieName releaseYear classification budget directorID ACTOR with attributes of: actorID firstname surname contact gender integer PK character(20) character(20) integer PK character(40) date character(3) money integer integer PK character(20) character(20) character(10) character(1) MOVIEACTOR with attributes of: movieID integer PK actorID integer PK FIT2104 Sample Final Examination Page 18 of 19 Appendix C: ActorMultiEdit.php Image1. FIT2104 Sample Final Examination Image 2. Page 19 of 19 

51作业君

Email:51zuoyejun

@gmail.com

添加客服微信: abby12468