0% found this document useful (0 votes)
70 views11 pages

ICT2613ON2017

ICT2613ON2017

Uploaded by

Rotondwa Mulondo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views11 pages

ICT2613ON2017

ICT2613ON2017

Uploaded by

Rotondwa Mulondo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

INSTRUCTIONS:

1. This examination paper consists of 9 pages and 2 additional pages for rough work.
2. This is a closed book examination.
3. The mark for each question is given in brackets next to the question.
4. Answer all six questions in the blocks provided in the question paper.

GOOD LUCK!

[TURN OVER]
2 ICT2613
October/November 2017
Question 1 [10]
1.1 What is PHP? (1)

1.2 What software is essential to execute PHP scripts? (1)

1.3 If a file name ends with .php, can it contain HTML code? (1)

1.4 Name the web browser you have used in this module to complete the assignments. (1)

1.5 Name the database server you have used in this module to complete the assignments. (1)

1.6 List the steps you have taken in order to publish your Assignment 2 on an Internet Server. Assume
that you have completed and tested all the tasks, including index.php, of Assignment 2 on your
local server. (5)

[TURN OVER]
3 ICT2613
October/November 2017
Question 2 [16]
Consider the PHP statement and answer the questions that follow:

echo 'Good luck with ICT2613 exam.';

2.1 Declare a camel case variable to store a module code and initialize it to ICT2613. Substitute this
newly declared variable in the echo statement. The echo statement should use single quotes (') and
the concatenation operator. (3)

2.2 What is the purpose of the htmlspecialchars() function? (2)

2.3 Rewrite the echo statement you have written for question 2.1 to make use of the
htmlspecialchars() function. (1)

2.4 Rewrite the echo statement you have written for question 2.1 to make use of double quotes (")
without using the concatenation operator. (1)

2.5 Declare and initialize an array with three module codes, ICT2613, ICT2612 and ICT1513. (2)

[TURN OVER]
4 ICT2613
October/November 2017
2.6 Write a function that contains an echo statement to display the sentence, Good luck with
xxx exam., where xxx is substituted with the value passed to its parameter. (3)

2.7 Write a for loop that iterates through the array you have written for question 2.5, and invokes the
function you have written for question 2.6 for each module code in the array. (4)

Question 3 [14]
Study the code below and answer the questions that follow:

<form>
<label>Modules:</label> <br>
<input type="radio" name="module_code" value="ICT2613"> ICT2613
<input type="radio" name="module_code" value="ICT2612"> ICT2612
<input type="radio" name="module_code" value="ICT1513"> ICT1513
</form>

3.1 Draw the form displayed by the given code. (3)

[TURN OVER]
5 ICT2613
October/November 2017
3.2 Rewrite the form so that
• it also displays a Submit button
• when the form is submitted, it is processed by a PHP file named question3.php
• its data is sent to the server using the HTTP POST method.

You need not rewrite all the given code; only indicate what additional code needs to be added and
where. (4)

3.3 State another HTTP method to send form data to a web server. (1)

3.4 Which HTTP method should be used if you do not want to include parameters in the URL for
security reasons? (1)

3.5 Write PHP code to


• create an associative array with keys ICT2613, ICT2612 and ICT1513, and PHP, Java and
JavaScript as their respective values
• read the form data - if a module code is selected in the form, the programming language used in
the module is displayed using an echo statement. The associative array should be used to
obtain the programming language for the selected module. (5)

[TURN OVER]
6 ICT2613
October/November 2017
Question 4 [15]

4.1 Refer to the code below:

if(($age > 17) && ($score > 50)){


$message = 'Loan approved';
}
else if(($age > 15) && ($score > 50)){
$message = 'You will require guarantee';
}
else {
$message = 'Loan not approved';
}

4.1.1 Write down a value each for $age and $score so that $message will store 'Loan
approved'. (2)

4.1.2 Write down a value each for $age and $score so that $message will store 'Loan not
approved'. (2)

4.1.3 Write down a value each for $age and $score so that $message will store 'You will
require guarantee'. (2)

4.2 Write a switch statement that takes a module code and stores the programming language used in
that module in a variable $result. The languages used in ICT2613, ICT2612 and ICT1513 are
PHP, Java and JavaScript. For any other module code, $result should store 'Unknown'. (5)

[TURN OVER]
7 ICT2613
October/November 2017

4.3 Write a while loop to generate the following number sequence: 10 8 6 4 2 0. The
sequence should be generated using appropriate logic, and it should not be hard coded. (4)

Question 5 [14]

Consider a SQL database diploma with a table named modules. The modules table has the
following columns:

- code, which is the primary key of the table for storing unique 7 character module codes
- name, which stores module names
- lecturer, which stores the names of the primary lecturers for the modules

Assume that the modules database table has been populated with the following information:
ICT2612 Interactive Programming Mrs C van Staden
ICT2613 Internet Programming Mrs A Thomas
ICT3612 Advanced Internet Programming Mrs P Le Roux

5.1 Write PHP code to create a PDO object named $db to connect to the above-mentioned database.
(5)

[TURN OVER]
8 ICT2613
October/November 2017

5.2 Assume that a database connection is established using a PDO object named $db. What is the
output generated by the following code? (6)
$query = 'SELECT code, name FROM modules ORDER BY name';
$statement = $db->prepare($query);
$statement->execute();
$modules = $statement->fetchAll();
$statement->closeCursor();
foreach($modules as $ms){
echo "$ms[0],$ms[1]<br>";
}

5.3 Explain briefly how the code of a web application that uses a database should be organized using
the MVC pattern. (3)

[TURN OVER]
9 ICT2613
October/November 2017

Question 6 [6]

6.1 What is stored in $date after the statement $date = date('Y M d'); ? (2)

6.2 Consider the statement $module = "ICT2613"; and answer the questions below:

6.2.1 What will be displayed after the statement echo lcfirst($module);? (2)

6.2.2 What will be displayed after the statement echo strrev($module);? (2)

©
UNISA 2017

[TURN OVER]
10 ICT2613
October/November 2017
ROUGH WORK PAGE

[TURN OVER]
11 ICT2613
October/November 2017

ROUGH WORK PAGE

You might also like