web代写-FIT2104
时间:2022-10-26
Office Use Only

Sample
Examination Period

Faculty of Information Technology

EXAM CODES: FIT2104

TITLE OF PAPER: Web-interfaced database - PAPER 1

EXAM DURATION: 3 hours writing time

READING TIME: 10 minutes

THIS PAPER IS FOR STUDENTS STUDYING AT:( tick where applicable)

 Berwick  Clayton  Malaysia  Off Campus Learning  Open Learning
 Caulfield  Gippsland  Peninsula  Enhancement Studies  Sth Africa
 Parkville  Other (specify)


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  YES  NO

CALCULATORS  YES  NO

SPECIFICALLY PERMITTED ITEMS  YES  NO
if yes, items permitted are:


Candidates must complete this section if required to write answers within this paper


STUDENT ID: __ __ __ __ __ __ __ __ DESK NUMBER: __ __ __ __ __

FIT2104 Sample Final Examination
Page 2 of 19

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. one
b. two
c. three
d. 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

FIT2104 Sample Final Examination
Page 3 of 19



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 following variable assignments is 'by reference' assignment in PHP ?
a. $value1= $value
b. $value1= &$value
c. $value1= *$value
d. None of the stated

9. Which ONE of the following best describes CakePHP's preferred naming conventions?

a. Database table names plural, Model names singular, Controller names plural.
b. Model names plural, Database table names plural, Controller names plural.
c. Controller names plural, Database table names singular, Model names singular.
d. Controller names plural, Model names plural, Database table names singular.


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
FIT2104 Sample Final Examination
Page 4 of 19

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.










































FIT2104 Sample Final Examination
Page 5 of 19

Question 2. [6 marks]
Identify and briefly describe the 3 different types of prototypes a developer may use
as part of their design approach.

















































FIT2104 Sample Final Examination
Page 6 of 19


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.



PHP Read File



function displayFile($fname)
{

$trans = get_html_translation_table(HTML_ENTITIES);































FIT2104 Sample Final Examination
Page 7 of 19













































}

displayFile("DisplayPost.php");

?>



FIT2104 Sample Final Examination
Page 8 of 19

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
code would appear here to handle connection to database and data retrieval
DO NOT WRITE THE CODE TO DO THIS
?>


Exam Actor List Box






Select an Actor:


FIT2104 Sample Final Examination
Page 9 of 19

Question 4 cont …..

Write the code for the list box here












































FIT2104 Sample Final Examination
Page 10 of 19

Question 5. [20 marks]

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.

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



Exam Actor Multi Delete


code would appear here to handle connection to database
DO NOT WRITE THE CODE TO DO THIS
Use the Connection Identifier $conn

if(empty($_POST["actorID"]))
{


?>










?>


FIT2104 Sample Final Examination
Page 11 of 19

Question 5 ANSWER cont….








id firstname surname

value="


">















  
























FIT2104 Sample Final Examination
Page 12 of 19

Question 6. [6 marks]
Give the output from the following PHP script as it would appear in a web browser.



PHP Array Test


function showit($a)
{
if (is_array($a))
{
foreach ($a as $key=>$value)
{
echo "$key:$value ";
}
}
else
{
echo "$a:", gettype($a);
}
echo "
";
}
$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);
?>



OUTPUT










FIT2104 Sample Final Examination
Page 13 of 19

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.

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;
}
}
?>



















FIT2104 Sample Final Examination
Page 14 of 19

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.


class Director_DAO
{





private $_conn;








public function find_by_id( )
{













}
}

FIT2104 Sample Final Examination
Page 15 of 19

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



















Views




















FIT2104 Sample Final Examination
Page 16 of 19

Question 9 cont….

Controllers











































FIT2104 Sample Final Examination
Page 17 of 19

Appendix A: Sample Output for Question 3


FIT2104 Sample Final Examination
Page 18 of 19

Appendix B: Table definitions for PHP Questions


DIRECTOR with attributes of:
directorID integer PK
firstname character(20)
surname character(20)

MOVIE with attributes of:
movieID integer PK
movieName character(40)
releaseYear date
classification character(3)
budget money
directorID integer

ACTOR with attributes of:
actorID integer PK
firstname character(20)
surname character(20)
contact character(10)
gender character(1)

MOVIEACTOR with attributes of:
movieID integer PK
actorID integer PK



FIT2104 Sample Final Examination
Page 19 of 19


Appendix C: ActorMultiEdit.php

Image1.



Image 2.




学霸联盟
essay、essay代写