程序代写代做代考 jquery html game Java database javascript Instructions:

Instructions:
(a) This paper has a total of FOURTEEN pages including the covering page.
(b) This paper contains TWO Sections.
(c) Section A is WORTH 40 marks and Section B
is WORTH 60 marks.
(d) Section A contains FOUR questions. Answer
ALL questions in Section A.
(e) Section B contains THREE questions.
Answer ALL questions in Section B.
(f) NO CALCULATOR IS ALLOWED.
Note:The result of this assessment will not be
counted if you do not meet the minimum attendance requirement (if any) governed by the general academic regulations of your programme/course unless approval of the campus principal has been granted.
MODULE TITLE:
INTERNET & MULTIMEDIA APPLICATIONS DEVELOPMENT
MODULE CODE: ITP4513
IVE Information Technology
Information & Communications Technology
&
Multimedia & Entertainment Technology
Programme Boards
HIGHER DIPLOMA IN
SOFTWARE ENGINEERING
(IT114105)
SEMESTER THREE MAIN EXAMINATION
24 JULY, 2019
1:30 PM TO 3:30 PM (2 hours)
© Vocational Training Council

Information Technology Discipline Programme/Year: IT114105/1
Page 1 of 13
This paper contains TWO sections.
Section A (40 marks)
This section contains FOUR questions. Answer ALL questions.
A1 You are given the following PHP script A1a.php.
Line
1.
2.
3.
4.
5.
6.
7.
8.
9.
(a) (b)
(c)
File: A1a.php
The PHP script A1b.php should produce the following execution output (Figure A1).
IQ. 127.0.0.1/A1b.php
The original string: reverse
The reversed string: esrever Figure A1
Implement the function reverse which reverses the order of the characters in a given string. You are not allowed to use the PHP built-in function strrev(). Hint : $s[$pos] will return the character at position $pos of the string $s. [5 marks]
File: A1b.php
[3 marks] output of A1a.php. [2 marks]
Write the execution output of A1a.php.
At line no. 5, after the keyword continue is replaced by break, write the execution
Line
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
“; $newStr = reverse($string);
echo “The reversed string: $newStr”;
?>
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Programme/Year: IT114105/1
A2
You are required to develop a PHP program A2.php which must meet the following functional requirements. [10 marks]
 In Figure A2a, if nothing is entered in the textbox, it should show a message “Please enter your name.” when the form is submitted.
 In Figure A2b, if the text “Chan Tai Man” is entered in the textbox, it should show a message which contains the textbox input when the form is submitted.
(_B• IQ. 127.0.O.1/A2.php?name=Chan+Tai+Mar Name:[ l
ISubmit ~
Hello Chan Tai Man 1t
Figure A2b Write the missing code for parts (a) to (f) in file A2.php below.
File: A2.php

Say hello

Name:
~ )• I Q. 127.0.0.1/A2.php?name=&btn=Submit
Name: I ISubmit ~
I
P lease enter yom n1!llle_
Figure A2a
Page 2 of 13
Line
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13. 14. 15. 16. 17. 18. 19.


) { // check whether the Submit button is clicked
) { // check whether input name is an empty string
;
echo “Hello
(f) !”;
}
?>
(a)
(b)
(c)
Internet & Multimedia Applications Development (ITP4513)
Main Examination
Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Page 3 of 13 Programme/Year: IT114105/1
A3 Write the missing code for parts (a) to (f) in the PHP script A3.php which processes the product ID and order quantity data passed in the query string.
Assume the following two GET requests are sent to the web server, the PHP script A3.php will store the productid value and qty value in a session file and then create a cookie to store the last received productid value.
http://127.0.0.1/A3.php?productid=P003&qty=10 http://127.0.0.1/A3.php?productid=P008&qty=2
If there is no query string in the GET request and the stored cookie is not expired, the PHP script A3.php will output the information as shown in Figure A3.
IQ. 127,0,0.1/A3,php
Product ID iin your last transaction is Poo8 Product ID Poo3 with quantify 10
Product ID Poo8 with quantity 2
File: A3.php 0) { // if a query string is found
= $qty;
(b)
10.
11.
12.
13. (e)
(c)
;
} else {
if ( (d) ) // if a cookie named lastid has been sent to the server
14. (f) ; 15. }
16. ?>
17.
(a)
(b) (c)
(d) (e) (f)

