Tutorial Letter 103/2/2020: Advanced Internet Programming
Tutorial Letter 103/2/2020: Advanced Internet Programming
Tutorial Letter 103/2/2020: Advanced Internet Programming
Tutorial letter 103/2/2020
ICT3612
Semester 2
School of Computing
This tutorial letter contains information about assignment 3
ICT3612/103/2
1. INTRODUCTION
Dear Student
This tutorial letter contains the requirements of Assignment 3. The due date is 28 September 2020 (This is
your last assignment for this semester and the due date was scheduled as late as possible, to assist students
in completing this important assignment. No late submissions can be accommodated and ONLY submissions
via myUnisa can be accommodated.) Do your best to submit 2‐3 days before this date, to prevent any
possible technical difficulties.
Please read this tutorial letter carefully and ensure to submit your own work. Make sure that you
understand all the rules and requirements. Also, please read the document Policy for Copyright
Infringement and Plagiarism with specific reference to point 4.3 and 5 from the Learner Support & Regions
/ Student Policies & Rules / Policy for Copyright Infringement and Plagiarism from Unisa’s website.
Furthermore, we have the right to request an oral examination if we deem it necessary to complete the
assessment process.
4.3 Dishonest practices may also amount to criminal offences, such as fraud, theft and criminal copyright
liability. Such dishonest practices include the following:
4.3.1 copying information from another person (e.g. another student’s assignment or portfolio) and
submitting identical work where such work is not the result of teamwork and indicated as such by all
participants;
4.3.2 buying an essay from a ghost‐writing service and pretending that it is one’s own work;
4.3.3 asking someone else to do an assignment on one’s behalf.
5. CONTRAVENTION OF THIS POLICY
A student or an employee who is guilty of the infringement of copyright or unethical practice will be
subject to the applicable disciplinary code.
Best wishes in completing your assignment 3.
2. COMPLETING ASSIGNMENT 3
a. As you did in ICT2613, first complete all the assignment tasks on your computer.
b. For each task page, create a text file with the same name. For example, for task1.php you will have
an extra file named task1.txt. This text file will contain the PHP code for that task (leave out any
HTML code that is not part of the PHP code). For each task you will thus have a .php and a .txt file.
Because it is a text file, the server will not parse (interpret) the PHP code in the file, allowing the marker
2
ICT3612/103/2
to view your code for that task.
c. Create a file named menu.inc. Inside this file, write HTML code that will produce a horizontal menu
with links to all the different task pages.
| Task 1 | Task 2 | Task 3 | Task 4 | etc.
d. Create a page named index.php. Just after the <body> tag, include the following line of PHP code:
<?php include 'menu.inc'; ?>
e. Include this line of PHP code in every .php task page. If you want to change a link for whatever reason,
then you only need to change it once in menu.inc, as opposed to every task page.
3
ICT3612/103/2
////////////////////////////// Task1 (a) //////////////////////////
Your code for task 1 (a)
////////////////////////////// Task1 (b) //////////////////////////
Your code for task 1 (b)
etc.
IMPORTANT:
a. If your code is not available in an iframe on a task page then that task will not be marked. The code
you submit to myUnisa is only used when we suspect plagiarism.
b. If the menu link to a task page or the task page itself is not available, then a task cannot be marked.
It cannot be left to the marker to work out how to access a task page.
c. If the text file cannot be loaded in the iframe then the task page will start loading and then go
blank. One reason why this happens is because file names hosted on a server are case‐sensitive.
Task1.txt is not the same as task1.txt. The same holds true for .php file names.
d. We mark the result (output) of your code. No output then no mark. We use the code in the iframe to
verify the output was generated as per the task requirement. In other words, we do not mark code only.
4. ASSIGNMENT 3 SUBMISSION PROCEDURE
This section outlines the EXACT steps to follow when submitting assignment 3 for marking
via myUnisa. It is very important to read and clearly understand these steps.
STEP 1:
Create a folder named Assignment3 on your computer.
STEP 2:
To access your site for marking, we will require a working URL. This URL will load the default
launch page (index.php ‐ which contains the horizontal menu).
Inside the folder created in step 1, create a new text file and save it as URL.txt. Copy (do not type)
the URL of your web site into this file. Test the URL and make sure we can access your site. If we
cannot access your site because of a wrong URL or because you forgot to include the URL/text file,
then your assignment 3 cannot be marked. This is no different to failing to answer a question in a
sit‐down examination.
Copy all your assignment 3 code (php files) and all the iframe text files into the folder you have
created above. Do not include any other "clutter" e.g. images you may have used. There should only
be .php and .txt files in this folder. Your zip file should not be more than 100KB in size.
Create another text file, and name it connection.txt. Inside this file, provide your live site's
4
ICT3612/103/2
database name, username and password (note it is NOT the database connection details as used on
your own computer, but the connection details used on the site that you are currently submitting
for marking ).
Create another text file named login_details.txt. In this file provide all the necessary login
details required to access the file manager you have used to upload your files. If you used a FTP
client, provide the required details.
STEP 3:
Using WinZip, zip this folder. WinZip will automatically give the zip file the name of your folder
(e.g. Assignment3.zip).
STEP 4:
Upload this zip file to myUnisa. Ensure you upload before the due date in case you experience
internet connection problems etc.
5. WEB SITE AVAILABILITY & OTHER RULES AND NOTES
a. If your menu is not available and we are required to use a browser back‐button to access a previous
page, you will be penalized 10% of the final mark awarded. If a task page is not found because of an
error you made in the menu link to that page, that task will not be marked. Note there is a difference
between a page not loading because the server is slow and a page not found. We revisit sites/pages that
load slowly.
b. Many free web hosting servers delete sites that are not accessed regularly. Nevertheless, you should
visit your site at least once a week until you have received your mark. If your site is not available, restore
it as quickly as possible using the same server site name and notify us via email ([email protected])
that your site was down and that it has been restored. Your original URL from the submitted zip file
will be used to access the restored site i.e. we will not accept a different URL.
c. You are not allowed to use any PHP frameworks or software that generates (complete) code on your
behalf. You must code the entire application by yourself.
d. You are expected to submit your own work. If we suspect plagiarism, we will award 0 marks for copied
work.
e. Web hosting sites can have down times and if so, please try later. For this reason, please do not wait for
the due date of the assignment to upload files on the web server. Try to do it in advance.
f. Marks for assignment 3 are awarded solely based on the website (navigation, output, code in iframes,
etc) you have created. Note that the code that you have submitted on myUnisa is used only for checking
plagiarism and record keeping.
5
ICT3612/103/2
6. SUPPORT PROVIDED
a. Tasks in this assignment can be done mainly using the prescribed chapters of the textbook.
b. Try and make use of Google to find solutions to errors. As a PHP‐developer you WILL spend hours on
Internet forums seeking solutions to problems.
c. Make use of PHP documentation available online (see chapter 2 on how to access it)
d. Participate in myUnisa forum
e. E‐mail the lecturer for help
7. ASSIGNMENT 3
1. Make use of comments in your code
2. All the tasks and subtasks (excluding code in the iframe) will produce output of some sort to the
screen. We first consider the output produced, and then look at the code to see how the output was
produced.
3. When a task has subtasks (marked using (a) and (b)), label the subtasks clearly in the output.
Task 1: Chapter 13: page name=task1.php 30 marks
This task consists of three different subtasks.
(a) [12 marks]
Code a function (boolToText()) that takes two arguments; the first argument takes a boolean value (0
or 1) and the second argument takes the format in which the given boolean value must be displayed. The
default value for the second argument is 1.
When the value of the second argument is 1, the function displays "False" for 0 and "True" for 1. When the
value of the second argument is 2, the function displays "No" for 0 and "Yes" for 1. When the value of the
second argument is 3, the function displays "Negative" for 0 and "Positive" for 1. For any other format, the
function displays 0 for 0 and 1 for 1.
Invoke the function four times as follows:
boolToText(0);
boolToText(1, 2);
boolToText(0, 3);
boolToText(1, 5);
(b) [7 marks]
Code a function named displayStrings() that accepts any number of string arguments using a
variable‐length parameter list. The function must display each string and its respective length.
Invoke the function twice as follows:
displayStrings("Gauteng ", "North West ");
displayStrings("Tshwane ", "Durban ", "Polokwane ", "Pretoria ");
6
ICT3612/103/2
(c) [11 marks]
Code a function that accepts two associative arrays; one with product codes as keys and numbers of each
product in stock as values and the second one with product codes as keys and price of the product per item.
The function must display product information in a table format with product code, number of items in stock,
price of a product and total value of the product in stock (price of an item times the number of items in
stock) in four different columns.
Below the table display the total value of all the products, which is the sum of all values in the last column
of the table.
Invoke the function with two associative arrays. Both associative arrays must have five elements each and
the same keys. However, the order of keys must be different in these two arrays.
Task 2: Chapter 14: page name=task2.php 40 marks
This task consists of two different subtasks.
(a) [15 marks]
Code a class named Person, which has three data properties to store the name, a telephone number and
an e‐mail address of a person.
The class must have a constructor to initialise all three data properties, three set methods and three get
methods to change and access the data properties of the class.
The class must also have a toString() method with an argument named $csv initialised to a default
boolean value true. By default, this function must return the value of data properties in comma separated
values (refer to Chapter 23, Section named ‘How to read and write CSV data’). On the other hand, if the
method is called with boolean value false, it returns a string representation of the data properties in a
different format (for example, see showAll() method in Section ‘How to loop through an object’s
properties’ in Chapter 14).
Create an object of the class Person, invoke all six set and get methods, and invoke toString() with
both boolean values. Display the results returned by toString()for both method calls.
(b) [25 marks]
In this question, you will write four classes namely, Payment, Salary, Hourly and Commission, where
Payment is the superclass of the other three classes. These three subclasses represent different types of
payments for employees in an organisation.
Code Payment as an abstract class with a data property type to store the type of payment. This class has a
constructor that takes the type of argument. It has a get method (getType()) to return the type of
payment. It also has an abstract method named pay().
7
ICT3612/103/2
Code a concrete subclass of Payment named Salary, with a data property to store the salary. It has a
constructor that accepts an argument that represents the salary and initializes the type of payment to
"salary" by calling the superclass constructor. It must code the pay() method, which simply returns the
salary stored in the data property.
Code a concrete subclass of Payment named Hourly, with a data property to store the hourly rate and
number of hours worked. It has a constructor that accepts an argument that represents the hourly rate and
initializes the type of payment to "hourly" by calling the superclass constructor. It has a method named
addHours() that takes one argument, which is used to increase the data property that stores hours
worked by the value passed to the method. It must code the pay() method, which returns the number of
hours worked times the hourly rate.
Code a concrete subclass of Payment named Commission, with a data property to store the total sales
amount and commission rate in terms of percentage. It has a constructor that accepts an argument that
represents the commission rate and initializes the type of payment to "commission" by calling the superclass
constructor. It has a method named addSales() that takes one argument, which is used to increase the
data property that stores the total sales amount by the value passed to the method. It must code the pay()
method, which returns the percentage of the total sales, where both percentage and total sales are stored
as data properties.
Create an object each of Salary, Hourly and Commission. For each of these objects invoke all relevant
methods, and display the values returned by getType() and pay().
Task 3: Chapter 14 and 15 : page name=task3.php 15 marks
This task consists of two different subtasks.
(a) [10 marks]
Write a class named Validate that can be used to validate user selected usernames and passwords for a
system.
The class has two static properties and they both store regular expressions to validate usernames and
passwords. The username must only consist of four lowercase letters. The password must be a 6 to 8‐digit
number.
The class has two static methods. The first method accepts a username and validates it against the regular
expression for username and returns true or false. The second method accepts a password and validates it
against the regular expression for password and returns true or false.
Invoke the methods in Validate twice each, with usernames and passwords that will return true and false
in different calls of the relevant methods.
(b) [5 marks]
For the given pattern /^[01]?\d\/[0-3]\d\/\d{4}$/ present one string that will be accepted by
the pattern and another string that will not be accepted by the pattern.
8
ICT3612/103/2
Code the pattern and the input strings in preg_match(). Display the values returned by preg_match()
for both valid and invalid input strings.
Task 4: Chapter 16: page name=task4.php 10 marks
Refer to the figure in the Section titled ‘How to apply the third normal form’ in Chapter 16.
Explain briefly what each table represent (i.e. the entity it represents). List all the primary and foreign keys
for each table.
Task 5: Chapter 16, 17, 18, 19: page name=task5.php 25 marks
Create a database with four tables. The basic structure of the tables and relationships between the tables
are illustrated below:
Populate the tables with realistic data, with at least 5 rows of data in each table. Note that the SQL data type
for each column is not given in the diagram. So you have to decide on this aspect.
Connect to the database and display the contents of all four database tables in four different HTML tables
on the web page.
Below the HTML tables, there must be a form with five radio buttons where the user can choose to view the
results of one of the five different SELECT queries at a time. Details of these five SELECT queries are given
below:
1) The first SELECT query must make use of the ORDER BY clause
2) The second SELECT query must make use of the LIKE operator
3) The third SELECT query must make use of an inner join that joins two tables
4) The fourth SELECT query must make use of a WHERE clause with the AND logical operator
(5) The fifth SELECT query must make use of the aggregate function AVG.
You can decide on the other details of these SELECT queries.
9
ICT3612/103/2
Task 6: Chapter 23: page name=task6.php 15 marks
This task consists of two different subtasks.
(a) [10 marks]
In this task, task 2(a) will be extended so that an array of five Person objects are created. Write the comma
separated values format of each object in separate lines in a file named persons.txt. Make use of the
toString() method of Person to obtain comma separated values.
Create a hyperlink pointing to the file persons.txt and include it on the task page. When the user clicks
on the link, the browser can then download it.
(b) [5 marks]
Write code to open the current directory find the names of all the files in the directory and print the results
in a bulleted list.
©
UNISA 2020
10