INSTRUCTIONS AND INFORMATION
Once extracted, the following list of files will be available in the folder DataSept2019:
Question 1:
Question 2:
Question 3:
Question 4:
QUESTION 1: GENERAL PROGRAMMING SKILLS
Do the following:
1.1 Button [1.1 Join]
A learner at school needs to create a profile so that he/she can upload videos to be viewed on the school’s intranet.
A learner must enter his/her e-mail address, password, grade and age. Each of these details must satisfy certain criteria before the learner can be registered to upload videos, i.e. the panel named pnlQuestion1_2 can then be enabled.
Write code in the Q1_1btnJoin event handler to do the following:
1.1.1 Declare suitable variables and extract the input (name, e-mail, age, grade) from the input components.
1.1.2 Write code to test if the input satisfies the criteria as described below:
1.2 Button [1.2 Upload]
The size of a video is measured in Megabytes (Mb) and the speed of uploading a video is measured in Megabytes per second (Mb/s).
Learners will choose a category from the combobox, cmbCategory, and then they will enter the title and size of the video they wish to upload and the speed of their internet connection line in the edit boxes provided.
Write code to do the following:
1.2.1 Obtain the input from the input components.
1.2.2 The length of the video title must be a maximum of 23 characters. If the length is greater than 23 characters, then the edit box, edtTitle, must be cleared and the procedure must close.
1.2.3 Calculate how many minutes it will take to upload the video, using the details described below:
1.2.4 A video code must be compiled using the following criteria:
1.2.5 All details of the video must be displayed in the richedit component, redUploads, in the following order:
<Title of video> <Video Code> <Category> <Minutes to upload>
NOTE: Headings for the richedit component have been provided in the code of the event handler.
Example of output:
QUESTION 2: OBJECT-ORIENTED PROGRAMMING
Your school’s computer club has started to develop a program where learners can comment, like or dislike videos that are available for viewing. Each video must store the amount of likes and dislikes and all comments associated with that video. Each video must also be rated according to the number of likes and dislikes associated with it. |
Do the following:
The following user interface is displayed when the video, Bugs, has been chosen.
Complete the code for this program, as specified in QUESTION 2.1 and QUESTION 2.2.
2.1 The incomplete class (TVideo) contains the declaration of five attributes that describe the objVideo object.
NAMES OF ATTRIBUTES | DESCRIPTION |
fvideoname | The name of the video |
fcomments | A string containing a list of all comments including the name of the video, names of the learners who made the comments and the date of each comment |
flikes | The number of likes for the video |
fdislikes | The number of dislikes for the video |
frating | The number of stars that the video is rated at |
The following complete methods have been provided in the unit VideoClass.pas:
addLike, addDislike, toString
Complete the code in the object class, as described in QUESTION 2.1.1 to QUESTION 2.1.4 below.
2.1.1 Write code for a constructor method named Create that will receive the name of a video as a parameter.
Assign this parameter value to the correct attribute and initialise the attributes for the number of likes and dislikes to zero. (4)
2.1.2 Write code for a method named AddNewComment that will receive two string parameters which will each represent a comment and a date. Set the value of the attribute fcomments as described below:
The two parameters must be joined to the attribute fcomments :
2.1.3 Write a method named SetRating which will set a value to the attribute, frating, according to the following criteria:
2.1.4 Write code for a method named GetRating which must return a string consisting of stars (*).
The string must contain stars (*) joined together depending on the value of the attribute, frating. Example: If frating is 2 then the string will consist of 2 stars. (**) (5)
2.2 An incomplete unit Question2_u.pas has been provided.
It contains code for the object class to be accessible and has an object variable objVideo already declared. It also contains a variable to hold the system date.
NOTE: The system date is provided and saved in a string variable named SystemDate in the unit Question2_u.pas
Global variables supplied: objVideo: tvideo; SystemDate: string;
Code to calculate the system date and to display the picture file chosen from the list box has been provided. Do NOT delete or change any provided code.
The user will choose a video to view and code is provided in the onclick event of the list box named lbxVideos to load a picture onto the image component and show the panels for adding likes, dislikes and comments.
Follow the instructions below to code the solution:
2.2.1 OnClick event of the list box named lbxVideos
(TQuestion2.lbxVideosClick)
The user chooses a video name from the list box, lbxVideos.
Write code to instantiate the object objVideo using the video name chosen. (3)
2.2.2 Button bitbtnLike [2.2.2 Like] and Button bitbtnDislike [2.2.2 Dislike]
In the onclick event of bitbtnLike, use the method of the class named addLike to add a ‘like’ to the video object
In the onclick event of bitbtnDislik, use the method of the class named addDislike to add a ‘dislike’ to the video object. (2)
2.2.3 Button Q2_2_3btnView [2.2.3 Watch this video]
Write code using a dialog box to allow the user to enter “Y” or “N” to the question: “Do you like this video?”.
If the answer is “Y”, then write code to execute the onclick event of the bitmap button named bitbtnLike, otherwise write code to execute the onclick event of the bitmap button named bitbtnDislike.
Add code using the methods of the class named SetRating and
GetRating to update the rating and then display the updated rating in the panel named pnlRatings. (6)
2.2.4 Button Q2_2_4btnSubmit [2.2.4 Submit this comment] The user will enter a name and a comment in the edit boxes provided.
You must write code to join these two strings together with the comment on a separate line.
Example of compiled string: Jane Doe
This is a good video
Clear the richedit component named redComments.
Use the methods of the class named addNewComment (with the compiled string and system date as parameters) and toString, to update and display the comments in the richedit component named redComments.
Example of output for QUESTION 2.2.4:
(7)
QUESTION 3: DATABASE PROGRAMMING
The database VideoClub.mdb contains the details of profile names of people who upload videos for viewing by members of a video club as well as all the videos belonging to each profile. The database contains two tables, namely Profile and Video.
Table: Profile
This table contains the profile name of a person who uploads videos and the date that their profile was created.
Field name | Data type | Description |
ProfileID | Autonumber | A unique number assigned to each profile |
ProfileName | Text (50) | The name of the profile |
DateCreated | Date/Time | The date on which the profile was created |
Example of data in the Profile table:
Table: Video
This table contains all the videos that have been uploaded by the profiles.
Field name | Data type | Description |
VideoID | Text (50) | A unique code assigned to the video |
VideoTitle | Text (80) | The title of the video |
DatePublished | Date/Time | The date that the video was published |
Views | Number | The number of views for the video |
Likes | Number | The number of likes for the video |
Dislikes | Number | The number of dislikes for the video |
Comments | Number | The number of comments for the video |
ProfileID | Number | The number that identifies the profile that the video belongs to |
Example of data of the first ten records of the Video table.
The following one-to-many relationship with referential integrity exists between the two tables in the database:
Do the following:
The user interface is displayed on the next page.
NOTE:
Variable | Data type | Description |
tblProfiles | TADOTable | Refers to the table named Profile |
tblVideos | TADOTable | Refers to the table named Video |
3.1 In this section you may ONLY use SQL statements to answer QUESTION 3.1.1 to QUESTION 3.1.5.
Code to execute the SQL statements and display the results of the queries is provided. The SQL statements are incomplete.
The section of the user interface for SQL questions is displayed below:
Do the following to complete the incomplete SQL statements assigned to the variables sSQL1, sSQL2, sSQL3, sSQL4 and sSQL5 per question respectively.
3.1.1 Button [3.1.1]
Write SQL code to display the DateCreated and the ProfileName of all profiles sorted from the newest to the oldest profile created.
Example of output:
(4)
3.1.2 Button [3.1.2]
The user must enter the name of a profile. Code has been provided for the profile name “DonDoe” to be entered in an input box and saved in a variable named sline.
Write SQL code to display the DatePublished and earnings of all videos that have been uploaded by the profile name stored in the variable sline. Both tables must be used.
The earnings are calculated by subtracting the number of dislikes from the number of likes and adding the number of comments. The result of this calculation is then divided by the number of views.
Earnings = (Likes – Dislikes + Comments) / Views.
The earnings must be formatted as currency to two decimal places and displayed as the heading Earnings.
Example of output:
(9)
3.1.3 Button [3.1.3]
Write an SQL statement to display video titles [VideoTitle] where the number of views is greater than or equal to 1000 and the number of dislikes is less than or equal to 10.
Example of output of the first five records:
(4)
3.1.4 Button [3.1.4]
Write an SQL statement to delete the video that was published in the year 2008.
(Code has been written to display the successfully updated table after deletion, in order of DatePublished from oldest to newest.)
Example of output:
(4)
3.1.5 Button [3.1.5]
Write an SQL statement to change the name of the profile named TimmyTom to Tim Horton.
(Code has been written to display the successful results.)
Example of output:
(3)
3.2 In this section, only Delphi programming code may be used to answer QUESTION 3.2.1 and QUESTION 3.2.2.
NO marks will be awarded for SQL statements in QUESTION 3.2.
The section of the user interface for QUESTION 3.2 is shown below:
3.2.1 Button [3.2.1]
Write code to display all video titles in the richedit, redDisplay, that contain the single word ‘the’ in the video title.
Example of output:
(6)
3.2.2 Button [3.2.2]
Write code to delete all videos that have more than 8 dislikes.
Example of output of all records displayed in the database grid, dbgVideos:
(6)
QUESTION 4: PROBLEM-SOLVING PROGRAMMING
Do the following:
Supplied GUI:
The supplied GUI represents the interface of the program used by the school’s computer club to analyse and make changes to videos and profiles.
A text file is included which contains the profile names, video codes and the length of each video in seconds.
The format of the text file is:
<Profile name><Video code><length of video in seconds>
Code has been written to read only two of the three items from each line of the text file into 2 global, parallel arrays, named arrProfiles and arrMinutes.
ArrMinutes contains the duration of each video as integers. These were calculated from the seconds converted to minutes and then rounded to integers.
ArrProfiles contains strings representing the profile names
The variable icountarr holds the total number of items for the two parallel arrays.
Code has been written in the OnActivate event of the form to read data from the text file into the two arrays and then display the array contents into the rich edit.
When the program is run, the two arrays are displayed in the richedit as shown in the diagram below:
Complete the code for each question, QUESTION 4.1 and QUESTION 4.2.
NOTE:
4.1 Menu option [4.1 Sort and Remove]
4.1.1 Sort both parallel arrays, arrProfiles and arrMinutes, in alphabetical order of the profile names.
Below is a display of the result of sorting the arrays in alphabetical order of profile name:
4.1.2 Remove all details of the profile name “DonDoe” from both arrays, arrProfiles and arrMinutes.
4.1.3 Create a text file using the file name Revised.txt and write all contents of the two sorted and revised arrays to the text file in the following order:
< Profile name><semicolon><length of video in minutes>
4.1 Example of the output to a text file:
(17)
4.2 Menu option [4.2 Advertisements]
The school’s computer club has obtained funding from advertising companies. Each video belonging to learners who have profiles may have 2 advertisements or 4 advertisements placed in positions during all of their videos’ playback times.
The diagram below shows the stringgrid on the form when the program is run.
The contents of the global 2-dimensional array are displayed in the stringgrid component in the onactivate event of the form using the Display procedure which has been written for you.
A global 2-dimensional array named arr2D containing real data types has been supplied.
In this question you must fill the two-dimensional array named arr2D with data representing the positions that adverts will occur during the playback of videos. You must then call the Display procedure to display the contents of the array arr2D in the stringgrid.
No advertisement will occur at the start of the playback of the video.
The first advert will take place at ¼ of the way during playback.
The second advert will take place at half way through the video during playback. The third advert will take place at the ¾ point of the video during playback. The last (fourth) advert will take place when the video stops playing.
The user will choose a profile name from the combobox provided. Code has been provided for the user to enter the number of advertisements required into an input box component for the selected profile name. This quantity is stored in a local variable name inumber.
Only 2 advertisements or 4 advertisements can be chosen for a profile name.
The profile name chosen will then have that amount of advertisements running through all his/her videos.
The two-dimensional array must then be filled with position times of advertisement placements of all videos belonging to that chosen profile name.
If two advertisements are chosen for a profile, then the advertisements must appear at the first quarter point of the video during playback and then at the third quarter point of the video during playback.
If four advertisements are chosen for a profile, then the advertisements must appear at the first quarter point of the video during playback and then at the half way point of the video playback and again at the third quarter point of the video during playback and lastly, at the end of the video during playback.
4.2 Example of output if SteveXolo is chosen and 4 advertisements are required:
4.2 Example of output if SteveXolo is chosen and 2 advertisements are required:
(19)
TOTAL: 150