Create a new session file if it does not exist, otherwise open the existing session file.
[1 mark] Store the qty value in the session file using productid value as the index. [1 mark]
Create a cookie named lastid to store the productid value found in the query string.
echo “Product ID in your last transaction is {$_COOKIE[‘lastid’]}
“;
The cookie should expire after 2 hours.
Check if a cookie named lastid has been sent to the server.
Write a foreach loop to output all session data as shown in Figure A3. Delete all session data.
[2 marks] [1 mark] [4 marks] [1 mark]
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Programme/Year: IT114105/1
return the JSON representation converted from the array $awardinfo: {
“student”: “Chan Tai Man”,
“AGPAobtained”: 3.2,
“classification”: [“Distinction”, “Credit”, “Pass”], “AGPArequired”: [3.5, 3, 1]
}
[4 marks]
File : A4JSON.php
Page 4 of 13
A4 (a)
Write the missing code for the code fragment of file A4JSON.php which creates the following JSON string from an associative array $awardinfo, and then use echo to
Line
1.
2.
3.
4.
5.
6.

(b)
Assume the URL of the PHP script A4JSON.php is http://127.0.0.1/A4JSON.php. Write the missing code for parts (i) to (iv) in the code fragment of file A4.html which executes the jQuery $.ajax() method by using GET type request to display following message in an alert message box of the web browser: [6 marks]
Student Chan Tai Man is awarded the Credit classification
Explanation to output :
The student obtained Award GPA (AGPAobtained) 3.2 which can only meet the minimum required AGPA (AGPArequired) 3 for the Credit award classification.
Line
1.
2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19.
File : A4,html



Internet & Multimedia Applications Development (ITP4513)
Main Examination
Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Programme/Year: IT114105/1
Section B (60 marks)
This section contains THREE questions. Answer ALL questions.
Host address: 127.0.0.1
Login username: root
Database name: salesdb
Login Password: mysecret
Column
Format
Description
orderid
int
Order ID (Primary Key) e.g. 2
productid
varchar(5)
Product ID e.g. P1011, P2089
quantity
int
Order Quantity e.g. 5
deliverymode
varchar(15)
Delivery Method e.g. express, super express
orderid
productid
quantity
deliverymode
1
P1011
2
express
2
P2089
5
express
3
P1011
3
super express
4
P1011
1
express
B1 You are required to develop a PHP program B1b.php to add new order records to the MySQL database using form data submitted from file B1a.html.
_____...=,
Delivery Mode : 0 E.xpress I Create Order i
Figure 1A
Information of MySQL database
Schema of table custorders
Quantity '-4-1
Page 5 of 13
~ • I Q_ 127.0.0.1/81a.html
Money Saver Shop
Ordering System
name is productid name is quantity
Product ID P2089 name is deliverymode ,.......!::====::;-'.
form submits by post method to program B1b.php
Before the form data in Figure 1A is added to the database, there are four records in the custorders table:
[Question B1 continues on the next page.]
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline
Programme/Year: IT114105/1
Page 6 of 13
[Question B1 continued from the last page.]
After a new record is added to the database, program B1b.php should display all records
and a summary of all records grouped by productid as shown in Figure 1B. ~ • IQ. 127.0.0.1/B1b.php
Y our Order Records
A total of 5 orders.
IOrder ID IIProduct ID IIQuantityIDelivery ModeI
11 IIP1011
12 ;1P 2 0 8 9
I3 II P1011
~ =-:J[fuiu :=][1 =-:J~ ess =-:J [ L = 7 1 P 2 0 8 9 1[ 4 l l s u p e r e x p r e s ~s
Product P2089, total order quantity =9 Product P1011, total order quantity =6
Figure 1B
Carefully study the program comments, and then provide the missing code for parts (a) to
(b) of file conn.php and parts (c) to (l) of file B1b.php. [20 marks] File: conn.php

File : B1b.php
function newID($conn) {
// this function returns the next primary key value for a new record to be added // assume this function is completely implemented
}
extract($_POST);
$newid = newID($conn);
$sqlInsert = (c) ; // store a SQL INSERT statement in $sqlInsert
11 2 ll s "3
IIexpress I II e x p r e s s I Isuper e>.'Press I
Line
1.
2.
(a)
(b)
3.
4.
5.
Line
1.
2.
3.
4.
5.
6.
7.


Your Order Records

";
echo "

A total of $num orders.

";
Page 7 of 13
Line
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
if (
(e)
) // check if the database server fails to add a new record
// Display all order records
$sqlSelect =
(f)
; // store a SQL SELECT statement in $sqlSelect
(g)
or die(mysqli_error($conn)); // create a result set in variable $rs
$num =
(h)
; // find the number of records in the result set $rs
?>

31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
43.
44. (k) ; // release the memory used by the result set 45.
46. 47. 48. 49. 50. 51. 52. 53. 54. 55.

EOD;
echo $rowCode;
} // end of while-loop mysqli_close($conn);
?>

Order ID Product ID Quantity Delivery Mode
$orderid $productid $quantity $deliverymode

Product $productid, total order quantity = $total

"; }
?>
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Page 8 of 13 Programme/Year: IT114105/1
B2 You are required to develop a product ordering page B2.html. The displayed product data will be retrieved dynamically from a text file shopinfo.json using AJAX. The pay amount will be updated automatically according to the product selection in the dropdown list and the order quantity.
File : shopinfo.json {
"shopname":"Money Saver Shop", "products":[
{ "productid":"P1011", "name":"USB Cable", "price":10 },
{ "productid":"P2089", "name":"SD Card", "price":80 } ],
"deliveryfee":50 }
When page B2.html is loaded into the web browser, data from file shopinfo.json will be retrieved using AJAX to display the shop name (Figure 2A) and add options for the product dropdown list (Figure 2B).
Line
1.
2.
3.
4.
5.
6.
7.
8.
8=)• IQ. 127.0.0.1/B2.html
Money Saver Shop Ordering System
ProductIUSBCable$10 v I Quantity Io
Delivery Mode : @ Express Pay Amount = $0
ICreateOrder I
ProductIsocard $80 "I Quantity I1
t!JI
O Super Express
~I
O Super Express
Delive
Pay Amount = $0
Figure 2B
ProductISDCard $80 IvI Quantity 12
Delivery Mode : @ Express Pay Amount= $160
ICreateOrder I
Figure 2D
Figure 2A
Delivery Mode : @ Express
Pay Amount= $13o(Delivery fee is added)
~I
O Super Express
ICreateOrder I
Figure 2C
When the total order amount (price ($80) × quantity (1) = $80) is less than or equal to $100, a delivery fee will be added, therefore the pay amount is $130 (total order amount + delivery fee = $80 + $50 = $130) (Figure 2C). On the contrary, no delivery fee is added for the order shown in Figure 2D since the total order amount (price ($80) × quantity (2) = $160) is greater than $100.
Carefully study the program comments, and then provide the missing code for parts (a) to (k) of file B2.html. [20 marks]
[Question B2 continues on the next page.]
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Programme/Year: IT114105/1
Page 9 of 13
[Question B2 continued from the last page.]
Line
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
File : B2.html


[Question B2 continues on the next page.]
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Programme/Year: IT114105/1
[Question B2 continued from the last page.]
Page 10 of 13
Line
49.
50.
51.
52.
53.
54.
55.
56.
57.
58.
59.
60.
61.
62.
File : B2.html

Ordering System




Delivery Mode :

65.

Pay Amount = $0
66.

67.
68.

69.
70.
(k)
(k)
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council

Information Technology Discipline Page 11 of 13 Programme/Year: IT114105/1
B3 You are required to create a web page B3.html which simulates an arrow shooting game. The web page B3.html should draw a target board which consists of four concentric circles.
Figure 3A shows the drawing on the canvas when the web page is first loaded. The target board is always drawn at the center of the canvas using the values of several global variables declared at line nos. 6 to 9 of file B3.html. Whenever the value of any input control is changed, the web page should erase the content of the canvas and redraw the target board.
Figure 3B shows the target board is redrawn after the gap size is changed, also hit marks and score information is displayed after the [Shoot] button is clicked.
score is 1 (grey circle) score is 2 (blue circle) score is 3 (red circle) score is 4 (yellow circle)
gap size is 30px
score information
TotalScore=2 +2 +3=·
Gap Size : 10px
1 u m b e r o f S h o o t s b" ' _ _ _ _ _ _ _ _ . . . .
[ Shoot [
circle radius of the smallest circle is 20px
hit marks
Gap Size : 1opx
K u m b e r o f S h o o t s 3 rShoot I
3opx
Figure 3A
Write the missing code for parts (a) to (j) in file B3.html.
File : B3.html



Gap Size : 10px
30px
Number of Shoots



***** END OF PAPER *****
File : B3.html
// draw the initial content of the canvas
// whenever the gap size or number of shoots is changed function drawScreen() {
gap = ; // retrieve the gap size value from the input
(a)
(b)
ctx.restore(); // restore canvas context
(c)
Internet & Multimedia Applications Development (ITP4513) Main Examination Semester 3 (2018/2019)
© Vocational Training Council